X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1d4355f619ca8098d12f330741017e417a756083..3ccd49e586d7dbd2c7e1e87296f4b6c293b176fc:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 47a74742b..8fa891b32 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -8,6 +8,7 @@ #include "dolphinmainwindow.h" +#include "admin/workerintegration.h" #include "dolphin_generalsettings.h" #include "dolphinbookmarkhandler.h" #include "dolphincontextmenu.h" @@ -37,8 +38,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -80,6 +83,7 @@ #include #include #include +#include #include @@ -96,7 +100,7 @@ namespace const int CurrentDolphinVersion = 202; // The maximum number of entries in the back/forward popup menu const int MaxNumberOfNavigationentries = 12; -// The maximum number of "Activate Tab" shortcuts +// The maximum number of "Go to Tab" shortcuts const int MaxActivateTabShortcuts = 9; } @@ -109,6 +113,7 @@ DolphinMainWindow::DolphinMainWindow() , m_remoteEncoding(nullptr) , m_settingsDialog() , m_bookmarkHandler(nullptr) + , m_disabledActionNotifier(nullptr) , m_lastHandleUrlOpenJob(nullptr) , m_terminalPanel(nullptr) , m_placesPanel(nullptr) @@ -133,6 +138,10 @@ DolphinMainWindow::DolphinMainWindow() setStateConfigGroup("State"); +#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) + new KColorSchemeManager(this); // Sets a sensible color scheme which fixes unreadable icons and text on Windows. +#endif + connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, this, &DolphinMainWindow::showErrorMessage); KIO::FileUndoManager *undoManager = KIO::FileUndoManager::self(); @@ -173,6 +182,11 @@ DolphinMainWindow::DolphinMainWindow() m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl); + m_disabledActionNotifier = new DisabledActionNotifier(this); + connect(m_disabledActionNotifier, &DisabledActionNotifier::disabledActionTriggered, this, [this](const QAction *, QString reason) { + m_activeViewContainer->showMessage(reason, DolphinViewContainer::Warning); + }); + setupDockWidgets(); setupGUI(Save | Create | ToolBar); @@ -770,8 +784,14 @@ void DolphinMainWindow::updateNewMenu() void DolphinMainWindow::createDirectory() { - m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); - m_newFileMenu->createDirectory(); + // When creating directory, namejob is being run. In network folders, + // this job can take long time, so instead of starting multiple namejobs, + // just check if we are already running one. This prevents opening multiple + // dialogs. BUG:481401 + if (!m_newFileMenu->isCreateDirectoryRunning()) { + m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); + m_newFileMenu->createDirectory(); + } } void DolphinMainWindow::quit() @@ -848,6 +868,10 @@ void DolphinMainWindow::updatePasteAction() QAction *pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); QPair pasteInfo = m_activeViewContainer->view()->pasteInfo(); pasteAction->setEnabled(pasteInfo.first); + m_disabledActionNotifier->setDisabledReason(pasteAction, + m_activeViewContainer->rootItem().isWritable() + ? i18nc("@info", "Cannot paste: The clipboard is empty.") + : i18nc("@info", "Cannot paste: You do not have permission to write into this folder.")); pasteAction->setText(pasteInfo.second); } @@ -1378,6 +1402,11 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) // trash:/ is writable but we don't want to create new items in it. // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash")); + // 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. + QTimer::singleShot(0, this, [this]() { + m_disabledActionNotifier->setDisabledReason(actionCollection()->action(QStringLiteral("create_dir")), + i18nc("@info", "Cannot create new folder: You do not have permission to create items in this folder.")); + }); } void DolphinMainWindow::openContextMenu(const QPoint &pos, const KFileItem &item, const KFileItemList &selectedItems, const QUrl &url) @@ -1640,7 +1669,7 @@ void DolphinMainWindow::setupActions() newWindow->setToolTip(i18nc("@info", "Open a new Dolphin window")); newWindow->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " - "window just like this one with the current location and view." + "window just like this one with the current location." "You can drag and drop items between windows.")); newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new"))); @@ -1649,8 +1678,8 @@ void DolphinMainWindow::setupActions() newTab->setText(i18nc("@action:inmenu File", "New Tab")); newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " - "Tab with the current location and view." - "A tab is an additional view within this window. " + "Tab with the current location." + "Tabs allow you to quickly switch between multiple locations and views within this window. " "You can drag and drop items between tabs.")); actionCollection()->setDefaultShortcut(newTab, Qt::CTRL | Qt::Key_T); connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); @@ -1665,10 +1694,11 @@ void DolphinMainWindow::setupActions() QAction *closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); + closeTab->setToolTip(i18nc("@info", "Close Tab")); closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " - "currently viewed tab. If no more tabs are left this window " - "will close instead.")); + "currently viewed tab. If no more tabs are left, this closes " + "the whole window instead.")); QAction *quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); @@ -1719,9 +1749,10 @@ void DolphinMainWindow::setupActions() m_actionTextHelper->registerTextWhenNothingIsSelected(copyToOtherViewAction, i18nc("@action:inmenu", "Copy to Other View…")); copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from " - "the active view to the inactive split view.")); + "the view in focus to the other view. " + "(Only available while in Split View mode.)")); copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); - copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to Inactive Split View")); + copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to Other View")); actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT | Qt::Key_F5); connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToInactiveSplitView); @@ -1730,9 +1761,10 @@ void DolphinMainWindow::setupActions() m_actionTextHelper->registerTextWhenNothingIsSelected(moveToOtherViewAction, i18nc("@action:inmenu", "Move to Other View…")); moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from " - "the active view to the inactive split view.")); + "the view in focus to the other view. " + "(Only available while in Split View mode.)")); moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); - moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to Inactive Split View")); + moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to Other View")); actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT | Qt::Key_F6); connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToInactiveSplitView); @@ -1742,7 +1774,7 @@ void DolphinMainWindow::setupActions() showFilterBar->setWhatsThis(xi18nc("@info:whatsthis", "This opens the " "Filter Bar at the bottom of the window. " - "There you can enter a text to filter the files and folders currently displayed. " + "There you can enter text to filter the files and folders currently displayed. " "Only those that contain the text in their name will be kept in view.")); showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter"))); actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL | Qt::Key_I, Qt::Key_Slash}); @@ -1765,10 +1797,10 @@ void DolphinMainWindow::setupActions() searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders")); searchAction->setWhatsThis(xi18nc("@info:whatsthis find", "This helps you " - "find files and folders by opening a find bar. " + "find files and folders by opening a search bar. " "There you can enter search terms and specify settings to find the " - "objects you are looking for.Use this help again on " - "the find bar so we can have a look at it while the settings are " + "items you are looking for.Use this help again on " + "the search bar so we can have a look at it while the settings are " "explained.")); // toggle_search acts as a copy of the main searchAction to be used mainly @@ -1820,7 +1852,7 @@ void DolphinMainWindow::setupActions() invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection")); invertSelection->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all " - "objects that you have currently not selected instead.")); + "items that you have currently not selected instead.")); invertSelection->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert"))); actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A); connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection); @@ -1833,14 +1865,17 @@ void DolphinMainWindow::setupActions() // setup 'View' menu // (note that most of it is set up in DolphinViewActionHandler) + Admin::WorkerIntegration::createActAsAdminAction(actionCollection(), this); + m_splitViewAction = actionCollection()->add(QStringLiteral("split_view")); m_splitViewMenuAction = actionCollection()->addAction(QStringLiteral("split_view_menu")); - m_splitViewAction->setWhatsThis(xi18nc("@info:whatsthis find", - "This splits " - "the folder view below into two autonomous views.This " - "way you can see two locations at once and move items between them " - "quickly.Click this again afterwards to recombine the views.")); + m_splitViewAction->setWhatsThis(xi18nc("@info:whatsthis split", + "This presents " + "a second view side-by-side with the current view, so you can see " + "the contents of two folders at once and easily move items between " + "them.The view that is not \"in focus\" will be dimmed. " + "Click this button again to close one of the views.")); m_splitViewMenuAction->setWhatsThis(m_splitViewAction->whatsThis()); // only set it for the menu version @@ -1851,8 +1886,8 @@ void DolphinMainWindow::setupActions() QAction *popoutSplit = actionCollection()->addAction(QStringLiteral("popout_split_view")); popoutSplit->setWhatsThis(xi18nc("@info:whatsthis", - "If the folder view has been split, this will pop the active folder " - "view out into a new window.")); + "If the view has been split, this will pop the view in focus " + "out into a new window.")); popoutSplit->setIcon(QIcon::fromTheme(QStringLiteral("window-new"))); actionCollection()->setDefaultShortcut(popoutSplit, Qt::SHIFT | Qt::Key_F3); connect(popoutSplit, &QAction::triggered, this, &DolphinMainWindow::popoutSplitView); @@ -1940,10 +1975,10 @@ void DolphinMainWindow::setupActions() undoAction->setWhatsThis(xi18nc("@info:whatsthis", "This undoes " "the last change you made to files or folders." - "Such changes include creating, renaming " + "Such changes include creating, renaming " "and moving them to a different location " - "or to the Trash. Changes that can't " - "be undone will ask for your confirmation.")); + "or to the Trash. Any changes that cannot be undone " + "will ask for your confirmation beforehand.")); undoAction->setEnabled(false); // undo should be disabled by default { @@ -1969,8 +2004,8 @@ void DolphinMainWindow::setupActions() homeAction->setWhatsThis(xi18nc("@info:whatsthis", "Go to your " "Home folder.Every user account " - "has their own Home that contains their data " - "including folders that contain personal application data.")); + "has their own Home that contains their personal files, " + "as well as hidden folders for their applications' data and configuration files.")); // setup 'Tools' menu QAction *compareFiles = actionCollection()->addAction(QStringLiteral("compare_files")); @@ -1993,7 +2028,7 @@ void DolphinMainWindow::setupActions() openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); openTerminal->setWhatsThis(xi18nc("@info:whatsthis", "This opens a terminal application for the viewed location." - "To learn more about terminals use the help in the terminal application.")); + "To learn more about terminals use the help features in the terminal application.")); openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4); connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal); @@ -2003,7 +2038,7 @@ void DolphinMainWindow::setupActions() openTerminalHere->setText(i18nc("@action:inmenu Tools", "Open Terminal Here")); openTerminalHere->setWhatsThis(xi18nc("@info:whatsthis", "This opens terminal applications for the selected items' locations." - "To learn more about terminals use the help in the terminal application.")); + "To learn more about terminals use the help features in the terminal application.")); openTerminalHere->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); actionCollection()->setDefaultShortcut(openTerminalHere, Qt::SHIFT | Qt::ALT | Qt::Key_F4); connect(openTerminalHere, &QAction::triggered, this, &DolphinMainWindow::openTerminalHere); @@ -2029,10 +2064,10 @@ void DolphinMainWindow::setupActions() KToggleAction *showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection()); showMenuBar->setWhatsThis(xi18nc("@info:whatsthis", "This switches between having a Menubar " - "and having a %1 button. Both " + "and having an %1 button. Both " "contain mostly the same actions and configuration options." - "The Menubar takes up more space but allows for fast and organised access to all " - "actions an application has to offer.The %1 button " + "The Menubar takes up more space but allows for fast and organized access to all " + "actions an application has to offer.The %1 button " "is simpler and small which makes triggering advanced actions more time consuming.", hamburgerMenuAction->text().replace('&', ""))); connect(showMenuBar, @@ -2061,7 +2096,7 @@ void DolphinMainWindow::setupActions() for (int i = 0; i < MaxActivateTabShortcuts; ++i) { QAction *activateTab = actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i)); - activateTab->setText(i18nc("@action:inmenu", "Activate Tab %1", i + 1)); + activateTab->setText(i18nc("@action:inmenu", "Go to Tab %1", i + 1)); activateTab->setEnabled(false); connect(activateTab, &QAction::triggered, this, [this, i]() { m_tabWidget->activateTab(i); @@ -2074,21 +2109,22 @@ void DolphinMainWindow::setupActions() } QAction *activateLastTab = actionCollection()->addAction(QStringLiteral("activate_last_tab")); - activateLastTab->setText(i18nc("@action:inmenu", "Activate Last Tab")); + activateLastTab->setIconText(i18nc("@action:inmenu", "Last Tab")); + activateLastTab->setText(i18nc("@action:inmenu", "Go to Last Tab")); activateLastTab->setEnabled(false); connect(activateLastTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateLastTab); actionCollection()->setDefaultShortcut(activateLastTab, Qt::ALT | Qt::Key_0); QAction *activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab")); activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab")); - activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab")); + activateNextTab->setText(i18nc("@action:inmenu", "Go to Next Tab")); activateNextTab->setEnabled(false); connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab); actionCollection()->setDefaultShortcuts(activateNextTab, nextTabKeys); QAction *activatePrevTab = actionCollection()->addAction(QStringLiteral("activate_prev_tab")); activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab")); - activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab")); + activatePrevTab->setText(i18nc("@action:inmenu", "Go to Previous Tab")); activatePrevTab->setEnabled(false); connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab); actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys); @@ -2155,7 +2191,7 @@ void DolphinMainWindow::setupDockWidgets() connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl); infoDock->setWidget(infoPanel); - createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoDock, QStringLiteral("show_information_panel")); + createPanelAction(QIcon::fromTheme(QStringLiteral("documentinfo")), Qt::Key_F11, infoDock, QStringLiteral("show_information_panel")); addDockWidget(Qt::RightDockWidgetArea, infoDock); connect(this, &DolphinMainWindow::urlChanged, infoPanel, &InformationPanel::setUrl); @@ -2256,7 +2292,7 @@ void DolphinMainWindow::setupDockWidgets() "The location in the terminal will always match the folder " "view so you can navigate using either.The terminal " "panel is not needed for basic computer usage but can be useful " - "for advanced tasks. To learn more about terminals use the help " + "for advanced tasks. To learn more about terminals use the help features " "in a standalone terminal application like Konsole.")); terminalDock->setWhatsThis(xi18nc("@info:whatsthis", "This is " @@ -2264,7 +2300,7 @@ void DolphinMainWindow::setupDockWidgets() "normal terminal but will match the location of the folder view " "so you can navigate using either.The terminal panel " "is not needed for basic computer usage but can be useful for " - "advanced tasks. To learn more about terminals use the help in a " + "advanced tasks. To learn more about terminals use the help features in a " "standalone terminal application like Konsole.") + panelWhatsThis); } @@ -2309,7 +2345,7 @@ void DolphinMainWindow::setupDockWidgets() actionShowAllPlaces->setWhatsThis(i18nc("@info:whatsthis", "This displays " "all places in the places panel that have been hidden. They will " - "appear semi-transparent unless you uncheck their hide property.")); + "appear semi-transparent and allow you to uncheck their \"Hide\" property.")); connect(actionShowAllPlaces, &QAction::triggered, this, [this](bool checked) { m_placesPanel->setShowAll(checked); @@ -2406,16 +2442,42 @@ void DolphinMainWindow::updateFileAndEditActions() const bool enableMoveToTrash = capabilitiesSource.isLocal() && capabilitiesSource.supportsMoving(); renameAction->setEnabled(capabilitiesSource.supportsMoving()); - moveToTrashAction->setEnabled(enableMoveToTrash); + m_disabledActionNotifier->setDisabledReason(renameAction, i18nc("@info", "Cannot rename: You do not have permission to rename items in this folder.")); deleteAction->setEnabled(capabilitiesSource.supportsDeleting()); - deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting() && !enableMoveToTrash); + m_disabledActionNotifier->setDisabledReason(deleteAction, + i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder.")); cutAction->setEnabled(capabilitiesSource.supportsMoving()); + m_disabledActionNotifier->setDisabledReason(cutAction, i18nc("@info", "Cannot cut: You do not have permission to move items from this folder.")); copyLocation->setEnabled(list.length() == 1); showTarget->setEnabled(list.length() == 1 && list.at(0).isLink()); duplicateAction->setEnabled(capabilitiesSource.supportsWriting()); + m_disabledActionNotifier->setDisabledReason(duplicateAction, + i18nc("@info", "Cannot duplicate here: You do not have permission to create items in this folder.")); + + if (enableMoveToTrash) { + moveToTrashAction->setEnabled(true); + deleteWithTrashShortcut->setEnabled(false); + m_disabledActionNotifier->clearDisabledReason(deleteWithTrashShortcut); + } else { + moveToTrashAction->setEnabled(false); + deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting()); + m_disabledActionNotifier->setDisabledReason(deleteWithTrashShortcut, + i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder.")); + } } - if (m_tabWidget->currentTabPage()->splitViewEnabled() && !list.isEmpty()) { + if (!m_tabWidget->currentTabPage()->splitViewEnabled()) { + // No need to set the disabled reason here, as it's obvious to the user that the reason is the split view being disabled. + copyToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->clearDisabledReason(copyToOtherViewAction); + moveToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->clearDisabledReason(moveToOtherViewAction); + } else if (list.isEmpty()) { + copyToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, i18nc("@info", "Cannot copy to other view: No files selected.")); + moveToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, i18nc("@info", "Cannot move to other view: No files selected.")); + } else { DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); KFileItem capabilitiesDestination; @@ -2430,12 +2492,29 @@ void DolphinMainWindow::updateFileAndEditActions() return item.url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash) != destUrl; }); - copyToOtherViewAction->setEnabled(capabilitiesDestination.isWritable() && allNotTargetOrigin); - moveToOtherViewAction->setEnabled((list.isEmpty() || capabilitiesSource.supportsMoving()) && capabilitiesDestination.isWritable() - && allNotTargetOrigin); - } else { - copyToOtherViewAction->setEnabled(false); - moveToOtherViewAction->setEnabled(false); + if (!allNotTargetOrigin) { + copyToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, + i18nc("@info", "Cannot copy to other view: The other view already contains these items.")); + moveToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, + i18nc("@info", "Cannot move to other view: The other view already contains these items.")); + } else if (!capabilitiesDestination.isWritable()) { + copyToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->setDisabledReason( + copyToOtherViewAction, + i18nc("@info", "Cannot copy to other view: You do not have permission to write into the destination folder.")); + moveToOtherViewAction->setEnabled(false); + m_disabledActionNotifier->setDisabledReason( + moveToOtherViewAction, + i18nc("@info", "Cannot move to other view: You do not have permission to write into the destination folder.")); + } else { + copyToOtherViewAction->setEnabled(true); + moveToOtherViewAction->setEnabled(capabilitiesSource.supportsMoving()); + m_disabledActionNotifier->setDisabledReason( + moveToOtherViewAction, + i18nc("@info", "Cannot move to other view: You do not have permission to move items from this folder.")); + } } } @@ -2518,6 +2597,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container) connect(view, &DolphinView::goForwardRequested, this, &DolphinMainWindow::goForward); connect(view, &DolphinView::urlActivated, this, &DolphinMainWindow::handleUrl); connect(view, &DolphinView::goUpRequested, this, &DolphinMainWindow::goUp); + connect(view, &DolphinView::doubleClickViewBackground, this, &DolphinMainWindow::slotDoubleClickViewBackground); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged, this, &DolphinMainWindow::changeUrl); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged, this, &DolphinMainWindow::updateHistory); @@ -2551,14 +2631,14 @@ void DolphinMainWindow::updateSplitActions() m_splitViewAction->setText(i18nc("@action:intoolbar Close left view", "Close")); m_splitViewAction->setToolTip(i18nc("@info", "Close left view")); m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close"))); - popoutSplitAction->setText(i18nc("@action:intoolbar Move left split view to a new window", "Pop out")); - popoutSplitAction->setToolTip(i18nc("@info", "Move left split view to a new window")); + popoutSplitAction->setText(i18nc("@action:intoolbar Move left view to a new window", "Pop out Left View")); + popoutSplitAction->setToolTip(i18nc("@info", "Move left view to a new window")); } else { m_splitViewAction->setText(i18nc("@action:intoolbar Close right view", "Close")); m_splitViewAction->setToolTip(i18nc("@info", "Close right view")); m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close"))); - popoutSplitAction->setText(i18nc("@action:intoolbar Move right split view to a new window", "Pop out")); - popoutSplitAction->setToolTip(i18nc("@info", "Move right split view to a new window")); + popoutSplitAction->setText(i18nc("@action:intoolbar Move right view to a new window", "Pop out Right View")); + popoutSplitAction->setToolTip(i18nc("@info", "Move right view to a new window")); } popoutSplitAction->setEnabled(true); if (!m_splitViewAction->menu()) { @@ -2570,7 +2650,7 @@ void DolphinMainWindow::updateSplitActions() m_splitViewAction->setText(i18nc("@action:intoolbar Split view", "Split")); m_splitViewAction->setToolTip(i18nc("@info", "Split view")); m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new"))); - popoutSplitAction->setText(i18nc("@action:intoolbar Move active split view to a new window", "Pop out")); + popoutSplitAction->setText(i18nc("@action:intoolbar Move view in focus to a new window", "Pop out")); popoutSplitAction->setEnabled(false); if (m_splitViewAction->menu()) { m_splitViewAction->removeAction(popoutSplitAction); @@ -2834,4 +2914,38 @@ bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem) return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem)); } +void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button) +{ + Q_UNUSED(button) // might be of use later + + GeneralSettings *settings = GeneralSettings::self(); + QString clickAction = settings->doubleClickViewAction(); + + DolphinView *view = activeViewContainer()->view(); + if (view == nullptr || clickAction == "none") { + return; + } + + if (clickAction == customCommand) { + // run custom command set by the user + QString path = view->url().toLocalFile(); + QString clickCustomAction = settings->doubleClickViewCustomAction(); + clickCustomAction.replace("{path}", path.prepend('"').append('"')); + + m_job = new KIO::CommandLauncherJob(clickCustomAction); + m_job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); + m_job->start(); + + } else { + // get the action set by the user and trigger it + const KActionCollection *actions = actionCollection(); + QAction *action = actions->action(clickAction); + if (action == nullptr) { + qCWarning(DolphinDebug) << QStringLiteral("Double-click view: action `%1` was not found").arg(clickAction); + return; + } + action->trigger(); + } +} + #include "moc_dolphinmainwindow.cpp"