X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/38c34eeca315c7be58e65d4d3fb72aaf7b866719..4cbeb81b2b8e2d37c93cda4d88787e08e0658291:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 5d31a55dc..a88e1a594 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -42,12 +42,7 @@ #include #include #include -#include -#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) #include -#else -#include -#endif #include #include #include @@ -59,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -70,7 +64,6 @@ #include #include -#include #include #include @@ -88,6 +81,12 @@ #include #include +#include + +#if HAVE_X11 +#include +#endif + namespace { // Used for GeneralSettings::version() to determine whether @@ -163,6 +162,9 @@ DolphinMainWindow::DolphinMainWindow() connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory); connect(m_actionHandler, &DolphinViewActionHandler::selectionModeChangeTriggered, this, &DolphinMainWindow::slotSetSelectionMode); + Q_CHECK_PTR(actionCollection()->action(QStringLiteral("create_dir"))); + m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action(QStringLiteral("create_dir"))); + m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl); @@ -265,6 +267,11 @@ bool DolphinMainWindow::isInformationPanelEnabled() const #endif } +bool DolphinMainWindow::isSplitViewEnabledInCurrentTab() const +{ + return m_tabWidget->currentTabPage()->splitViewEnabled(); +} + void DolphinMainWindow::openFiles(const QStringList &files, bool splitView) { openFiles(QUrl::fromStringList(files), splitView); @@ -276,8 +283,10 @@ void DolphinMainWindow::activateWindow(const QString &activationToken) if (KWindowSystem::isPlatformWayland()) { KWindowSystem::setCurrentXdgActivationToken(activationToken); - } else { + } else if (KWindowSystem::isPlatformX11()) { +#if HAVE_X11 KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken.toUtf8()); +#endif } KWindowSystem::activateWindow(window()->windowHandle()); @@ -497,21 +506,63 @@ void DolphinMainWindow::openInNewWindow() } } -void DolphinMainWindow::showTarget() +void DolphinMainWindow::openInSplitView(const QUrl &url) { - const auto link = m_activeViewContainer->view()->selectedItems().at(0); - const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir(); - auto linkDestination = link.linkDest(); - if (QFileInfo(linkDestination).isRelative()) { - linkDestination = linkLocationDir.filePath(linkDestination); + QUrl newSplitViewUrl = url; + + if (newSplitViewUrl.isEmpty()) { + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + if (list.count() == 1) { + const KFileItem &item = list.first(); + newSplitViewUrl = DolphinView::openItemAsFolderUrl(item); + } + } + + if (newSplitViewUrl.isEmpty()) { + return; } - if (QFileInfo::exists(linkDestination)) { - KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)}); + + DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); + if (tabPage->splitViewEnabled()) { + tabPage->switchActiveView(); + tabPage->activeViewContainer()->setUrl(newSplitViewUrl); } else { - m_activeViewContainer->showMessage(xi18nc("@info", "Could not access %1.", linkDestination), DolphinViewContainer::Warning); + tabPage->setSplitViewEnabled(true, WithAnimation, newSplitViewUrl); + updateViewActions(); } } +void DolphinMainWindow::showTarget() +{ + const KFileItem link = m_activeViewContainer->view()->selectedItems().at(0); + const QUrl destinationUrl = link.url().resolved(QUrl(link.linkDest())); + + auto job = KIO::stat(destinationUrl, KIO::StatJob::SourceSide, KIO::StatNoDetails); + + connect(job, &KJob::finished, this, [this, destinationUrl](KJob *job) { + KIO::StatJob *statJob = static_cast(job); + + if (statJob->error()) { + m_activeViewContainer->showMessage(job->errorString(), DolphinViewContainer::Error); + } else { + KIO::highlightInFileManager({destinationUrl}); + } + }); +} + +bool DolphinMainWindow::event(QEvent *event) +{ + if (event->type() == QEvent::ShortcutOverride) { + const QKeyEvent *keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Space && m_activeViewContainer->view()->handleSpaceAsNormalKey()) { + event->accept(); + return true; + } + } + + return KXmlGuiWindow::event(event); +} + void DolphinMainWindow::showEvent(QShowEvent *event) { KXmlGuiWindow::showEvent(event); @@ -606,7 +657,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent *event) QStringList(), i18n("Do not ask again"), &doNotAskAgainCheckboxResult, - KMessageBox::Dangerous); + KMessageBox::Notify | KMessageBox::Dangerous); if (doNotAskAgainCheckboxResult) { GeneralSettings::setConfirmClosingTerminalRunningProgram(false); @@ -653,20 +704,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup &group) void DolphinMainWindow::updateNewMenu() { m_newFileMenu->checkUpToDate(); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0) m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); -#else - m_newFileMenu->setPopupFiles(QList() << activeViewContainer()->url()); -#endif } void DolphinMainWindow::createDirectory() { -#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0) m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); -#else - m_newFileMenu->setPopupFiles(QList() << activeViewContainer()->url()); -#endif m_newFileMenu->createDirectory(); } @@ -801,10 +844,11 @@ void DolphinMainWindow::slotAboutToShowBackPopupMenu() { const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory(); int entries = 0; - m_backAction->menu()->clear(); + QMenu *menu = m_backAction->popupMenu(); + menu->clear(); for (int i = urlNavigator->historyIndex() + 1; i < urlNavigator->historySize() && entries < MaxNumberOfNavigationentries; ++i, ++entries) { - QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_backAction->menu()); - m_backAction->menu()->addAction(action); + QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu); + menu->addAction(action); } } @@ -829,10 +873,10 @@ void DolphinMainWindow::slotAboutToShowForwardPopupMenu() { const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory(); int entries = 0; - m_forwardAction->menu()->clear(); + QMenu *menu = m_forwardAction->popupMenu(); for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) { - QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_forwardAction->menu()); - m_forwardAction->menu()->addAction(action); + QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu); + menu->addAction(action); } } @@ -877,7 +921,6 @@ void DolphinMainWindow::toggleSplitView() { DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled(), WithAnimation); - updateViewActions(); } @@ -1136,7 +1179,8 @@ void DolphinMainWindow::openTerminalHere() { QList urls = {}; - for (const KFileItem &item : m_activeViewContainer->view()->selectedItems()) { + const auto selectedItems = m_activeViewContainer->view()->selectedItems(); + for (const KFileItem &item : selectedItems) { QUrl url = item.targetUrl(); if (item.isFile()) { url.setPath(QFileInfo(url.path()).absolutePath()); @@ -1154,29 +1198,19 @@ void DolphinMainWindow::openTerminalHere() if (urls.count() > 5) { 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()); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) - const int answer = KMessageBox::warningTwoActions( + const int answer = KMessageBox::warningContinueCancel( this, question, {}, -#else - const int answer = KMessageBox::warningYesNo( - this, - question, - {}, -#endif KGuiItem(i18ncp("@action:button", "Open %1 Terminal", "Open %1 Terminals", urls.count()), QStringLiteral("utilities-terminal")), - KStandardGuiItem::cancel()); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) - if (answer != KMessageBox::PrimaryAction) { -#else - if (answer != KMessageBox::Yes) { -#endif + KStandardGuiItem::cancel(), + QStringLiteral("ConfirmOpenManyTerminals")); + if (answer != KMessageBox::PrimaryAction && answer != KMessageBox::Continue) { return; } } - for (const QUrl &url : urls) { + for (const QUrl &url : std::as_const(urls)) { openTerminalJob(url); } } @@ -1241,11 +1275,7 @@ void DolphinMainWindow::handleUrl(const QUrl &url) activeViewContainer()->setUrl(url); } else { m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) m_lastHandleUrlOpenJob->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -#else - m_lastHandleUrlOpenJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -#endif m_lastHandleUrlOpenJob->setShowOpenOrExecuteDialog(true); connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this, [this, url](const QString &mimetype) { @@ -1423,7 +1453,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer *viewContainer) connect(oldViewContainer->view(), &DolphinView::requestItemInfo, this, &DolphinMainWindow::requestItemInfo); // Disconnect other slots. - disconnect(nullptr, + disconnect(oldViewContainer, &DolphinViewContainer::selectionModeChanged, actionCollection()->action(QStringLiteral("toggle_selection_mode")), &QAction::setChecked); @@ -1469,7 +1499,7 @@ void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString &mo setViewsToHomeIfMountPathOpen(mountPath); }); - if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) { + if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsChildOf(mountPath)) { m_tearDownFromPlacesRequested = true; m_terminalPanel->goHome(); // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged @@ -1484,7 +1514,7 @@ void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString &mo setViewsToHomeIfMountPathOpen(mountPath); }); - if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) { + if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsChildOf(mountPath)) { m_tearDownFromPlacesRequested = false; m_terminalPanel->goHome(); } @@ -1519,7 +1549,8 @@ void DolphinMainWindow::setupActions() auto hamburgerMenuAction = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection()); // setup 'File' menu - m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this); + m_newFileMenu = new DolphinNewFileMenu(nullptr, this); + actionCollection()->addAction(QStringLiteral("new_menu"), m_newFileMenu); QMenu *menu = m_newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); menu->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); @@ -1606,8 +1637,8 @@ void DolphinMainWindow::setupActions() + cutCopyPastePara); QAction *copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view")); - copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Inactive Split View")); - m_actionTextHelper->registerTextWhenNothingIsSelected(copyToOtherViewAction, i18nc("@action:inmenu", "Copy to Inactive Split View…")); + copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Other View")); + 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.")); @@ -1617,8 +1648,8 @@ void DolphinMainWindow::setupActions() connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToInactiveSplitView); QAction *moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view")); - moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Inactive Split View")); - m_actionTextHelper->registerTextWhenNothingIsSelected(moveToOtherViewAction, i18nc("@action:inmenu", "Move to Inactive Split View…")); + moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Other View")); + 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.")); @@ -1628,7 +1659,7 @@ void DolphinMainWindow::setupActions() connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToInactiveSplitView); QAction *showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar")); - showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter...")); + showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter…")); showFilterBar->setToolTip(i18nc("@info:tooltip", "Show Filter Bar")); showFilterBar->setWhatsThis(xi18nc("@info:whatsthis", "This opens the " @@ -1652,7 +1683,7 @@ void DolphinMainWindow::setupActions() connect(toggleFilter, &QAction::triggered, this, &DolphinMainWindow::toggleFilterBar); QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); - searchAction->setText(i18n("Search...")); + searchAction->setText(i18n("Search…")); searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders")); searchAction->setWhatsThis(xi18nc("@info:whatsthis find", "This helps you " @@ -1687,6 +1718,7 @@ void DolphinMainWindow::setupActions() "")); toggleSelectionModeAction->setIcon(QIcon::fromTheme(QStringLiteral("quickwizard"))); toggleSelectionModeAction->setCheckable(true); + actionCollection()->setDefaultShortcut(toggleSelectionModeAction, Qt::Key_Space ); connect(toggleSelectionModeAction, &QAction::triggered, this, &DolphinMainWindow::toggleSelectionMode); // A special version of the toggleSelectionModeAction for the toolbar that also contains a menu @@ -1697,7 +1729,7 @@ void DolphinMainWindow::setupActions() toggleSelectionModeToolBarAction->setWhatsThis(toggleSelectionModeAction->whatsThis()); actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction); toggleSelectionModeToolBarAction->setCheckable(true); - toggleSelectionModeToolBarAction->setPopupMode(QToolButton::DelayedPopup); + toggleSelectionModeToolBarAction->setPopupMode(KToolBarPopupAction::DelayedPopup); connect(toggleSelectionModeToolBarAction, &QAction::triggered, toggleSelectionModeAction, &QAction::trigger); connect(toggleSelectionModeAction, &QAction::toggled, toggleSelectionModeToolBarAction, &QAction::setChecked); @@ -1742,7 +1774,14 @@ void DolphinMainWindow::setupActions() stashSplit->setVisible(sessionInterface && sessionInterface->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier"))); connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash); - KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection()); + QAction *redisplay = KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection()); + redisplay->setToolTip(i18nc("@info:tooltip", "Refresh view")); + redisplay->setWhatsThis(xi18nc("@info:whatsthis refresh", + "This refreshes " + "the folder view." + "If the contents of this folder have changed, refreshing will re-scan this folder " + "and show you a newly-updated view of the files and folders contained here." + "If the view is split, this refreshes the one that is currently in focus.")); QAction *stop = actionCollection()->addAction(QStringLiteral("stop")); stop->setText(i18nc("@action:inmenu View", "Stop")); @@ -1769,7 +1808,7 @@ void DolphinMainWindow::setupActions() replaceLocation->setWhatsThis(xi18nc("@info:whatsthis", "This switches to editing the location and selects it " "so you can quickly enter a different location.")); - actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL | Qt::Key_L); + actionCollection()->setDefaultShortcuts(replaceLocation, {Qt::CTRL | Qt::Key_L, Qt::ALT | Qt::Key_D}); connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation); // setup 'Go' menu @@ -1779,14 +1818,15 @@ void DolphinMainWindow::setupActions() m_backAction->setObjectName(backAction->objectName()); m_backAction->setShortcuts(backAction->shortcuts()); } - m_backAction->setPopupMode(QToolButton::DelayedPopup); + m_backAction->setPopupMode(KToolBarPopupAction::DelayedPopup); connect(m_backAction, &QAction::triggered, this, &DolphinMainWindow::goBack); - connect(m_backAction->menu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu); - connect(m_backAction->menu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoBack); + connect(m_backAction->popupMenu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu); + connect(m_backAction->popupMenu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoBack); actionCollection()->addAction(m_backAction->objectName(), m_backAction); auto backShortcuts = m_backAction->shortcuts(); - backShortcuts.append(QKeySequence(Qt::Key_Backspace)); + // Prepend this shortcut, to avoid being hidden by the two-slot UI (#371130) + backShortcuts.prepend(QKeySequence(Qt::Key_Backspace)); actionCollection()->setDefaultShortcuts(m_backAction, backShortcuts); DolphinRecentTabsMenu *recentTabsMenu = new DolphinRecentTabsMenu(this); @@ -1819,18 +1859,18 @@ void DolphinMainWindow::setupActions() m_forwardAction->setObjectName(forwardAction->objectName()); m_forwardAction->setShortcuts(forwardAction->shortcuts()); } - m_forwardAction->setPopupMode(QToolButton::DelayedPopup); + m_forwardAction->setPopupMode(KToolBarPopupAction::DelayedPopup); connect(m_forwardAction, &QAction::triggered, this, &DolphinMainWindow::goForward); - connect(m_forwardAction->menu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu); - connect(m_forwardAction->menu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoForward); + connect(m_forwardAction->popupMenu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu); + connect(m_forwardAction->popupMenu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoForward); actionCollection()->addAction(m_forwardAction->objectName(), m_forwardAction); actionCollection()->setDefaultShortcuts(m_forwardAction, m_forwardAction->shortcuts()); // enable middle-click to open in a new tab auto *middleClickEventFilter = new MiddleClickActionEventFilter(this); connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked); - m_backAction->menu()->installEventFilter(middleClickEventFilter); - m_forwardAction->menu()->installEventFilter(middleClickEventFilter); + m_backAction->popupMenu()->installEventFilter(middleClickEventFilter); + m_forwardAction->popupMenu()->installEventFilter(middleClickEventFilter); KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection()); QAction *homeAction = KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection()); homeAction->setWhatsThis(xi18nc("@info:whatsthis", @@ -1981,6 +2021,13 @@ void DolphinMainWindow::setupActions() openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window")); openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new"))); connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow); + + QAction *openInSplitViewAction = actionCollection()->addAction(QStringLiteral("open_in_split_view")); + openInSplitViewAction->setText(i18nc("@action:inmenu", "Open in Split View")); + openInSplitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new"))); + connect(openInSplitViewAction, &QAction::triggered, this, [this]() { + openInSplitView(QUrl()); + }); } void DolphinMainWindow::setupDockWidgets() @@ -2156,6 +2203,7 @@ void DolphinMainWindow::setupDockWidgets() connect(m_placesPanel, &PlacesPanel::newWindowRequested, this, [this](const QUrl &url) { Dolphin::openNewWindow({url}, this); }); + connect(m_placesPanel, &PlacesPanel::openInSplitViewRequested, this, &DolphinMainWindow::openInSplitView); connect(m_placesPanel, &PlacesPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage); connect(this, &DolphinMainWindow::urlChanged, m_placesPanel, &PlacesPanel::setUrl); connect(placesDock, &DolphinDockWidget::visibilityChanged, &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged); @@ -2276,18 +2324,24 @@ void DolphinMainWindow::updateFileAndEditActions() duplicateAction->setEnabled(capabilitiesSource.supportsWriting()); } - if (m_tabWidget->currentTabPage()->splitViewEnabled()) { + if (m_tabWidget->currentTabPage()->splitViewEnabled() && !list.isEmpty()) { DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); KFileItem capabilitiesDestination; if (tabPage->primaryViewActive()) { - capabilitiesDestination = tabPage->secondaryViewContainer()->url(); + capabilitiesDestination = tabPage->secondaryViewContainer()->rootItem(); } else { - capabilitiesDestination = tabPage->primaryViewContainer()->url(); + capabilitiesDestination = tabPage->primaryViewContainer()->rootItem(); } - copyToOtherViewAction->setEnabled(capabilitiesDestination.isWritable()); - moveToOtherViewAction->setEnabled((list.isEmpty() || capabilitiesSource.supportsMoving()) && capabilitiesDestination.isWritable()); + const auto destUrl = capabilitiesDestination.url(); + const bool allNotTargetOrigin = std::all_of(list.cbegin(), list.cend(), [destUrl](const KFileItem &item) { + 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); @@ -2443,6 +2497,7 @@ void DolphinMainWindow::createPanelAction(const QIcon &icon, const QKeySequence panelAction->setText(dockAction->text()); panelAction->setIcon(icon); dockAction->setIcon(icon); + dockAction->setEnabled(true); actionCollection()->setDefaultShortcut(panelAction, shortcut); connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger); @@ -2504,15 +2559,23 @@ void DolphinMainWindow::setupWhatsThis() // Help menu + auto setStandardActionWhatsThis = [this](KStandardAction::StandardAction actionId, + const QString &whatsThis) { + // Check for the existence of an action since it can be restricted through the Kiosk system + if (auto *action = actionCollection()->action(KStandardAction::name(actionId))) { + action->setWhatsThis(whatsThis); + } + }; + // i18n: If the external link isn't available in your language it might make // sense to state the external link's language in brackets to not // frustrate the user. If there are multiple languages that the user might // know with a reasonable chance you might want to have 2 external links. // The same might be true for any external link you translate. - actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents))->setWhatsThis(xi18nc("@info:whatsthis handbook", "This opens the Handbook for this application. It provides explanations for every part of Dolphin.If you want more elaborate introductions to the different features of Dolphin click here. It will open the dedicated page in the KDE UserBase Wiki.")); + setStandardActionWhatsThis(KStandardAction::HelpContents, xi18nc("@info:whatsthis handbook", "This opens the Handbook for this application. It provides explanations for every part of Dolphin.If you want more elaborate introductions to the different features of Dolphin click here. It will open the dedicated page in the KDE UserBase Wiki.")); // (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 ) - actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis))->setWhatsThis( + setStandardActionWhatsThis(KStandardAction::WhatsThis, xi18nc("@info:whatsthis whatsthis button", "This is the button that invokes the help feature you are " "using right now! Click it, then click any component of this " @@ -2524,7 +2587,7 @@ void DolphinMainWindow::setupWhatsThis() "UserBase Wiki.The \"What's this?\" help is " "missing in most other windows so don't get too used to this.")); - actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug))->setWhatsThis( + setStandardActionWhatsThis(KStandardAction::ReportBug, xi18nc("@info:whatsthis","This opens a " "window that will guide you through reporting errors or flaws " "in this application or in other KDE software." @@ -2533,7 +2596,7 @@ void DolphinMainWindow::setupWhatsThis() "" "click here.")); - actionCollection()->action(KStandardAction::name(KStandardAction::Donate))->setWhatsThis( + setStandardActionWhatsThis(KStandardAction::Donate, xi18nc("@info:whatsthis", "This opens a " "web page where you can donate to " "support the continued work on this application and many " @@ -2545,18 +2608,18 @@ void DolphinMainWindow::setupWhatsThis() "KDE e.V. is the non-profit " "organization behind the KDE community.")); - actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage))->setWhatsThis( + setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage, xi18nc("@info:whatsthis", "With this you can change the language this application uses." "You can even set secondary languages which will be used " "if texts are not available in your preferred language.")); - actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp))->setWhatsThis( + setStandardActionWhatsThis(KStandardAction::AboutApp, xi18nc("@info:whatsthis","This opens a " "window that informs you about the version, license, " "used libraries and maintainers of this application.")); - actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE))->setWhatsThis( + setStandardActionWhatsThis(KStandardAction::AboutKDE, xi18nc("@info:whatsthis","This opens a " "window with information about KDE. " "The KDE community are the people behind this free software." @@ -2652,3 +2715,5 @@ bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem) { return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem)); } + +#include "moc_dolphinmainwindow.cpp"