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 "admin/workerintegration.h"
12 #include "dolphin_generalsettings.h"
13 #include "dolphinbookmarkhandler.h"
14 #include "dolphincontextmenu.h"
15 #include "dolphindockwidget.h"
16 #include "dolphinmainwindowadaptor.h"
17 #include "dolphinnavigatorswidgetaction.h"
18 #include "dolphinnewfilemenu.h"
19 #include "dolphinplacesmodelsingleton.h"
20 #include "dolphinrecenttabsmenu.h"
21 #include "dolphintabpage.h"
22 #include "dolphinurlnavigatorscontroller.h"
23 #include "dolphinviewcontainer.h"
25 #include "middleclickactioneventfilter.h"
26 #include "panels/folders/folderspanel.h"
27 #include "panels/places/placespanel.h"
28 #include "panels/terminal/terminalpanel.h"
29 #include "selectionmode/actiontexthelper.h"
30 #include "settings/dolphinsettingsdialog.h"
31 #include "statusbar/dolphinstatusbar.h"
32 #include "views/dolphinnewfilemenuobserver.h"
33 #include "views/dolphinremoteencoding.h"
34 #include "views/dolphinviewactionhandler.h"
35 #include "views/draganddrophelper.h"
36 #include "views/viewproperties.h"
38 #include <KActionCollection>
39 #include <KActionMenu>
40 #include <KAuthorized>
41 #include <KColorSchemeManager>
44 #include <KDialogJobUiDelegate>
45 #include <KDualAction>
46 #include <KFileItemListProperties>
47 #include <KIO/CommandLauncherJob>
48 #include <KIO/JobUiDelegateFactory>
49 #include <KIO/OpenFileManagerWindowJob>
50 #include <KIO/OpenUrlJob>
51 #include <KJobWidgets>
52 #include <KLocalizedString>
53 #include <KMessageBox>
54 #include <KProtocolInfo>
55 #include <KProtocolManager>
57 #include <KShortcutsDialog>
58 #include <KStandardAction>
60 #include <KTerminalLauncherJob>
61 #include <KToggleAction>
63 #include <KToolBarPopupAction>
64 #include <KUrlComboBox>
65 #include <KUrlNavigator>
66 #include <KWindowSystem>
67 #include <KXMLGUIFactory>
69 #include <kwidgetsaddons_version.h>
71 #include <QApplication>
73 #include <QCloseEvent>
74 #include <QDesktopServices>
76 #include <QDomDocument>
80 #include <QPushButton>
82 #include <QStandardPaths>
84 #include <QToolButton>
85 #include <QtConcurrentRun>
86 #include <dolphindebug.h>
91 #include <KStartupInfo>
96 // Used for GeneralSettings::version() to determine whether
97 // an updated version of Dolphin is running, so as to migrate
98 // removed/renamed ...etc config entries; increment it in such
100 const int CurrentDolphinVersion
= 202;
101 // The maximum number of entries in the back/forward popup menu
102 const int MaxNumberOfNavigationentries
= 12;
103 // The maximum number of "Go to Tab" shortcuts
104 const int MaxActivateTabShortcuts
= 9;
107 DolphinMainWindow::DolphinMainWindow()
108 : KXmlGuiWindow(nullptr)
109 , m_newFileMenu(nullptr)
110 , m_tabWidget(nullptr)
111 , m_activeViewContainer(nullptr)
112 , m_actionHandler(nullptr)
113 , m_remoteEncoding(nullptr)
115 , m_bookmarkHandler(nullptr)
116 , m_disabledActionNotifier(nullptr)
117 , m_lastHandleUrlOpenJob(nullptr)
118 , m_terminalPanel(nullptr)
119 , m_placesPanel(nullptr)
120 , m_tearDownFromPlacesRequested(false)
121 , m_backAction(nullptr)
122 , m_forwardAction(nullptr)
123 , m_splitViewAction(nullptr)
124 , m_splitViewMenuAction(nullptr)
125 , m_sessionSaveTimer(nullptr)
126 , m_sessionSaveWatcher(nullptr)
127 , m_sessionSaveScheduled(false)
129 Q_INIT_RESOURCE(dolphin
);
131 new MainWindowAdaptor(this);
134 setWindowFlags(Qt::WindowContextHelpButtonHint
);
136 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
137 setObjectName(QStringLiteral("Dolphin#"));
139 setStateConfigGroup("State");
141 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
142 new KColorSchemeManager(this); // Sets a sensible color scheme which fixes unreadable icons and text on Windows.
145 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
, this, &DolphinMainWindow::showErrorMessage
);
147 KIO::FileUndoManager
*undoManager
= KIO::FileUndoManager::self();
148 undoManager
->setUiInterface(new UndoUiInterface());
150 connect(undoManager
, &KIO::FileUndoManager::undoAvailable
, this, &DolphinMainWindow::slotUndoAvailable
);
151 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
, this, &DolphinMainWindow::slotUndoTextChanged
);
152 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
, this, &DolphinMainWindow::clearStatusBar
);
153 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
, this, &DolphinMainWindow::showCommand
);
155 const bool firstRun
= (GeneralSettings::version() < 200);
157 GeneralSettings::setViewPropsTimestamp(QDateTime::currentDateTime());
160 setAcceptDrops(true);
162 auto *navigatorsWidgetAction
= new DolphinNavigatorsWidgetAction(this);
163 actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction
);
164 m_tabWidget
= new DolphinTabWidget(navigatorsWidgetAction
, this);
165 m_tabWidget
->setObjectName("tabWidget");
166 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
, this, &DolphinMainWindow::activeViewChanged
);
167 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
, this, &DolphinMainWindow::tabCountChanged
);
168 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
, this, &DolphinMainWindow::updateWindowTitle
);
169 setCentralWidget(m_tabWidget
);
171 m_actionTextHelper
= new SelectionMode::ActionTextHelper(this);
174 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), m_actionTextHelper
, this);
175 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
176 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
177 connect(m_actionHandler
, &DolphinViewActionHandler::selectionModeChangeTriggered
, this, &DolphinMainWindow::slotSetSelectionMode
);
179 Q_CHECK_PTR(actionCollection()->action(QStringLiteral("create_dir")));
180 m_newFileMenu
->setNewFolderShortcutAction(actionCollection()->action(QStringLiteral("create_dir")));
182 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
183 connect(this, &DolphinMainWindow::urlChanged
, m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
185 m_disabledActionNotifier
= new DisabledActionNotifier(this);
186 connect(m_disabledActionNotifier
, &DisabledActionNotifier::disabledActionTriggered
, this, [this](const QAction
*, QString reason
) {
187 m_activeViewContainer
->showMessage(reason
, DolphinViewContainer::Warning
);
192 setupGUI(Save
| Create
| ToolBar
);
193 stateChanged(QStringLiteral("new_file"));
195 QClipboard
*clipboard
= QApplication::clipboard();
196 connect(clipboard
, &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
198 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
199 toggleFilterBarAction
->setChecked(GeneralSettings::filterBar());
202 menuBar()->setVisible(false);
205 const bool showMenu
= !menuBar()->isHidden();
206 QAction
*showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
207 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
209 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
210 hamburgerMenu
->setMenuBar(menuBar());
211 hamburgerMenu
->setShowMenuBarAction(showMenuBarAction
);
212 connect(hamburgerMenu
, &KHamburgerMenu::aboutToShowMenu
, this, &DolphinMainWindow::updateHamburgerMenu
);
213 hamburgerMenu
->hideActionsOf(toolBar());
214 if (GeneralSettings::version() < 201 && !toolBar()->actions().contains(hamburgerMenu
)) {
215 addHamburgerMenuToToolbar();
218 updateAllowedToolbarAreas();
220 // enable middle-click on back/forward/up to open in a new tab
221 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
222 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
223 toolBar()->installEventFilter(middleClickEventFilter
);
227 connect(KSycoca::self(), &KSycoca::databaseChanged
, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
229 QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
231 m_fileItemActions
.setParentWidget(this);
232 connect(&m_fileItemActions
, &KFileItemActions::error
, this, [this](const QString
&errorMessage
) {
233 showErrorMessage(errorMessage
);
236 connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged
, this, &DolphinMainWindow::slotSplitViewChanged
);
239 DolphinMainWindow::~DolphinMainWindow()
241 // This fixes a crash on Wayland when closing the mainwindow while another dialog is open.
242 disconnect(QGuiApplication::clipboard(), &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
245 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
247 QVector
<DolphinViewContainer
*> viewContainers
;
249 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
250 DolphinTabPage
*tabPage
= m_tabWidget
->tabPageAt(i
);
252 viewContainers
<< tabPage
->primaryViewContainer();
253 if (tabPage
->splitViewEnabled()) {
254 viewContainers
<< tabPage
->secondaryViewContainer();
257 return viewContainers
;
260 void DolphinMainWindow::openDirectories(const QList
<QUrl
> &dirs
, bool splitView
)
262 m_tabWidget
->openDirectories(dirs
, splitView
);
265 void DolphinMainWindow::openDirectories(const QStringList
&dirs
, bool splitView
)
267 openDirectories(QUrl::fromStringList(dirs
), splitView
);
270 void DolphinMainWindow::openFiles(const QList
<QUrl
> &files
, bool splitView
)
272 m_tabWidget
->openFiles(files
, splitView
);
275 bool DolphinMainWindow::isFoldersPanelEnabled() const
277 return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
280 bool DolphinMainWindow::isInformationPanelEnabled() const
283 return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
289 bool DolphinMainWindow::isSplitViewEnabledInCurrentTab() const
291 return m_tabWidget
->currentTabPage()->splitViewEnabled();
294 void DolphinMainWindow::openFiles(const QStringList
&files
, bool splitView
)
296 openFiles(QUrl::fromStringList(files
), splitView
);
299 void DolphinMainWindow::activateWindow(const QString
&activationToken
)
301 window()->setAttribute(Qt::WA_NativeWindow
, true);
303 if (KWindowSystem::isPlatformWayland()) {
304 KWindowSystem::setCurrentXdgActivationToken(activationToken
);
305 } else if (KWindowSystem::isPlatformX11()) {
307 KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken
.toUtf8());
311 KWindowSystem::activateWindow(window()->windowHandle());
314 bool DolphinMainWindow::isActiveWindow()
316 return window()->isActiveWindow();
319 void DolphinMainWindow::showCommand(CommandType command
)
321 DolphinStatusBar
*statusBar
= m_activeViewContainer
->statusBar();
323 case KIO::FileUndoManager::Copy
:
324 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
326 case KIO::FileUndoManager::Move
:
327 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
329 case KIO::FileUndoManager::Link
:
330 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
332 case KIO::FileUndoManager::Trash
:
333 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
335 case KIO::FileUndoManager::Rename
:
336 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
339 case KIO::FileUndoManager::Mkdir
:
340 statusBar
->setText(i18nc("@info:status", "Created folder."));
348 void DolphinMainWindow::pasteIntoFolder()
350 m_activeViewContainer
->view()->pasteIntoFolder();
353 void DolphinMainWindow::changeUrl(const QUrl
&url
)
355 if (!KProtocolManager::supportsListing(url
)) {
356 // The URL navigator only checks for validity, not
357 // if the URL can be listed. An error message is
358 // shown due to DolphinViewContainer::restoreView().
362 m_activeViewContainer
->setUrl(url
);
363 updateFileAndEditActions();
368 Q_EMIT
urlChanged(url
);
371 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
&url
)
373 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
374 m_placesPanel
->proceedWithTearDown();
375 m_tearDownFromPlacesRequested
= false;
378 m_activeViewContainer
->setAutoGrabFocus(false);
380 m_activeViewContainer
->setAutoGrabFocus(true);
383 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
385 KToggleAction
*editableLocationAction
= static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
386 editableLocationAction
->setChecked(editable
);
389 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
&selection
)
391 updateFileAndEditActions();
393 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
395 QAction
*compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
396 if (selectedUrlsCount
== 2) {
397 compareFilesAction
->setEnabled(isKompareInstalled());
399 compareFilesAction
->setEnabled(false);
402 Q_EMIT
selectionChanged(selection
);
405 void DolphinMainWindow::updateHistory()
407 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
408 const int index
= urlNavigator
->historyIndex();
410 QAction
*backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
412 backAction
->setToolTip(i18nc("@info", "Go back"));
413 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
414 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
417 QAction
*forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
419 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
420 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward", "This undoes a <interface>Go|Back</interface> action."));
421 forwardAction
->setEnabled(index
> 0);
425 void DolphinMainWindow::updateFilterBarAction(bool show
)
427 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
428 toggleFilterBarAction
->setChecked(show
);
431 void DolphinMainWindow::openNewMainWindow()
433 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
436 void DolphinMainWindow::openNewActivatedTab()
438 // keep browsers compatibility, new tab is always after last one
439 auto openNewTabAfterLastTabConfigured
= GeneralSettings::openNewTabAfterLastTab();
440 GeneralSettings::setOpenNewTabAfterLastTab(true);
441 m_tabWidget
->openNewActivatedTab();
442 GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured
);
445 void DolphinMainWindow::addToPlaces()
450 // If nothing is selected, act on the current dir
451 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
452 url
= m_activeViewContainer
->url();
453 name
= m_activeViewContainer
->placesText();
455 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
456 url
= dirToAdd
.url();
457 name
= dirToAdd
.name();
461 if (m_activeViewContainer
->isSearchModeEnabled()) {
462 icon
= QStringLiteral("folder-saved-search-symbolic");
464 icon
= KIO::iconNameForUrl(url
);
466 DolphinPlacesModelSingleton::instance().placesModel()->addPlace(name
, url
, icon
);
470 void DolphinMainWindow::openNewTab(const QUrl
&url
)
472 m_tabWidget
->openNewTab(url
, QUrl());
475 void DolphinMainWindow::openNewTabAndActivate(const QUrl
&url
)
477 m_tabWidget
->openNewActivatedTab(url
, QUrl());
480 void DolphinMainWindow::openNewWindow(const QUrl
&url
)
482 Dolphin::openNewWindow({url
}, this);
485 void DolphinMainWindow::slotSplitViewChanged()
487 m_tabWidget
->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation
);
488 updateSplitActions();
491 void DolphinMainWindow::openInNewTab()
493 const KFileItemList
&list
= m_activeViewContainer
->view()->selectedItems();
494 bool tabCreated
= false;
496 for (const KFileItem
&item
: list
) {
497 const QUrl
&url
= DolphinView::openItemAsFolderUrl(item
);
498 if (!url
.isEmpty()) {
504 // if no new tab has been created from the selection
505 // open the current directory in a new tab
507 openNewTab(m_activeViewContainer
->url());
511 void DolphinMainWindow::openInNewWindow()
515 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
516 if (list
.isEmpty()) {
517 newWindowUrl
= m_activeViewContainer
->url();
518 } else if (list
.count() == 1) {
519 const KFileItem
&item
= list
.first();
520 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
523 if (!newWindowUrl
.isEmpty()) {
524 Dolphin::openNewWindow({newWindowUrl
}, this);
528 void DolphinMainWindow::openInSplitView(const QUrl
&url
)
530 QUrl newSplitViewUrl
= url
;
532 if (newSplitViewUrl
.isEmpty()) {
533 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
534 if (list
.count() == 1) {
535 const KFileItem
&item
= list
.first();
536 newSplitViewUrl
= DolphinView::openItemAsFolderUrl(item
);
540 if (newSplitViewUrl
.isEmpty()) {
544 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
545 if (tabPage
->splitViewEnabled()) {
546 tabPage
->switchActiveView();
547 tabPage
->activeViewContainer()->setUrl(newSplitViewUrl
);
549 tabPage
->setSplitViewEnabled(true, WithAnimation
, newSplitViewUrl
);
554 void DolphinMainWindow::showTarget()
556 const KFileItem link
= m_activeViewContainer
->view()->selectedItems().at(0);
557 const QUrl destinationUrl
= link
.url().resolved(QUrl(link
.linkDest()));
559 auto job
= KIO::stat(destinationUrl
, KIO::StatJob::SourceSide
, KIO::StatNoDetails
);
561 connect(job
, &KJob::finished
, this, [this, destinationUrl
](KJob
*job
) {
562 KIO::StatJob
*statJob
= static_cast<KIO::StatJob
*>(job
);
564 if (statJob
->error()) {
565 m_activeViewContainer
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
567 KIO::highlightInFileManager({destinationUrl
});
572 bool DolphinMainWindow::event(QEvent
*event
)
574 if (event
->type() == QEvent::ShortcutOverride
) {
575 const QKeyEvent
*keyEvent
= static_cast<QKeyEvent
*>(event
);
576 if (keyEvent
->key() == Qt::Key_Space
&& m_activeViewContainer
->view()->handleSpaceAsNormalKey()) {
582 return KXmlGuiWindow::event(event
);
585 void DolphinMainWindow::showEvent(QShowEvent
*event
)
587 KXmlGuiWindow::showEvent(event
);
589 if (!event
->spontaneous()) {
590 m_activeViewContainer
->view()->setFocus();
594 void DolphinMainWindow::closeEvent(QCloseEvent
*event
)
596 // Find out if Dolphin is closed directly by the user or
597 // by the session manager because the session is closed
598 bool closedByUser
= true;
599 if (qApp
->isSavingSession()) {
600 closedByUser
= false;
603 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && !GeneralSettings::rememberOpenedTabs() && closedByUser
) {
604 // Ask the user if he really wants to quit and close all tabs.
605 // Open a confirmation dialog with 3 buttons:
606 // QDialogButtonBox::Yes -> Quit
607 // QDialogButtonBox::No -> Close only the current tab
608 // QDialogButtonBox::Cancel -> do nothing
609 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
610 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
611 dialog
->setModal(true);
612 QDialogButtonBox
*buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
613 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
),
614 KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()),
615 QIcon::fromTheme(QStringLiteral("application-exit"))));
616 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
617 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
618 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
620 bool doNotAskAgainCheckboxResult
= false;
622 const auto result
= KMessageBox::createKMessageBox(dialog
,
624 QMessageBox::Warning
,
625 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
627 i18n("Do not ask again"),
628 &doNotAskAgainCheckboxResult
,
629 KMessageBox::Notify
);
631 if (doNotAskAgainCheckboxResult
) {
632 GeneralSettings::setConfirmClosingMultipleTabs(false);
636 case QDialogButtonBox::Yes
:
639 case QDialogButtonBox::No
:
640 // Close only the current tab
641 m_tabWidget
->closeTab();
649 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
650 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
651 // Open a confirmation dialog with 3 buttons:
652 // QDialogButtonBox::Yes -> Quit
653 // QDialogButtonBox::No -> Show Terminal Panel
654 // QDialogButtonBox::Cancel -> do nothing
655 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
656 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
657 dialog
->setModal(true);
658 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
659 if (!m_terminalPanel
->isVisible()) {
660 standardButtons
|= QDialogButtonBox::No
;
662 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
663 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
664 if (!m_terminalPanel
->isVisible()) {
665 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
667 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
669 bool doNotAskAgainCheckboxResult
= false;
671 const auto result
= KMessageBox::createKMessageBox(
674 QMessageBox::Warning
,
675 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
677 i18n("Do not ask again"),
678 &doNotAskAgainCheckboxResult
,
679 KMessageBox::Notify
| KMessageBox::Dangerous
);
681 if (doNotAskAgainCheckboxResult
) {
682 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
686 case QDialogButtonBox::Yes
:
689 case QDialogButtonBox::No
:
690 actionCollection()->action("show_terminal_panel")->trigger();
691 // Do not quit, ignore quit event
699 if (m_sessionSaveTimer
&& (m_sessionSaveTimer
->isActive() || m_sessionSaveWatcher
->isRunning())) {
700 const bool sessionSaveTimerActive
= m_sessionSaveTimer
->isActive();
702 m_sessionSaveTimer
->stop();
703 m_sessionSaveWatcher
->disconnect();
704 m_sessionSaveWatcher
->waitForFinished();
706 if (sessionSaveTimerActive
|| m_sessionSaveScheduled
) {
711 GeneralSettings::setVersion(CurrentDolphinVersion
);
712 GeneralSettings::self()->save();
714 KXmlGuiWindow::closeEvent(event
);
717 void DolphinMainWindow::slotSaveSession()
719 m_sessionSaveScheduled
= false;
721 if (m_sessionSaveWatcher
->isRunning()) {
722 // The previous session is still being saved - schedule another save.
723 m_sessionSaveWatcher
->disconnect();
724 connect(m_sessionSaveWatcher
, &QFutureWatcher
<void>::finished
, this, &DolphinMainWindow::slotSaveSession
, Qt::SingleShotConnection
);
725 m_sessionSaveScheduled
= true;
726 } else if (!m_sessionSaveTimer
->isActive()) {
727 // No point in saving the session if the timer is running (since it will save the session again when it times out).
728 KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin"));
729 KConfig
*config
= KConfigGui::sessionConfig();
730 saveGlobalProperties(config
);
731 savePropertiesInternal(config
, 1);
733 auto future
= QtConcurrent::run([config
]() {
736 m_sessionSaveWatcher
->setFuture(future
);
740 void DolphinMainWindow::setSessionAutoSaveEnabled(bool enable
)
743 if (!m_sessionSaveTimer
) {
744 m_sessionSaveTimer
= new QTimer(this);
745 m_sessionSaveWatcher
= new QFutureWatcher
<void>(this);
746 m_sessionSaveTimer
->setSingleShot(true);
747 m_sessionSaveTimer
->setInterval(22000);
749 connect(m_sessionSaveTimer
, &QTimer::timeout
, this, &DolphinMainWindow::slotSaveSession
);
752 connect(m_tabWidget
, &DolphinTabWidget::urlChanged
, m_sessionSaveTimer
, qOverload
<>(&QTimer::start
), Qt::UniqueConnection
);
753 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
, m_sessionSaveTimer
, qOverload
<>(&QTimer::start
), Qt::UniqueConnection
);
754 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
, m_sessionSaveTimer
, qOverload
<>(&QTimer::start
), Qt::UniqueConnection
);
755 } else if (m_sessionSaveTimer
) {
756 m_sessionSaveTimer
->stop();
757 m_sessionSaveWatcher
->disconnect();
758 m_sessionSaveScheduled
= false;
760 m_sessionSaveWatcher
->waitForFinished();
762 m_sessionSaveTimer
->deleteLater();
763 m_sessionSaveWatcher
->deleteLater();
764 m_sessionSaveTimer
= nullptr;
765 m_sessionSaveWatcher
= nullptr;
769 void DolphinMainWindow::saveProperties(KConfigGroup
&group
)
771 m_tabWidget
->saveProperties(group
);
774 void DolphinMainWindow::readProperties(const KConfigGroup
&group
)
776 m_tabWidget
->readProperties(group
);
779 void DolphinMainWindow::updateNewMenu()
781 m_newFileMenu
->checkUpToDate();
782 m_newFileMenu
->setWorkingDirectory(activeViewContainer()->url());
785 void DolphinMainWindow::createDirectory()
787 // When creating directory, namejob is being run. In network folders,
788 // this job can take long time, so instead of starting multiple namejobs,
789 // just check if we are already running one. This prevents opening multiple
790 // dialogs. BUG:481401
791 if (!m_newFileMenu
->isCreateDirectoryRunning()) {
792 m_newFileMenu
->setWorkingDirectory(activeViewContainer()->url());
793 m_newFileMenu
->createDirectory();
797 void DolphinMainWindow::quit()
802 void DolphinMainWindow::showErrorMessage(const QString
&message
)
804 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
807 void DolphinMainWindow::slotUndoAvailable(bool available
)
809 QAction
*undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
811 undoAction
->setEnabled(available
);
815 void DolphinMainWindow::slotUndoTextChanged(const QString
&text
)
817 QAction
*undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
819 undoAction
->setText(text
);
823 void DolphinMainWindow::undo()
826 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
827 KIO::FileUndoManager::self()->undo();
830 void DolphinMainWindow::cut()
832 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
833 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CutContents
);
835 m_activeViewContainer
->view()->cutSelectedItemsToClipboard();
836 m_activeViewContainer
->setSelectionModeEnabled(false);
840 void DolphinMainWindow::copy()
842 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
843 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CopyContents
);
845 m_activeViewContainer
->view()->copySelectedItemsToClipboard();
846 m_activeViewContainer
->setSelectionModeEnabled(false);
850 void DolphinMainWindow::paste()
852 m_activeViewContainer
->view()->paste();
855 void DolphinMainWindow::find()
857 m_activeViewContainer
->setSearchModeEnabled(true);
860 void DolphinMainWindow::updateSearchAction()
862 QAction
*toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
863 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
866 void DolphinMainWindow::updatePasteAction()
868 QAction
*pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
869 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
870 pasteAction
->setEnabled(pasteInfo
.first
);
871 m_disabledActionNotifier
->setDisabledReason(pasteAction
,
872 m_activeViewContainer
->rootItem().isWritable()
873 ? i18nc("@info", "Cannot paste: The clipboard is empty.")
874 : i18nc("@info", "Cannot paste: You do not have permission to write into this folder."));
875 pasteAction
->setText(pasteInfo
.second
);
878 void DolphinMainWindow::slotDirectoryLoadingCompleted()
883 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
885 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
887 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
889 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
891 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
896 QAction
*DolphinMainWindow::urlNavigatorHistoryAction(const KUrlNavigator
*urlNavigator
, int historyIndex
, QObject
*parent
)
898 const QUrl url
= urlNavigator
->locationUrl(historyIndex
);
900 QString text
= url
.toDisplayString(QUrl::PreferLocalFile
);
902 if (!urlNavigator
->showFullPath()) {
903 const KFilePlacesModel
*placesModel
= DolphinPlacesModelSingleton::instance().placesModel();
905 const QModelIndex closestIdx
= placesModel
->closestItem(url
);
906 if (closestIdx
.isValid()) {
907 const QUrl placeUrl
= placesModel
->url(closestIdx
);
909 text
= placesModel
->text(closestIdx
);
911 QString pathInsidePlace
= url
.path().mid(placeUrl
.path().length());
913 if (!pathInsidePlace
.isEmpty() && !pathInsidePlace
.startsWith(QLatin1Char('/'))) {
914 pathInsidePlace
.prepend(QLatin1Char('/'));
917 if (pathInsidePlace
!= QLatin1Char('/')) {
918 text
.append(pathInsidePlace
);
923 QAction
*action
= new QAction(QIcon::fromTheme(KIO::iconNameForUrl(url
)), text
, parent
);
924 action
->setData(historyIndex
);
928 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
930 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
932 QMenu
*menu
= m_backAction
->popupMenu();
934 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
935 QAction
*action
= urlNavigatorHistoryAction(urlNavigator
, i
, menu
);
936 menu
->addAction(action
);
940 void DolphinMainWindow::slotGoBack(QAction
*action
)
942 int gotoIndex
= action
->data().value
<int>();
943 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
944 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
949 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
*action
)
952 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
953 openNewTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
957 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
959 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
961 QMenu
*menu
= m_forwardAction
->popupMenu();
962 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
963 QAction
*action
= urlNavigatorHistoryAction(urlNavigator
, i
, menu
);
964 menu
->addAction(action
);
968 void DolphinMainWindow::slotGoForward(QAction
*action
)
970 int gotoIndex
= action
->data().value
<int>();
971 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
972 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
977 void DolphinMainWindow::slotSetSelectionMode(bool enabled
, SelectionMode::BottomBar::Contents bottomBarContents
)
979 m_activeViewContainer
->setSelectionModeEnabled(enabled
, actionCollection(), bottomBarContents
);
982 void DolphinMainWindow::selectAll()
986 // if the URL navigator is editable and focused, select the whole
987 // URL instead of all items of the view
989 KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigator();
990 QLineEdit
*lineEdit
= urlNavigator
->editor()->lineEdit();
991 const bool selectUrl
= urlNavigator
->isUrlEditable() && lineEdit
->hasFocus();
993 lineEdit
->selectAll();
995 m_activeViewContainer
->view()->selectAll();
999 void DolphinMainWindow::invertSelection()
1002 m_activeViewContainer
->view()->invertSelection();
1005 void DolphinMainWindow::toggleSplitView()
1007 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
1008 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled(), WithAnimation
);
1009 m_tabWidget
->updateTabName(m_tabWidget
->indexOf(tabPage
));
1010 updateViewActions();
1013 void DolphinMainWindow::popoutSplitView()
1015 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
1016 if (!tabPage
->splitViewEnabled())
1018 openNewWindow((GeneralSettings::closeActiveSplitView() ? tabPage
->activeViewContainer() : tabPage
->inactiveViewContainer())->url());
1019 tabPage
->setSplitViewEnabled(false, WithAnimation
);
1020 updateSplitActions();
1023 void DolphinMainWindow::toggleSplitStash()
1025 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
1026 tabPage
->setSplitViewEnabled(false, WithAnimation
);
1027 tabPage
->setSplitViewEnabled(true, WithAnimation
, QUrl("stash:/"));
1030 void DolphinMainWindow::copyToInactiveSplitView()
1032 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
1033 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CopyToOtherViewContents
);
1035 m_tabWidget
->copyToInactiveSplitView();
1036 m_activeViewContainer
->setSelectionModeEnabled(false);
1040 void DolphinMainWindow::moveToInactiveSplitView()
1042 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
1043 m_activeViewContainer
->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::MoveToOtherViewContents
);
1045 m_tabWidget
->moveToInactiveSplitView();
1046 m_activeViewContainer
->setSelectionModeEnabled(false);
1050 void DolphinMainWindow::reloadView()
1053 m_activeViewContainer
->reload();
1054 m_activeViewContainer
->statusBar()->updateSpaceInfo();
1057 void DolphinMainWindow::stopLoading()
1059 m_activeViewContainer
->view()->stopLoading();
1062 void DolphinMainWindow::enableStopAction()
1064 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
1067 void DolphinMainWindow::disableStopAction()
1069 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
1072 void DolphinMainWindow::toggleSelectionMode()
1074 const bool checked
= !m_activeViewContainer
->isSelectionModeEnabled();
1076 m_activeViewContainer
->setSelectionModeEnabled(checked
, actionCollection(), SelectionMode::BottomBar::Contents::GeneralContents
);
1077 actionCollection()->action(QStringLiteral("toggle_selection_mode"))->setChecked(checked
);
1080 void DolphinMainWindow::showFilterBar()
1082 m_activeViewContainer
->setFilterBarVisible(true);
1085 void DolphinMainWindow::toggleFilterBar()
1087 const bool checked
= !m_activeViewContainer
->isFilterBarVisible();
1088 m_activeViewContainer
->setFilterBarVisible(checked
);
1090 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
1091 toggleFilterBarAction
->setChecked(checked
);
1094 void DolphinMainWindow::toggleEditLocation()
1098 QAction
*action
= actionCollection()->action(QStringLiteral("editable_location"));
1099 KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigator();
1100 urlNavigator
->setUrlEditable(action
->isChecked());
1103 void DolphinMainWindow::replaceLocation()
1105 KUrlNavigator
*navigator
= m_activeViewContainer
->urlNavigator();
1106 QLineEdit
*lineEdit
= navigator
->editor()->lineEdit();
1108 // If the text field currently has focus and everything is selected,
1109 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
1110 if (navigator
->isUrlEditable() && lineEdit
->hasFocus() && lineEdit
->selectedText() == lineEdit
->text()) {
1111 navigator
->setUrlEditable(false);
1113 navigator
->setUrlEditable(true);
1114 navigator
->setFocus();
1115 lineEdit
->selectAll();
1119 void DolphinMainWindow::togglePanelLockState()
1121 const bool newLockState
= !GeneralSettings::lockPanels();
1122 const auto childrenObjects
= children();
1123 for (QObject
*child
: childrenObjects
) {
1124 DolphinDockWidget
*dock
= qobject_cast
<DolphinDockWidget
*>(child
);
1126 dock
->setLocked(newLockState
);
1130 DolphinPlacesModelSingleton::instance().placesModel()->setPanelsLocked(newLockState
);
1132 GeneralSettings::setLockPanels(newLockState
);
1135 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
1137 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
1138 m_activeViewContainer
->view()->setFocus();
1142 void DolphinMainWindow::goBack()
1144 DolphinUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
1145 urlNavigator
->goBack();
1147 if (urlNavigator
->locationState().isEmpty()) {
1148 // An empty location state indicates a redirection URL,
1149 // which must be skipped too
1150 urlNavigator
->goBack();
1154 void DolphinMainWindow::goForward()
1156 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goForward();
1159 void DolphinMainWindow::goUp()
1161 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goUp();
1164 void DolphinMainWindow::goHome()
1166 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goHome();
1169 void DolphinMainWindow::goBackInNewTab()
1171 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
1172 const int index
= urlNavigator
->historyIndex() + 1;
1173 openNewTab(urlNavigator
->locationUrl(index
));
1176 void DolphinMainWindow::goForwardInNewTab()
1178 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
1179 const int index
= urlNavigator
->historyIndex() - 1;
1180 openNewTab(urlNavigator
->locationUrl(index
));
1183 void DolphinMainWindow::goUpInNewTab()
1185 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
1186 openNewTab(KIO::upUrl(currentUrl
));
1189 void DolphinMainWindow::goHomeInNewTab()
1191 openNewTab(Dolphin::homeUrl());
1194 void DolphinMainWindow::compareFiles()
1196 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
1197 if (items
.count() != 2) {
1198 // The action is disabled in this case, but it could have been triggered
1199 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
1203 QUrl urlA
= items
.at(0).url();
1204 QUrl urlB
= items
.at(1).url();
1206 QString
command(QStringLiteral("kompare -c \""));
1207 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
1208 command
.append("\" \"");
1209 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
1210 command
.append('\"');
1212 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(command
, this);
1213 job
->setDesktopName(QStringLiteral("org.kde.kompare"));
1217 void DolphinMainWindow::toggleShowMenuBar()
1219 const bool visible
= menuBar()->isVisible();
1220 menuBar()->setVisible(!visible
);
1223 QPointer
<QAction
> DolphinMainWindow::preferredSearchTool()
1225 m_searchTools
.clear();
1227 KService::Ptr kfind
= KService::serviceByDesktopName(QStringLiteral("org.kde.kfind"));
1233 auto *action
= new QAction(QIcon::fromTheme(kfind
->icon()), kfind
->name(), this);
1235 connect(action
, &QAction::triggered
, this, [this, kfind
] {
1236 auto *job
= new KIO::ApplicationLauncherJob(kfind
);
1237 job
->setUrls({m_activeViewContainer
->url()});
1244 void DolphinMainWindow::updateOpenPreferredSearchToolAction()
1246 QAction
*openPreferredSearchTool
= actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
1247 if (!openPreferredSearchTool
) {
1250 QPointer
<QAction
> tool
= preferredSearchTool();
1252 openPreferredSearchTool
->setVisible(true);
1253 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open %1", tool
->text()));
1254 // Only override with the app icon if it is the default, i.e. the user hasn't configured one manually
1255 // https://bugs.kde.org/show_bug.cgi?id=442815
1256 if (openPreferredSearchTool
->icon().name() == QLatin1String("search")) {
1257 openPreferredSearchTool
->setIcon(tool
->icon());
1260 openPreferredSearchTool
->setVisible(false);
1261 // still visible in Shortcuts configuration window
1262 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1263 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1267 void DolphinMainWindow::openPreferredSearchTool()
1269 QPointer
<QAction
> tool
= preferredSearchTool();
1275 void DolphinMainWindow::openTerminal()
1277 openTerminalJob(m_activeViewContainer
->url());
1280 void DolphinMainWindow::openTerminalHere()
1282 QList
<QUrl
> urls
= {};
1284 const auto selectedItems
= m_activeViewContainer
->view()->selectedItems();
1285 for (const KFileItem
&item
: selectedItems
) {
1286 QUrl url
= item
.targetUrl();
1287 if (item
.isFile()) {
1288 url
.setPath(QFileInfo(url
.path()).absolutePath());
1290 if (!urls
.contains(url
)) {
1295 // No items are selected. Open a terminal window for the current location.
1296 if (urls
.count() == 0) {
1301 if (urls
.count() > 5) {
1302 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());
1303 const int answer
= KMessageBox::warningContinueCancel(
1307 KGuiItem(i18ncp("@action:button", "Open %1 Terminal", "Open %1 Terminals", urls
.count()), QStringLiteral("utilities-terminal")),
1308 KStandardGuiItem::cancel(),
1309 QStringLiteral("ConfirmOpenManyTerminals"));
1310 if (answer
!= KMessageBox::PrimaryAction
&& answer
!= KMessageBox::Continue
) {
1315 for (const QUrl
&url
: std::as_const(urls
)) {
1316 openTerminalJob(url
);
1320 void DolphinMainWindow::openTerminalJob(const QUrl
&url
)
1322 if (url
.isLocalFile()) {
1323 auto job
= new KTerminalLauncherJob(QString());
1324 job
->setWorkingDirectory(url
.toLocalFile());
1329 // Not a local file, with protocol Class ":local", try stat'ing
1330 if (KProtocolInfo::protocolClass(url
.scheme()) == QLatin1String(":local")) {
1331 KIO::StatJob
*job
= KIO::mostLocalUrl(url
);
1332 KJobWidgets::setWindow(job
, this);
1333 connect(job
, &KJob::result
, this, [job
]() {
1335 if (!job
->error()) {
1336 statUrl
= job
->mostLocalUrl();
1339 auto job
= new KTerminalLauncherJob(QString());
1340 job
->setWorkingDirectory(statUrl
.isLocalFile() ? statUrl
.toLocalFile() : QDir::homePath());
1347 // Nothing worked, just use $HOME
1348 auto job
= new KTerminalLauncherJob(QString());
1349 job
->setWorkingDirectory(QDir::homePath());
1353 void DolphinMainWindow::editSettings()
1355 if (!m_settingsDialog
) {
1356 DolphinViewContainer
*container
= activeViewContainer();
1357 container
->view()->writeSettings();
1359 const QUrl url
= container
->url();
1360 DolphinSettingsDialog
*settingsDialog
= new DolphinSettingsDialog(url
, this, actionCollection());
1361 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
1362 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, &DolphinUrlNavigatorsController::slotReadSettings
);
1363 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
1364 settingsDialog
->show();
1365 m_settingsDialog
= settingsDialog
;
1367 m_settingsDialog
.data()->raise();
1371 void DolphinMainWindow::handleUrl(const QUrl
&url
)
1373 delete m_lastHandleUrlOpenJob
;
1374 m_lastHandleUrlOpenJob
= nullptr;
1376 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
1377 activeViewContainer()->setUrl(url
);
1379 m_lastHandleUrlOpenJob
= new KIO::OpenUrlJob(url
);
1380 m_lastHandleUrlOpenJob
->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
1381 m_lastHandleUrlOpenJob
->setShowOpenOrExecuteDialog(true);
1383 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::mimeTypeFound
, this, [this, url
](const QString
&mimetype
) {
1384 if (mimetype
== QLatin1String("inode/directory")) {
1385 // If it's a dir, we'll take it from here
1386 m_lastHandleUrlOpenJob
->kill();
1387 m_lastHandleUrlOpenJob
= nullptr;
1388 activeViewContainer()->setUrl(url
);
1392 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::result
, this, [this]() {
1393 m_lastHandleUrlOpenJob
= nullptr;
1396 m_lastHandleUrlOpenJob
->start();
1400 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1402 // trash:/ is writable but we don't want to create new items in it.
1403 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1404 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1405 // 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.
1406 QTimer::singleShot(0, this, [this]() {
1407 m_disabledActionNotifier
->setDisabledReason(actionCollection()->action(QStringLiteral("create_dir")),
1408 i18nc("@info", "Cannot create new folder: You do not have permission to create items in this folder."));
1412 void DolphinMainWindow::openContextMenu(const QPoint
&pos
, const KFileItem
&item
, const KFileItemList
&selectedItems
, const QUrl
&url
)
1414 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, item
, selectedItems
, url
, &m_fileItemActions
);
1415 contextMenu
->exec(pos
);
1417 // Delete the menu, unless it has been deleted in its own nested event loop already.
1419 contextMenu
->deleteLater();
1423 QMenu
*DolphinMainWindow::createPopupMenu()
1425 QMenu
*menu
= KXmlGuiWindow::createPopupMenu();
1427 menu
->addSeparator();
1428 menu
->addAction(actionCollection()->action(QStringLiteral("lock_panels")));
1433 void DolphinMainWindow::updateHamburgerMenu()
1435 KActionCollection
*ac
= actionCollection();
1436 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(ac
->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
1437 auto menu
= hamburgerMenu
->menu();
1439 menu
= new QMenu(this);
1440 hamburgerMenu
->setMenu(menu
);
1441 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("basic_actions"))->menu());
1442 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("zoom"))->menu());
1446 const QList
<QAction
*> toolbarActions
= toolBar()->actions();
1448 if (!toolBar()->isVisible()) {
1449 // If neither the menu bar nor the toolbar are visible, these actions should be available.
1450 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)));
1451 menu
->addAction(toolBarMenuAction());
1452 menu
->addSeparator();
1455 // This group of actions (until the next separator) contains all the most basic actions
1456 // necessary to use Dolphin effectively.
1457 menu
->addAction(ac
->action(QStringLiteral("go_back")));
1458 menu
->addAction(ac
->action(QStringLiteral("go_forward")));
1460 menu
->addMenu(m_newFileMenu
->menu());
1461 if (!toolBar()->isVisible() || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_selection_mode_tool_bar")))) {
1462 menu
->addAction(ac
->action(QStringLiteral("toggle_selection_mode")));
1464 menu
->addAction(ac
->action(QStringLiteral("basic_actions")));
1465 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Undo
)));
1466 if (!toolBar()->isVisible()
1467 || (!toolbarActions
.contains(ac
->action(QStringLiteral("toggle_search")))
1468 && !toolbarActions
.contains(ac
->action(QStringLiteral("open_preferred_search_tool"))))) {
1469 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Find
)));
1470 // This way a search action will only be added if none of the three available
1471 // search actions is present on the toolbar.
1473 if (!toolBar()->isVisible() || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_filter")))) {
1474 menu
->addAction(ac
->action(QStringLiteral("show_filter_bar")));
1475 // This way a filter action will only be added if none of the two available
1476 // filter actions is present on the toolbar.
1478 menu
->addSeparator();
1480 // The second group of actions (up until the next separator) contains actions for opening
1481 // additional views to interact with the file system.
1482 menu
->addAction(ac
->action(QStringLiteral("file_new")));
1483 menu
->addAction(ac
->action(QStringLiteral("new_tab")));
1484 if (ac
->action(QStringLiteral("undo_close_tab"))->isEnabled()) {
1485 menu
->addAction(ac
->action(QStringLiteral("closed_tabs")));
1487 menu
->addAction(ac
->action(QStringLiteral("open_terminal")));
1488 menu
->addSeparator();
1490 // The third group contains actions to change what one sees in the view
1491 // and to change the more general UI.
1492 if (!toolBar()->isVisible()
1493 || (!toolbarActions
.contains(ac
->action(QStringLiteral("icons"))) && !toolbarActions
.contains(ac
->action(QStringLiteral("compact")))
1494 && !toolbarActions
.contains(ac
->action(QStringLiteral("details"))) && !toolbarActions
.contains(ac
->action(QStringLiteral("view_mode"))))) {
1495 menu
->addAction(ac
->action(QStringLiteral("view_mode")));
1497 menu
->addAction(ac
->action(QStringLiteral("show_hidden_files")));
1498 menu
->addAction(ac
->action(QStringLiteral("sort")));
1499 menu
->addAction(ac
->action(QStringLiteral("group")));
1500 menu
->addAction(ac
->action(QStringLiteral("additional_info")));
1501 if (!GeneralSettings::showStatusBar() || !GeneralSettings::showZoomSlider()) {
1502 menu
->addAction(ac
->action(QStringLiteral("zoom")));
1504 menu
->addAction(ac
->action(QStringLiteral("panels")));
1506 // The "Configure" menu is not added to the actionCollection() because there is hardly
1507 // a good reason for users to put it on their toolbar.
1508 auto configureMenu
= menu
->addMenu(QIcon::fromTheme(QStringLiteral("configure")), i18nc("@action:inmenu menu for configure actions", "Configure"));
1509 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
)));
1510 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)));
1511 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)));
1512 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Preferences
)));
1513 hamburgerMenu
->hideActionsOf(configureMenu
);
1516 void DolphinMainWindow::slotPlaceActivated(const QUrl
&url
)
1518 DolphinViewContainer
*view
= activeViewContainer();
1520 if (view
->url() == url
) {
1521 view
->clearFilterBar(); // Fixes bug 259382.
1523 // We can end up here if the user clicked a device in the Places Panel
1524 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1527 view
->disableUrlNavigatorSelectionRequests();
1529 view
->enableUrlNavigatorSelectionRequests();
1533 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1535 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1538 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
*viewContainer
)
1540 DolphinViewContainer
*oldViewContainer
= m_activeViewContainer
;
1541 Q_ASSERT(viewContainer
);
1543 m_activeViewContainer
= viewContainer
;
1545 if (oldViewContainer
) {
1546 const QAction
*toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1547 toggleSearchAction
->disconnect(oldViewContainer
);
1549 // Disconnect all signals between the old view container (container,
1550 // view and url navigator) and main window.
1551 oldViewContainer
->disconnect(this);
1552 oldViewContainer
->view()->disconnect(this);
1553 oldViewContainer
->urlNavigatorInternalWithHistory()->disconnect(this);
1554 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
1555 navigators
->primaryUrlNavigator()->disconnect(this);
1556 if (auto secondaryUrlNavigator
= navigators
->secondaryUrlNavigator()) {
1557 secondaryUrlNavigator
->disconnect(this);
1560 // except the requestItemInfo so that on hover the information panel can still be updated
1561 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
, this, &DolphinMainWindow::requestItemInfo
);
1563 // Disconnect other slots.
1564 disconnect(oldViewContainer
,
1565 &DolphinViewContainer::selectionModeChanged
,
1566 actionCollection()->action(QStringLiteral("toggle_selection_mode")),
1567 &QAction::setChecked
);
1570 connectViewSignals(viewContainer
);
1572 m_actionHandler
->setCurrentView(viewContainer
->view());
1575 updateFileAndEditActions();
1576 updatePasteAction();
1577 updateViewActions();
1579 updateSearchAction();
1581 const QUrl url
= viewContainer
->url();
1582 Q_EMIT
urlChanged(url
);
1585 void DolphinMainWindow::tabCountChanged(int count
)
1587 const bool enableTabActions
= (count
> 1);
1588 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1589 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1591 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1592 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1593 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1596 void DolphinMainWindow::updateWindowTitle()
1598 const QString newTitle
= m_activeViewContainer
->captionWindowTitle();
1599 if (windowTitle() != newTitle
) {
1600 setWindowTitle(newTitle
);
1604 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
&mountPath
)
1606 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1607 setViewsToHomeIfMountPathOpen(mountPath
);
1610 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectoryIsChildOf(mountPath
)) {
1611 m_tearDownFromPlacesRequested
= true;
1612 m_terminalPanel
->goHome();
1613 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1615 m_placesPanel
->proceedWithTearDown();
1619 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
&mountPath
)
1621 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1622 setViewsToHomeIfMountPathOpen(mountPath
);
1625 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectoryIsChildOf(mountPath
)) {
1626 m_tearDownFromPlacesRequested
= false;
1627 m_terminalPanel
->goHome();
1631 void DolphinMainWindow::slotKeyBindings()
1633 KShortcutsDialog
dialog(KShortcutsEditor::AllActions
, KShortcutsEditor::LetterShortcutsAllowed
, this);
1634 dialog
.addCollection(actionCollection());
1635 if (m_terminalPanel
) {
1636 KActionCollection
*konsolePartActionCollection
= m_terminalPanel
->actionCollection();
1637 if (konsolePartActionCollection
) {
1638 dialog
.addCollection(konsolePartActionCollection
, QStringLiteral("KonsolePart"));
1644 void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString
&mountPath
)
1646 const QVector
<DolphinViewContainer
*> theViewContainers
= viewContainers();
1647 for (DolphinViewContainer
*viewContainer
: theViewContainers
) {
1648 if (viewContainer
&& viewContainer
->url().toLocalFile().startsWith(mountPath
)) {
1649 viewContainer
->setUrl(QUrl::fromLocalFile(QDir::homePath()));
1652 disconnect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, nullptr, nullptr);
1655 void DolphinMainWindow::setupActions()
1657 auto hamburgerMenuAction
= KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
1659 // setup 'File' menu
1660 m_newFileMenu
= new DolphinNewFileMenu(nullptr, this);
1661 actionCollection()->addAction(QStringLiteral("new_menu"), m_newFileMenu
);
1662 QMenu
*menu
= m_newFileMenu
->menu();
1663 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1664 menu
->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
1665 m_newFileMenu
->setPopupMode(QToolButton::InstantPopup
);
1666 connect(menu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateNewMenu
);
1668 QAction
*newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1669 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1670 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1671 newWindow
->setWhatsThis(xi18nc("@info:whatsthis",
1673 "window just like this one with the current location."
1674 "<nl/>You can drag and drop items between windows."));
1675 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1677 QAction
*newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1678 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1679 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1680 newTab
->setWhatsThis(xi18nc("@info:whatsthis",
1682 "<emphasis>Tab</emphasis> with the current location."
1683 "<nl/>Tabs allow you to quickly switch between multiple locations and views within this window. "
1684 "You can drag and drop items between tabs."));
1685 actionCollection()->setDefaultShortcut(newTab
, Qt::CTRL
| Qt::Key_T
);
1686 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1688 QAction
*addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1689 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1690 addToPlaces
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1691 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis",
1692 "This adds the selected folder "
1693 "to the Places panel."));
1694 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1696 QAction
*closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1697 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1698 closeTab
->setToolTip(i18nc("@info", "Close Tab"));
1699 closeTab
->setWhatsThis(i18nc("@info:whatsthis",
1701 "currently viewed tab. If no more tabs are left, this closes "
1702 "the whole window instead."));
1704 QAction
*quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1705 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1707 // setup 'Edit' menu
1708 KStandardAction::undo(this, &DolphinMainWindow::undo
, actionCollection());
1710 // i18n: This will be the last paragraph for the whatsthis for all three:
1711 // Cut, Copy and Paste
1712 const QString cutCopyPastePara
= xi18nc("@info:whatsthis",
1713 "<para><emphasis>Cut, "
1714 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1715 "applications and are among the most used commands. That's why their "
1716 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1717 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1718 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1719 QAction
*cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1720 m_actionTextHelper
->registerTextWhenNothingIsSelected(cutAction
, i18nc("@action", "Cut…"));
1721 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut",
1722 "This copies the items "
1723 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1724 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1725 "the clipboard to a new location. The items will be removed from their "
1726 "initial location.")
1727 + cutCopyPastePara
);
1728 QAction
*copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1729 m_actionTextHelper
->registerTextWhenNothingIsSelected(copyAction
, i18nc("@action", "Copy…"));
1730 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy",
1732 "items in your current selection to the <emphasis>clipboard</emphasis>."
1733 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1734 "from the clipboard to a new location.")
1735 + cutCopyPastePara
);
1736 QAction
*paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1737 // The text of the paste-action is modified dynamically by Dolphin
1738 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1739 // due to the long text, the text "Paste" is used:
1740 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1741 paste
->setWhatsThis(xi18nc("@info:whatsthis paste",
1742 "This copies the items from "
1743 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1744 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1745 "action they are removed from their old location.")
1746 + cutCopyPastePara
);
1748 QAction
*copyToOtherViewAction
= actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
1749 copyToOtherViewAction
->setText(i18nc("@action:inmenu", "Copy to Other View"));
1750 m_actionTextHelper
->registerTextWhenNothingIsSelected(copyToOtherViewAction
, i18nc("@action:inmenu", "Copy to Other View…"));
1751 copyToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Copy",
1752 "This copies the selected items from "
1753 "the view in focus to the other view. "
1754 "(Only available while in Split View mode.)"));
1755 copyToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
1756 copyToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Copy to Other View"));
1757 actionCollection()->setDefaultShortcut(copyToOtherViewAction
, Qt::SHIFT
| Qt::Key_F5
);
1758 connect(copyToOtherViewAction
, &QAction::triggered
, this, &DolphinMainWindow::copyToInactiveSplitView
);
1760 QAction
*moveToOtherViewAction
= actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
1761 moveToOtherViewAction
->setText(i18nc("@action:inmenu", "Move to Other View"));
1762 m_actionTextHelper
->registerTextWhenNothingIsSelected(moveToOtherViewAction
, i18nc("@action:inmenu", "Move to Other View…"));
1763 moveToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Move",
1764 "This moves the selected items from "
1765 "the view in focus to the other view. "
1766 "(Only available while in Split View mode.)"));
1767 moveToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
1768 moveToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Move to Other View"));
1769 actionCollection()->setDefaultShortcut(moveToOtherViewAction
, Qt::SHIFT
| Qt::Key_F6
);
1770 connect(moveToOtherViewAction
, &QAction::triggered
, this, &DolphinMainWindow::moveToInactiveSplitView
);
1772 QAction
*showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1773 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Filter…"));
1774 showFilterBar
->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
1775 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis",
1777 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1778 "There you can enter text to filter the files and folders currently displayed. "
1779 "Only those that contain the text in their name will be kept in view."));
1780 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1781 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
| Qt::Key_I
, Qt::Key_Slash
});
1782 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1784 // toggle_filter acts as a copy of the main showFilterBar to be used mainly
1785 // in the toolbar, with no default shortcut attached, to avoid messing with
1786 // existing workflows (filter bar always open and Ctrl-I to focus)
1787 QAction
*toggleFilter
= actionCollection()->addAction(QStringLiteral("toggle_filter"));
1788 toggleFilter
->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
1789 toggleFilter
->setIconText(i18nc("@action:intoolbar", "Filter"));
1790 toggleFilter
->setIcon(showFilterBar
->icon());
1791 toggleFilter
->setToolTip(showFilterBar
->toolTip());
1792 toggleFilter
->setWhatsThis(showFilterBar
->whatsThis());
1793 toggleFilter
->setCheckable(true);
1794 connect(toggleFilter
, &QAction::triggered
, this, &DolphinMainWindow::toggleFilterBar
);
1796 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1797 searchAction
->setText(i18n("Search…"));
1798 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1799 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find",
1800 "<para>This helps you "
1801 "find files and folders by opening a <emphasis>search bar</emphasis>. "
1802 "There you can enter search terms and specify settings to find the "
1803 "items you are looking for.</para><para>Use this help again on "
1804 "the search bar so we can have a look at it while the settings are "
1805 "explained.</para>"));
1807 // toggle_search acts as a copy of the main searchAction to be used mainly
1808 // in the toolbar, with no default shortcut attached, to avoid messing with
1809 // existing workflows (search bar always open and Ctrl-F to focus)
1810 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1811 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1812 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1813 toggleSearchAction
->setIcon(searchAction
->icon());
1814 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1815 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1816 toggleSearchAction
->setCheckable(true);
1818 QAction
*toggleSelectionModeAction
= actionCollection()->addAction(QStringLiteral("toggle_selection_mode"));
1819 // i18n: This action toggles a selection mode.
1820 toggleSelectionModeAction
->setText(i18nc("@action:inmenu", "Select Files and Folders"));
1821 // i18n: Opens a selection mode for selecting files/folders.
1822 // The text is kept so unspecific because it will be shown on the toolbar where space is at a premium.
1823 toggleSelectionModeAction
->setIconText(i18nc("@action:intoolbar", "Select"));
1824 toggleSelectionModeAction
->setWhatsThis(xi18nc(
1826 "<para>This application only knows which files or folders should be acted on if they are"
1827 " <emphasis>selected</emphasis> first. Press this to toggle a <emphasis>Selection Mode</emphasis> which makes selecting and deselecting as easy as "
1828 "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."
1830 toggleSelectionModeAction
->setIcon(QIcon::fromTheme(QStringLiteral("quickwizard")));
1831 toggleSelectionModeAction
->setCheckable(true);
1832 actionCollection()->setDefaultShortcut(toggleSelectionModeAction
, Qt::Key_Space
);
1833 connect(toggleSelectionModeAction
, &QAction::triggered
, this, &DolphinMainWindow::toggleSelectionMode
);
1835 // A special version of the toggleSelectionModeAction for the toolbar that also contains a menu
1836 // with the selectAllAction and invertSelectionAction.
1837 auto *toggleSelectionModeToolBarAction
=
1838 new KToolBarPopupAction(toggleSelectionModeAction
->icon(), toggleSelectionModeAction
->iconText(), actionCollection());
1839 toggleSelectionModeToolBarAction
->setToolTip(toggleSelectionModeAction
->text());
1840 toggleSelectionModeToolBarAction
->setWhatsThis(toggleSelectionModeAction
->whatsThis());
1841 actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction
);
1842 toggleSelectionModeToolBarAction
->setCheckable(true);
1843 toggleSelectionModeToolBarAction
->setPopupMode(KToolBarPopupAction::DelayedPopup
);
1844 connect(toggleSelectionModeToolBarAction
, &QAction::triggered
, toggleSelectionModeAction
, &QAction::trigger
);
1845 connect(toggleSelectionModeAction
, &QAction::toggled
, toggleSelectionModeToolBarAction
, &QAction::setChecked
);
1847 QAction
*selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1848 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis",
1850 "files and folders in the current location."));
1852 QAction
*invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1853 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1854 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert",
1856 "items that you have currently <emphasis>not</emphasis> selected instead."));
1857 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1858 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1859 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1861 QMenu
*toggleSelectionModeActionMenu
= new QMenu(this);
1862 toggleSelectionModeActionMenu
->addAction(selectAllAction
);
1863 toggleSelectionModeActionMenu
->addAction(invertSelection
);
1864 toggleSelectionModeToolBarAction
->setMenu(toggleSelectionModeActionMenu
);
1866 // setup 'View' menu
1867 // (note that most of it is set up in DolphinViewActionHandler)
1869 Admin::WorkerIntegration::createActAsAdminAction(actionCollection(), this);
1871 m_splitViewAction
= actionCollection()->add
<KActionMenu
>(QStringLiteral("split_view"));
1872 m_splitViewMenuAction
= actionCollection()->addAction(QStringLiteral("split_view_menu"));
1874 m_splitViewAction
->setWhatsThis(xi18nc("@info:whatsthis split",
1875 "<para>This presents "
1876 "a second view side-by-side with the current view, so you can see "
1877 "the contents of two folders at once and easily move items between "
1878 "them.</para><para>The view that is not \"in focus\" will be dimmed. "
1879 "</para>Click this button again to close one of the views."));
1880 m_splitViewMenuAction
->setWhatsThis(m_splitViewAction
->whatsThis());
1882 // only set it for the menu version
1883 actionCollection()->setDefaultShortcut(m_splitViewMenuAction
, Qt::Key_F3
);
1885 connect(m_splitViewAction
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1886 connect(m_splitViewMenuAction
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1888 QAction
*popoutSplit
= actionCollection()->addAction(QStringLiteral("popout_split_view"));
1889 popoutSplit
->setWhatsThis(xi18nc("@info:whatsthis",
1890 "If the view has been split, this will pop the view in focus "
1891 "out into a new window."));
1892 popoutSplit
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1893 actionCollection()->setDefaultShortcut(popoutSplit
, Qt::SHIFT
| Qt::Key_F3
);
1894 connect(popoutSplit
, &QAction::triggered
, this, &DolphinMainWindow::popoutSplitView
);
1896 QAction
*stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1897 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
| Qt::Key_S
);
1898 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1899 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1900 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1901 stashSplit
->setCheckable(false);
1902 QDBusConnectionInterface
*sessionInterface
= QDBusConnection::sessionBus().interface();
1903 stashSplit
->setVisible(sessionInterface
&& sessionInterface
->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
1904 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1906 QAction
*redisplay
= KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1907 redisplay
->setToolTip(i18nc("@info:tooltip", "Refresh view"));
1908 redisplay
->setWhatsThis(xi18nc("@info:whatsthis refresh",
1909 "<para>This refreshes "
1910 "the folder view.</para>"
1911 "<para>If the contents of this folder have changed, refreshing will re-scan this folder "
1912 "and show you a newly-updated view of the files and folders contained here.</para>"
1913 "<para>If the view is split, this refreshes the one that is currently in focus.</para>"));
1915 QAction
*stop
= actionCollection()->addAction(QStringLiteral("stop"));
1916 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1917 stop
->setToolTip(i18nc("@info", "Stop loading"));
1918 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1919 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1920 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1922 KToggleAction
*editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1923 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1924 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1925 "This toggles the <emphasis>Location Bar</emphasis> to be "
1926 "editable so you can directly enter a location you want to go to.<nl/>"
1927 "You can also switch to editing by clicking to the right of the "
1928 "location and switch back by confirming the edited location."));
1929 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1930 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1932 QAction
*replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1933 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1934 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1935 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1936 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1937 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1938 "This switches to editing the location and selects it "
1939 "so you can quickly enter a different location."));
1940 actionCollection()->setDefaultShortcuts(replaceLocation
, {Qt::CTRL
| Qt::Key_L
, Qt::ALT
| Qt::Key_D
});
1941 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1945 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1946 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1947 m_backAction
->setObjectName(backAction
->objectName());
1948 m_backAction
->setShortcuts(backAction
->shortcuts());
1950 m_backAction
->setPopupMode(KToolBarPopupAction::DelayedPopup
);
1951 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1952 connect(m_backAction
->popupMenu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1953 connect(m_backAction
->popupMenu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1954 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1956 auto backShortcuts
= m_backAction
->shortcuts();
1957 // Prepend this shortcut, to avoid being hidden by the two-slot UI (#371130)
1958 backShortcuts
.prepend(QKeySequence(Qt::Key_Backspace
));
1959 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1961 DolphinRecentTabsMenu
*recentTabsMenu
= new DolphinRecentTabsMenu(this);
1962 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1963 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
, recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1964 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
, m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1965 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
, this, &DolphinMainWindow::closedTabsCountChanged
);
1967 QAction
*undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1968 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1969 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab", "This returns you to the previously closed tab."));
1970 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_T
);
1971 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1972 undoCloseTab
->setEnabled(false);
1973 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1975 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1976 undoAction
->setWhatsThis(xi18nc("@info:whatsthis",
1978 "the last change you made to files or folders.<nl/>"
1979 "Such changes include <interface>creating</interface>, <interface>renaming</interface> "
1980 "and <interface>moving</interface> them to a different location "
1981 "or to the <filename>Trash</filename>. <nl/>Any changes that cannot be undone "
1982 "will ask for your confirmation beforehand."));
1983 undoAction
->setEnabled(false); // undo should be disabled by default
1986 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1987 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1988 m_forwardAction
->setObjectName(forwardAction
->objectName());
1989 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1991 m_forwardAction
->setPopupMode(KToolBarPopupAction::DelayedPopup
);
1992 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1993 connect(m_forwardAction
->popupMenu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1994 connect(m_forwardAction
->popupMenu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1995 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1996 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1998 // enable middle-click to open in a new tab
1999 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
2000 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
2001 m_backAction
->popupMenu()->installEventFilter(middleClickEventFilter
);
2002 m_forwardAction
->popupMenu()->installEventFilter(middleClickEventFilter
);
2003 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
2004 QAction
*homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
2005 homeAction
->setWhatsThis(xi18nc("@info:whatsthis",
2007 "<filename>Home</filename> folder.<nl/>Every user account "
2008 "has their own <filename>Home</filename> that contains their personal files, "
2009 "as well as hidden folders for their applications' data and configuration files."));
2011 // setup 'Tools' menu
2012 QAction
*compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
2013 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
2014 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
2015 compareFiles
->setEnabled(false);
2016 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
2018 QAction
*openPreferredSearchTool
= actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
2019 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
2020 openPreferredSearchTool
->setWhatsThis(xi18nc("@info:whatsthis",
2021 "<para>This opens a preferred search tool for the viewed location.</para>"
2022 "<para>Use <emphasis>More Search Tools</emphasis> menu to configure it.</para>"));
2023 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
2024 actionCollection()->setDefaultShortcut(openPreferredSearchTool
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F
);
2025 connect(openPreferredSearchTool
, &QAction::triggered
, this, &DolphinMainWindow::openPreferredSearchTool
);
2027 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
2028 QAction
*openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
2029 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
2030 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
2031 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
2032 "<para>To learn more about terminals use the help features in the terminal application.</para>"));
2033 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
2034 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
| Qt::Key_F4
);
2035 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
2037 QAction
*openTerminalHere
= actionCollection()->addAction(QStringLiteral("open_terminal_here"));
2038 // i18n: "Here" refers to the location(s) of the currently selected item(s) or the currently viewed location if nothing is selected.
2039 openTerminalHere
->setText(i18nc("@action:inmenu Tools", "Open Terminal Here"));
2040 openTerminalHere
->setWhatsThis(xi18nc("@info:whatsthis",
2041 "<para>This opens <emphasis>terminal</emphasis> applications for the selected items' locations.</para>"
2042 "<para>To learn more about terminals use the help features in the terminal application.</para>"));
2043 openTerminalHere
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
2044 actionCollection()->setDefaultShortcut(openTerminalHere
, Qt::SHIFT
| Qt::ALT
| Qt::Key_F4
);
2045 connect(openTerminalHere
, &QAction::triggered
, this, &DolphinMainWindow::openTerminalHere
);
2048 QAction
*focusTerminalPanel
= actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
2049 focusTerminalPanel
->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2050 focusTerminalPanel
->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
2051 actionCollection()->setDefaultShortcut(focusTerminalPanel
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F4
);
2052 connect(focusTerminalPanel
, &QAction::triggered
, this, &DolphinMainWindow::focusTerminalPanel
);
2056 // setup 'Bookmarks' menu
2057 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
2058 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
2059 // Make the toolbar button version work properly on click
2060 bookmarkMenu
->setPopupMode(QToolButton::InstantPopup
);
2061 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
2062 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
2064 // setup 'Settings' menu
2065 KToggleAction
*showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
2066 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
2067 "<para>This switches between having a <emphasis>Menubar</emphasis> "
2068 "and having an <interface>%1</interface> button. Both "
2069 "contain mostly the same actions and configuration options.</para>"
2070 "<para>The Menubar takes up more space but allows for fast and organized access to all "
2071 "actions an application has to offer.</para><para>The %1 button "
2072 "is simpler and small which makes triggering advanced actions more time consuming.</para>",
2073 hamburgerMenuAction
->text().replace('&', "")));
2074 connect(showMenuBar
,
2075 &KToggleAction::triggered
, // Fixes #286822
2077 &DolphinMainWindow::toggleShowMenuBar
,
2078 Qt::QueuedConnection
);
2080 KToggleAction
*showStatusBar
= KStandardAction::showStatusbar(nullptr, nullptr, actionCollection());
2081 showStatusBar
->setChecked(GeneralSettings::showStatusBar());
2082 connect(GeneralSettings::self(), &GeneralSettings::showStatusBarChanged
, showStatusBar
, &KToggleAction::setChecked
);
2083 connect(showStatusBar
, &KToggleAction::triggered
, this, [this](bool checked
) {
2084 GeneralSettings::setShowStatusBar(checked
);
2088 KStandardAction::keyBindings(this, &DolphinMainWindow::slotKeyBindings
, actionCollection());
2089 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
2091 // not in menu actions
2092 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
2093 nextTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::Key_Tab
));
2095 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
2096 prevTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::SHIFT
| Qt::Key_Tab
));
2098 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
2099 QAction
*activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
2100 activateTab
->setText(i18nc("@action:inmenu", "Go to Tab %1", i
+ 1));
2101 activateTab
->setEnabled(false);
2102 connect(activateTab
, &QAction::triggered
, this, [this, i
]() {
2103 m_tabWidget
->activateTab(i
);
2106 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
2108 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
2112 QAction
*activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
2113 activateLastTab
->setIconText(i18nc("@action:inmenu", "Last Tab"));
2114 activateLastTab
->setText(i18nc("@action:inmenu", "Go to Last Tab"));
2115 activateLastTab
->setEnabled(false);
2116 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
2117 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
| Qt::Key_0
);
2119 QAction
*activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
2120 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
2121 activateNextTab
->setText(i18nc("@action:inmenu", "Go to Next Tab"));
2122 activateNextTab
->setEnabled(false);
2123 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
2124 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
2126 QAction
*activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
2127 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
2128 activatePrevTab
->setText(i18nc("@action:inmenu", "Go to Previous Tab"));
2129 activatePrevTab
->setEnabled(false);
2130 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
2131 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
2134 QAction
*showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
2135 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
2136 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
2137 showTarget
->setEnabled(false);
2138 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
2140 QAction
*openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
2141 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
2142 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
2143 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
2145 QAction
*openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
2146 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
2147 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
2148 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
2150 QAction
*openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
2151 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
2152 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
2153 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
2155 QAction
*openInSplitViewAction
= actionCollection()->addAction(QStringLiteral("open_in_split_view"));
2156 openInSplitViewAction
->setText(i18nc("@action:inmenu", "Open in Split View"));
2157 openInSplitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2158 connect(openInSplitViewAction
, &QAction::triggered
, this, [this]() {
2159 openInSplitView(QUrl());
2163 void DolphinMainWindow::setupDockWidgets()
2165 const bool lock
= GeneralSettings::lockPanels();
2167 DolphinPlacesModelSingleton::instance().placesModel()->setPanelsLocked(lock
);
2169 KDualAction
*lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
2170 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
2171 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
2172 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
2173 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
2174 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis",
2176 "switches between having panels <emphasis>locked</emphasis> or "
2177 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
2178 "dragged to the other side of the window and have a close "
2179 "button.<nl/>Locked panels are embedded more cleanly."));
2180 lockLayoutAction
->setActive(lock
);
2181 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
2183 // Setup "Information"
2184 DolphinDockWidget
*infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
2185 infoDock
->setLocked(lock
);
2186 infoDock
->setObjectName(QStringLiteral("infoDock"));
2187 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
2190 InformationPanel
*infoPanel
= new InformationPanel(infoDock
);
2191 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
2192 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
2193 infoDock
->setWidget(infoPanel
);
2195 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoDock
, QStringLiteral("show_information_panel"));
2197 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
2198 connect(this, &DolphinMainWindow::urlChanged
, infoPanel
, &InformationPanel::setUrl
);
2199 connect(this, &DolphinMainWindow::selectionChanged
, infoPanel
, &InformationPanel::setSelection
);
2200 connect(this, &DolphinMainWindow::requestItemInfo
, infoPanel
, &InformationPanel::requestDelayedItemInfo
);
2201 connect(this, &DolphinMainWindow::fileItemsChanged
, infoPanel
, &InformationPanel::slotFilesItemChanged
);
2202 connect(this, &DolphinMainWindow::settingsChanged
, infoPanel
, &InformationPanel::readSettings
);
2205 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
2206 const QString panelWhatsThis
= xi18nc("@info:whatsthis",
2208 "hide panels like this go to <interface>Menu|Panels</interface> "
2209 "or <interface>View|Panels</interface>.</para>");
2212 ->action(QStringLiteral("show_information_panel"))
2213 ->setWhatsThis(xi18nc("@info:whatsthis",
2214 "<para> This toggles the "
2215 "<emphasis>information</emphasis> panel at the right side of the "
2216 "window.</para><para>The panel provides in-depth information "
2217 "about the items your mouse is hovering over or about the selected "
2218 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
2219 "For single items a preview of their contents is provided.</para>"));
2221 infoDock
->setWhatsThis(xi18nc("@info:whatsthis",
2223 "provides in-depth information about the items your mouse is "
2224 "hovering over or about the selected items. Otherwise it informs "
2225 "you about the currently viewed folder.<nl/>For single items a "
2226 "preview of their contents is provided.</para><para>You can configure "
2227 "which and how details are given here by right-clicking.</para>")
2231 DolphinDockWidget
*foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
2232 foldersDock
->setLocked(lock
);
2233 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
2234 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
2235 FoldersPanel
*foldersPanel
= new FoldersPanel(foldersDock
);
2236 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
2237 foldersDock
->setWidget(foldersPanel
);
2239 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersDock
, QStringLiteral("show_folders_panel"));
2241 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
2242 connect(this, &DolphinMainWindow::urlChanged
, foldersPanel
, &FoldersPanel::setUrl
);
2243 connect(foldersPanel
, &FoldersPanel::folderActivated
, this, &DolphinMainWindow::changeUrl
);
2244 connect(foldersPanel
, &FoldersPanel::folderInNewTab
, this, &DolphinMainWindow::openNewTab
);
2245 connect(foldersPanel
, &FoldersPanel::folderInNewActiveTab
, this, &DolphinMainWindow::openNewTabAndActivate
);
2246 connect(foldersPanel
, &FoldersPanel::errorMessage
, this, &DolphinMainWindow::showErrorMessage
);
2249 ->action(QStringLiteral("show_folders_panel"))
2250 ->setWhatsThis(xi18nc("@info:whatsthis",
2252 "<emphasis>folders</emphasis> panel at the left side of the window."
2253 "<nl/><nl/>It shows the folders of the <emphasis>file system"
2254 "</emphasis> in a <emphasis>tree view</emphasis>."));
2255 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis",
2257 "shows the folders of the <emphasis>file system</emphasis> in a "
2258 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
2259 "there. Click the arrow to the left of a folder to see its subfolders. "
2260 "This allows quick switching between any folders.</para>")
2265 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
2266 DolphinDockWidget
*terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
2267 terminalDock
->setLocked(lock
);
2268 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
2269 terminalDock
->setContentsMargins(0, 0, 0, 0);
2270 m_terminalPanel
= new TerminalPanel(terminalDock
);
2271 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
2272 terminalDock
->setWidget(m_terminalPanel
);
2274 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
2275 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
2276 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
, m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
2277 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
, this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
2279 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalDock
, QStringLiteral("show_terminal_panel"));
2281 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
2282 connect(this, &DolphinMainWindow::urlChanged
, m_terminalPanel
, &TerminalPanel::setUrl
);
2284 if (GeneralSettings::version() < 200) {
2285 terminalDock
->hide();
2289 ->action(QStringLiteral("show_terminal_panel"))
2290 ->setWhatsThis(xi18nc("@info:whatsthis",
2291 "<para>This toggles the "
2292 "<emphasis>terminal</emphasis> panel at the bottom of the window."
2293 "<nl/>The location in the terminal will always match the folder "
2294 "view so you can navigate using either.</para><para>The terminal "
2295 "panel is not needed for basic computer usage but can be useful "
2296 "for advanced tasks. To learn more about terminals use the help features "
2297 "in a standalone terminal application like Konsole.</para>"));
2298 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis",
2300 "the <emphasis>terminal</emphasis> panel. It behaves like a "
2301 "normal terminal but will match the location of the folder view "
2302 "so you can navigate using either.</para><para>The terminal panel "
2303 "is not needed for basic computer usage but can be useful for "
2304 "advanced tasks. To learn more about terminals use the help features in a "
2305 "standalone terminal application like Konsole.</para>")
2310 if (GeneralSettings::version() < 200) {
2312 foldersDock
->hide();
2316 DolphinDockWidget
*placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
2317 placesDock
->setLocked(lock
);
2318 placesDock
->setObjectName(QStringLiteral("placesDock"));
2319 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
2321 m_placesPanel
= new PlacesPanel(placesDock
);
2322 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
2323 placesDock
->setWidget(m_placesPanel
);
2325 createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9
, placesDock
, QStringLiteral("show_places_panel"));
2327 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
2328 connect(m_placesPanel
, &PlacesPanel::placeActivated
, this, &DolphinMainWindow::slotPlaceActivated
);
2329 connect(m_placesPanel
, &PlacesPanel::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2330 connect(m_placesPanel
, &PlacesPanel::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2331 connect(m_placesPanel
, &PlacesPanel::newWindowRequested
, this, [this](const QUrl
&url
) {
2332 Dolphin::openNewWindow({url
}, this);
2334 connect(m_placesPanel
, &PlacesPanel::openInSplitViewRequested
, this, &DolphinMainWindow::openInSplitView
);
2335 connect(m_placesPanel
, &PlacesPanel::errorMessage
, this, &DolphinMainWindow::showErrorMessage
);
2336 connect(this, &DolphinMainWindow::urlChanged
, m_placesPanel
, &PlacesPanel::setUrl
);
2337 connect(placesDock
, &DolphinDockWidget::visibilityChanged
, &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged
);
2338 connect(this, &DolphinMainWindow::settingsChanged
, m_placesPanel
, &PlacesPanel::readSettings
);
2339 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
, this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
2340 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
, this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
2341 DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
2343 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
2344 actionShowAllPlaces
->setCheckable(true);
2345 actionShowAllPlaces
->setDisabled(true);
2346 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis",
2348 "all places in the places panel that have been hidden. They will "
2349 "appear semi-transparent and allow you to uncheck their \"Hide\" property."));
2351 connect(actionShowAllPlaces
, &QAction::triggered
, this, [this](bool checked
) {
2352 m_placesPanel
->setShowAll(checked
);
2354 connect(m_placesPanel
, &PlacesPanel::allPlacesShownChanged
, actionShowAllPlaces
, &QAction::setChecked
);
2357 ->action(QStringLiteral("show_places_panel"))
2358 ->setWhatsThis(xi18nc("@info:whatsthis",
2359 "<para>This toggles the "
2360 "<emphasis>places</emphasis> panel at the left side of the window."
2361 "</para><para>It allows you to go to locations you have "
2362 "bookmarked and to access disk or media attached to the computer "
2363 "or to the network. It also contains sections to find recently "
2364 "saved files or files of a certain type.</para>"));
2365 placesDock
->setWhatsThis(xi18nc("@info:whatsthis",
2366 "<para>This is the "
2367 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
2368 "you have bookmarked and to access disk or media attached to the "
2369 "computer or to the network. It also contains sections to find "
2370 "recently saved files or files of a certain type.</para><para>"
2371 "Click on an entry to go there. Click with the right mouse button "
2372 "instead to open any entry in a new tab or new window.</para>"
2373 "<para>New entries can be added by dragging folders onto this panel. "
2374 "Right-click any section or entry to hide it. Right-click an empty "
2375 "space on this panel and select <interface>Show Hidden Places"
2376 "</interface> to display it again.</para>")
2379 // Add actions into the "Panels" menu
2380 KActionMenu
*panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
2381 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
2382 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
2383 panelsMenu
->setPopupMode(QToolButton::InstantPopup
);
2384 const KActionCollection
*ac
= actionCollection();
2385 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
2387 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
2389 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
2390 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
2391 panelsMenu
->addSeparator();
2392 panelsMenu
->addAction(actionShowAllPlaces
);
2393 panelsMenu
->addAction(lockLayoutAction
);
2395 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
] {
2396 actionShowAllPlaces
->setEnabled(DolphinPlacesModelSingleton::instance().placesModel()->hiddenCount());
2400 void DolphinMainWindow::updateFileAndEditActions()
2402 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
2403 const KActionCollection
*col
= actionCollection();
2404 KFileItemListProperties
capabilitiesSource(list
);
2406 QAction
*renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
2407 QAction
*moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
2408 QAction
*deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
2409 QAction
*cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
2410 QAction
*duplicateAction
= col
->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler
2411 QAction
*addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
2412 QAction
*copyToOtherViewAction
= col
->action(QStringLiteral("copy_to_inactive_split_view"));
2413 QAction
*moveToOtherViewAction
= col
->action(QStringLiteral("move_to_inactive_split_view"));
2414 QAction
*copyLocation
= col
->action(QString("copy_location"));
2416 if (list
.isEmpty()) {
2417 stateChanged(QStringLiteral("has_no_selection"));
2419 // All actions that need a selection to function can be enabled because they should trigger selection mode.
2420 renameAction
->setEnabled(true);
2421 moveToTrashAction
->setEnabled(true);
2422 deleteAction
->setEnabled(true);
2423 cutAction
->setEnabled(true);
2424 duplicateAction
->setEnabled(true);
2425 addToPlacesAction
->setEnabled(true);
2426 copyLocation
->setEnabled(true);
2427 // Them triggering selection mode and not directly acting on selected items is signified by adding "…" to their text.
2428 m_actionTextHelper
->textsWhenNothingIsSelectedEnabled(true);
2431 m_actionTextHelper
->textsWhenNothingIsSelectedEnabled(false);
2432 stateChanged(QStringLiteral("has_selection"));
2434 QAction
*deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
2435 QAction
*showTarget
= col
->action(QStringLiteral("show_target"));
2437 if (list
.length() == 1 && list
.first().isDir()) {
2438 addToPlacesAction
->setEnabled(true);
2440 addToPlacesAction
->setEnabled(false);
2443 const bool enableMoveToTrash
= capabilitiesSource
.isLocal() && capabilitiesSource
.supportsMoving();
2445 renameAction
->setEnabled(capabilitiesSource
.supportsMoving());
2446 m_disabledActionNotifier
->setDisabledReason(renameAction
, i18nc("@info", "Cannot rename: You do not have permission to rename items in this folder."));
2447 deleteAction
->setEnabled(capabilitiesSource
.supportsDeleting());
2448 m_disabledActionNotifier
->setDisabledReason(deleteAction
,
2449 i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
2450 cutAction
->setEnabled(capabilitiesSource
.supportsMoving());
2451 m_disabledActionNotifier
->setDisabledReason(cutAction
, i18nc("@info", "Cannot cut: You do not have permission to move items from this folder."));
2452 copyLocation
->setEnabled(list
.length() == 1);
2453 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
2454 duplicateAction
->setEnabled(capabilitiesSource
.supportsWriting());
2455 m_disabledActionNotifier
->setDisabledReason(duplicateAction
,
2456 i18nc("@info", "Cannot duplicate here: You do not have permission to create items in this folder."));
2458 if (enableMoveToTrash
) {
2459 moveToTrashAction
->setEnabled(true);
2460 deleteWithTrashShortcut
->setEnabled(false);
2461 m_disabledActionNotifier
->clearDisabledReason(deleteWithTrashShortcut
);
2463 moveToTrashAction
->setEnabled(false);
2464 deleteWithTrashShortcut
->setEnabled(capabilitiesSource
.supportsDeleting());
2465 m_disabledActionNotifier
->setDisabledReason(deleteWithTrashShortcut
,
2466 i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
2470 if (!m_tabWidget
->currentTabPage()->splitViewEnabled()) {
2471 // No need to set the disabled reason here, as it's obvious to the user that the reason is the split view being disabled.
2472 copyToOtherViewAction
->setEnabled(false);
2473 m_disabledActionNotifier
->clearDisabledReason(copyToOtherViewAction
);
2474 moveToOtherViewAction
->setEnabled(false);
2475 m_disabledActionNotifier
->clearDisabledReason(moveToOtherViewAction
);
2476 } else if (list
.isEmpty()) {
2477 copyToOtherViewAction
->setEnabled(false);
2478 m_disabledActionNotifier
->setDisabledReason(copyToOtherViewAction
, i18nc("@info", "Cannot copy to other view: No files selected."));
2479 moveToOtherViewAction
->setEnabled(false);
2480 m_disabledActionNotifier
->setDisabledReason(moveToOtherViewAction
, i18nc("@info", "Cannot move to other view: No files selected."));
2482 DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
2483 KFileItem capabilitiesDestination
;
2485 if (tabPage
->primaryViewActive()) {
2486 capabilitiesDestination
= tabPage
->secondaryViewContainer()->rootItem();
2488 capabilitiesDestination
= tabPage
->primaryViewContainer()->rootItem();
2491 const auto destUrl
= capabilitiesDestination
.url();
2492 const bool allNotTargetOrigin
= std::all_of(list
.cbegin(), list
.cend(), [destUrl
](const KFileItem
&item
) {
2493 return item
.url().adjusted(QUrl::RemoveFilename
| QUrl::StripTrailingSlash
) != destUrl
;
2496 if (!allNotTargetOrigin
) {
2497 copyToOtherViewAction
->setEnabled(false);
2498 m_disabledActionNotifier
->setDisabledReason(copyToOtherViewAction
,
2499 i18nc("@info", "Cannot copy to other view: The other view already contains these items."));
2500 moveToOtherViewAction
->setEnabled(false);
2501 m_disabledActionNotifier
->setDisabledReason(moveToOtherViewAction
,
2502 i18nc("@info", "Cannot move to other view: The other view already contains these items."));
2503 } else if (!capabilitiesDestination
.isWritable()) {
2504 copyToOtherViewAction
->setEnabled(false);
2505 m_disabledActionNotifier
->setDisabledReason(
2506 copyToOtherViewAction
,
2507 i18nc("@info", "Cannot copy to other view: You do not have permission to write into the destination folder."));
2508 moveToOtherViewAction
->setEnabled(false);
2509 m_disabledActionNotifier
->setDisabledReason(
2510 moveToOtherViewAction
,
2511 i18nc("@info", "Cannot move to other view: You do not have permission to write into the destination folder."));
2513 copyToOtherViewAction
->setEnabled(true);
2514 moveToOtherViewAction
->setEnabled(capabilitiesSource
.supportsMoving());
2515 m_disabledActionNotifier
->setDisabledReason(
2516 moveToOtherViewAction
,
2517 i18nc("@info", "Cannot move to other view: You do not have permission to move items from this folder."));
2522 void DolphinMainWindow::updateViewActions()
2524 m_actionHandler
->updateViewActions();
2526 QAction
*toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
2527 toggleFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
2529 updateSplitActions();
2532 void DolphinMainWindow::updateGoActions()
2534 QAction
*goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
2535 const QUrl currentUrl
= m_activeViewContainer
->url();
2536 // I think this is one of the best places to firstly be confronted
2537 // with a file system and its hierarchy. Talking about the root
2538 // directory might seem too much here but it is the question that
2539 // naturally arises in this context.
2540 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis",
2542 "the folder that contains the currently viewed one.</para>"
2543 "<para>All files and folders are organized in a hierarchical "
2544 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
2545 "a directory that contains all data connected to this computer"
2546 "—the <emphasis>root directory</emphasis>.</para>"));
2547 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
2550 void DolphinMainWindow::refreshViews()
2552 m_tabWidget
->refreshViews();
2554 if (GeneralSettings::modifiedStartupSettings()) {
2555 updateWindowTitle();
2558 updateSplitActions();
2560 Q_EMIT
settingsChanged();
2563 void DolphinMainWindow::clearStatusBar()
2565 m_activeViewContainer
->statusBar()->resetToDefaultText();
2568 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
*container
)
2570 connect(container
, &DolphinViewContainer::showFilterBarChanged
, this, &DolphinMainWindow::updateFilterBarAction
);
2571 connect(container
, &DolphinViewContainer::writeStateChanged
, this, &DolphinMainWindow::slotWriteStateChanged
);
2572 slotWriteStateChanged(container
->view()->isFolderWritable());
2573 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
, this, &DolphinMainWindow::updateSearchAction
);
2574 connect(container
, &DolphinViewContainer::captionChanged
, this, &DolphinMainWindow::updateWindowTitle
);
2575 connect(container
, &DolphinViewContainer::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2576 connect(container
, &DolphinViewContainer::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2578 const QAction
*toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
2579 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
2581 // Make the toggled state of the selection mode actions visually follow the selection mode state of the view.
2582 auto toggleSelectionModeAction
= actionCollection()->action(QStringLiteral("toggle_selection_mode"));
2583 toggleSelectionModeAction
->setChecked(m_activeViewContainer
->isSelectionModeEnabled());
2584 connect(m_activeViewContainer
, &DolphinViewContainer::selectionModeChanged
, toggleSelectionModeAction
, &QAction::setChecked
);
2586 const DolphinView
*view
= container
->view();
2587 connect(view
, &DolphinView::selectionChanged
, this, &DolphinMainWindow::slotSelectionChanged
);
2588 connect(view
, &DolphinView::requestItemInfo
, this, &DolphinMainWindow::requestItemInfo
);
2589 connect(view
, &DolphinView::fileItemsChanged
, this, &DolphinMainWindow::fileItemsChanged
);
2590 connect(view
, &DolphinView::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2591 connect(view
, &DolphinView::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2592 connect(view
, &DolphinView::windowRequested
, this, &DolphinMainWindow::openNewWindow
);
2593 connect(view
, &DolphinView::requestContextMenu
, this, &DolphinMainWindow::openContextMenu
);
2594 connect(view
, &DolphinView::directoryLoadingStarted
, this, &DolphinMainWindow::enableStopAction
);
2595 connect(view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinMainWindow::disableStopAction
);
2596 connect(view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
2597 connect(view
, &DolphinView::goBackRequested
, this, &DolphinMainWindow::goBack
);
2598 connect(view
, &DolphinView::goForwardRequested
, this, &DolphinMainWindow::goForward
);
2599 connect(view
, &DolphinView::urlActivated
, this, &DolphinMainWindow::handleUrl
);
2600 connect(view
, &DolphinView::goUpRequested
, this, &DolphinMainWindow::goUp
);
2601 connect(view
, &DolphinView::doubleClickViewBackground
, this, &DolphinMainWindow::slotDoubleClickViewBackground
);
2603 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged
, this, &DolphinMainWindow::changeUrl
);
2604 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged
, this, &DolphinMainWindow::updateHistory
);
2606 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
2607 const KUrlNavigator
*navigator
=
2608 m_tabWidget
->currentTabPage()->primaryViewActive() ? navigators
->primaryUrlNavigator() : navigators
->secondaryUrlNavigator();
2610 QAction
*editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
2611 editableLocactionAction
->setChecked(navigator
->isUrlEditable());
2612 connect(navigator
, &KUrlNavigator::editableStateChanged
, this, &DolphinMainWindow::slotEditableStateChanged
);
2613 connect(navigator
, &KUrlNavigator::tabRequested
, this, &DolphinMainWindow::openNewTab
);
2614 connect(navigator
, &KUrlNavigator::activeTabRequested
, this, &DolphinMainWindow::openNewTabAndActivate
);
2615 connect(navigator
, &KUrlNavigator::newWindowRequested
, this, &DolphinMainWindow::openNewWindow
);
2618 void DolphinMainWindow::updateSplitActions()
2620 QAction
*popoutSplitAction
= actionCollection()->action(QStringLiteral("popout_split_view"));
2622 auto setActionPopupMode
= [this](KActionMenu
*action
, QToolButton::ToolButtonPopupMode popupMode
) {
2623 action
->setPopupMode(popupMode
);
2624 if (auto *buttonForAction
= qobject_cast
<QToolButton
*>(toolBar()->widgetForAction(action
))) {
2625 buttonForAction
->setPopupMode(popupMode
);
2629 const DolphinTabPage
*tabPage
= m_tabWidget
->currentTabPage();
2630 if (tabPage
->splitViewEnabled()) {
2631 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2632 m_splitViewAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2633 m_splitViewAction
->setToolTip(i18nc("@info", "Close left view"));
2634 m_splitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2635 popoutSplitAction
->setText(i18nc("@action:intoolbar Move left view to a new window", "Pop out Left View"));
2636 popoutSplitAction
->setToolTip(i18nc("@info", "Move left view to a new window"));
2638 m_splitViewAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2639 m_splitViewAction
->setToolTip(i18nc("@info", "Close right view"));
2640 m_splitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2641 popoutSplitAction
->setText(i18nc("@action:intoolbar Move right view to a new window", "Pop out Right View"));
2642 popoutSplitAction
->setToolTip(i18nc("@info", "Move right view to a new window"));
2644 popoutSplitAction
->setEnabled(true);
2645 if (!m_splitViewAction
->menu()) {
2646 setActionPopupMode(m_splitViewAction
, QToolButton::MenuButtonPopup
);
2647 m_splitViewAction
->setMenu(new QMenu
);
2648 m_splitViewAction
->addAction(popoutSplitAction
);
2651 m_splitViewAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2652 m_splitViewAction
->setToolTip(i18nc("@info", "Split view"));
2653 m_splitViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2654 popoutSplitAction
->setText(i18nc("@action:intoolbar Move view in focus to a new window", "Pop out"));
2655 popoutSplitAction
->setEnabled(false);
2656 if (m_splitViewAction
->menu()) {
2657 m_splitViewAction
->removeAction(popoutSplitAction
);
2658 m_splitViewAction
->menu()->deleteLater();
2659 m_splitViewAction
->setMenu(nullptr);
2660 setActionPopupMode(m_splitViewAction
, QToolButton::DelayedPopup
);
2664 // Update state from toolbar action
2665 m_splitViewMenuAction
->setText(m_splitViewAction
->text());
2666 m_splitViewMenuAction
->setToolTip(m_splitViewAction
->toolTip());
2667 m_splitViewMenuAction
->setIcon(m_splitViewAction
->icon());
2670 void DolphinMainWindow::updateAllowedToolbarAreas()
2672 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
2673 if (toolBar()->actions().contains(navigators
)) {
2674 toolBar()->setAllowedAreas(Qt::TopToolBarArea
| Qt::BottomToolBarArea
);
2675 if (toolBarArea(toolBar()) == Qt::LeftToolBarArea
|| toolBarArea(toolBar()) == Qt::RightToolBarArea
) {
2676 addToolBar(Qt::TopToolBarArea
, toolBar());
2679 toolBar()->setAllowedAreas(Qt::AllToolBarAreas
);
2683 bool DolphinMainWindow::isKompareInstalled() const
2685 static bool initialized
= false;
2686 static bool installed
= false;
2688 // TODO: maybe replace this approach later by using a menu
2689 // plugin like kdiff3plugin.cpp
2690 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2696 void DolphinMainWindow::createPanelAction(const QIcon
&icon
, const QKeySequence
&shortcut
, QDockWidget
*dockWidget
, const QString
&actionName
)
2698 auto dockAction
= dockWidget
->toggleViewAction();
2699 dockAction
->setIcon(icon
);
2700 dockAction
->setEnabled(true);
2702 QAction
*panelAction
= actionCollection()->addAction(actionName
, dockAction
);
2703 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2706 void DolphinMainWindow::setupWhatsThis()
2709 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2710 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2711 "configuration options. Left-click on any of the menus on this "
2712 "bar to see its contents.</para><para>The Menubar can be hidden "
2713 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2714 "most of its contents become available through a <interface>Menu"
2715 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2716 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2717 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2718 "frequently used actions.</para><para>It is highly customizable. "
2719 "All items you see in the <interface>Menu</interface> or "
2720 "in the <interface>Menubar</interface> can be placed on the "
2721 "Toolbar. Just right-click on it and select <interface>Configure "
2722 "Toolbars…</interface> or find this action within the <interface>"
2724 "</para><para>The location of the bar and the style of its "
2725 "buttons can also be changed in the right-click menu. Right-click "
2726 "a button if you want to show or hide its text.</para>"));
2727 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2728 "<para>Here you can see the <emphasis>folders</emphasis> and "
2729 "<emphasis>files</emphasis> that are at the location described in "
2730 "the <interface>Location Bar</interface> above. This area is the "
2731 "central part of this application where you navigate to the files "
2732 "you want to use.</para><para>For an elaborate and general "
2733 "introduction to this application <link "
2734 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2735 "click here</link>. This will open an introductory article from "
2736 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2737 "explanations of all the features of this <emphasis>view</emphasis> "
2738 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2739 "instead. This will open a page from the <emphasis>Handbook"
2740 "</emphasis> that covers the basics.</para>"));
2743 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2744 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2745 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2746 "There you can set up key combinations to trigger an action when "
2747 "they are pressed simultaneously. All commands in this application can "
2748 "be triggered this way.</para>"));
2749 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2750 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2751 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2752 "<para>All items you see in the <interface>Menu</interface> can also be placed on the Toolbar.</para>"));
2753 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2754 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2755 "change a multitude of settings for this application. For an explanation "
2756 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2757 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2761 auto setStandardActionWhatsThis
= [this](KStandardAction::StandardAction actionId
,
2762 const QString
&whatsThis
) {
2763 // Check for the existence of an action since it can be restricted through the Kiosk system
2764 if (auto *action
= actionCollection()->action(KStandardAction::name(actionId
))) {
2765 action
->setWhatsThis(whatsThis
);
2769 // i18n: If the external link isn't available in your language it might make
2770 // sense to state the external link's language in brackets to not
2771 // frustrate the user. If there are multiple languages that the user might
2772 // know with a reasonable chance you might want to have 2 external links.
2773 // The same might be true for any external link you translate.
2774 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>"));
2775 // (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 )
2777 setStandardActionWhatsThis(KStandardAction::WhatsThis
,
2778 xi18nc("@info:whatsthis whatsthis button",
2779 "<para>This is the button that invokes the help feature you are "
2780 "using right now! Click it, then click any component of this "
2781 "application to ask \"What's this?\" about it. The mouse cursor "
2782 "will change appearance if no help is available for a spot.</para>"
2783 "<para>There are two other ways to get help: "
2784 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2785 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2786 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2787 "missing in most other windows so don't get too used to this.</para>"));
2789 setStandardActionWhatsThis(KStandardAction::ReportBug
,
2790 xi18nc("@info:whatsthis","<para>This opens a "
2791 "window that will guide you through reporting errors or flaws "
2792 "in this application or in other KDE software.</para>"
2793 "<para>High-quality bug reports are much appreciated. To learn "
2794 "how to make your bug report as effective as possible "
2795 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2796 "click here</link>.</para>"));
2798 setStandardActionWhatsThis(KStandardAction::Donate
,
2799 xi18nc("@info:whatsthis", "<para>This opens a "
2800 "<emphasis>web page</emphasis> where you can donate to "
2801 "support the continued work on this application and many "
2802 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2803 "<para>Donating is the easiest and fastest way to efficiently "
2804 "support KDE and its projects. KDE projects are available for "
2805 "free therefore your donation is needed to cover things that "
2806 "require money like servers, contributor meetings, etc.</para>"
2807 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2808 "organization behind the KDE community.</para>"));
2810 setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage
,
2811 xi18nc("@info:whatsthis",
2812 "With this you can change the language this application uses."
2813 "<nl/>You can even set secondary languages which will be used "
2814 "if texts are not available in your preferred language."));
2816 setStandardActionWhatsThis(KStandardAction::AboutApp
,
2817 xi18nc("@info:whatsthis","This opens a "
2818 "window that informs you about the version, license, "
2819 "used libraries and maintainers of this application."));
2821 setStandardActionWhatsThis(KStandardAction::AboutKDE
,
2822 xi18nc("@info:whatsthis","This opens a "
2823 "window with information about <emphasis>KDE</emphasis>. "
2824 "The KDE community are the people behind this free software."
2825 "<nl/>If you like using this application but don't know "
2826 "about KDE or want to see a cute dragon have a look!"));
2830 bool DolphinMainWindow::addHamburgerMenuToToolbar()
2832 QDomDocument domDocument
= KXMLGUIClient::domDocument();
2833 if (domDocument
.isNull()) {
2836 QDomNode toolbar
= domDocument
.elementsByTagName(QStringLiteral("ToolBar")).at(0);
2837 if (toolbar
.isNull()) {
2841 QDomElement hamburgerMenuElement
= domDocument
.createElement(QStringLiteral("Action"));
2842 hamburgerMenuElement
.setAttribute(QStringLiteral("name"), QStringLiteral("hamburger_menu"));
2843 toolbar
.appendChild(hamburgerMenuElement
);
2845 KXMLGUIFactory::saveConfigFile(domDocument
, xmlFile());
2849 // Make sure to also remove the <KXMLGUIFactory> and <QDomDocument> include
2850 // whenever this method is removed (maybe in the year ~2026).
2853 // Set a sane initial window size
2854 QSize
DolphinMainWindow::sizeHint() const
2856 return KXmlGuiWindow::sizeHint().expandedTo(QSize(760, 550));
2859 void DolphinMainWindow::saveNewToolbarConfig()
2861 KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
2862 // because the rest of this method decides things
2863 // based on the new config.
2864 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>(actionCollection()->action(QStringLiteral("url_navigators")));
2865 if (!toolBar()->actions().contains(navigators
)) {
2866 m_tabWidget
->currentTabPage()->insertNavigatorsWidget(navigators
);
2868 updateAllowedToolbarAreas();
2869 (static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu
))))->hideActionsOf(toolBar());
2872 void DolphinMainWindow::focusTerminalPanel()
2874 if (m_terminalPanel
->isVisible()) {
2875 if (m_terminalPanel
->terminalHasFocus()) {
2876 m_activeViewContainer
->view()->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2877 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2879 m_terminalPanel
->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2880 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2883 actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger();
2884 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2888 DolphinMainWindow::UndoUiInterface::UndoUiInterface()
2889 : KIO::FileUndoManager::UiInterface()
2893 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2897 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
*job
)
2899 DolphinMainWindow
*mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2901 DolphinViewContainer
*container
= mainWin
->activeViewContainer();
2902 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2904 KIO::FileUndoManager::UiInterface::jobError(job
);
2908 bool DolphinMainWindow::isUrlOpen(const QString
&url
)
2910 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput(url
));
2913 bool DolphinMainWindow::isItemVisibleInAnyView(const QString
&urlOfItem
)
2915 return m_tabWidget
->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem
));
2918 void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button
)
2920 Q_UNUSED(button
) // might be of use later
2922 GeneralSettings
*settings
= GeneralSettings::self();
2923 QString clickAction
= settings
->doubleClickViewAction();
2925 DolphinView
*view
= activeViewContainer()->view();
2926 if (view
== nullptr || clickAction
== "none") {
2930 if (clickAction
== customCommand
) {
2931 // run custom command set by the user
2932 QString path
= view
->url().toLocalFile();
2933 QString clickCustomAction
= settings
->doubleClickViewCustomAction();
2934 clickCustomAction
.replace("{path}", path
.prepend('"').append('"'));
2936 m_job
= new KIO::CommandLauncherJob(clickCustomAction
);
2937 m_job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
2941 // get the action set by the user and trigger it
2942 const KActionCollection
*actions
= actionCollection();
2943 QAction
*action
= actions
->action(clickAction
);
2944 if (action
== nullptr) {
2945 qCWarning(DolphinDebug
) << QStringLiteral("Double-click view: action `%1` was not found").arg(clickAction
);
2952 #include "moc_dolphinmainwindow.cpp"