1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #include "dolphinmainwindow.h"
24 #include "config-terminal.h"
26 #include "dolphinbookmarkhandler.h"
27 #include "dolphindockwidget.h"
28 #include "dolphincontextmenu.h"
29 #include "dolphinnewfilemenu.h"
30 #include "dolphinrecenttabsmenu.h"
31 #include "dolphinviewcontainer.h"
32 #include "dolphintabpage.h"
33 #include "middleclickactioneventfilter.h"
34 #include "panels/folders/folderspanel.h"
35 #include "panels/places/placesitemmodel.h"
36 #include "panels/places/placespanel.h"
37 #include "panels/information/informationpanel.h"
38 #include "panels/terminal/terminalpanel.h"
39 #include "settings/dolphinsettingsdialog.h"
40 #include "statusbar/dolphinstatusbar.h"
41 #include "views/dolphinviewactionhandler.h"
42 #include "views/dolphinremoteencoding.h"
43 #include "views/draganddrophelper.h"
44 #include "views/viewproperties.h"
45 #include "views/dolphinnewfilemenuobserver.h"
46 #include "dolphin_generalsettings.h"
48 #include <KActionCollection>
49 #include <KActionMenu>
50 #include <KAuthorized>
52 #include <KDualAction>
53 #include <KFileItemListProperties>
55 #include <KIO/JobUiDelegate>
56 #include <KIO/OpenFileManagerWindowJob>
57 #include <KJobWidgets>
58 #include <KLocalizedString>
59 #include <KMessageBox>
60 #include <KProtocolInfo>
61 #include <KProtocolManager>
64 #include <KStandardAction>
65 #include <KStartupInfo>
66 #include <KToggleAction>
68 #include <KToolBarPopupAction>
69 #include <KToolInvocation>
70 #include <KUrlComboBox>
71 #include <KUrlNavigator>
72 #include <KWindowSystem>
74 #include <QApplication>
76 #include <QCloseEvent>
77 #include <QDesktopServices>
83 #include <QPushButton>
85 #include <QStandardPaths>
87 #include <QToolButton>
88 #include <QWhatsThisClickedEvent>
91 // Used for GeneralSettings::version() to determine whether
92 // an updated version of Dolphin is running.
93 const int CurrentDolphinVersion
= 200;
94 // The maximum number of entries in the back/forward popup menu
95 const int MaxNumberOfNavigationentries
= 12;
96 // The maximum number of "Activate Tab" shortcuts
97 const int MaxActivateTabShortcuts
= 9;
100 DolphinMainWindow::DolphinMainWindow() :
101 KXmlGuiWindow(nullptr),
102 m_newFileMenu(nullptr),
104 m_tabWidget(nullptr),
105 m_activeViewContainer(nullptr),
106 m_actionHandler(nullptr),
107 m_remoteEncoding(nullptr),
109 m_bookmarkHandler(nullptr),
110 m_controlButton(nullptr),
111 m_updateToolBarTimer(nullptr),
112 m_lastHandleUrlStatJob(nullptr),
113 m_terminalPanel(nullptr),
114 m_placesPanel(nullptr),
115 m_tearDownFromPlacesRequested(false),
116 m_backAction(nullptr),
117 m_forwardAction(nullptr)
119 Q_INIT_RESOURCE(dolphin
);
121 setWindowFlags(Qt::WindowContextHelpButtonHint
);
123 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
124 setObjectName(QStringLiteral("Dolphin#"));
126 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
127 this, &DolphinMainWindow::showErrorMessage
);
129 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
130 undoManager
->setUiInterface(new UndoUiInterface());
132 connect(undoManager
, QOverload
<bool>::of(&KIO::FileUndoManager::undoAvailable
),
133 this, &DolphinMainWindow::slotUndoAvailable
);
134 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
135 this, &DolphinMainWindow::slotUndoTextChanged
);
136 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
137 this, &DolphinMainWindow::clearStatusBar
);
138 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
139 this, &DolphinMainWindow::showCommand
);
141 GeneralSettings
* generalSettings
= GeneralSettings::self();
142 const bool firstRun
= (generalSettings
->version() < 200);
144 generalSettings
->setViewPropsTimestamp(QDateTime::currentDateTime());
147 setAcceptDrops(true);
149 m_tabWidget
= new DolphinTabWidget(this);
150 m_tabWidget
->setObjectName("tabWidget");
151 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
152 this, &DolphinMainWindow::activeViewChanged
);
153 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
154 this, &DolphinMainWindow::tabCountChanged
);
155 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
156 this, &DolphinMainWindow::updateWindowTitle
);
157 setCentralWidget(m_tabWidget
);
161 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
162 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
163 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
165 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
166 connect(this, &DolphinMainWindow::urlChanged
,
167 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
171 setupGUI(Keys
| Save
| Create
| ToolBar
);
172 stateChanged(QStringLiteral("new_file"));
174 QClipboard
* clipboard
= QApplication::clipboard();
175 connect(clipboard
, &QClipboard::dataChanged
,
176 this, &DolphinMainWindow::updatePasteAction
);
178 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
179 showFilterBarAction
->setChecked(generalSettings
->filterBar());
182 menuBar()->setVisible(false);
183 // Assure a proper default size if Dolphin runs the first time
187 const bool showMenu
= !menuBar()->isHidden();
188 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
189 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
191 createControlButton();
194 // enable middle-click on back/forward/up to open in a new tab
195 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
196 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
197 toolBar()->installEventFilter(middleClickEventFilter
);
202 DolphinMainWindow::~DolphinMainWindow()
206 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
208 QVector
<DolphinViewContainer
*> viewContainers
;
209 viewContainers
.reserve(m_tabWidget
->count());
210 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
211 viewContainers
<< m_tabWidget
->tabPageAt(i
)->activeViewContainer();
213 return viewContainers
;
216 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
218 m_tabWidget
->openDirectories(dirs
, splitView
);
221 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
223 openDirectories(QUrl::fromStringList(dirs
), splitView
);
226 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
228 m_tabWidget
->openFiles(files
, splitView
);
231 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
233 openFiles(QUrl::fromStringList(files
), splitView
);
236 void DolphinMainWindow::activateWindow()
238 KStartupInfo::setNewStartupId(window(), KStartupInfo::startupId());
239 KWindowSystem::activateWindow(window()->effectiveWinId());
242 void DolphinMainWindow::showCommand(CommandType command
)
244 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
246 case KIO::FileUndoManager::Copy
:
247 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
249 case KIO::FileUndoManager::Move
:
250 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
252 case KIO::FileUndoManager::Link
:
253 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
255 case KIO::FileUndoManager::Trash
:
256 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
258 case KIO::FileUndoManager::Rename
:
259 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
262 case KIO::FileUndoManager::Mkdir
:
263 statusBar
->setText(i18nc("@info:status", "Created folder."));
271 void DolphinMainWindow::pasteIntoFolder()
273 m_activeViewContainer
->view()->pasteIntoFolder();
276 void DolphinMainWindow::changeUrl(const QUrl
&url
)
278 if (!KProtocolManager::supportsListing(url
)) {
279 // The URL navigator only checks for validity, not
280 // if the URL can be listed. An error message is
281 // shown due to DolphinViewContainer::restoreView().
285 m_activeViewContainer
->setUrl(url
);
286 updateFileAndEditActions();
291 emit
urlChanged(url
);
294 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
296 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
297 m_placesPanel
->proceedWithTearDown();
298 m_tearDownFromPlacesRequested
= false;
301 m_activeViewContainer
->setAutoGrabFocus(false);
303 m_activeViewContainer
->setAutoGrabFocus(true);
306 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
308 KToggleAction
* editableLocationAction
=
309 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
310 editableLocationAction
->setChecked(editable
);
313 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
315 updateFileAndEditActions();
317 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
319 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
320 if (selectedUrlsCount
== 2) {
321 compareFilesAction
->setEnabled(isKompareInstalled());
323 compareFilesAction
->setEnabled(false);
326 emit
selectionChanged(selection
);
329 void DolphinMainWindow::updateHistory()
331 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
332 const int index
= urlNavigator
->historyIndex();
334 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
336 backAction
->setToolTip(i18nc("@info", "Go back"));
337 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
338 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
341 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
343 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
344 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
345 "This undoes a <interface>Go|Back</interface> action."));
346 forwardAction
->setEnabled(index
> 0);
350 void DolphinMainWindow::updateFilterBarAction(bool show
)
352 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
353 showFilterBarAction
->setChecked(show
);
356 void DolphinMainWindow::openNewMainWindow()
358 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
361 void DolphinMainWindow::openNewActivatedTab()
363 m_tabWidget
->openNewActivatedTab();
366 void DolphinMainWindow::addToPlaces()
371 // If nothing is selected, act on the current dir
372 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
373 url
= m_activeViewContainer
->url();
374 name
= m_activeViewContainer
->placesText();
376 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
377 url
= dirToAdd
.url();
378 name
= dirToAdd
.name();
381 PlacesItemModel model
;
383 if (m_activeViewContainer
->isSearchModeEnabled()) {
384 icon
= QStringLiteral("folder-saved-search-symbolic");
386 icon
= KIO::iconNameForUrl(url
);
388 model
.createPlacesItem(name
, url
, icon
);
392 void DolphinMainWindow::openNewTab(const QUrl
& url
, DolphinTabWidget::TabPlacement tabPlacement
)
394 m_tabWidget
->openNewTab(url
, QUrl(), tabPlacement
);
397 void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl
& url
)
399 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterCurrentTab
);
402 void DolphinMainWindow::openNewTabAfterLastTab(const QUrl
& url
)
404 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterLastTab
);
407 void DolphinMainWindow::openInNewTab()
409 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
410 bool tabCreated
= false;
412 foreach (const KFileItem
& item
, list
) {
413 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
414 if (!url
.isEmpty()) {
415 openNewTabAfterCurrentTab(url
);
420 // if no new tab has been created from the selection
421 // open the current directory in a new tab
423 openNewTabAfterCurrentTab(m_activeViewContainer
->url());
427 void DolphinMainWindow::openInNewWindow()
431 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
432 if (list
.isEmpty()) {
433 newWindowUrl
= m_activeViewContainer
->url();
434 } else if (list
.count() == 1) {
435 const KFileItem
& item
= list
.first();
436 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
439 if (!newWindowUrl
.isEmpty()) {
440 Dolphin::openNewWindow({newWindowUrl
}, this);
444 void DolphinMainWindow::showTarget()
446 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
447 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
448 auto linkDestination
= link
.linkDest();
449 if (QFileInfo(linkDestination
).isRelative()) {
450 linkDestination
= linkLocationDir
.filePath(linkDestination
);
452 if (QFileInfo::exists(linkDestination
)) {
453 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
455 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
456 DolphinViewContainer::Warning
);
460 void DolphinMainWindow::showEvent(QShowEvent
* event
)
462 KXmlGuiWindow::showEvent(event
);
464 if (!event
->spontaneous()) {
465 m_activeViewContainer
->view()->setFocus();
469 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
471 // Find out if Dolphin is closed directly by the user or
472 // by the session manager because the session is closed
473 bool closedByUser
= true;
474 if (qApp
->isSavingSession()) {
475 closedByUser
= false;
478 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser
) {
479 // Ask the user if he really wants to quit and close all tabs.
480 // Open a confirmation dialog with 3 buttons:
481 // QDialogButtonBox::Yes -> Quit
482 // QDialogButtonBox::No -> Close only the current tab
483 // QDialogButtonBox::Cancel -> do nothing
484 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
485 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
486 dialog
->setModal(true);
487 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
488 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
489 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
490 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
491 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
493 bool doNotAskAgainCheckboxResult
= false;
495 const auto result
= KMessageBox::createKMessageBox(dialog
,
497 QMessageBox::Warning
,
498 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
500 i18n("Do not ask again"),
501 &doNotAskAgainCheckboxResult
,
502 KMessageBox::Notify
);
504 if (doNotAskAgainCheckboxResult
) {
505 GeneralSettings::setConfirmClosingMultipleTabs(false);
509 case QDialogButtonBox::Yes
:
512 case QDialogButtonBox::No
:
513 // Close only the current tab
514 m_tabWidget
->closeTab();
522 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
523 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
524 // Open a confirmation dialog with 3 buttons:
525 // QDialogButtonBox::Yes -> Quit
526 // QDialogButtonBox::No -> Show Terminal Panel
527 // QDialogButtonBox::Cancel -> do nothing
528 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
529 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
530 dialog
->setModal(true);
531 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
532 if (!m_terminalPanel
->isVisible()) {
533 standardButtons
|= QDialogButtonBox::No
;
535 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
536 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
537 if (!m_terminalPanel
->isVisible()) {
539 buttons
->button(QDialogButtonBox::No
),
540 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
542 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
544 bool doNotAskAgainCheckboxResult
= false;
546 const auto result
= KMessageBox::createKMessageBox(
549 QMessageBox::Warning
,
550 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
552 i18n("Do not ask again"),
553 &doNotAskAgainCheckboxResult
,
554 KMessageBox::Dangerous
);
556 if (doNotAskAgainCheckboxResult
) {
557 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
561 case QDialogButtonBox::Yes
:
564 case QDialogButtonBox::No
:
565 actionCollection()->action("show_terminal_panel")->trigger();
566 // Do not quit, ignore quit event
574 GeneralSettings::setVersion(CurrentDolphinVersion
);
575 GeneralSettings::self()->save();
577 KXmlGuiWindow::closeEvent(event
);
580 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
582 m_tabWidget
->saveProperties(group
);
585 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
587 m_tabWidget
->readProperties(group
);
590 void DolphinMainWindow::updateNewMenu()
592 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
593 m_newFileMenu
->checkUpToDate();
594 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
597 void DolphinMainWindow::createDirectory()
599 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
600 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
601 m_newFileMenu
->createDirectory();
604 void DolphinMainWindow::quit()
609 void DolphinMainWindow::showErrorMessage(const QString
& message
)
611 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
614 void DolphinMainWindow::slotUndoAvailable(bool available
)
616 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
618 undoAction
->setEnabled(available
);
622 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
624 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
626 undoAction
->setText(text
);
630 void DolphinMainWindow::undo()
633 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
634 KIO::FileUndoManager::self()->undo();
637 void DolphinMainWindow::cut()
639 m_activeViewContainer
->view()->cutSelectedItems();
642 void DolphinMainWindow::copy()
644 m_activeViewContainer
->view()->copySelectedItems();
647 void DolphinMainWindow::paste()
649 m_activeViewContainer
->view()->paste();
652 void DolphinMainWindow::find()
654 m_activeViewContainer
->setSearchModeEnabled(true);
657 void DolphinMainWindow::updateSearchAction()
659 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
660 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
663 void DolphinMainWindow::updatePasteAction()
665 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
666 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
667 pasteAction
->setEnabled(pasteInfo
.first
);
668 pasteAction
->setText(pasteInfo
.second
);
671 void DolphinMainWindow::slotDirectoryLoadingCompleted()
676 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
678 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
680 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
682 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
684 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
689 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
691 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
693 m_backAction
->menu()->clear();
694 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
695 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_backAction
->menu());
697 m_backAction
->menu()->addAction(action
);
701 void DolphinMainWindow::slotGoBack(QAction
* action
)
703 int gotoIndex
= action
->data().value
<int>();
704 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
705 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
710 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
713 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
714 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
718 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
720 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
722 m_forwardAction
->menu()->clear();
723 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
724 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
726 m_forwardAction
->menu()->addAction(action
);
730 void DolphinMainWindow::slotGoForward(QAction
* action
)
732 int gotoIndex
= action
->data().value
<int>();
733 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
734 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
739 void DolphinMainWindow::selectAll()
743 // if the URL navigator is editable and focused, select the whole
744 // URL instead of all items of the view
746 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
747 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
748 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
749 lineEdit
->hasFocus();
751 lineEdit
->selectAll();
753 m_activeViewContainer
->view()->selectAll();
757 void DolphinMainWindow::invertSelection()
760 m_activeViewContainer
->view()->invertSelection();
763 void DolphinMainWindow::toggleSplitView()
765 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
766 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled());
771 void DolphinMainWindow::toggleSplitStash()
773 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
774 tabPage
->setSplitViewEnabled(false);
775 tabPage
->setSplitViewEnabled(true, QUrl("stash:/"));
778 void DolphinMainWindow::reloadView()
781 m_activeViewContainer
->reload();
782 m_activeViewContainer
->statusBar()->updateSpaceInfo();
785 void DolphinMainWindow::stopLoading()
787 m_activeViewContainer
->view()->stopLoading();
790 void DolphinMainWindow::enableStopAction()
792 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
795 void DolphinMainWindow::disableStopAction()
797 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
800 void DolphinMainWindow::showFilterBar()
802 m_activeViewContainer
->setFilterBarVisible(true);
805 void DolphinMainWindow::toggleEditLocation()
809 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
810 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
811 urlNavigator
->setUrlEditable(action
->isChecked());
814 void DolphinMainWindow::replaceLocation()
816 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
817 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
819 // If the text field currently has focus and everything is selected,
820 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
821 if (navigator
->isUrlEditable()
822 && lineEdit
->hasFocus()
823 && lineEdit
->selectedText() == lineEdit
->text() ) {
824 navigator
->setUrlEditable(false);
826 navigator
->setUrlEditable(true);
827 navigator
->setFocus();
828 lineEdit
->selectAll();
832 void DolphinMainWindow::togglePanelLockState()
834 const bool newLockState
= !GeneralSettings::lockPanels();
835 foreach (QObject
* child
, children()) {
836 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
838 dock
->setLocked(newLockState
);
842 GeneralSettings::setLockPanels(newLockState
);
845 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
847 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
848 m_activeViewContainer
->view()->setFocus();
852 void DolphinMainWindow::goBack()
854 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
855 urlNavigator
->goBack();
857 if (urlNavigator
->locationState().isEmpty()) {
858 // An empty location state indicates a redirection URL,
859 // which must be skipped too
860 urlNavigator
->goBack();
864 void DolphinMainWindow::goForward()
866 m_activeViewContainer
->urlNavigator()->goForward();
869 void DolphinMainWindow::goUp()
871 m_activeViewContainer
->urlNavigator()->goUp();
874 void DolphinMainWindow::goHome()
876 m_activeViewContainer
->urlNavigator()->goHome();
879 void DolphinMainWindow::goBackInNewTab()
881 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
882 const int index
= urlNavigator
->historyIndex() + 1;
883 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
886 void DolphinMainWindow::goForwardInNewTab()
888 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
889 const int index
= urlNavigator
->historyIndex() - 1;
890 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
893 void DolphinMainWindow::goUpInNewTab()
895 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
896 openNewTabAfterCurrentTab(KIO::upUrl(currentUrl
));
899 void DolphinMainWindow::goHomeInNewTab()
901 openNewTabAfterCurrentTab(Dolphin::homeUrl());
904 void DolphinMainWindow::compareFiles()
906 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
907 if (items
.count() != 2) {
908 // The action is disabled in this case, but it could have been triggered
909 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
913 QUrl urlA
= items
.at(0).url();
914 QUrl urlB
= items
.at(1).url();
916 QString
command(QStringLiteral("kompare -c \""));
917 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
918 command
.append("\" \"");
919 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
920 command
.append('\"');
921 KRun::runCommand(command
, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
924 void DolphinMainWindow::toggleShowMenuBar()
926 const bool visible
= menuBar()->isVisible();
927 menuBar()->setVisible(!visible
);
929 createControlButton();
931 deleteControlButton();
935 void DolphinMainWindow::openTerminal()
937 QString
dir(QDir::homePath());
939 // If the given directory is not local, it can still be the URL of an
940 // ioslave using UDS_LOCAL_PATH which to be converted first.
941 KIO::StatJob
* statJob
= KIO::mostLocalUrl(m_activeViewContainer
->url());
942 KJobWidgets::setWindow(statJob
, this);
944 QUrl url
= statJob
->mostLocalUrl();
946 //If the URL is local after the above conversion, set the directory.
947 if (url
.isLocalFile()) {
948 dir
= url
.toLocalFile();
951 KToolInvocation::invokeTerminal(QString(), dir
);
954 void DolphinMainWindow::editSettings()
956 if (!m_settingsDialog
) {
957 DolphinViewContainer
* container
= activeViewContainer();
958 container
->view()->writeSettings();
960 const QUrl url
= container
->url();
961 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this);
962 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
963 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
964 settingsDialog
->show();
965 m_settingsDialog
= settingsDialog
;
967 m_settingsDialog
.data()->raise();
971 void DolphinMainWindow::handleUrl(const QUrl
& url
)
973 delete m_lastHandleUrlStatJob
;
974 m_lastHandleUrlStatJob
= nullptr;
976 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
977 activeViewContainer()->setUrl(url
);
978 } else if (KProtocolManager::supportsListing(url
)) {
979 // stat the URL to see if it is a dir or not
980 m_lastHandleUrlStatJob
= KIO::stat(url
, KIO::HideProgressInfo
);
981 if (m_lastHandleUrlStatJob
->uiDelegate()) {
982 KJobWidgets::setWindow(m_lastHandleUrlStatJob
, this);
984 connect(m_lastHandleUrlStatJob
, &KIO::Job::result
,
985 this, &DolphinMainWindow::slotHandleUrlStatFinished
);
988 new KRun(url
, this); // Automatically deletes itself after being finished
992 void DolphinMainWindow::slotHandleUrlStatFinished(KJob
* job
)
994 m_lastHandleUrlStatJob
= nullptr;
995 const KIO::UDSEntry entry
= static_cast<KIO::StatJob
*>(job
)->statResult();
996 const QUrl url
= static_cast<KIO::StatJob
*>(job
)->url();
998 activeViewContainer()->setUrl(url
);
1000 new KRun(url
, this); // Automatically deletes itself after being finished
1004 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1006 // trash:/ is writable but we don't want to create new items in it.
1007 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1008 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1011 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1012 const KFileItem
& item
,
1014 const QList
<QAction
*>& customActions
)
1016 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
);
1017 contextMenu
.data()->setCustomActions(customActions
);
1018 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1021 case DolphinContextMenu::OpenParentFolder
:
1022 changeUrl(KIO::upUrl(item
.url()));
1023 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1024 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1027 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1028 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1031 case DolphinContextMenu::OpenParentFolderInNewTab
:
1032 openNewTabAfterLastTab(KIO::upUrl(item
.url()));
1035 case DolphinContextMenu::None
:
1040 // Delete the menu, unless it has been deleted in its own nested event loop already.
1042 contextMenu
->deleteLater();
1046 void DolphinMainWindow::updateControlMenu()
1048 QMenu
* menu
= qobject_cast
<QMenu
*>(sender());
1051 // All actions get cleared by QMenu::clear(). This includes the sub-menus
1052 // because 'menu' is their parent.
1055 KActionCollection
* ac
= actionCollection();
1057 menu
->addMenu(m_newFileMenu
->menu());
1058 addActionToMenu(ac
->action(QStringLiteral("file_new")), menu
);
1059 addActionToMenu(ac
->action(QStringLiteral("new_tab")), menu
);
1060 addActionToMenu(ac
->action(QStringLiteral("closed_tabs")), menu
);
1062 menu
->addSeparator();
1064 // Add "Edit" actions
1065 bool added
= addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Undo
)), menu
) |
1066 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::SelectAll
)), menu
) |
1067 addActionToMenu(ac
->action(QStringLiteral("invert_selection")), menu
);
1070 menu
->addSeparator();
1073 // Add "View" actions
1074 if (!GeneralSettings::showZoomSlider()) {
1075 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomIn
)), menu
);
1076 addActionToMenu(ac
->action(QStringLiteral("view_zoom_reset")), menu
);
1077 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomOut
)), menu
);
1078 menu
->addSeparator();
1081 added
= addActionToMenu(ac
->action(QStringLiteral("show_preview")), menu
) |
1082 addActionToMenu(ac
->action(QStringLiteral("show_in_groups")), menu
) |
1083 addActionToMenu(ac
->action(QStringLiteral("show_hidden_files")), menu
) |
1084 addActionToMenu(ac
->action(QStringLiteral("additional_info")), menu
) |
1085 addActionToMenu(ac
->action(QStringLiteral("view_properties")), menu
);
1088 menu
->addSeparator();
1091 // Add a curated assortment of items from the "Tools" menu
1092 addActionToMenu(ac
->action(QStringLiteral("show_filter_bar")), menu
);
1093 addActionToMenu(ac
->action(QStringLiteral("open_terminal")), menu
);
1095 menu
->addSeparator();
1097 // Add "Show Panels" menu
1098 addActionToMenu(ac
->action(QStringLiteral("panels")), menu
);
1100 // Add "Settings" menu entries
1101 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)), menu
);
1102 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)), menu
);
1103 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Preferences
)), menu
);
1104 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)), menu
);
1107 auto helpMenu
= m_helpMenu
->menu();
1108 helpMenu
->setIcon(QIcon::fromTheme(QStringLiteral("system-help")));
1109 menu
->addMenu(helpMenu
);
1112 void DolphinMainWindow::updateToolBar()
1114 if (!menuBar()->isVisible()) {
1115 createControlButton();
1119 void DolphinMainWindow::slotControlButtonDeleted()
1121 m_controlButton
= nullptr;
1122 m_updateToolBarTimer
->start();
1125 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1127 DolphinViewContainer
* view
= activeViewContainer();
1129 if (view
->url() == url
) {
1130 // We can end up here if the user clicked a device in the Places Panel
1131 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1138 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1140 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1143 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1145 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1146 Q_ASSERT(viewContainer
);
1148 m_activeViewContainer
= viewContainer
;
1150 if (oldViewContainer
) {
1151 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1152 toggleSearchAction
->disconnect(oldViewContainer
);
1154 // Disconnect all signals between the old view container (container,
1155 // view and url navigator) and main window.
1156 oldViewContainer
->disconnect(this);
1157 oldViewContainer
->view()->disconnect(this);
1158 oldViewContainer
->urlNavigator()->disconnect(this);
1160 // except the requestItemInfo so that on hover the information panel can still be updated
1161 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1162 this, &DolphinMainWindow::requestItemInfo
);
1165 connectViewSignals(viewContainer
);
1167 m_actionHandler
->setCurrentView(viewContainer
->view());
1170 updateFileAndEditActions();
1171 updatePasteAction();
1172 updateViewActions();
1174 updateSearchAction();
1176 const QUrl url
= viewContainer
->url();
1177 emit
urlChanged(url
);
1180 void DolphinMainWindow::tabCountChanged(int count
)
1182 const bool enableTabActions
= (count
> 1);
1183 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1184 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1186 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1187 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1188 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1191 void DolphinMainWindow::updateWindowTitle()
1193 const QString newTitle
= m_activeViewContainer
->caption();
1194 if (windowTitle() != newTitle
) {
1195 setWindowTitle(newTitle
);
1199 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1201 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1202 m_tearDownFromPlacesRequested
= true;
1203 m_terminalPanel
->goHome();
1204 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1206 m_placesPanel
->proceedWithTearDown();
1210 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1212 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1213 m_tearDownFromPlacesRequested
= false;
1214 m_terminalPanel
->goHome();
1218 void DolphinMainWindow::setupActions()
1220 // setup 'File' menu
1221 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1222 QMenu
* menu
= m_newFileMenu
->menu();
1223 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1224 menu
->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
1225 m_newFileMenu
->setDelayed(false);
1226 connect(menu
, &QMenu::aboutToShow
,
1227 this, &DolphinMainWindow::updateNewMenu
);
1229 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1230 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1231 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1232 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1233 "window just like this one with the current location and view."
1234 "<nl/>You can drag and drop items between windows."));
1235 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1237 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1238 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1239 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1240 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1241 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1242 "A tab is an additional view within this window. "
1243 "You can drag and drop items between tabs."));
1244 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
+ Qt::Key_T
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_N
});
1245 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1247 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1248 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1249 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1250 "to the Places panel."));
1251 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1253 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1254 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1255 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1256 "currently viewed tab. If no more tabs are left this window "
1257 "will close instead."));
1259 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1260 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1262 // setup 'Edit' menu
1263 KStandardAction::undo(this,
1264 &DolphinMainWindow::undo
,
1265 actionCollection());
1267 // i18n: This will be the last paragraph for the whatsthis for all three:
1268 // Cut, Copy and Paste
1269 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1270 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1271 "applications and are among the most used commands. That's why their "
1272 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1273 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1274 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1275 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1276 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1277 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1278 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1279 "the clipboard to a new location. The items will be removed from their "
1280 "initial location.") + cutCopyPastePara
);
1281 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1282 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1283 "items in your current selection to the <emphasis>clipboard</emphasis>."
1284 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1285 "from the clipboard to a new location.") + cutCopyPastePara
);
1286 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1287 // The text of the paste-action is modified dynamically by Dolphin
1288 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1289 // due to the long text, the text "Paste" is used:
1290 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1291 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1292 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1293 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1294 "action they are removed from their old location.") + cutCopyPastePara
);
1296 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1297 searchAction
->setText(i18n("Search..."));
1298 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1299 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1300 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1301 "There you can enter search terms and specify settings to find the "
1302 "objects you are looking for.</para><para>Use this help again on "
1303 "the find bar so we can have a look at it while the settings are "
1304 "explained.</para>"));
1306 // toggle_search acts as a copy of the main searchAction to be used mainly
1307 // in the toolbar, with no default shortcut attached, to avoid messing with
1308 // existing workflows (search bar always open and Ctrl-F to focus)
1309 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1310 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1311 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1312 toggleSearchAction
->setIcon(searchAction
->icon());
1313 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1314 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1315 toggleSearchAction
->setCheckable(true);
1317 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1318 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1319 "files and folders in the current location."));
1321 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1322 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1323 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1324 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1325 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1326 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_A
);
1327 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1329 // setup 'View' menu
1330 // (note that most of it is set up in DolphinViewActionHandler)
1332 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1333 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1334 "the folder view below into two autonomous views.</para><para>This "
1335 "way you can see two locations at once and move items between them "
1336 "quickly.</para>Click this again afterwards to recombine the views."));
1337 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1338 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1340 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1341 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
+ Qt::Key_S
);
1342 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1343 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1344 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1345 stashSplit
->setCheckable(false);
1346 stashSplit
->setVisible(KProtocolInfo::isKnownProtocol("stash"));
1347 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1349 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1351 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1352 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1353 stop
->setToolTip(i18nc("@info", "Stop loading"));
1354 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1355 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1356 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1358 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1359 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1360 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1361 "This toggles the <emphasis>Location Bar</emphasis> to be "
1362 "editable so you can directly enter a location you want to go to.<nl/>"
1363 "You can also switch to editing by clicking to the right of the "
1364 "location and switch back by confirming the edited location."));
1365 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1366 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1368 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1369 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1370 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1371 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1372 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1373 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1374 "This switches to editing the location and selects it "
1375 "so you can quickly enter a different location."));
1376 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
+ Qt::Key_L
);
1377 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1381 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1382 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1383 m_backAction
->setObjectName(backAction
->objectName());
1384 m_backAction
->setShortcuts(backAction
->shortcuts());
1386 m_backAction
->setDelayed(true);
1387 m_backAction
->setStickyMenu(false);
1388 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1389 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1390 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1391 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1393 auto backShortcuts
= m_backAction
->shortcuts();
1394 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1395 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1397 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1398 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1399 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1400 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1401 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1402 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1403 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1404 this, &DolphinMainWindow::closedTabsCountChanged
);
1406 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1407 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1408 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1409 "This returns you to the previously closed tab."));
1410 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_T
);
1411 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1412 undoCloseTab
->setEnabled(false);
1413 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1415 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1416 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1417 "the last change you made to files or folders.<nl/>"
1418 "Such changes include <interface>creating, renaming</interface> "
1419 "and <interface>moving</interface> them to a different location "
1420 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1421 "be undone will ask for your confirmation."));
1422 undoAction
->setEnabled(false); // undo should be disabled by default
1425 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1426 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1427 m_forwardAction
->setObjectName(forwardAction
->objectName());
1428 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1430 m_forwardAction
->setDelayed(true);
1431 m_forwardAction
->setStickyMenu(false);
1432 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1433 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1434 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1435 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1436 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1438 // enable middle-click to open in a new tab
1439 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1440 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1441 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1442 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1443 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1444 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1445 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1446 "<filename>Home</filename> folder.<nl/>Every user account "
1447 "has their own <filename>Home</filename> that contains their data "
1448 "including folders that contain personal application data."));
1450 // setup 'Tools' menu
1451 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1452 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1453 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1454 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1455 "There you can enter a text to filter the files and folders currently displayed. "
1456 "Only those that contain the text in their name will be kept in view."));
1457 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1458 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
+ Qt::Key_I
, Qt::Key_Slash
});
1459 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1461 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1462 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1463 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1464 compareFiles
->setEnabled(false);
1465 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1467 #ifdef HAVE_TERMINAL
1468 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1469 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1470 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1471 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1472 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1473 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1474 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
1475 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
+ Qt::Key_F4
);
1476 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1480 // setup 'Bookmarks' menu
1481 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1482 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1483 // Make the toolbar button version work properly on click
1484 bookmarkMenu
->setDelayed(false);
1485 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1486 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1488 // setup 'Settings' menu
1489 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1490 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1491 "This switches between having a <emphasis>Menubar</emphasis> "
1492 "and having a <interface>Control</interface> button. Both "
1493 "contain mostly the same commands and configuration options."));
1494 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1495 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1496 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1498 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1499 m_helpMenu
= new KHelpMenu(nullptr);
1500 m_helpMenu
->menu()->installEventFilter(this);
1501 // remove duplicate shortcuts
1502 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setShortcut(QKeySequence());
1503 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setShortcut(QKeySequence());
1505 // not in menu actions
1506 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1507 nextTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::Key_Tab
));
1509 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1510 prevTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_Tab
));
1512 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1513 QAction
* activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
1514 activateTab
->setText(i18nc("@action:inmenu", "Activate Tab %1", i
+ 1));
1515 activateTab
->setEnabled(false);
1516 connect(activateTab
, &QAction::triggered
, this, [this, i
]() { m_tabWidget
->activateTab(i
); });
1518 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
1520 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
1524 QAction
* activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
1525 activateLastTab
->setText(i18nc("@action:inmenu", "Activate Last Tab"));
1526 activateLastTab
->setEnabled(false);
1527 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
1528 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
+ Qt::Key_0
);
1530 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1531 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1532 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1533 activateNextTab
->setEnabled(false);
1534 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1535 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1537 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1538 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1539 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1540 activatePrevTab
->setEnabled(false);
1541 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1542 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1545 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1546 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1547 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1548 showTarget
->setEnabled(false);
1549 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1551 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1552 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1553 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1554 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1556 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1557 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1558 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1559 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1561 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1562 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1563 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1564 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1567 void DolphinMainWindow::setupDockWidgets()
1569 const bool lock
= GeneralSettings::lockPanels();
1571 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1572 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1573 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1574 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1575 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1576 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1577 "switches between having panels <emphasis>locked</emphasis> or "
1578 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1579 "dragged to the other side of the window and have a close "
1580 "button.<nl/>Locked panels are embedded more cleanly."));
1581 lockLayoutAction
->setActive(lock
);
1582 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1584 // Setup "Information"
1585 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1586 infoDock
->setLocked(lock
);
1587 infoDock
->setObjectName(QStringLiteral("infoDock"));
1588 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1591 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1592 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1593 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1594 infoDock
->setWidget(infoPanel
);
1596 QAction
* infoAction
= infoDock
->toggleViewAction();
1597 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1599 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1600 connect(this, &DolphinMainWindow::urlChanged
,
1601 infoPanel
, &InformationPanel::setUrl
);
1602 connect(this, &DolphinMainWindow::selectionChanged
,
1603 infoPanel
, &InformationPanel::setSelection
);
1604 connect(this, &DolphinMainWindow::requestItemInfo
,
1605 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1608 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1609 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1610 "hide panels like this go to <interface>Control|Panels</interface> "
1611 "or <interface>View|Panels</interface>.</para>");
1613 actionCollection()->action(QStringLiteral("show_information_panel"))
1614 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1615 "<emphasis>information</emphasis> panel at the right side of the "
1616 "window.</para><para>The panel provides in-depth information "
1617 "about the items your mouse is hovering over or about the selected "
1618 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1619 "For single items a preview of their contents is provided.</para>"));
1621 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1622 "provides in-depth information about the items your mouse is "
1623 "hovering over or about the selected items. Otherwise it informs "
1624 "you about the currently viewed folder.<nl/>For single items a "
1625 "preview of their contents is provided.</para><para>You can configure "
1626 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1629 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1630 foldersDock
->setLocked(lock
);
1631 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1632 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1633 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1634 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1635 foldersDock
->setWidget(foldersPanel
);
1637 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1638 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1640 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1641 connect(this, &DolphinMainWindow::urlChanged
,
1642 foldersPanel
, &FoldersPanel::setUrl
);
1643 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1644 this, &DolphinMainWindow::changeUrl
);
1645 connect(foldersPanel
, &FoldersPanel::folderMiddleClicked
,
1646 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1647 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1648 this, &DolphinMainWindow::showErrorMessage
);
1650 actionCollection()->action(QStringLiteral("show_folders_panel"))
1651 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1652 "<emphasis>folders</emphasis> panel at the left side of the window."
1653 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1654 "</emphasis> in a <emphasis>tree view</emphasis>."));
1655 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1656 "shows the folders of the <emphasis>file system</emphasis> in a "
1657 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1658 "there. Click the arrow to the left of a folder to see its subfolders. "
1659 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1662 #ifdef HAVE_TERMINAL
1663 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1664 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1665 terminalDock
->setLocked(lock
);
1666 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1667 m_terminalPanel
= new TerminalPanel(terminalDock
);
1668 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1669 terminalDock
->setWidget(m_terminalPanel
);
1671 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1672 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1673 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1674 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1675 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1676 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1678 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1679 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1681 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1682 connect(this, &DolphinMainWindow::urlChanged
,
1683 m_terminalPanel
, &TerminalPanel::setUrl
);
1685 if (GeneralSettings::version() < 200) {
1686 terminalDock
->hide();
1689 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1690 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1691 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1692 "<nl/>The location in the terminal will always match the folder "
1693 "view so you can navigate using either.</para><para>The terminal "
1694 "panel is not needed for basic computer usage but can be useful "
1695 "for advanced tasks. To learn more about terminals use the help "
1696 "in a standalone terminal application like Konsole.</para>"));
1697 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1698 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1699 "normal terminal but will match the location of the folder view "
1700 "so you can navigate using either.</para><para>The terminal panel "
1701 "is not needed for basic computer usage but can be useful for "
1702 "advanced tasks. To learn more about terminals use the help in a "
1703 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1707 if (GeneralSettings::version() < 200) {
1709 foldersDock
->hide();
1713 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1714 placesDock
->setLocked(lock
);
1715 placesDock
->setObjectName(QStringLiteral("placesDock"));
1716 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1718 m_placesPanel
= new PlacesPanel(placesDock
);
1719 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1720 placesDock
->setWidget(m_placesPanel
);
1722 QAction
*placesAction
= placesDock
->toggleViewAction();
1723 createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1725 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1726 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1727 this, &DolphinMainWindow::slotPlaceActivated
);
1728 connect(m_placesPanel
, &PlacesPanel::placeMiddleClicked
,
1729 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1730 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1731 this, &DolphinMainWindow::showErrorMessage
);
1732 connect(this, &DolphinMainWindow::urlChanged
,
1733 m_placesPanel
, &PlacesPanel::setUrl
);
1734 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1735 m_tabWidget
, &DolphinTabWidget::slotPlacesPanelVisibilityChanged
);
1736 connect(this, &DolphinMainWindow::settingsChanged
,
1737 m_placesPanel
, &PlacesPanel::readSettings
);
1738 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1739 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1740 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1741 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1742 m_tabWidget
->slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1744 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1745 actionShowAllPlaces
->setCheckable(true);
1746 actionShowAllPlaces
->setDisabled(true);
1747 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1748 "all places in the places panel that have been hidden. They will "
1749 "appear semi-transparent unless you uncheck their hide property."));
1751 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1752 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1753 m_placesPanel
->showHiddenEntries(checked
);
1756 connect(m_placesPanel
, &PlacesPanel::showHiddenEntriesChanged
, this, [actionShowAllPlaces
] (bool checked
){
1757 actionShowAllPlaces
->setChecked(checked
);
1758 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1761 actionCollection()->action(QStringLiteral("show_places_panel"))
1762 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1763 "<emphasis>places</emphasis> panel at the left side of the window."
1764 "</para><para>It allows you to go to locations you have "
1765 "bookmarked and to access disk or media attached to the computer "
1766 "or to the network. It also contains sections to find recently "
1767 "saved files or files of a certain type.</para>"));
1768 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1769 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1770 "you have bookmarked and to access disk or media attached to the "
1771 "computer or to the network. It also contains sections to find "
1772 "recently saved files or files of a certain type.</para><para>"
1773 "Click on an entry to go there. Click with the right mouse button "
1774 "instead to open any entry in a new tab or new window.</para>"
1775 "<para>New entries can be added by dragging folders onto this panel. "
1776 "Right-click any section or entry to hide it. Right-click an empty "
1777 "space on this panel and select <interface>Show Hidden Places"
1778 "</interface> to display it again.</para>") + panelWhatsThis
);
1780 // Add actions into the "Panels" menu
1781 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
1782 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
1783 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
1784 panelsMenu
->setDelayed(false);
1785 const KActionCollection
* ac
= actionCollection();
1786 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
1788 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
1790 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
1791 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
1792 panelsMenu
->addSeparator();
1793 panelsMenu
->addAction(actionShowAllPlaces
);
1794 panelsMenu
->addAction(lockLayoutAction
);
1796 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
1797 actionShowAllPlaces
->setEnabled(m_placesPanel
->hiddenListCount());
1802 void DolphinMainWindow::updateFileAndEditActions()
1804 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
1805 const KActionCollection
* col
= actionCollection();
1806 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
1808 if (list
.isEmpty()) {
1809 stateChanged(QStringLiteral("has_no_selection"));
1811 addToPlacesAction
->setEnabled(true);
1812 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer
->placesText()));
1814 stateChanged(QStringLiteral("has_selection"));
1816 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
1817 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
1818 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
1819 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
1820 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
1821 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
1823 if (list
.length() == 1 && list
.first().isDir()) {
1824 addToPlacesAction
->setEnabled(true);
1825 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list
.first().name()));
1827 addToPlacesAction
->setEnabled(false);
1828 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1831 KFileItemListProperties
capabilities(list
);
1832 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
1834 renameAction
->setEnabled(capabilities
.supportsMoving());
1835 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1836 deleteAction
->setEnabled(capabilities
.supportsDeleting());
1837 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
1838 cutAction
->setEnabled(capabilities
.supportsMoving());
1839 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
1843 void DolphinMainWindow::updateViewActions()
1845 m_actionHandler
->updateViewActions();
1847 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
1848 showFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
1850 updateSplitAction();
1852 QAction
* editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
1853 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
1854 editableLocactionAction
->setChecked(urlNavigator
->isUrlEditable());
1857 void DolphinMainWindow::updateGoActions()
1859 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
1860 const QUrl currentUrl
= m_activeViewContainer
->url();
1861 // I think this is one of the best places to firstly be confronted
1862 // with a file system and its hierarchy. Talking about the root
1863 // directory might seem too much here but it is the question that
1864 // naturally arises in this context.
1865 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
1866 "the folder that contains the currently viewed one.</para>"
1867 "<para>All files and folders are organized in a hierarchical "
1868 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
1869 "a directory that contains all data connected to this computer"
1870 "—the <emphasis>root directory</emphasis>.</para>"));
1871 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
1874 void DolphinMainWindow::createControlButton()
1876 if (m_controlButton
) {
1879 Q_ASSERT(!m_controlButton
);
1881 m_controlButton
= new QToolButton(this);
1882 m_controlButton
->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
1883 m_controlButton
->setToolTip(i18nc("@action", "Show menu"));
1884 m_controlButton
->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis
);
1885 m_controlButton
->setPopupMode(QToolButton::InstantPopup
);
1887 QMenu
* controlMenu
= new QMenu(m_controlButton
);
1888 connect(controlMenu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateControlMenu
);
1889 controlMenu
->installEventFilter(this);
1891 m_controlButton
->setMenu(controlMenu
);
1893 toolBar()->addWidget(m_controlButton
);
1894 connect(toolBar(), &KToolBar::iconSizeChanged
,
1895 m_controlButton
, &QToolButton::setIconSize
);
1897 // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
1898 // gets edited. In this case we must add them again. The adding is done asynchronously by
1899 // m_updateToolBarTimer.
1900 connect(m_controlButton
, &QToolButton::destroyed
, this, &DolphinMainWindow::slotControlButtonDeleted
);
1901 m_updateToolBarTimer
= new QTimer(this);
1902 m_updateToolBarTimer
->setInterval(500);
1903 connect(m_updateToolBarTimer
, &QTimer::timeout
, this, &DolphinMainWindow::updateToolBar
);
1906 void DolphinMainWindow::deleteControlButton()
1908 delete m_controlButton
;
1909 m_controlButton
= nullptr;
1911 delete m_updateToolBarTimer
;
1912 m_updateToolBarTimer
= nullptr;
1915 bool DolphinMainWindow::addActionToMenu(QAction
* action
, QMenu
* menu
)
1920 const KToolBar
* toolBarWidget
= toolBar();
1921 foreach (const QWidget
* widget
, action
->associatedWidgets()) {
1922 if (widget
== toolBarWidget
) {
1927 menu
->addAction(action
);
1931 void DolphinMainWindow::refreshViews()
1933 m_tabWidget
->refreshViews();
1935 if (GeneralSettings::modifiedStartupSettings()) {
1936 // The startup settings have been changed by the user (see bug #254947).
1937 // Synchronize the split-view setting with the active view:
1938 const bool splitView
= GeneralSettings::splitView();
1939 m_tabWidget
->currentTabPage()->setSplitViewEnabled(splitView
);
1940 updateSplitAction();
1941 updateWindowTitle();
1944 emit
settingsChanged();
1947 void DolphinMainWindow::clearStatusBar()
1949 m_activeViewContainer
->statusBar()->resetToDefaultText();
1952 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
1954 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
1955 this, &DolphinMainWindow::updateFilterBarAction
);
1956 connect(container
, &DolphinViewContainer::writeStateChanged
,
1957 this, &DolphinMainWindow::slotWriteStateChanged
);
1958 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
1959 this, &DolphinMainWindow::updateSearchAction
);
1961 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1962 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
1964 const DolphinView
* view
= container
->view();
1965 connect(view
, &DolphinView::selectionChanged
,
1966 this, &DolphinMainWindow::slotSelectionChanged
);
1967 connect(view
, &DolphinView::requestItemInfo
,
1968 this, &DolphinMainWindow::requestItemInfo
);
1969 connect(view
, &DolphinView::tabRequested
,
1970 this, &DolphinMainWindow::openNewTab
);
1971 connect(view
, &DolphinView::requestContextMenu
,
1972 this, &DolphinMainWindow::openContextMenu
);
1973 connect(view
, &DolphinView::directoryLoadingStarted
,
1974 this, &DolphinMainWindow::enableStopAction
);
1975 connect(view
, &DolphinView::directoryLoadingCompleted
,
1976 this, &DolphinMainWindow::disableStopAction
);
1977 connect(view
, &DolphinView::directoryLoadingCompleted
,
1978 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
1979 connect(view
, &DolphinView::goBackRequested
,
1980 this, &DolphinMainWindow::goBack
);
1981 connect(view
, &DolphinView::goForwardRequested
,
1982 this, &DolphinMainWindow::goForward
);
1983 connect(view
, &DolphinView::urlActivated
,
1984 this, &DolphinMainWindow::handleUrl
);
1986 const KUrlNavigator
* navigator
= container
->urlNavigator();
1987 connect(navigator
, &KUrlNavigator::urlChanged
,
1988 this, &DolphinMainWindow::changeUrl
);
1989 connect(navigator
, &KUrlNavigator::historyChanged
,
1990 this, &DolphinMainWindow::updateHistory
);
1991 connect(navigator
, &KUrlNavigator::editableStateChanged
,
1992 this, &DolphinMainWindow::slotEditableStateChanged
);
1993 connect(navigator
, &KUrlNavigator::tabRequested
,
1994 this, &DolphinMainWindow::openNewTabAfterLastTab
);
1997 void DolphinMainWindow::updateSplitAction()
1999 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
2000 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2001 if (tabPage
->splitViewEnabled()) {
2002 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2003 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2004 splitAction
->setToolTip(i18nc("@info", "Close left view"));
2005 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2007 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2008 splitAction
->setToolTip(i18nc("@info", "Close right view"));
2009 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2012 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2013 splitAction
->setToolTip(i18nc("@info", "Split view"));
2014 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2018 bool DolphinMainWindow::isKompareInstalled() const
2020 static bool initialized
= false;
2021 static bool installed
= false;
2023 // TODO: maybe replace this approach later by using a menu
2024 // plugin like kdiff3plugin.cpp
2025 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2031 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2032 const QKeySequence
& shortcut
,
2033 QAction
* dockAction
,
2034 const QString
& actionName
)
2036 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2037 panelAction
->setCheckable(true);
2038 panelAction
->setChecked(dockAction
->isChecked());
2039 panelAction
->setText(dockAction
->text());
2040 panelAction
->setIcon(icon
);
2041 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2043 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2044 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2047 void DolphinMainWindow::setupWhatsThis()
2050 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2051 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2052 "configuration options. Left-click on any of the menus on this "
2053 "bar to see its contents.</para><para>The Menubar can be hidden "
2054 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2055 "most of its contents become available through a <interface>Control"
2056 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2057 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2058 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2059 "frequently used actions.</para><para>It is highly customizable. "
2060 "All items you see in the <interface>Control</interface> menu or "
2061 "in the <interface>Menubar</interface> can be placed on the "
2062 "Toolbar. Just right-click on it and select <interface>Configure "
2063 "Toolbars…</interface> or find this action in the <interface>"
2064 "Control</interface> or <interface>Settings</interface> menu."
2065 "</para><para>The location of the bar and the style of its "
2066 "buttons can also be changed in the right-click menu. Right-click "
2067 "a button if you want to show or hide its text.</para>"));
2068 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2069 "<para>Here you can see the <emphasis>folders</emphasis> and "
2070 "<emphasis>files</emphasis> that are at the location described in "
2071 "the <interface>Location Bar</interface> above. This area is the "
2072 "central part of this application where you navigate to the files "
2073 "you want to use.</para><para>For an elaborate and general "
2074 "introduction to this application <link "
2075 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2076 "click here</link>. This will open an introductory article from "
2077 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2078 "explanations of all the features of this <emphasis>view</emphasis> "
2079 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2080 "instead. This will open a page from the <emphasis>Handbook"
2081 "</emphasis> that covers the basics.</para>"));
2084 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2085 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2086 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2087 "There you can set up key combinations to trigger an action when "
2088 "they are pressed simultaneously. All commands in this application can "
2089 "be triggered this way.</para>"));
2090 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2091 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2092 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2093 "<para>All items you see in the <interface>Control</interface> menu "
2094 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2095 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2096 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2097 "change a multitude of settings for this application. For an explanation "
2098 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2099 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2102 // The whatsthis has to be set for the m_helpMenu and for the
2103 // StandardAction separately because both are used in different locations.
2104 // m_helpMenu is only used for createControlButton() button.
2106 // Links do not work within the Menubar so texts without links are provided there.
2108 // i18n: If the external link isn't available in your language you should
2109 // probably state the external link language at least in brackets to not
2110 // frustrate the user. If there are multiple languages that the user might
2111 // know with a reasonable chance you might want to have 2 external links.
2112 // The same is in my opinion true for every external link you translate.
2113 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2114 "<para>This opens the Handbook for this application. It provides "
2115 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2116 actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents
))
2117 ->setWhatsThis(whatsThisHelpContents
2118 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2119 "<para>If you want more elaborate introductions to the "
2120 "different features of <emphasis>Dolphin</emphasis> "
2121 "go to the KDE UserBase Wiki.</para>"));
2122 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setWhatsThis(whatsThisHelpContents
2123 + xi18nc("@info:whatsthis second half of handbook text with link",
2124 "<para>If you want more elaborate introductions to the "
2125 "different features of <emphasis>Dolphin</emphasis> "
2126 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2127 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2129 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2130 "<para>This is the button that invokes the help feature you are "
2131 "using right now! Click it, then click any component of this "
2132 "application to ask \"What's this?\" about it. The mouse cursor "
2133 "will change appearance if no help is available for a spot.</para>");
2134 actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis
))
2135 ->setWhatsThis(whatsThisWhatsThis
2136 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2137 "<para>There are two other ways to get help for this application: The "
2138 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2139 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2140 "article about <emphasis>File Management</emphasis> online."
2141 "</para><para>The \"What's this?\" help is "
2142 "missing in most other windows so don't get too used to this.</para>"));
2143 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setWhatsThis(whatsThisWhatsThis
2144 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2145 "<para>There are two other ways to get help: "
2146 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2147 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2148 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2149 "missing in most other windows so don't get too used to this.</para>"));
2151 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2152 "window that will guide you through reporting errors or flaws "
2153 "in this application or in other KDE software.</para>");
2154 actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug
))
2155 ->setWhatsThis(whatsThisReportBug
);
2156 m_helpMenu
->action(KHelpMenu::menuReportBug
)->setWhatsThis(whatsThisReportBug
2157 + xi18nc("@info:whatsthis second half of reportbug text with link",
2158 "<para>High-quality bug reports are much appreciated. To learn "
2159 "how to make your bug report as effective as possible "
2160 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2161 "click here</link>.</para>"));
2163 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2164 "<emphasis>web page</emphasis> where you can donate to "
2165 "support the continued work on this application and many "
2166 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2167 "<para>Donating is the easiest and fastest way to efficiently "
2168 "support KDE and its projects. KDE projects are available for "
2169 "free therefore your donation is needed to cover things that "
2170 "require money like servers, contributor meetings, etc.</para>"
2171 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2172 "organization behind the KDE community.</para>");
2173 actionCollection()->action(KStandardAction::name(KStandardAction::Donate
))
2174 ->setWhatsThis(whatsThisDonate
);
2175 m_helpMenu
->action(KHelpMenu::menuDonate
)->setWhatsThis(whatsThisDonate
);
2177 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2178 "With this you can change the language this application uses."
2179 "<nl/>You can even set secondary languages which will be used "
2180 "if texts are not available in your preferred language.");
2181 actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
))
2182 ->setWhatsThis(whatsThisSwitchLanguage
);
2183 m_helpMenu
->action(KHelpMenu::menuSwitchLanguage
)->setWhatsThis(whatsThisSwitchLanguage
);
2185 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2186 "window that informs you about the version, license, "
2187 "used libraries and maintainers of this application.");
2188 actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp
))
2189 ->setWhatsThis(whatsThisAboutApp
);
2190 m_helpMenu
->action(KHelpMenu::menuAboutApp
)->setWhatsThis(whatsThisAboutApp
);
2192 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2193 "window with information about <emphasis>KDE</emphasis>. "
2194 "The KDE community are the people behind this free software."
2195 "<nl/>If you like using this application but don't know "
2196 "about KDE or want to see a cute dragon have a look!");
2197 actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE
))
2198 ->setWhatsThis(whatsThisAboutKDE
);
2199 m_helpMenu
->action(KHelpMenu::menuAboutKDE
)->setWhatsThis(whatsThisAboutKDE
);
2202 bool DolphinMainWindow::event(QEvent
*event
)
2204 if (event
->type() == QEvent::WhatsThisClicked
) {
2206 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2207 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2210 return KXmlGuiWindow::event(event
);
2213 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2216 if (event
->type() == QEvent::WhatsThisClicked
) {
2218 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2219 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2225 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2226 KIO::FileUndoManager::UiInterface()
2230 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2234 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2236 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2238 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2239 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2241 KIO::FileUndoManager::UiInterface::jobError(job
);
2245 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2247 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));