2 * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2006 Stefan Monov <logixoul@gmail.com>
4 * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0-or-later
9 #include "dolphinmainwindow.h"
11 #include "dolphin_generalsettings.h"
12 #include "dolphinbookmarkhandler.h"
13 #include "dolphincontextmenu.h"
14 #include "dolphindockwidget.h"
15 #include "dolphinmainwindowadaptor.h"
16 #include "dolphinnavigatorswidgetaction.h"
17 #include "dolphinnewfilemenu.h"
18 #include "dolphinplacesmodelsingleton.h"
19 #include "dolphinrecenttabsmenu.h"
20 #include "dolphintabpage.h"
21 #include "dolphinurlnavigatorscontroller.h"
22 #include "dolphinviewcontainer.h"
24 #include "middleclickactioneventfilter.h"
25 #include "panels/folders/folderspanel.h"
26 #include "panels/places/placespanel.h"
27 #include "panels/terminal/terminalpanel.h"
28 #include "selectionmode/actiontexthelper.h"
29 #include "settings/dolphinsettingsdialog.h"
30 #include "statusbar/dolphinstatusbar.h"
31 #include "views/dolphinnewfilemenuobserver.h"
32 #include "views/dolphinremoteencoding.h"
33 #include "views/dolphinviewactionhandler.h"
34 #include "views/draganddrophelper.h"
35 #include "views/viewproperties.h"
37 #include <KActionCollection>
38 #include <KActionMenu>
39 #include <KAuthorized>
40 #include <KColorSchemeManager>
43 #include <KDialogJobUiDelegate>
44 #include <KDualAction>
45 #include <KFileItemListProperties>
46 #include <KIO/CommandLauncherJob>
47 #include <KIO/JobUiDelegateFactory>
48 #include <KIO/OpenFileManagerWindowJob>
49 #include <KIO/OpenUrlJob>
50 #include <KJobWidgets>
51 #include <KLocalizedString>
52 #include <KMessageBox>
53 #include <KProtocolInfo>
54 #include <KProtocolManager>
56 #include <KShortcutsDialog>
57 #include <KStandardAction>
59 #include <KTerminalLauncherJob>
60 #include <KToggleAction>
62 #include <KToolBarPopupAction>
63 #include <KUrlComboBox>
64 #include <KUrlNavigator>
65 #include <KWindowSystem>
66 #include <KXMLGUIFactory>
68 #include <kwidgetsaddons_version.h>
70 #include <QApplication>
72 #include <QCloseEvent>
73 #include <QDesktopServices>
75 #include <QDomDocument>
79 #include <QPushButton>
81 #include <QStandardPaths>
83 #include <QToolButton>
84 #include <QtConcurrentRun>
85 #include <dolphindebug.h>
90 #include <KStartupInfo>
95 // Used for GeneralSettings::version() to determine whether
96 // an updated version of Dolphin is running, so as to migrate
97 // removed/renamed ...etc config entries; increment it in such
99 const int CurrentDolphinVersion
= 202;
100 // The maximum number of entries in the back/forward popup menu
101 const int MaxNumberOfNavigationentries
= 12;
102 // The maximum number of "Go to Tab" shortcuts
103 const int MaxActivateTabShortcuts
= 9;
106 DolphinMainWindow::DolphinMainWindow()
107 : KXmlGuiWindow(nullptr)
108 , m_newFileMenu(nullptr)
109 , m_tabWidget(nullptr)
110 , m_activeViewContainer(nullptr)
111 , m_actionHandler(nullptr)
112 , m_remoteEncoding(nullptr)
114 , m_bookmarkHandler(nullptr)
115 , m_disabledActionNotifier(nullptr)
116 , m_lastHandleUrlOpenJob(nullptr)
117 , m_terminalPanel(nullptr)
118 , m_placesPanel(nullptr)
119 , m_tearDownFromPlacesRequested(false)
120 , m_backAction(nullptr)
121 , m_forwardAction(nullptr)
122 , m_splitViewAction(nullptr)
123 , m_splitViewMenuAction(nullptr)
124 , m_sessionSaveTimer(nullptr)
125 , m_sessionSaveWatcher(nullptr)
126 , m_sessionSaveScheduled(false)
128 Q_INIT_RESOURCE(dolphin
);
130 new MainWindowAdaptor(this);
133 setWindowFlags(Qt::WindowContextHelpButtonHint
);
135 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
136 setObjectName(QStringLiteral("Dolphin#"));
138 setStateConfigGroup("State");
140 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
141 new KColorSchemeManager(this); // Sets a sensible color scheme which fixes unreadable icons and text on Windows.
144 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
, this, &DolphinMainWindow::showErrorMessage
);
146 KIO::FileUndoManager
*undoManager
= KIO::FileUndoManager::self();
147 undoManager
->setUiInterface(new UndoUiInterface());
149 connect(undoManager
, &KIO::FileUndoManager::undoAvailable
, this, &DolphinMainWindow::slotUndoAvailable
);
150 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
, this, &DolphinMainWindow::slotUndoTextChanged
);
151 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
, this, &DolphinMainWindow::clearStatusBar
);
152 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
, this, &DolphinMainWindow::showCommand
);
154 const bool firstRun
= (GeneralSettings::version() < 200);
156 GeneralSettings::setViewPropsTimestamp(QDateTime::currentDateTime());
159 setAcceptDrops(true);
161 auto *navigatorsWidgetAction
= new DolphinNavigatorsWidgetAction(this);
162 actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction
);
163 m_tabWidget
= new DolphinTabWidget(navigatorsWidgetAction
, this);
164 m_tabWidget
->setObjectName("tabWidget");
165 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
, this, &DolphinMainWindow::activeViewChanged
);
166 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
, this, &DolphinMainWindow::tabCountChanged
);
167 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
, this, &DolphinMainWindow::updateWindowTitle
);
168 setCentralWidget(m_tabWidget
);
170 m_actionTextHelper
= new SelectionMode::ActionTextHelper(this);
173 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), m_actionTextHelper
, this);
174 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
175 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
176 connect(m_actionHandler
, &DolphinViewActionHandler::selectionModeChangeTriggered
, this, &DolphinMainWindow::slotSetSelectionMode
);
178 Q_CHECK_PTR(actionCollection()->action(QStringLiteral("create_dir")));
179 m_newFileMenu
->setNewFolderShortcutAction(actionCollection()->action(QStringLiteral("create_dir")));
181 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
182 connect(this, &DolphinMainWindow::urlChanged
, m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
184 m_disabledActionNotifier
= new DisabledActionNotifier(this);
185 connect(m_disabledActionNotifier
, &DisabledActionNotifier::disabledActionTriggered
, this, [this](const QAction
*, QString reason
) {
186 m_activeViewContainer
->showMessage(reason
, DolphinViewContainer::Warning
);
191 setupGUI(Save
| Create
| ToolBar
);
192 stateChanged(QStringLiteral("new_file"));
194 QClipboard
*clipboard
= QApplication::clipboard();
195 connect(clipboard
, &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
197 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
198 toggleFilterBarAction
->setChecked(GeneralSettings::filterBar());
201 menuBar()->setVisible(false);
204 const bool showMenu
= !menuBar()->isHidden();
205 QAction
*showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
206 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
208 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
209 hamburgerMenu
->setMenuBar(menuBar());
210 hamburgerMenu
->setShowMenuBarAction(showMenuBarAction
);
211 connect(hamburgerMenu
, &KHamburgerMenu::aboutToShowMenu
, this, &DolphinMainWindow::updateHamburgerMenu
);
212 hamburgerMenu
->hideActionsOf(toolBar());
213 if (GeneralSettings::version() < 201 && !toolBar()->actions().contains(hamburgerMenu
)) {
214 addHamburgerMenuToToolbar();
217 updateAllowedToolbarAreas();
219 // enable middle-click on back/forward/up to open in a new tab
220 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
221 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
222 toolBar()->installEventFilter(middleClickEventFilter
);
226 connect(KSycoca::self(), &KSycoca::databaseChanged
, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
228 QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
230 m_fileItemActions
.setParentWidget(this);
231 connect(&m_fileItemActions
, &KFileItemActions::error
, this, [this](const QString
&errorMessage
) {
232 showErrorMessage(errorMessage
);
235 connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged
, this, &DolphinMainWindow::slotSplitViewChanged
);
238 DolphinMainWindow::~DolphinMainWindow()
240 // This fixes a crash on Wayland when closing the mainwindow while another dialog is open.
241 disconnect(QGuiApplication::clipboard(), &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
244 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
246 QVector
<DolphinViewContainer
*> viewContainers
;
248 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
249 DolphinTabPage
*tabPage
= m_tabWidget
->tabPageAt(i
);
251 viewContainers
<< tabPage
->primaryViewContainer();
252 if (tabPage
->splitViewEnabled()) {
253 viewContainers
<< tabPage
->secondaryViewContainer();
256 return viewContainers
;
259 void DolphinMainWindow::openDirectories(const QList
<QUrl
> &dirs
, bool splitView
)
261 m_tabWidget
->openDirectories(dirs
, splitView
);
264 void DolphinMainWindow::openDirectories(const QStringList
&dirs
, bool splitView
)
266 openDirectories(QUrl::fromStringList(dirs
), splitView
);
269 void DolphinMainWindow::openFiles(const QList
<QUrl
> &files
, bool splitView
)
271 m_tabWidget
->openFiles(files
, splitView
);
274 bool DolphinMainWindow::isFoldersPanelEnabled() const
276 return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
279 bool DolphinMainWindow::isInformationPanelEnabled() const
282 return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
288 bool DolphinMainWindow::isSplitViewEnabledInCurrentTab() const
290 return m_tabWidget
->currentTabPage()->splitViewEnabled();
293 void DolphinMainWindow::openFiles(const QStringList
&files
, bool splitView
)
295 openFiles(QUrl::fromStringList(files
), splitView
);
298 void DolphinMainWindow::activateWindow(const QString
&activationToken
)
300 window()->setAttribute(Qt::WA_NativeWindow
, true);
302 if (KWindowSystem::isPlatformWayland()) {
303 KWindowSystem::setCurrentXdgActivationToken(activationToken
);
304 } else if (KWindowSystem::isPlatformX11()) {
306 KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken
.toUtf8());
310 KWindowSystem::activateWindow(window()->windowHandle());
313 bool DolphinMainWindow::isActiveWindow()
315 return window()->isActiveWindow();
318 void DolphinMainWindow::showCommand(CommandType command
)
320 DolphinStatusBar
*statusBar
= m_activeViewContainer
->statusBar();
322 case KIO::FileUndoManager::Copy
:
323 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
325 case KIO::FileUndoManager::Move
:
326 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
328 case KIO::FileUndoManager::Link
:
329 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
331 case KIO::FileUndoManager::Trash
:
332 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
334 case KIO::FileUndoManager::Rename
:
335 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
338 case KIO::FileUndoManager::Mkdir
:
339 statusBar
->setText(i18nc("@info:status", "Created folder."));
347 void DolphinMainWindow::pasteIntoFolder()
349 m_activeViewContainer
->view()->pasteIntoFolder();
352 void DolphinMainWindow::changeUrl(const QUrl
&url
)
354 if (!KProtocolManager::supportsListing(url
)) {
355 // The URL navigator only checks for validity, not
356 // if the URL can be listed. An error message is
357 // shown due to DolphinViewContainer::restoreView().
361 m_activeViewContainer
->setUrl(url
);
362 updateFileAndEditActions();
367 Q_EMIT
urlChanged(url
);
370 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
&url
)
372 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
373 m_placesPanel
->proceedWithTearDown();
374 m_tearDownFromPlacesRequested
= false;
377 m_activeViewContainer
->setAutoGrabFocus(false);
379 m_activeViewContainer
->setAutoGrabFocus(true);
382 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
384 KToggleAction
*editableLocationAction
= static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
385 editableLocationAction
->setChecked(editable
);
388 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
&selection
)
390 updateFileAndEditActions();
392 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
394 QAction
*compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
395 if (selectedUrlsCount
== 2) {
396 compareFilesAction
->setEnabled(isKompareInstalled());
398 compareFilesAction
->setEnabled(false);
401 Q_EMIT
selectionChanged(selection
);
404 void DolphinMainWindow::updateHistory()
406 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
407 const int index
= urlNavigator
->historyIndex();
409 QAction
*backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
411 backAction
->setToolTip(i18nc("@info", "Go back"));
412 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
413 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
416 QAction
*forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
418 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
419 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward", "This undoes a <interface>Go|Back</interface> action."));
420 forwardAction
->setEnabled(index
> 0);
424 void DolphinMainWindow::updateFilterBarAction(bool show
)
426 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
427 toggleFilterBarAction
->setChecked(show
);
430 void DolphinMainWindow::openNewMainWindow()
432 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
435 void DolphinMainWindow::openNewActivatedTab()
437 // keep browsers compatibility, new tab is always after last one
438 auto openNewTabAfterLastTabConfigured
= GeneralSettings::openNewTabAfterLastTab();
439 GeneralSettings::setOpenNewTabAfterLastTab(true);
440 m_tabWidget
->openNewActivatedTab();
441 GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured
);
444 void DolphinMainWindow::addToPlaces()
449 // If nothing is selected, act on the current dir
450 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
451 url
= m_activeViewContainer
->url();
452 name
= m_activeViewContainer
->placesText();
454 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
455 url
= dirToAdd
.url();
456 name
= dirToAdd
.name();
460 if (m_activeViewContainer
->isSearchModeEnabled()) {
461 icon
= QStringLiteral("folder-saved-search-symbolic");
463 icon
= KIO::iconNameForUrl(url
);
465 DolphinPlacesModelSingleton::instance().placesModel()->addPlace(name
, url
, icon
);
469 void DolphinMainWindow::openNewTab(const QUrl
&url
)
471 m_tabWidget
->openNewTab(url
, QUrl());
474 void DolphinMainWindow::openNewTabAndActivate(const QUrl
&url
)
476 m_tabWidget
->openNewActivatedTab(url
, QUrl());
479 void DolphinMainWindow::openNewWindow(const QUrl
&url
)
481 Dolphin::openNewWindow({url
}, this);
484 void DolphinMainWindow::slotSplitViewChanged()
486 m_tabWidget
->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation
);
487 updateSplitActions();
490 void DolphinMainWindow::openInNewTab()
492 const KFileItemList
&list
= m_activeViewContainer
->view()->selectedItems();
493 bool tabCreated
= false;
495 for (const KFileItem
&item
: list
) {
496 const QUrl
&url
= DolphinView::openItemAsFolderUrl(item
);
497 if (!url
.isEmpty()) {
503 // if no new tab has been created from the selection
504 // open the current directory in a new tab
506 openNewTab(m_activeViewContainer
->url());
510 void DolphinMainWindow::openInNewWindow()
514 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
515 if (list
.isEmpty()) {
516 newWindowUrl
= m_activeViewContainer
->url();
517 } else if (list
.count() == 1) {
518 const KFileItem
&item
= list
.first();
519 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
522 if (!newWindowUrl
.isEmpty()) {
523 Dolphin::openNewWindow({newWindowUrl
}, this);
527 void DolphinMainWindow::openInSplitView(const QUrl
&url
)
529 QUrl newSplitViewUrl
= url
;
531 if (newSplitViewUrl
.isEmpty()) {
532 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
533 if (list
.count() == 1) {
534 const KFileItem
&item
= list
.first();
535 newSplitViewUrl
= DolphinView::openItemAsFolderUrl(item
);
539 if (newSplitViewUrl
.isEmpty()) {
543 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
544 if (tabPage
->splitViewEnabled()) {
545 tabPage
->switchActiveView();
546 tabPage
->activeViewContainer()->setUrl(newSplitViewUrl
);
548 tabPage
->setSplitViewEnabled(true, WithAnimation
, newSplitViewUrl
);
553 void DolphinMainWindow::showTarget()
555 const KFileItem link
= m_activeViewContainer
->view()->selectedItems().at(0);
556 const QUrl destinationUrl
= link
.url().resolved(QUrl(link
.linkDest()));
558 auto job
= KIO::stat(destinationUrl
, KIO::StatJob::SourceSide
, KIO::StatNoDetails
);
560 connect(job
, &KJob::finished
, this, [this, destinationUrl
](KJob
*job
) {
561 KIO::StatJob
*statJob
= static_cast<KIO::StatJob
*>(job
);
563 if (statJob
->error()) {
564 m_activeViewContainer
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
566 KIO::highlightInFileManager({destinationUrl
});
571 bool DolphinMainWindow::event(QEvent
*event
)
573 if (event
->type() == QEvent::ShortcutOverride
) {
574 const QKeyEvent
*keyEvent
= static_cast<QKeyEvent
*>(event
);
575 if (keyEvent
->key() == Qt::Key_Space
&& m_activeViewContainer
->view()->handleSpaceAsNormalKey()) {
581 return KXmlGuiWindow::event(event
);
584 void DolphinMainWindow::showEvent(QShowEvent
*event
)
586 KXmlGuiWindow::showEvent(event
);
588 if (!event
->spontaneous()) {
589 m_activeViewContainer
->view()->setFocus();
593 void DolphinMainWindow::closeEvent(QCloseEvent
*event
)
595 // Find out if Dolphin is closed directly by the user or
596 // by the session manager because the session is closed
597 bool closedByUser
= true;
598 if (qApp
->isSavingSession()) {
599 closedByUser
= false;
602 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && !GeneralSettings::rememberOpenedTabs() && closedByUser
) {
603 // Ask the user if he really wants to quit and close all tabs.
604 // Open a confirmation dialog with 3 buttons:
605 // QDialogButtonBox::Yes -> Quit
606 // QDialogButtonBox::No -> Close only the current tab
607 // QDialogButtonBox::Cancel -> do nothing
608 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
609 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
610 dialog
->setModal(true);
611 QDialogButtonBox
*buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
612 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
),
613 KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()),
614 QIcon::fromTheme(QStringLiteral("application-exit"))));
615 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
616 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
617 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
619 bool doNotAskAgainCheckboxResult
= false;
621 const auto result
= KMessageBox::createKMessageBox(dialog
,
623 QMessageBox::Warning
,
624 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
626 i18n("Do not ask again"),
627 &doNotAskAgainCheckboxResult
,
628 KMessageBox::Notify
);
630 if (doNotAskAgainCheckboxResult
) {
631 GeneralSettings::setConfirmClosingMultipleTabs(false);
635 case QDialogButtonBox::Yes
:
638 case QDialogButtonBox::No
:
639 // Close only the current tab
640 m_tabWidget
->closeTab();
648 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
649 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
650 // Open a confirmation dialog with 3 buttons:
651 // QDialogButtonBox::Yes -> Quit
652 // QDialogButtonBox::No -> Show Terminal Panel
653 // QDialogButtonBox::Cancel -> do nothing
654 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
655 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
656 dialog
->setModal(true);
657 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
658 if (!m_terminalPanel
->isVisible()) {
659 standardButtons
|= QDialogButtonBox::No
;
661 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
662 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
663 if (!m_terminalPanel
->isVisible()) {
664 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
666 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
668 bool doNotAskAgainCheckboxResult
= false;
670 const auto result
= KMessageBox::createKMessageBox(
673 QMessageBox::Warning
,
674 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
676 i18n("Do not ask again"),
677 &doNotAskAgainCheckboxResult
,
678 KMessageBox::Notify
| KMessageBox::Dangerous
);
680 if (doNotAskAgainCheckboxResult
) {
681 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
685 case QDialogButtonBox::Yes
:
688 case QDialogButtonBox::No
:
689 actionCollection()->action("show_terminal_panel")->trigger();
690 // Do not quit, ignore quit event
698 if (m_sessionSaveTimer
&& (m_sessionSaveTimer
->isActive() || m_sessionSaveWatcher
->isRunning())) {
699 const bool sessionSaveTimerActive
= m_sessionSaveTimer
->isActive();
701 m_sessionSaveTimer
->stop();
702 m_sessionSaveWatcher
->disconnect();
703 m_sessionSaveWatcher
->waitForFinished();
705 if (sessionSaveTimerActive
|| m_sessionSaveScheduled
) {
710 GeneralSettings::setVersion(CurrentDolphinVersion
);
711 GeneralSettings::self()->save();
713 KXmlGuiWindow::closeEvent(event
);
716 void DolphinMainWindow::slotSaveSession()
718 m_sessionSaveScheduled
= false;
720 if (m_sessionSaveWatcher
->isRunning()) {
721 // The previous session is still being saved - schedule another save.
722 m_sessionSaveWatcher
->disconnect();
723 connect(m_sessionSaveWatcher
, &QFutureWatcher
<void>::finished
, this, &DolphinMainWindow::slotSaveSession
, Qt::SingleShotConnection
);
724 m_sessionSaveScheduled
= true;
725 } else if (!m_sessionSaveTimer
->isActive()) {
726 // No point in saving the session if the timer is running (since it will save the session again when it times out).
727 KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin"));
728 KConfig
*config
= KConfigGui::sessionConfig();
729 saveGlobalProperties(config
);
730 savePropertiesInternal(config
, 1);
732 auto future
= QtConcurrent::run([config
]() {
735 m_sessionSaveWatcher
->setFuture(future
);
739 void DolphinMainWindow::setSessionAutoSaveEnabled(bool enable
)
742 if (!m_sessionSaveTimer
) {
743 m_sessionSaveTimer
= new QTimer(this);
744 m_sessionSaveWatcher
= new QFutureWatcher
<void>(this);
745 m_sessionSaveTimer
->setSingleShot(true);
746 m_sessionSaveTimer
->setInterval(22000);
748 connect(m_sessionSaveTimer
, &QTimer::timeout
, this, &DolphinMainWindow::slotSaveSession
);
751 connect(m_tabWidget
, &DolphinTabWidget::urlChanged
, m_sessionSaveTimer
, qOverload
<>(&QTimer::start
), Qt::UniqueConnection
);
752 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
, m_sessionSaveTimer
, qOverload
<>(&QTimer::start
), Qt::UniqueConnection
);
753 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
, m_sessionSaveTimer
, qOverload
<>(&QTimer::start
), Qt::UniqueConnection
);
754 } else if (m_sessionSaveTimer
) {
755 m_sessionSaveTimer
->stop();
756 m_sessionSaveWatcher
->disconnect();
757 m_sessionSaveScheduled
= false;
759 m_sessionSaveWatcher
->waitForFinished();
761 m_sessionSaveTimer
->deleteLater();
762 m_sessionSaveWatcher
->deleteLater();
763 m_sessionSaveTimer
= nullptr;
764 m_sessionSaveWatcher
= nullptr;
768 void DolphinMainWindow::saveProperties(KConfigGroup
&group
)
770 m_tabWidget
->saveProperties(group
);
773 void DolphinMainWindow::readProperties(const KConfigGroup
&group
)
775 m_tabWidget
->readProperties(group
);
778 void DolphinMainWindow::updateNewMenu()
780 m_newFileMenu
->checkUpToDate();
781 m_newFileMenu
->setWorkingDirectory(activeViewContainer()->url());
784 void DolphinMainWindow::createDirectory()
786 // When creating directory, namejob is being run. In network folders,
787 // this job can take long time, so instead of starting multiple namejobs,
788 // just check if we are already running one. This prevents opening multiple
789 // dialogs. BUG:481401
790 if (!m_newFileMenu
->isCreateDirectoryRunning()) {
791 m_newFileMenu
->setWorkingDirectory(activeViewContainer()->url());
792 m_newFileMenu
->createDirectory();
796 void DolphinMainWindow::quit()
801 void DolphinMainWindow::showErrorMessage(const QString
&message
)
803 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
806 void DolphinMainWindow::slotUndoAvailable(bool available
)
808 QAction
*undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
810 undoAction
->setEnabled(available
);
814 void DolphinMainWindow::slotUndoTextChanged(const QString
&text
)
816 QAction
*undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
818 undoAction
->setText(text
);
822 void DolphinMainWindow::undo()
825 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
826 KIO::FileUndoManager::self()->undo();
829 void DolphinMainWindow::cut()
831 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
832 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CutContents
);
834 m_activeViewContainer
->view()->cutSelectedItemsToClipboard();
835 m_activeViewContainer
->setSelectionModeEnabled(false);
839 void DolphinMainWindow::copy()
841 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
842 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CopyContents
);
844 m_activeViewContainer
->view()->copySelectedItemsToClipboard();
845 m_activeViewContainer
->setSelectionModeEnabled(false);
849 void DolphinMainWindow::paste()
851 m_activeViewContainer
->view()->paste();
854 void DolphinMainWindow::find()
856 m_activeViewContainer
->setSearchModeEnabled(true);
859 void DolphinMainWindow::updateSearchAction()
861 QAction
*toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
862 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
865 void DolphinMainWindow::updatePasteAction()
867 QAction
*pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
868 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
869 pasteAction
->setEnabled(pasteInfo
.first
);
870 m_disabledActionNotifier
->setDisabledReason(pasteAction
,
871 m_activeViewContainer
->rootItem().isWritable()
872 ? i18nc("@info", "Cannot paste: The clipboard is empty.")
873 : i18nc("@info", "Cannot paste: You do not have permission to write into this folder."));
874 pasteAction
->setText(pasteInfo
.second
);
877 void DolphinMainWindow::slotDirectoryLoadingCompleted()
882 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
884 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
886 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
888 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
890 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
895 QAction
*DolphinMainWindow::urlNavigatorHistoryAction(const KUrlNavigator
*urlNavigator
, int historyIndex
, QObject
*parent
)
897 const QUrl url
= urlNavigator
->locationUrl(historyIndex
);
899 QString text
= url
.toDisplayString(QUrl::PreferLocalFile
);
901 if (!urlNavigator
->showFullPath()) {
902 const KFilePlacesModel
*placesModel
= DolphinPlacesModelSingleton::instance().placesModel();
904 const QModelIndex closestIdx
= placesModel
->closestItem(url
);
905 if (closestIdx
.isValid()) {
906 const QUrl placeUrl
= placesModel
->url(closestIdx
);
908 text
= placesModel
->text(closestIdx
);
910 QString pathInsidePlace
= url
.path().mid(placeUrl
.path().length());
912 if (!pathInsidePlace
.isEmpty() && !pathInsidePlace
.startsWith(QLatin1Char('/'))) {
913 pathInsidePlace
.prepend(QLatin1Char('/'));
916 if (pathInsidePlace
!= QLatin1Char('/')) {
917 text
.append(pathInsidePlace
);
922 QAction
*action
= new QAction(QIcon::fromTheme(KIO::iconNameForUrl(url
)), text
, parent
);
923 action
->setData(historyIndex
);
927 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
929 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
931 QMenu
*menu
= m_backAction
->popupMenu();
933 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
934 QAction
*action
= urlNavigatorHistoryAction(urlNavigator
, i
, menu
);
935 menu
->addAction(action
);
939 void DolphinMainWindow::slotGoBack(QAction
*action
)
941 int gotoIndex
= action
->data().value
<int>();
942 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
943 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
948 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
*action
)
951 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
952 openNewTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
956 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
958 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
960 QMenu
*menu
= m_forwardAction
->popupMenu();
961 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
962 QAction
*action
= urlNavigatorHistoryAction(urlNavigator
, i
, menu
);
963 menu
->addAction(action
);
967 void DolphinMainWindow::slotGoForward(QAction
*action
)
969 int gotoIndex
= action
->data().value
<int>();
970 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
971 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
976 void DolphinMainWindow::slotSetSelectionMode(bool enabled
, SelectionMode::BottomBar::Contents bottomBarContents
)
978 m_activeViewContainer
->setSelectionModeEnabled(enabled
, actionCollection(), bottomBarContents
);
981 void DolphinMainWindow::selectAll()
985 // if the URL navigator is editable and focused, select the whole
986 // URL instead of all items of the view
988 KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigator();
989 QLineEdit
*lineEdit
= urlNavigator
->editor()->lineEdit();
990 const bool selectUrl
= urlNavigator
->isUrlEditable() && lineEdit
->hasFocus();
992 lineEdit
->selectAll();
994 m_activeViewContainer
->view()->selectAll();
998 void DolphinMainWindow::invertSelection()
1001 m_activeViewContainer
->view()->invertSelection();
1004 void DolphinMainWindow::toggleSplitView()
1006 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
1007 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled(), WithAnimation
);
1008 m_tabWidget
->updateTabName(m_tabWidget
->indexOf(tabPage
));
1009 updateViewActions();
1012 void DolphinMainWindow::popoutSplitView()
1014 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
1015 if (!tabPage
->splitViewEnabled())
1017 openNewWindow((GeneralSettings::closeActiveSplitView() ? tabPage
->activeViewContainer() : tabPage
->inactiveViewContainer())->url());
1018 tabPage
->setSplitViewEnabled(false, WithAnimation
);
1019 updateSplitActions();
1022 void DolphinMainWindow::toggleSplitStash()
1024 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
1025 tabPage
->setSplitViewEnabled(false, WithAnimation
);
1026 tabPage
->setSplitViewEnabled(true, WithAnimation
, QUrl("stash:/"));
1029 void DolphinMainWindow::copyToInactiveSplitView()
1031 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
1032 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CopyToOtherViewContents
);
1034 m_tabWidget
->copyToInactiveSplitView();
1035 m_activeViewContainer
->setSelectionModeEnabled(false);
1039 void DolphinMainWindow::moveToInactiveSplitView()
1041 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
1042 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::MoveToOtherViewContents
);
1044 m_tabWidget
->moveToInactiveSplitView();
1045 m_activeViewContainer
->setSelectionModeEnabled(false);
1049 void DolphinMainWindow::reloadView()
1052 m_activeViewContainer
->reload();
1053 m_activeViewContainer
->statusBar()->updateSpaceInfo();
1056 void DolphinMainWindow::stopLoading()
1058 m_activeViewContainer
->view()->stopLoading();
1061 void DolphinMainWindow::enableStopAction()
1063 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
1066 void DolphinMainWindow::disableStopAction()
1068 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
1071 void DolphinMainWindow::toggleSelectionMode()
1073 const bool checked
= !m_activeViewContainer
->isSelectionModeEnabled();
1075 m_activeViewContainer
->setSelectionModeEnabled(checked
, actionCollection(), SelectionMode::BottomBar::Contents::GeneralContents
);
1076 actionCollection()->action(QStringLiteral("toggle_selection_mode"))->setChecked(checked
);
1079 void DolphinMainWindow::showFilterBar()
1081 m_activeViewContainer
->setFilterBarVisible(true);
1084 void DolphinMainWindow::toggleFilterBar()
1086 const bool checked
= !m_activeViewContainer
->isFilterBarVisible();
1087 m_activeViewContainer
->setFilterBarVisible(checked
);
1089 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
1090 toggleFilterBarAction
->setChecked(checked
);
1093 void DolphinMainWindow::toggleEditLocation()
1097 QAction
*action
= actionCollection()->action(QStringLiteral("editable_location"));
1098 KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigator();
1099 urlNavigator
->setUrlEditable(action
->isChecked());
1102 void DolphinMainWindow::replaceLocation()
1104 KUrlNavigator
*navigator
= m_activeViewContainer
->urlNavigator();
1105 QLineEdit
*lineEdit
= navigator
->editor()->lineEdit();
1107 // If the text field currently has focus and everything is selected,
1108 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
1109 if (navigator
->isUrlEditable() && lineEdit
->hasFocus() && lineEdit
->selectedText() == lineEdit
->text()) {
1110 navigator
->setUrlEditable(false);
1112 navigator
->setUrlEditable(true);
1113 navigator
->setFocus();
1114 lineEdit
->selectAll();
1118 void DolphinMainWindow::togglePanelLockState()
1120 const bool newLockState
= !GeneralSettings::lockPanels();
1121 const auto childrenObjects
= children();
1122 for (QObject
*child
: childrenObjects
) {
1123 DolphinDockWidget
*dock
= qobject_cast
<DolphinDockWidget
*>(child
);
1125 dock
->setLocked(newLockState
);
1129 DolphinPlacesModelSingleton::instance().placesModel()->setPanelsLocked(newLockState
);
1131 GeneralSettings::setLockPanels(newLockState
);
1134 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
1136 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
1137 m_activeViewContainer
->view()->setFocus();
1141 void DolphinMainWindow::goBack()
1143 DolphinUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
1144 urlNavigator
->goBack();
1146 if (urlNavigator
->locationState().isEmpty()) {
1147 // An empty location state indicates a redirection URL,
1148 // which must be skipped too
1149 urlNavigator
->goBack();
1153 void DolphinMainWindow::goForward()
1155 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goForward();
1158 void DolphinMainWindow::goUp()
1160 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goUp();
1163 void DolphinMainWindow::goHome()
1165 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goHome();
1168 void DolphinMainWindow::goBackInNewTab()
1170 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
1171 const int index
= urlNavigator
->historyIndex() + 1;
1172 openNewTab(urlNavigator
->locationUrl(index
));
1175 void DolphinMainWindow::goForwardInNewTab()
1177 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
1178 const int index
= urlNavigator
->historyIndex() - 1;
1179 openNewTab(urlNavigator
->locationUrl(index
));
1182 void DolphinMainWindow::goUpInNewTab()
1184 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
1185 openNewTab(KIO::upUrl(currentUrl
));
1188 void DolphinMainWindow::goHomeInNewTab()
1190 openNewTab(Dolphin::homeUrl());
1193 void DolphinMainWindow::compareFiles()
1195 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
1196 if (items
.count() != 2) {
1197 // The action is disabled in this case, but it could have been triggered
1198 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
1202 QUrl urlA
= items
.at(0).url();
1203 QUrl urlB
= items
.at(1).url();
1205 QString
command(QStringLiteral("kompare -c \""));
1206 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
1207 command
.append("\" \"");
1208 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
1209 command
.append('\"');
1211 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(command
, this);
1212 job
->setDesktopName(QStringLiteral("org.kde.kompare"));
1216 void DolphinMainWindow::toggleShowMenuBar()
1218 const bool visible
= menuBar()->isVisible();
1219 menuBar()->setVisible(!visible
);
1222 QPointer
<QAction
> DolphinMainWindow::preferredSearchTool()
1224 m_searchTools
.clear();
1226 KService::Ptr kfind
= KService::serviceByDesktopName(QStringLiteral("org.kde.kfind"));
1232 auto *action
= new QAction(QIcon::fromTheme(kfind
->icon()), kfind
->name(), this);
1234 connect(action
, &QAction::triggered
, this, [this, kfind
] {
1235 auto *job
= new KIO::ApplicationLauncherJob(kfind
);
1236 job
->setUrls({m_activeViewContainer
->url()});
1243 void DolphinMainWindow::updateOpenPreferredSearchToolAction()
1245 QAction
*openPreferredSearchTool
= actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
1246 if (!openPreferredSearchTool
) {
1249 QPointer
<QAction
> tool
= preferredSearchTool();
1251 openPreferredSearchTool
->setVisible(true);
1252 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open %1", tool
->text()));
1253 // Only override with the app icon if it is the default, i.e. the user hasn't configured one manually
1254 // https://bugs.kde.org/show_bug.cgi?id=442815
1255 if (openPreferredSearchTool
->icon().name() == QLatin1String("search")) {
1256 openPreferredSearchTool
->setIcon(tool
->icon());
1259 openPreferredSearchTool
->setVisible(false);
1260 // still visible in Shortcuts configuration window
1261 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1262 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1266 void DolphinMainWindow::openPreferredSearchTool()
1268 QPointer
<QAction
> tool
= preferredSearchTool();
1274 void DolphinMainWindow::openTerminal()
1276 openTerminalJob(m_activeViewContainer
->url());
1279 void DolphinMainWindow::openTerminalHere()
1281 QList
<QUrl
> urls
= {};
1283 const auto selectedItems
= m_activeViewContainer
->view()->selectedItems();
1284 for (const KFileItem
&item
: selectedItems
) {
1285 QUrl url
= item
.targetUrl();
1286 if (item
.isFile()) {
1287 url
.setPath(QFileInfo(url
.path()).absolutePath());
1289 if (!urls
.contains(url
)) {
1294 // No items are selected. Open a terminal window for the current location.
1295 if (urls
.count() == 0) {
1300 if (urls
.count() > 5) {
1301 QString question
= i18np("Are you sure you want to open 1 terminal window?", "Are you sure you want to open %1 terminal windows?", urls
.count());
1302 const int answer
= KMessageBox::warningContinueCancel(
1306 KGuiItem(i18ncp("@action:button", "Open %1 Terminal", "Open %1 Terminals", urls
.count()), QStringLiteral("utilities-terminal")),
1307 KStandardGuiItem::cancel(),
1308 QStringLiteral("ConfirmOpenManyTerminals"));
1309 if (answer
!= KMessageBox::PrimaryAction
&& answer
!= KMessageBox::Continue
) {
1314 for (const QUrl
&url
: std::as_const(urls
)) {
1315 openTerminalJob(url
);
1319 void DolphinMainWindow::openTerminalJob(const QUrl
&url
)
1321 if (url
.isLocalFile()) {
1322 auto job
= new KTerminalLauncherJob(QString());
1323 job
->setWorkingDirectory(url
.toLocalFile());
1328 // Not a local file, with protocol Class ":local", try stat'ing
1329 if (KProtocolInfo::protocolClass(url
.scheme()) == QLatin1String(":local")) {
1330 KIO::StatJob
*job
= KIO::mostLocalUrl(url
);
1331 KJobWidgets::setWindow(job
, this);
1332 connect(job
, &KJob::result
, this, [job
]() {
1334 if (!job
->error()) {
1335 statUrl
= job
->mostLocalUrl();
1338 auto job
= new KTerminalLauncherJob(QString());
1339 job
->setWorkingDirectory(statUrl
.isLocalFile() ? statUrl
.toLocalFile() : QDir::homePath());
1346 // Nothing worked, just use $HOME
1347 auto job
= new KTerminalLauncherJob(QString());
1348 job
->setWorkingDirectory(QDir::homePath());
1352 void DolphinMainWindow::editSettings()
1354 if (!m_settingsDialog
) {
1355 DolphinViewContainer
*container
= activeViewContainer();
1356 container
->view()->writeSettings();
1358 const QUrl url
= container
->url();
1359 DolphinSettingsDialog
*settingsDialog
= new DolphinSettingsDialog(url
, this, actionCollection());
1360 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
1361 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, &DolphinUrlNavigatorsController::slotReadSettings
);
1362 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
1363 settingsDialog
->show();
1364 m_settingsDialog
= settingsDialog
;
1366 m_settingsDialog
.data()->raise();
1370 void DolphinMainWindow::handleUrl(const QUrl
&url
)
1372 delete m_lastHandleUrlOpenJob
;
1373 m_lastHandleUrlOpenJob
= nullptr;
1375 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
1376 activeViewContainer()->setUrl(url
);
1378 m_lastHandleUrlOpenJob
= new KIO::OpenUrlJob(url
);
1379 m_lastHandleUrlOpenJob
->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
1380 m_lastHandleUrlOpenJob
->setShowOpenOrExecuteDialog(true);
1382 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::mimeTypeFound
, this, [this, url
](const QString
&mimetype
) {
1383 if (mimetype
== QLatin1String("inode/directory")) {
1384 // If it's a dir, we'll take it from here
1385 m_lastHandleUrlOpenJob
->kill();
1386 m_lastHandleUrlOpenJob
= nullptr;
1387 activeViewContainer()->setUrl(url
);
1391 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::result
, this, [this]() {
1392 m_lastHandleUrlOpenJob
= nullptr;
1395 m_lastHandleUrlOpenJob
->start();
1399 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1401 // trash:/ is writable but we don't want to create new items in it.
1402 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1403 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1404 // When the menu is disabled, actions in it are disabled later in the event loop, and we need to set the disabled reason after that.
1405 QTimer::singleShot(0, this, [this]() {
1406 m_disabledActionNotifier
->setDisabledReason(actionCollection()->action(QStringLiteral("create_dir")),
1407 i18nc("@info", "Cannot create new folder: You do not have permission to create items in this folder."));
1411 void DolphinMainWindow::openContextMenu(const QPoint
&pos
, const KFileItem
&item
, const KFileItemList
&selectedItems
, const QUrl
&url
)
1413 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, item
, selectedItems
, url
, &m_fileItemActions
);
1414 contextMenu
->exec(pos
);
1416 // Delete the menu, unless it has been deleted in its own nested event loop already.
1418 contextMenu
->deleteLater();
1422 QMenu
*DolphinMainWindow::createPopupMenu()
1424 QMenu
*menu
= KXmlGuiWindow::createPopupMenu();
1426 menu
->addSeparator();
1427 menu
->addAction(actionCollection()->action(QStringLiteral("lock_panels")));
1432 void DolphinMainWindow::updateHamburgerMenu()
1434 KActionCollection
*ac
= actionCollection();
1435 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(ac
->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
1436 auto menu
= hamburgerMenu
->menu();
1438 menu
= new QMenu(this);
1439 hamburgerMenu
->setMenu(menu
);
1440 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("basic_actions"))->menu());
1441 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("zoom"))->menu());
1445 const QList
<QAction
*> toolbarActions
= toolBar()->actions();
1447 if (!toolBar()->isVisible()) {
1448 // If neither the menu bar nor the toolbar are visible, these actions should be available.
1449 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)));
1450 menu
->addAction(toolBarMenuAction());
1451 menu
->addSeparator();
1454 // This group of actions (until the next separator) contains all the most basic actions
1455 // necessary to use Dolphin effectively.
1456 menu
->addAction(ac
->action(QStringLiteral("go_back")));
1457 menu
->addAction(ac
->action(QStringLiteral("go_forward")));
1459 menu
->addMenu(m_newFileMenu
->menu());
1460 if (!toolBar()->isVisible() || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_selection_mode_tool_bar")))) {
1461 menu
->addAction(ac
->action(QStringLiteral("toggle_selection_mode")));
1463 menu
->addAction(ac
->action(QStringLiteral("basic_actions")));
1464 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Undo
)));
1465 if (!toolBar()->isVisible()
1466 || (!toolbarActions
.contains(ac
->action(QStringLiteral("toggle_search")))
1467 && !toolbarActions
.contains(ac
->action(QStringLiteral("open_preferred_search_tool"))))) {
1468 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Find
)));
1469 // This way a search action will only be added if none of the three available
1470 // search actions is present on the toolbar.
1472 if (!toolBar()->isVisible() || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_filter")))) {
1473 menu
->addAction(ac
->action(QStringLiteral("show_filter_bar")));
1474 // This way a filter action will only be added if none of the two available
1475 // filter actions is present on the toolbar.
1477 menu
->addSeparator();
1479 // The second group of actions (up until the next separator) contains actions for opening
1480 // additional views to interact with the file system.
1481 menu
->addAction(ac
->action(QStringLiteral("file_new")));
1482 menu
->addAction(ac
->action(QStringLiteral("new_tab")));
1483 if (ac
->action(QStringLiteral("undo_close_tab"))->isEnabled()) {
1484 menu
->addAction(ac
->action(QStringLiteral("closed_tabs")));
1486 menu
->addAction(ac
->action(QStringLiteral("open_terminal")));
1487 menu
->addSeparator();
1489 // The third group contains actions to change what one sees in the view
1490 // and to change the more general UI.
1491 if (!toolBar()->isVisible()
1492 || (!toolbarActions
.contains(ac
->action(QStringLiteral("icons"))) && !toolbarActions
.contains(ac
->action(QStringLiteral("compact")))
1493 && !toolbarActions
.contains(ac
->action(QStringLiteral("details"))) && !toolbarActions
.contains(ac
->action(QStringLiteral("view_mode"))))) {
1494 menu
->addAction(ac
->action(QStringLiteral("view_mode")));
1496 menu
->addAction(ac
->action(QStringLiteral("show_hidden_files")));
1497 menu
->addAction(ac
->action(QStringLiteral("sort")));
1498 menu
->addAction(ac
->action(QStringLiteral("additional_info")));
1499 if (!GeneralSettings::showStatusBar() || !GeneralSettings::showZoomSlider()) {
1500 menu
->addAction(ac
->action(QStringLiteral("zoom")));
1502 menu
->addAction(ac
->action(QStringLiteral("panels")));
1504 // The "Configure" menu is not added to the actionCollection() because there is hardly
1505 // a good reason for users to put it on their toolbar.
1506 auto configureMenu
= menu
->addMenu(QIcon::fromTheme(QStringLiteral("configure")), i18nc("@action:inmenu menu for configure actions", "Configure"));
1507 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
)));
1508 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)));
1509 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)));
1510 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Preferences
)));
1511 hamburgerMenu
->hideActionsOf(configureMenu
);
1514 void DolphinMainWindow::slotPlaceActivated(const QUrl
&url
)
1516 DolphinViewContainer
*view
= activeViewContainer();
1518 if (view
->url() == url
) {
1519 view
->clearFilterBar(); // Fixes bug 259382.
1521 // We can end up here if the user clicked a device in the Places Panel
1522 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1525 view
->disableUrlNavigatorSelectionRequests();
1527 view
->enableUrlNavigatorSelectionRequests();
1531 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1533 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1536 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
*viewContainer
)
1538 DolphinViewContainer
*oldViewContainer
= m_activeViewContainer
;
1539 Q_ASSERT(viewContainer
);
1541 m_activeViewContainer
= viewContainer
;
1543 if (oldViewContainer
) {
1544 const QAction
*toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1545 toggleSearchAction
->disconnect(oldViewContainer
);
1547 // Disconnect all signals between the old view container (container,
1548 // view and url navigator) and main window.
1549 oldViewContainer
->disconnect(this);
1550 oldViewContainer
->view()->disconnect(this);
1551 oldViewContainer
->urlNavigatorInternalWithHistory()->disconnect(this);
1552 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
1553 navigators
->primaryUrlNavigator()->disconnect(this);
1554 if (auto secondaryUrlNavigator
= navigators
->secondaryUrlNavigator()) {
1555 secondaryUrlNavigator
->disconnect(this);
1558 // except the requestItemInfo so that on hover the information panel can still be updated
1559 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
, this, &DolphinMainWindow::requestItemInfo
);
1561 // Disconnect other slots.
1562 disconnect(oldViewContainer
,
1563 &DolphinViewContainer::selectionModeChanged
,
1564 actionCollection()->action(QStringLiteral("toggle_selection_mode")),
1565 &QAction::setChecked
);
1568 connectViewSignals(viewContainer
);
1570 m_actionHandler
->setCurrentView(viewContainer
->view());
1573 updateFileAndEditActions();
1574 updatePasteAction();
1575 updateViewActions();
1577 updateSearchAction();
1579 const QUrl url
= viewContainer
->url();
1580 Q_EMIT
urlChanged(url
);
1583 void DolphinMainWindow::tabCountChanged(int count
)
1585 const bool enableTabActions
= (count
> 1);
1586 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1587 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1589 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1590 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1591 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1594 void DolphinMainWindow::updateWindowTitle()
1596 const QString newTitle
= m_activeViewContainer
->captionWindowTitle();
1597 if (windowTitle() != newTitle
) {
1598 setWindowTitle(newTitle
);
1602 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
&mountPath
)
1604 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1605 setViewsToHomeIfMountPathOpen(mountPath
);
1608 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectoryIsChildOf(mountPath
)) {
1609 m_tearDownFromPlacesRequested
= true;
1610 m_terminalPanel
->goHome();
1611 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1613 m_placesPanel
->proceedWithTearDown();
1617 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
&mountPath
)
1619 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1620 setViewsToHomeIfMountPathOpen(mountPath
);
1623 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectoryIsChildOf(mountPath
)) {
1624 m_tearDownFromPlacesRequested
= false;
1625 m_terminalPanel
->goHome();
1629 void DolphinMainWindow::slotKeyBindings()
1631 KShortcutsDialog
dialog(KShortcutsEditor::AllActions
, KShortcutsEditor::LetterShortcutsAllowed
, this);
1632 dialog
.addCollection(actionCollection());
1633 if (m_terminalPanel
) {
1634 KActionCollection
*konsolePartActionCollection
= m_terminalPanel
->actionCollection();
1635 if (konsolePartActionCollection
) {
1636 dialog
.addCollection(konsolePartActionCollection
, QStringLiteral("KonsolePart"));
1642 void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString
&mountPath
)
1644 const QVector
<DolphinViewContainer
*> theViewContainers
= viewContainers();
1645 for (DolphinViewContainer
*viewContainer
: theViewContainers
) {
1646 if (viewContainer
&& viewContainer
->url().toLocalFile().startsWith(mountPath
)) {
1647 viewContainer
->setUrl(QUrl::fromLocalFile(QDir::homePath()));
1650 disconnect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, nullptr, nullptr);
1653 void DolphinMainWindow::setupActions()
1655 auto hamburgerMenuAction
= KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
1657 // setup 'File' menu
1658 m_newFileMenu
= new DolphinNewFileMenu(nullptr, this);
1659 actionCollection()->addAction(QStringLiteral("new_menu"), m_newFileMenu
);
1660 QMenu
*menu
= m_newFileMenu
->menu();
1661 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1662 menu
->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
1663 m_newFileMenu
->setPopupMode(QToolButton::InstantPopup
);
1664 connect(menu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateNewMenu
);
1666 QAction
*newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1667 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1668 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1669 newWindow
->setWhatsThis(xi18nc("@info:whatsthis",
1671 "window just like this one with the current location."
1672 "<nl/>You can drag and drop items between windows."));
1673 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1675 QAction
*newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1676 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1677 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1678 newTab
->setWhatsThis(xi18nc("@info:whatsthis",
1680 "<emphasis>Tab</emphasis> with the current location."
1681 "<nl/>Tabs allow you to quickly switch between multiple locations and views within this window. "
1682 "You can drag and drop items between tabs."));
1683 actionCollection()->setDefaultShortcut(newTab
, Qt::CTRL
| Qt::Key_T
);
1684 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1686 QAction
*addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1687 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1688 addToPlaces
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1689 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis",
1690 "This adds the selected folder "
1691 "to the Places panel."));
1692 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1694 QAction
*closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1695 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1696 closeTab
->setToolTip(i18nc("@info", "Close Tab"));
1697 closeTab
->setWhatsThis(i18nc("@info:whatsthis",
1699 "currently viewed tab. If no more tabs are left, this closes "
1700 "the whole window instead."));
1702 QAction
*quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1703 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1705 // setup 'Edit' menu
1706 KStandardAction::undo(this, &DolphinMainWindow::undo
, actionCollection());
1708 // i18n: This will be the last paragraph for the whatsthis for all three:
1709 // Cut, Copy and Paste
1710 const QString cutCopyPastePara
= xi18nc("@info:whatsthis",
1711 "<para><emphasis>Cut, "
1712 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1713 "applications and are among the most used commands. That's why their "
1714 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1715 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1716 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1717 QAction
*cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1718 m_actionTextHelper
->registerTextWhenNothingIsSelected(cutAction
, i18nc("@action", "Cut…"));
1719 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut",
1720 "This copies the items "
1721 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1722 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1723 "the clipboard to a new location. The items will be removed from their "
1724 "initial location.")
1725 + cutCopyPastePara
);
1726 QAction
*copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1727 m_actionTextHelper
->registerTextWhenNothingIsSelected(copyAction
, i18nc("@action", "Copy…"));
1728 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy",
1730 "items in your current selection to the <emphasis>clipboard</emphasis>."
1731 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1732 "from the clipboard to a new location.")
1733 + cutCopyPastePara
);
1734 QAction
*paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1735 // The text of the paste-action is modified dynamically by Dolphin
1736 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1737 // due to the long text, the text "Paste" is used:
1738 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1739 paste
->setWhatsThis(xi18nc("@info:whatsthis paste",
1740 "This copies the items from "
1741 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1742 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1743 "action they are removed from their old location.")
1744 + cutCopyPastePara
);
1746 QAction
*copyToOtherViewAction
= actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
1747 copyToOtherViewAction
->setText(i18nc("@action:inmenu", "Copy to Other View"));
1748 m_actionTextHelper
->registerTextWhenNothingIsSelected(copyToOtherViewAction
, i18nc("@action:inmenu", "Copy to Other View…"));
1749 copyToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Copy",
1750 "This copies the selected items from "
1751 "the view in focus to the other view. "
1752 "(Only available while in Split View mode.)"));
1753 copyToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
1754 copyToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Copy to Other View"));
1755 actionCollection()->setDefaultShortcut(copyToOtherViewAction
, Qt::SHIFT
| Qt::Key_F5
);
1756 connect(copyToOtherViewAction
, &QAction::triggered
, this, &DolphinMainWindow::copyToInactiveSplitView
);
1758 QAction
*moveToOtherViewAction
= actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
1759 moveToOtherViewAction
->setText(i18nc("@action:inmenu", "Move to Other View"));
1760 m_actionTextHelper
->registerTextWhenNothingIsSelected(moveToOtherViewAction
, i18nc("@action:inmenu", "Move to Other View…"));
1761 moveToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Move",
1762 "This moves the selected items from "
1763 "the view in focus to the other view. "
1764 "(Only available while in Split View mode.)"));
1765 moveToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
1766 moveToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Move to Other View"));
1767 actionCollection()->setDefaultShortcut(moveToOtherViewAction
, Qt::SHIFT
| Qt::Key_F6
);
1768 connect(moveToOtherViewAction
, &QAction::triggered
, this, &DolphinMainWindow::moveToInactiveSplitView
);
1770 QAction
*showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1771 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Filter…"));
1772 showFilterBar
->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
1773 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis",
1775 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1776 "There you can enter text to filter the files and folders currently displayed. "
1777 "Only those that contain the text in their name will be kept in view."));
1778 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1779 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
| Qt::Key_I
, Qt::Key_Slash
});
1780 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1782 // toggle_filter acts as a copy of the main showFilterBar to be used mainly
1783 // in the toolbar, with no default shortcut attached, to avoid messing with
1784 // existing workflows (filter bar always open and Ctrl-I to focus)
1785 QAction
*toggleFilter
= actionCollection()->addAction(QStringLiteral("toggle_filter"));
1786 toggleFilter
->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
1787 toggleFilter
->setIconText(i18nc("@action:intoolbar", "Filter"));
1788 toggleFilter
->setIcon(showFilterBar
->icon());
1789 toggleFilter
->setToolTip(showFilterBar
->toolTip());
1790 toggleFilter
->setWhatsThis(showFilterBar
->whatsThis());
1791 toggleFilter
->setCheckable(true);
1792 connect(toggleFilter
, &QAction::triggered
, this, &DolphinMainWindow::toggleFilterBar
);
1794 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1795 searchAction
->setText(i18n("Search…"));
1796 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1797 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find",
1798 "<para>This helps you "
1799 "find files and folders by opening a <emphasis>search bar</emphasis>. "
1800 "There you can enter search terms and specify settings to find the "
1801 "items you are looking for.</para><para>Use this help again on "
1802 "the search bar so we can have a look at it while the settings are "
1803 "explained.</para>"));
1805 // toggle_search acts as a copy of the main searchAction to be used mainly
1806 // in the toolbar, with no default shortcut attached, to avoid messing with
1807 // existing workflows (search bar always open and Ctrl-F to focus)
1808 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1809 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1810 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1811 toggleSearchAction
->setIcon(searchAction
->icon());
1812 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1813 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1814 toggleSearchAction
->setCheckable(true);
1816 QAction
*toggleSelectionModeAction
= actionCollection()->addAction(QStringLiteral("toggle_selection_mode"));
1817 // i18n: This action toggles a selection mode.
1818 toggleSelectionModeAction
->setText(i18nc("@action:inmenu", "Select Files and Folders"));
1819 // i18n: Opens a selection mode for selecting files/folders.
1820 // The text is kept so unspecific because it will be shown on the toolbar where space is at a premium.
1821 toggleSelectionModeAction
->setIconText(i18nc("@action:intoolbar", "Select"));
1822 toggleSelectionModeAction
->setWhatsThis(xi18nc(
1824 "<para>This application only knows which files or folders should be acted on if they are"
1825 " <emphasis>selected</emphasis> first. Press this to toggle a <emphasis>Selection Mode</emphasis> which makes selecting and deselecting as easy as "
1826 "pressing an item once.</para><para>While in this mode, a quick access bar at the bottom shows available actions for the currently selected items."
1828 toggleSelectionModeAction
->setIcon(QIcon::fromTheme(QStringLiteral("quickwizard")));
1829 toggleSelectionModeAction
->setCheckable(true);
1830 actionCollection()->setDefaultShortcut(toggleSelectionModeAction
, Qt::Key_Space
);
1831 connect(toggleSelectionModeAction
, &QAction::triggered
, this, &DolphinMainWindow::toggleSelectionMode
);
1833 // A special version of the toggleSelectionModeAction for the toolbar that also contains a menu
1834 // with the selectAllAction and invertSelectionAction.
1835 auto *toggleSelectionModeToolBarAction
=
1836 new KToolBarPopupAction(toggleSelectionModeAction
->icon(), toggleSelectionModeAction
->iconText(), actionCollection());
1837 toggleSelectionModeToolBarAction
->setToolTip(toggleSelectionModeAction
->text());
1838 toggleSelectionModeToolBarAction
->setWhatsThis(toggleSelectionModeAction
->whatsThis());
1839 actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction
);
1840 toggleSelectionModeToolBarAction
->setCheckable(true);
1841 toggleSelectionModeToolBarAction
->setPopupMode(KToolBarPopupAction::DelayedPopup
);
1842 connect(toggleSelectionModeToolBarAction
, &QAction::triggered
, toggleSelectionModeAction
, &QAction::trigger
);
1843 connect(toggleSelectionModeAction
, &QAction::toggled
, toggleSelectionModeToolBarAction
, &QAction::setChecked
);
1845 QAction
*selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1846 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis",
1848 "files and folders in the current location."));
1850 QAction
*invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1851 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1852 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert",
1854 "items that you have currently <emphasis>not</emphasis> selected instead."));
1855 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1856 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1857 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1859 QMenu
*toggleSelectionModeActionMenu
= new QMenu(this);
1860 toggleSelectionModeActionMenu
->addAction(selectAllAction
);
1861 toggleSelectionModeActionMenu
->addAction(invertSelection
);
1862 toggleSelectionModeToolBarAction
->setMenu(toggleSelectionModeActionMenu
);
1864 // setup 'View' menu
1865 // (note that most of it is set up in DolphinViewActionHandler)
1867 m_splitViewAction
= actionCollection()->add
<KActionMenu
>(QStringLiteral("split_view"));
1868 m_splitViewMenuAction
= actionCollection()->addAction(QStringLiteral("split_view_menu"));
1870 m_splitViewAction
->setWhatsThis(xi18nc("@info:whatsthis split",
1871 "<para>This presents "
1872 "a second view side-by-side with the current view, so you can see "
1873 "the contents of two folders at once and easily move items between "
1874 "them.</para><para>The view that is not \"in focus\" will be dimmed. "
1875 "</para>Click this button again to close one of the views."));
1876 m_splitViewMenuAction
->setWhatsThis(m_splitViewAction
->whatsThis());
1878 // only set it for the menu version
1879 actionCollection()->setDefaultShortcut(m_splitViewMenuAction
, Qt::Key_F3
);
1881 connect(m_splitViewAction
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1882 connect(m_splitViewMenuAction
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1884 QAction
*popoutSplit
= actionCollection()->addAction(QStringLiteral("popout_split_view"));
1885 popoutSplit
->setWhatsThis(xi18nc("@info:whatsthis",
1886 "If the view has been split, this will pop the view in focus "
1887 "out into a new window."));
1888 popoutSplit
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1889 actionCollection()->setDefaultShortcut(popoutSplit
, Qt::SHIFT
| Qt::Key_F3
);
1890 connect(popoutSplit
, &QAction::triggered
, this, &DolphinMainWindow::popoutSplitView
);
1892 QAction
*stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1893 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
| Qt::Key_S
);
1894 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1895 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1896 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1897 stashSplit
->setCheckable(false);
1898 QDBusConnectionInterface
*sessionInterface
= QDBusConnection::sessionBus().interface();
1899 stashSplit
->setVisible(sessionInterface
&& sessionInterface
->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
1900 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1902 QAction
*redisplay
= KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1903 redisplay
->setToolTip(i18nc("@info:tooltip", "Refresh view"));
1904 redisplay
->setWhatsThis(xi18nc("@info:whatsthis refresh",
1905 "<para>This refreshes "
1906 "the folder view.</para>"
1907 "<para>If the contents of this folder have changed, refreshing will re-scan this folder "
1908 "and show you a newly-updated view of the files and folders contained here.</para>"
1909 "<para>If the view is split, this refreshes the one that is currently in focus.</para>"));
1911 QAction
*stop
= actionCollection()->addAction(QStringLiteral("stop"));
1912 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1913 stop
->setToolTip(i18nc("@info", "Stop loading"));
1914 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1915 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1916 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1918 KToggleAction
*editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1919 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1920 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1921 "This toggles the <emphasis>Location Bar</emphasis> to be "
1922 "editable so you can directly enter a location you want to go to.<nl/>"
1923 "You can also switch to editing by clicking to the right of the "
1924 "location and switch back by confirming the edited location."));
1925 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1926 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1928 QAction
*replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1929 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1930 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1931 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1932 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1933 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1934 "This switches to editing the location and selects it "
1935 "so you can quickly enter a different location."));
1936 actionCollection()->setDefaultShortcuts(replaceLocation
, {Qt::CTRL
| Qt::Key_L
, Qt::ALT
| Qt::Key_D
});
1937 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1941 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1942 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1943 m_backAction
->setObjectName(backAction
->objectName());
1944 m_backAction
->setShortcuts(backAction
->shortcuts());
1946 m_backAction
->setPopupMode(KToolBarPopupAction::DelayedPopup
);
1947 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1948 connect(m_backAction
->popupMenu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1949 connect(m_backAction
->popupMenu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1950 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1952 auto backShortcuts
= m_backAction
->shortcuts();
1953 // Prepend this shortcut, to avoid being hidden by the two-slot UI (#371130)
1954 backShortcuts
.prepend(QKeySequence(Qt::Key_Backspace
));
1955 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1957 DolphinRecentTabsMenu
*recentTabsMenu
= new DolphinRecentTabsMenu(this);
1958 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1959 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
, recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1960 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
, m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1961 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
, this, &DolphinMainWindow::closedTabsCountChanged
);
1963 QAction
*undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1964 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1965 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab", "This returns you to the previously closed tab."));
1966 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_T
);
1967 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1968 undoCloseTab
->setEnabled(false);
1969 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1971 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1972 undoAction
->setWhatsThis(xi18nc("@info:whatsthis",
1974 "the last change you made to files or folders.<nl/>"
1975 "Such changes include <interface>creating</interface>, <interface>renaming</interface> "
1976 "and <interface>moving</interface> them to a different location "
1977 "or to the <filename>Trash</filename>. <nl/>Any changes that cannot be undone "
1978 "will ask for your confirmation beforehand."));
1979 undoAction
->setEnabled(false); // undo should be disabled by default
1982 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1983 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1984 m_forwardAction
->setObjectName(forwardAction
->objectName());
1985 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1987 m_forwardAction
->setPopupMode(KToolBarPopupAction::DelayedPopup
);
1988 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1989 connect(m_forwardAction
->popupMenu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1990 connect(m_forwardAction
->popupMenu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1991 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1992 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1994 // enable middle-click to open in a new tab
1995 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1996 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1997 m_backAction
->popupMenu()->installEventFilter(middleClickEventFilter
);
1998 m_forwardAction
->popupMenu()->installEventFilter(middleClickEventFilter
);
1999 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
2000 QAction
*homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
2001 homeAction
->setWhatsThis(xi18nc("@info:whatsthis",
2003 "<filename>Home</filename> folder.<nl/>Every user account "
2004 "has their own <filename>Home</filename> that contains their personal files, "
2005 "as well as hidden folders for their applications' data and configuration files."));
2007 // setup 'Tools' menu
2008 QAction
*compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
2009 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
2010 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
2011 compareFiles
->setEnabled(false);
2012 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
2014 QAction
*openPreferredSearchTool
= actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
2015 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
2016 openPreferredSearchTool
->setWhatsThis(xi18nc("@info:whatsthis",
2017 "<para>This opens a preferred search tool for the viewed location.</para>"
2018 "<para>Use <emphasis>More Search Tools</emphasis> menu to configure it.</para>"));
2019 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
2020 actionCollection()->setDefaultShortcut(openPreferredSearchTool
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F
);
2021 connect(openPreferredSearchTool
, &QAction::triggered
, this, &DolphinMainWindow::openPreferredSearchTool
);
2023 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
2024 QAction
*openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
2025 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
2026 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
2027 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
2028 "<para>To learn more about terminals use the help features in the terminal application.</para>"));
2029 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
2030 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
| Qt::Key_F4
);
2031 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
2033 QAction
*openTerminalHere
= actionCollection()->addAction(QStringLiteral("open_terminal_here"));
2034 // i18n: "Here" refers to the location(s) of the currently selected item(s) or the currently viewed location if nothing is selected.
2035 openTerminalHere
->setText(i18nc("@action:inmenu Tools", "Open Terminal Here"));
2036 openTerminalHere
->setWhatsThis(xi18nc("@info:whatsthis",
2037 "<para>This opens <emphasis>terminal</emphasis> applications for the selected items' locations.</para>"
2038 "<para>To learn more about terminals use the help features in the terminal application.</para>"));
2039 openTerminalHere
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
2040 actionCollection()->setDefaultShortcut(openTerminalHere
, Qt::SHIFT
| Qt::ALT
| Qt::Key_F4
);
2041 connect(openTerminalHere
, &QAction::triggered
, this, &DolphinMainWindow::openTerminalHere
);
2044 QAction
*focusTerminalPanel
= actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
2045 focusTerminalPanel
->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2046 focusTerminalPanel
->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
2047 actionCollection()->setDefaultShortcut(focusTerminalPanel
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F4
);
2048 connect(focusTerminalPanel
, &QAction::triggered
, this, &DolphinMainWindow::focusTerminalPanel
);
2052 // setup 'Bookmarks' menu
2053 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
2054 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
2055 // Make the toolbar button version work properly on click
2056 bookmarkMenu
->setPopupMode(QToolButton::InstantPopup
);
2057 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
2058 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
2060 // setup 'Settings' menu
2061 KToggleAction
*showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
2062 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
2063 "<para>This switches between having a <emphasis>Menubar</emphasis> "
2064 "and having an <interface>%1</interface> button. Both "
2065 "contain mostly the same actions and configuration options.</para>"
2066 "<para>The Menubar takes up more space but allows for fast and organized access to all "
2067 "actions an application has to offer.</para><para>The %1 button "
2068 "is simpler and small which makes triggering advanced actions more time consuming.</para>",
2069 hamburgerMenuAction
->text().replace('&', "")));
2070 connect(showMenuBar
,
2071 &KToggleAction::triggered
, // Fixes #286822
2073 &DolphinMainWindow::toggleShowMenuBar
,
2074 Qt::QueuedConnection
);
2076 KToggleAction
*showStatusBar
= KStandardAction::showStatusbar(nullptr, nullptr, actionCollection());
2077 showStatusBar
->setChecked(GeneralSettings::showStatusBar());
2078 connect(GeneralSettings::self(), &GeneralSettings::showStatusBarChanged
, showStatusBar
, &KToggleAction::setChecked
);
2079 connect(showStatusBar
, &KToggleAction::triggered
, this, [this](bool checked
) {
2080 GeneralSettings::setShowStatusBar(checked
);
2084 KStandardAction::keyBindings(this, &DolphinMainWindow::slotKeyBindings
, actionCollection());
2085 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
2087 // not in menu actions
2088 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
2089 nextTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::Key_Tab
));
2091 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
2092 prevTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::SHIFT
| Qt::Key_Tab
));
2094 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
2095 QAction
*activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
2096 activateTab
->setText(i18nc("@action:inmenu", "Go to Tab %1", i
+ 1));
2097 activateTab
->setEnabled(false);
2098 connect(activateTab
, &QAction::triggered
, this, [this, i
]() {
2099 m_tabWidget
->activateTab(i
);
2102 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
2104 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
2108 QAction
*activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
2109 activateLastTab
->setIconText(i18nc("@action:inmenu", "Last Tab"));
2110 activateLastTab
->setText(i18nc("@action:inmenu", "Go to Last Tab"));
2111 activateLastTab
->setEnabled(false);
2112 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
2113 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
| Qt::Key_0
);
2115 QAction
*activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
2116 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
2117 activateNextTab
->setText(i18nc("@action:inmenu", "Go to Next Tab"));
2118 activateNextTab
->setEnabled(false);
2119 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
2120 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
2122 QAction
*activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
2123 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
2124 activatePrevTab
->setText(i18nc("@action:inmenu", "Go to Previous Tab"));
2125 activatePrevTab
->setEnabled(false);
2126 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
2127 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
2130 QAction
*showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
2131 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
2132 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
2133 showTarget
->setEnabled(false);
2134 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
2136 QAction
*openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
2137 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
2138 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
2139 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
2141 QAction
*openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
2142 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
2143 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
2144 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
2146 QAction
*openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
2147 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
2148 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
2149 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
2151 QAction
*openInSplitViewAction
= actionCollection()->addAction(QStringLiteral("open_in_split_view"));
2152 openInSplitViewAction
->setText(i18nc("@action:inmenu", "Open in Split View"));
2153 openInSplitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2154 connect(openInSplitViewAction
, &QAction::triggered
, this, [this]() {
2155 openInSplitView(QUrl());
2159 void DolphinMainWindow::setupDockWidgets()
2161 const bool lock
= GeneralSettings::lockPanels();
2163 DolphinPlacesModelSingleton::instance().placesModel()->setPanelsLocked(lock
);
2165 KDualAction
*lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
2166 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
2167 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
2168 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
2169 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
2170 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis",
2172 "switches between having panels <emphasis>locked</emphasis> or "
2173 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
2174 "dragged to the other side of the window and have a close "
2175 "button.<nl/>Locked panels are embedded more cleanly."));
2176 lockLayoutAction
->setActive(lock
);
2177 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
2179 // Setup "Information"
2180 DolphinDockWidget
*infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
2181 infoDock
->setLocked(lock
);
2182 infoDock
->setObjectName(QStringLiteral("infoDock"));
2183 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
2186 InformationPanel
*infoPanel
= new InformationPanel(infoDock
);
2187 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
2188 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
2189 infoDock
->setWidget(infoPanel
);
2191 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoDock
, QStringLiteral("show_information_panel"));
2193 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
2194 connect(this, &DolphinMainWindow::urlChanged
, infoPanel
, &InformationPanel::setUrl
);
2195 connect(this, &DolphinMainWindow::selectionChanged
, infoPanel
, &InformationPanel::setSelection
);
2196 connect(this, &DolphinMainWindow::requestItemInfo
, infoPanel
, &InformationPanel::requestDelayedItemInfo
);
2197 connect(this, &DolphinMainWindow::fileItemsChanged
, infoPanel
, &InformationPanel::slotFilesItemChanged
);
2198 connect(this, &DolphinMainWindow::settingsChanged
, infoPanel
, &InformationPanel::readSettings
);
2201 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
2202 const QString panelWhatsThis
= xi18nc("@info:whatsthis",
2204 "hide panels like this go to <interface>Menu|Panels</interface> "
2205 "or <interface>View|Panels</interface>.</para>");
2208 ->action(QStringLiteral("show_information_panel"))
2209 ->setWhatsThis(xi18nc("@info:whatsthis",
2210 "<para> This toggles the "
2211 "<emphasis>information</emphasis> panel at the right side of the "
2212 "window.</para><para>The panel provides in-depth information "
2213 "about the items your mouse is hovering over or about the selected "
2214 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
2215 "For single items a preview of their contents is provided.</para>"));
2217 infoDock
->setWhatsThis(xi18nc("@info:whatsthis",
2219 "provides in-depth information about the items your mouse is "
2220 "hovering over or about the selected items. Otherwise it informs "
2221 "you about the currently viewed folder.<nl/>For single items a "
2222 "preview of their contents is provided.</para><para>You can configure "
2223 "which and how details are given here by right-clicking.</para>")
2227 DolphinDockWidget
*foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
2228 foldersDock
->setLocked(lock
);
2229 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
2230 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
2231 FoldersPanel
*foldersPanel
= new FoldersPanel(foldersDock
);
2232 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
2233 foldersDock
->setWidget(foldersPanel
);
2235 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersDock
, QStringLiteral("show_folders_panel"));
2237 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
2238 connect(this, &DolphinMainWindow::urlChanged
, foldersPanel
, &FoldersPanel::setUrl
);
2239 connect(foldersPanel
, &FoldersPanel::folderActivated
, this, &DolphinMainWindow::changeUrl
);
2240 connect(foldersPanel
, &FoldersPanel::folderInNewTab
, this, &DolphinMainWindow::openNewTab
);
2241 connect(foldersPanel
, &FoldersPanel::folderInNewActiveTab
, this, &DolphinMainWindow::openNewTabAndActivate
);
2242 connect(foldersPanel
, &FoldersPanel::errorMessage
, this, &DolphinMainWindow::showErrorMessage
);
2245 ->action(QStringLiteral("show_folders_panel"))
2246 ->setWhatsThis(xi18nc("@info:whatsthis",
2248 "<emphasis>folders</emphasis> panel at the left side of the window."
2249 "<nl/><nl/>It shows the folders of the <emphasis>file system"
2250 "</emphasis> in a <emphasis>tree view</emphasis>."));
2251 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis",
2253 "shows the folders of the <emphasis>file system</emphasis> in a "
2254 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
2255 "there. Click the arrow to the left of a folder to see its subfolders. "
2256 "This allows quick switching between any folders.</para>")
2261 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
2262 DolphinDockWidget
*terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
2263 terminalDock
->setLocked(lock
);
2264 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
2265 terminalDock
->setContentsMargins(0, 0, 0, 0);
2266 m_terminalPanel
= new TerminalPanel(terminalDock
);
2267 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
2268 terminalDock
->setWidget(m_terminalPanel
);
2270 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
2271 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
2272 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
, m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
2273 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
, this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
2275 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalDock
, QStringLiteral("show_terminal_panel"));
2277 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
2278 connect(this, &DolphinMainWindow::urlChanged
, m_terminalPanel
, &TerminalPanel::setUrl
);
2280 if (GeneralSettings::version() < 200) {
2281 terminalDock
->hide();
2285 ->action(QStringLiteral("show_terminal_panel"))
2286 ->setWhatsThis(xi18nc("@info:whatsthis",
2287 "<para>This toggles the "
2288 "<emphasis>terminal</emphasis> panel at the bottom of the window."
2289 "<nl/>The location in the terminal will always match the folder "
2290 "view so you can navigate using either.</para><para>The terminal "
2291 "panel is not needed for basic computer usage but can be useful "
2292 "for advanced tasks. To learn more about terminals use the help features "
2293 "in a standalone terminal application like Konsole.</para>"));
2294 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis",
2296 "the <emphasis>terminal</emphasis> panel. It behaves like a "
2297 "normal terminal but will match the location of the folder view "
2298 "so you can navigate using either.</para><para>The terminal panel "
2299 "is not needed for basic computer usage but can be useful for "
2300 "advanced tasks. To learn more about terminals use the help features in a "
2301 "standalone terminal application like Konsole.</para>")
2306 if (GeneralSettings::version() < 200) {
2308 foldersDock
->hide();
2312 DolphinDockWidget
*placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
2313 placesDock
->setLocked(lock
);
2314 placesDock
->setObjectName(QStringLiteral("placesDock"));
2315 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
2317 m_placesPanel
= new PlacesPanel(placesDock
);
2318 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
2319 placesDock
->setWidget(m_placesPanel
);
2321 createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9
, placesDock
, QStringLiteral("show_places_panel"));
2323 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
2324 connect(m_placesPanel
, &PlacesPanel::placeActivated
, this, &DolphinMainWindow::slotPlaceActivated
);
2325 connect(m_placesPanel
, &PlacesPanel::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2326 connect(m_placesPanel
, &PlacesPanel::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2327 connect(m_placesPanel
, &PlacesPanel::newWindowRequested
, this, [this](const QUrl
&url
) {
2328 Dolphin::openNewWindow({url
}, this);
2330 connect(m_placesPanel
, &PlacesPanel::openInSplitViewRequested
, this, &DolphinMainWindow::openInSplitView
);
2331 connect(m_placesPanel
, &PlacesPanel::errorMessage
, this, &DolphinMainWindow::showErrorMessage
);
2332 connect(this, &DolphinMainWindow::urlChanged
, m_placesPanel
, &PlacesPanel::setUrl
);
2333 connect(placesDock
, &DolphinDockWidget::visibilityChanged
, &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged
);
2334 connect(this, &DolphinMainWindow::settingsChanged
, m_placesPanel
, &PlacesPanel::readSettings
);
2335 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
, this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
2336 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
, this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
2337 DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
2339 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
2340 actionShowAllPlaces
->setCheckable(true);
2341 actionShowAllPlaces
->setDisabled(true);
2342 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis",
2344 "all places in the places panel that have been hidden. They will "
2345 "appear semi-transparent and allow you to uncheck their \"Hide\" property."));
2347 connect(actionShowAllPlaces
, &QAction::triggered
, this, [this](bool checked
) {
2348 m_placesPanel
->setShowAll(checked
);
2350 connect(m_placesPanel
, &PlacesPanel::allPlacesShownChanged
, actionShowAllPlaces
, &QAction::setChecked
);
2353 ->action(QStringLiteral("show_places_panel"))
2354 ->setWhatsThis(xi18nc("@info:whatsthis",
2355 "<para>This toggles the "
2356 "<emphasis>places</emphasis> panel at the left side of the window."
2357 "</para><para>It allows you to go to locations you have "
2358 "bookmarked and to access disk or media attached to the computer "
2359 "or to the network. It also contains sections to find recently "
2360 "saved files or files of a certain type.</para>"));
2361 placesDock
->setWhatsThis(xi18nc("@info:whatsthis",
2362 "<para>This is the "
2363 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
2364 "you have bookmarked and to access disk or media attached to the "
2365 "computer or to the network. It also contains sections to find "
2366 "recently saved files or files of a certain type.</para><para>"
2367 "Click on an entry to go there. Click with the right mouse button "
2368 "instead to open any entry in a new tab or new window.</para>"
2369 "<para>New entries can be added by dragging folders onto this panel. "
2370 "Right-click any section or entry to hide it. Right-click an empty "
2371 "space on this panel and select <interface>Show Hidden Places"
2372 "</interface> to display it again.</para>")
2375 // Add actions into the "Panels" menu
2376 KActionMenu
*panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
2377 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
2378 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
2379 panelsMenu
->setPopupMode(QToolButton::InstantPopup
);
2380 const KActionCollection
*ac
= actionCollection();
2381 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
2383 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
2385 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
2386 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
2387 panelsMenu
->addSeparator();
2388 panelsMenu
->addAction(actionShowAllPlaces
);
2389 panelsMenu
->addAction(lockLayoutAction
);
2391 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
] {
2392 actionShowAllPlaces
->setEnabled(DolphinPlacesModelSingleton::instance().placesModel()->hiddenCount());
2396 void DolphinMainWindow::updateFileAndEditActions()
2398 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
2399 const KActionCollection
*col
= actionCollection();
2400 KFileItemListProperties
capabilitiesSource(list
);
2402 QAction
*renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
2403 QAction
*moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
2404 QAction
*deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
2405 QAction
*cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
2406 QAction
*duplicateAction
= col
->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler
2407 QAction
*addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
2408 QAction
*copyToOtherViewAction
= col
->action(QStringLiteral("copy_to_inactive_split_view"));
2409 QAction
*moveToOtherViewAction
= col
->action(QStringLiteral("move_to_inactive_split_view"));
2410 QAction
*copyLocation
= col
->action(QString("copy_location"));
2412 if (list
.isEmpty()) {
2413 stateChanged(QStringLiteral("has_no_selection"));
2415 // All actions that need a selection to function can be enabled because they should trigger selection mode.
2416 renameAction
->setEnabled(true);
2417 moveToTrashAction
->setEnabled(true);
2418 deleteAction
->setEnabled(true);
2419 cutAction
->setEnabled(true);
2420 duplicateAction
->setEnabled(true);
2421 addToPlacesAction
->setEnabled(true);
2422 copyLocation
->setEnabled(true);
2423 // Them triggering selection mode and not directly acting on selected items is signified by adding "…" to their text.
2424 m_actionTextHelper
->textsWhenNothingIsSelectedEnabled(true);
2427 m_actionTextHelper
->textsWhenNothingIsSelectedEnabled(false);
2428 stateChanged(QStringLiteral("has_selection"));
2430 QAction
*deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
2431 QAction
*showTarget
= col
->action(QStringLiteral("show_target"));
2433 if (list
.length() == 1 && list
.first().isDir()) {
2434 addToPlacesAction
->setEnabled(true);
2436 addToPlacesAction
->setEnabled(false);
2439 const bool enableMoveToTrash
= capabilitiesSource
.isLocal() && capabilitiesSource
.supportsMoving();
2441 renameAction
->setEnabled(capabilitiesSource
.supportsMoving());
2442 m_disabledActionNotifier
->setDisabledReason(renameAction
, i18nc("@info", "Cannot rename: You do not have permission to rename items in this folder."));
2443 deleteAction
->setEnabled(capabilitiesSource
.supportsDeleting());
2444 m_disabledActionNotifier
->setDisabledReason(deleteAction
,
2445 i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
2446 cutAction
->setEnabled(capabilitiesSource
.supportsMoving());
2447 m_disabledActionNotifier
->setDisabledReason(cutAction
, i18nc("@info", "Cannot cut: You do not have permission to move items from this folder."));
2448 copyLocation
->setEnabled(list
.length() == 1);
2449 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
2450 duplicateAction
->setEnabled(capabilitiesSource
.supportsWriting());
2451 m_disabledActionNotifier
->setDisabledReason(duplicateAction
,
2452 i18nc("@info", "Cannot duplicate here: You do not have permission to create items in this folder."));
2454 if (enableMoveToTrash
) {
2455 moveToTrashAction
->setEnabled(true);
2456 deleteWithTrashShortcut
->setEnabled(false);
2457 m_disabledActionNotifier
->clearDisabledReason(deleteWithTrashShortcut
);
2459 moveToTrashAction
->setEnabled(false);
2460 deleteWithTrashShortcut
->setEnabled(capabilitiesSource
.supportsDeleting());
2461 m_disabledActionNotifier
->setDisabledReason(deleteWithTrashShortcut
,
2462 i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
2466 if (!m_tabWidget
->currentTabPage()->splitViewEnabled()) {
2467 // No need to set the disabled reason here, as it's obvious to the user that the reason is the split view being disabled.
2468 copyToOtherViewAction
->setEnabled(false);
2469 m_disabledActionNotifier
->clearDisabledReason(copyToOtherViewAction
);
2470 moveToOtherViewAction
->setEnabled(false);
2471 m_disabledActionNotifier
->clearDisabledReason(moveToOtherViewAction
);
2472 } else if (list
.isEmpty()) {
2473 copyToOtherViewAction
->setEnabled(false);
2474 m_disabledActionNotifier
->setDisabledReason(copyToOtherViewAction
, i18nc("@info", "Cannot copy to other view: No files selected."));
2475 moveToOtherViewAction
->setEnabled(false);
2476 m_disabledActionNotifier
->setDisabledReason(moveToOtherViewAction
, i18nc("@info", "Cannot move to other view: No files selected."));
2478 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
2479 KFileItem capabilitiesDestination
;
2481 if (tabPage
->primaryViewActive()) {
2482 capabilitiesDestination
= tabPage
->secondaryViewContainer()->rootItem();
2484 capabilitiesDestination
= tabPage
->primaryViewContainer()->rootItem();
2487 const auto destUrl
= capabilitiesDestination
.url();
2488 const bool allNotTargetOrigin
= std::all_of(list
.cbegin(), list
.cend(), [destUrl
](const KFileItem
&item
) {
2489 return item
.url().adjusted(QUrl::RemoveFilename
| QUrl::StripTrailingSlash
) != destUrl
;
2492 if (!allNotTargetOrigin
) {
2493 copyToOtherViewAction
->setEnabled(false);
2494 m_disabledActionNotifier
->setDisabledReason(copyToOtherViewAction
,
2495 i18nc("@info", "Cannot copy to other view: The other view already contains these items."));
2496 moveToOtherViewAction
->setEnabled(false);
2497 m_disabledActionNotifier
->setDisabledReason(moveToOtherViewAction
,
2498 i18nc("@info", "Cannot move to other view: The other view already contains these items."));
2499 } else if (!capabilitiesDestination
.isWritable()) {
2500 copyToOtherViewAction
->setEnabled(false);
2501 m_disabledActionNotifier
->setDisabledReason(
2502 copyToOtherViewAction
,
2503 i18nc("@info", "Cannot copy to other view: You do not have permission to write into the destination folder."));
2504 moveToOtherViewAction
->setEnabled(false);
2505 m_disabledActionNotifier
->setDisabledReason(
2506 moveToOtherViewAction
,
2507 i18nc("@info", "Cannot move to other view: You do not have permission to write into the destination folder."));
2509 copyToOtherViewAction
->setEnabled(true);
2510 moveToOtherViewAction
->setEnabled(capabilitiesSource
.supportsMoving());
2511 m_disabledActionNotifier
->setDisabledReason(
2512 moveToOtherViewAction
,
2513 i18nc("@info", "Cannot move to other view: You do not have permission to move items from this folder."));
2518 void DolphinMainWindow::updateViewActions()
2520 m_actionHandler
->updateViewActions();
2522 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
2523 toggleFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
2525 updateSplitActions();
2528 void DolphinMainWindow::updateGoActions()
2530 QAction
*goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
2531 const QUrl currentUrl
= m_activeViewContainer
->url();
2532 // I think this is one of the best places to firstly be confronted
2533 // with a file system and its hierarchy. Talking about the root
2534 // directory might seem too much here but it is the question that
2535 // naturally arises in this context.
2536 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis",
2538 "the folder that contains the currently viewed one.</para>"
2539 "<para>All files and folders are organized in a hierarchical "
2540 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
2541 "a directory that contains all data connected to this computer"
2542 "—the <emphasis>root directory</emphasis>.</para>"));
2543 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
2546 void DolphinMainWindow::refreshViews()
2548 m_tabWidget
->refreshViews();
2550 if (GeneralSettings::modifiedStartupSettings()) {
2551 updateWindowTitle();
2554 updateSplitActions();
2556 Q_EMIT
settingsChanged();
2559 void DolphinMainWindow::clearStatusBar()
2561 m_activeViewContainer
->statusBar()->resetToDefaultText();
2564 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
*container
)
2566 connect(container
, &DolphinViewContainer::showFilterBarChanged
, this, &DolphinMainWindow::updateFilterBarAction
);
2567 connect(container
, &DolphinViewContainer::writeStateChanged
, this, &DolphinMainWindow::slotWriteStateChanged
);
2568 slotWriteStateChanged(container
->view()->isFolderWritable());
2569 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
, this, &DolphinMainWindow::updateSearchAction
);
2570 connect(container
, &DolphinViewContainer::captionChanged
, this, &DolphinMainWindow::updateWindowTitle
);
2571 connect(container
, &DolphinViewContainer::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2572 connect(container
, &DolphinViewContainer::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2574 const QAction
*toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
2575 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
2577 // Make the toggled state of the selection mode actions visually follow the selection mode state of the view.
2578 auto toggleSelectionModeAction
= actionCollection()->action(QStringLiteral("toggle_selection_mode"));
2579 toggleSelectionModeAction
->setChecked(m_activeViewContainer
->isSelectionModeEnabled());
2580 connect(m_activeViewContainer
, &DolphinViewContainer::selectionModeChanged
, toggleSelectionModeAction
, &QAction::setChecked
);
2582 const DolphinView
*view
= container
->view();
2583 connect(view
, &DolphinView::selectionChanged
, this, &DolphinMainWindow::slotSelectionChanged
);
2584 connect(view
, &DolphinView::requestItemInfo
, this, &DolphinMainWindow::requestItemInfo
);
2585 connect(view
, &DolphinView::fileItemsChanged
, this, &DolphinMainWindow::fileItemsChanged
);
2586 connect(view
, &DolphinView::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2587 connect(view
, &DolphinView::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2588 connect(view
, &DolphinView::windowRequested
, this, &DolphinMainWindow::openNewWindow
);
2589 connect(view
, &DolphinView::requestContextMenu
, this, &DolphinMainWindow::openContextMenu
);
2590 connect(view
, &DolphinView::directoryLoadingStarted
, this, &DolphinMainWindow::enableStopAction
);
2591 connect(view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinMainWindow::disableStopAction
);
2592 connect(view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
2593 connect(view
, &DolphinView::goBackRequested
, this, &DolphinMainWindow::goBack
);
2594 connect(view
, &DolphinView::goForwardRequested
, this, &DolphinMainWindow::goForward
);
2595 connect(view
, &DolphinView::urlActivated
, this, &DolphinMainWindow::handleUrl
);
2596 connect(view
, &DolphinView::goUpRequested
, this, &DolphinMainWindow::goUp
);
2597 connect(view
, &DolphinView::doubleClickViewBackground
, this, &DolphinMainWindow::slotDoubleClickViewBackground
);
2599 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged
, this, &DolphinMainWindow::changeUrl
);
2600 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged
, this, &DolphinMainWindow::updateHistory
);
2602 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
2603 const KUrlNavigator
*navigator
=
2604 m_tabWidget
->currentTabPage()->primaryViewActive() ? navigators
->primaryUrlNavigator() : navigators
->secondaryUrlNavigator();
2606 QAction
*editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
2607 editableLocactionAction
->setChecked(navigator
->isUrlEditable());
2608 connect(navigator
, &KUrlNavigator::editableStateChanged
, this, &DolphinMainWindow::slotEditableStateChanged
);
2609 connect(navigator
, &KUrlNavigator::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2610 connect(navigator
, &KUrlNavigator::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2611 connect(navigator
, &KUrlNavigator::newWindowRequested
, this, &DolphinMainWindow::openNewWindow
);
2614 void DolphinMainWindow::updateSplitActions()
2616 QAction
*popoutSplitAction
= actionCollection()->action(QStringLiteral("popout_split_view"));
2618 auto setActionPopupMode
= [this](KActionMenu
*action
, QToolButton::ToolButtonPopupMode popupMode
) {
2619 action
->setPopupMode(popupMode
);
2620 if (auto *buttonForAction
= qobject_cast
<QToolButton
*>(toolBar()->widgetForAction(action
))) {
2621 buttonForAction
->setPopupMode(popupMode
);
2625 const DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
2626 if (tabPage
->splitViewEnabled()) {
2627 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2628 m_splitViewAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2629 m_splitViewAction
->setToolTip(i18nc("@info", "Close left view"));
2630 m_splitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2631 popoutSplitAction
->setText(i18nc("@action:intoolbar Move left view to a new window", "Pop out Left View"));
2632 popoutSplitAction
->setToolTip(i18nc("@info", "Move left view to a new window"));
2634 m_splitViewAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2635 m_splitViewAction
->setToolTip(i18nc("@info", "Close right view"));
2636 m_splitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2637 popoutSplitAction
->setText(i18nc("@action:intoolbar Move right view to a new window", "Pop out Right View"));
2638 popoutSplitAction
->setToolTip(i18nc("@info", "Move right view to a new window"));
2640 popoutSplitAction
->setEnabled(true);
2641 if (!m_splitViewAction
->menu()) {
2642 setActionPopupMode(m_splitViewAction
, QToolButton::MenuButtonPopup
);
2643 m_splitViewAction
->setMenu(new QMenu
);
2644 m_splitViewAction
->addAction(popoutSplitAction
);
2647 m_splitViewAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2648 m_splitViewAction
->setToolTip(i18nc("@info", "Split view"));
2649 m_splitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2650 popoutSplitAction
->setText(i18nc("@action:intoolbar Move view in focus to a new window", "Pop out"));
2651 popoutSplitAction
->setEnabled(false);
2652 if (m_splitViewAction
->menu()) {
2653 m_splitViewAction
->removeAction(popoutSplitAction
);
2654 m_splitViewAction
->menu()->deleteLater();
2655 m_splitViewAction
->setMenu(nullptr);
2656 setActionPopupMode(m_splitViewAction
, QToolButton::DelayedPopup
);
2660 // Update state from toolbar action
2661 m_splitViewMenuAction
->setText(m_splitViewAction
->text());
2662 m_splitViewMenuAction
->setToolTip(m_splitViewAction
->toolTip());
2663 m_splitViewMenuAction
->setIcon(m_splitViewAction
->icon());
2666 void DolphinMainWindow::updateAllowedToolbarAreas()
2668 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
2669 if (toolBar()->actions().contains(navigators
)) {
2670 toolBar()->setAllowedAreas(Qt::TopToolBarArea
| Qt::BottomToolBarArea
);
2671 if (toolBarArea(toolBar()) == Qt::LeftToolBarArea
|| toolBarArea(toolBar()) == Qt::RightToolBarArea
) {
2672 addToolBar(Qt::TopToolBarArea
, toolBar());
2675 toolBar()->setAllowedAreas(Qt::AllToolBarAreas
);
2679 bool DolphinMainWindow::isKompareInstalled() const
2681 static bool initialized
= false;
2682 static bool installed
= false;
2684 // TODO: maybe replace this approach later by using a menu
2685 // plugin like kdiff3plugin.cpp
2686 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2692 void DolphinMainWindow::createPanelAction(const QIcon
&icon
, const QKeySequence
&shortcut
, QDockWidget
*dockWidget
, const QString
&actionName
)
2694 auto dockAction
= dockWidget
->toggleViewAction();
2695 dockAction
->setIcon(icon
);
2696 dockAction
->setEnabled(true);
2698 QAction
*panelAction
= actionCollection()->addAction(actionName
, dockAction
);
2699 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2702 void DolphinMainWindow::setupWhatsThis()
2705 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2706 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2707 "configuration options. Left-click on any of the menus on this "
2708 "bar to see its contents.</para><para>The Menubar can be hidden "
2709 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2710 "most of its contents become available through a <interface>Menu"
2711 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2712 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2713 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2714 "frequently used actions.</para><para>It is highly customizable. "
2715 "All items you see in the <interface>Menu</interface> or "
2716 "in the <interface>Menubar</interface> can be placed on the "
2717 "Toolbar. Just right-click on it and select <interface>Configure "
2718 "Toolbars…</interface> or find this action within the <interface>"
2720 "</para><para>The location of the bar and the style of its "
2721 "buttons can also be changed in the right-click menu. Right-click "
2722 "a button if you want to show or hide its text.</para>"));
2723 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2724 "<para>Here you can see the <emphasis>folders</emphasis> and "
2725 "<emphasis>files</emphasis> that are at the location described in "
2726 "the <interface>Location Bar</interface> above. This area is the "
2727 "central part of this application where you navigate to the files "
2728 "you want to use.</para><para>For an elaborate and general "
2729 "introduction to this application <link "
2730 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2731 "click here</link>. This will open an introductory article from "
2732 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2733 "explanations of all the features of this <emphasis>view</emphasis> "
2734 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2735 "instead. This will open a page from the <emphasis>Handbook"
2736 "</emphasis> that covers the basics.</para>"));
2739 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2740 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2741 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2742 "There you can set up key combinations to trigger an action when "
2743 "they are pressed simultaneously. All commands in this application can "
2744 "be triggered this way.</para>"));
2745 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2746 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2747 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2748 "<para>All items you see in the <interface>Menu</interface> can also be placed on the Toolbar.</para>"));
2749 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2750 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2751 "change a multitude of settings for this application. For an explanation "
2752 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2753 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2757 auto setStandardActionWhatsThis
= [this](KStandardAction::StandardAction actionId
,
2758 const QString
&whatsThis
) {
2759 // Check for the existence of an action since it can be restricted through the Kiosk system
2760 if (auto *action
= actionCollection()->action(KStandardAction::name(actionId
))) {
2761 action
->setWhatsThis(whatsThis
);
2765 // i18n: If the external link isn't available in your language it might make
2766 // sense to state the external link's language in brackets to not
2767 // frustrate the user. If there are multiple languages that the user might
2768 // know with a reasonable chance you might want to have 2 external links.
2769 // The same might be true for any external link you translate.
2770 setStandardActionWhatsThis(KStandardAction::HelpContents
, xi18nc("@info:whatsthis handbook", "<para>This opens the Handbook for this application. It provides explanations for every part of <emphasis>Dolphin</emphasis>.</para><para>If you want more elaborate introductions to the different features of <emphasis>Dolphin</emphasis> <link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2771 // (The i18n call should be completely in the line following the i18n: comment without any line breaks within the i18n call or the comment might not be correctly extracted. See: https://commits.kde.org/kxmlgui/a31135046e1b3335b5d7bbbe6aa9a883ce3284c1 )
2773 setStandardActionWhatsThis(KStandardAction::WhatsThis
,
2774 xi18nc("@info:whatsthis whatsthis button",
2775 "<para>This is the button that invokes the help feature you are "
2776 "using right now! Click it, then click any component of this "
2777 "application to ask \"What's this?\" about it. The mouse cursor "
2778 "will change appearance if no help is available for a spot.</para>"
2779 "<para>There are two other ways to get help: "
2780 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2781 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2782 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2783 "missing in most other windows so don't get too used to this.</para>"));
2785 setStandardActionWhatsThis(KStandardAction::ReportBug
,
2786 xi18nc("@info:whatsthis","<para>This opens a "
2787 "window that will guide you through reporting errors or flaws "
2788 "in this application or in other KDE software.</para>"
2789 "<para>High-quality bug reports are much appreciated. To learn "
2790 "how to make your bug report as effective as possible "
2791 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2792 "click here</link>.</para>"));
2794 setStandardActionWhatsThis(KStandardAction::Donate
,
2795 xi18nc("@info:whatsthis", "<para>This opens a "
2796 "<emphasis>web page</emphasis> where you can donate to "
2797 "support the continued work on this application and many "
2798 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2799 "<para>Donating is the easiest and fastest way to efficiently "
2800 "support KDE and its projects. KDE projects are available for "
2801 "free therefore your donation is needed to cover things that "
2802 "require money like servers, contributor meetings, etc.</para>"
2803 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2804 "organization behind the KDE community.</para>"));
2806 setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage
,
2807 xi18nc("@info:whatsthis",
2808 "With this you can change the language this application uses."
2809 "<nl/>You can even set secondary languages which will be used "
2810 "if texts are not available in your preferred language."));
2812 setStandardActionWhatsThis(KStandardAction::AboutApp
,
2813 xi18nc("@info:whatsthis","This opens a "
2814 "window that informs you about the version, license, "
2815 "used libraries and maintainers of this application."));
2817 setStandardActionWhatsThis(KStandardAction::AboutKDE
,
2818 xi18nc("@info:whatsthis","This opens a "
2819 "window with information about <emphasis>KDE</emphasis>. "
2820 "The KDE community are the people behind this free software."
2821 "<nl/>If you like using this application but don't know "
2822 "about KDE or want to see a cute dragon have a look!"));
2826 bool DolphinMainWindow::addHamburgerMenuToToolbar()
2828 QDomDocument domDocument
= KXMLGUIClient::domDocument();
2829 if (domDocument
.isNull()) {
2832 QDomNode toolbar
= domDocument
.elementsByTagName(QStringLiteral("ToolBar")).at(0);
2833 if (toolbar
.isNull()) {
2837 QDomElement hamburgerMenuElement
= domDocument
.createElement(QStringLiteral("Action"));
2838 hamburgerMenuElement
.setAttribute(QStringLiteral("name"), QStringLiteral("hamburger_menu"));
2839 toolbar
.appendChild(hamburgerMenuElement
);
2841 KXMLGUIFactory::saveConfigFile(domDocument
, xmlFile());
2845 // Make sure to also remove the <KXMLGUIFactory> and <QDomDocument> include
2846 // whenever this method is removed (maybe in the year ~2026).
2849 // Set a sane initial window size
2850 QSize
DolphinMainWindow::sizeHint() const
2852 return KXmlGuiWindow::sizeHint().expandedTo(QSize(760, 550));
2855 void DolphinMainWindow::saveNewToolbarConfig()
2857 KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
2858 // because the rest of this method decides things
2859 // based on the new config.
2860 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
2861 if (!toolBar()->actions().contains(navigators
)) {
2862 m_tabWidget
->currentTabPage()->insertNavigatorsWidget(navigators
);
2864 updateAllowedToolbarAreas();
2865 (static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu
))))->hideActionsOf(toolBar());
2868 void DolphinMainWindow::focusTerminalPanel()
2870 if (m_terminalPanel
->isVisible()) {
2871 if (m_terminalPanel
->terminalHasFocus()) {
2872 m_activeViewContainer
->view()->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2873 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2875 m_terminalPanel
->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2876 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2879 actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger();
2880 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2884 DolphinMainWindow::UndoUiInterface::UndoUiInterface()
2885 : KIO::FileUndoManager::UiInterface()
2889 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2893 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
*job
)
2895 DolphinMainWindow
*mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2897 DolphinViewContainer
*container
= mainWin
->activeViewContainer();
2898 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2900 KIO::FileUndoManager::UiInterface::jobError(job
);
2904 bool DolphinMainWindow::isUrlOpen(const QString
&url
)
2906 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput(url
));
2909 bool DolphinMainWindow::isItemVisibleInAnyView(const QString
&urlOfItem
)
2911 return m_tabWidget
->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem
));
2914 void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button
)
2916 Q_UNUSED(button
) // might be of use later
2918 GeneralSettings
*settings
= GeneralSettings::self();
2919 QString clickAction
= settings
->doubleClickViewAction();
2921 DolphinView
*view
= activeViewContainer()->view();
2922 if (view
== nullptr || clickAction
== "none") {
2926 if (clickAction
== customCommand
) {
2927 // run custom command set by the user
2928 QString path
= view
->url().toLocalFile();
2929 QString clickCustomAction
= settings
->doubleClickViewCustomAction();
2930 clickCustomAction
.replace("{path}", path
.prepend('"').append('"'));
2932 m_job
= new KIO::CommandLauncherJob(clickCustomAction
);
2933 m_job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
2937 // get the action set by the user and trigger it
2938 const KActionCollection
*actions
= actionCollection();
2939 QAction
*action
= actions
->action(clickAction
);
2940 if (action
== nullptr) {
2941 qCWarning(DolphinDebug
) << QStringLiteral("Double-click view: action `%1` was not found").arg(clickAction
);
2948 #include "moc_dolphinmainwindow.cpp"