X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e0085fb2804eedfe91b05c1c0c272758466fb62f..a291c5999035bb17fe764c1910c3e78ba041f8ac:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index e615fbab8..668f511ee 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -21,6 +21,7 @@ #include "dolphinmainwindow.h" +#include "dolphinmainwindowadaptor.h" #include "config-terminal.h" #include "global.h" #include "dolphinbookmarkhandler.h" @@ -49,9 +50,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -118,6 +121,9 @@ DolphinMainWindow::DolphinMainWindow() : m_forwardAction(nullptr) { Q_INIT_RESOURCE(dolphin); + + new MainWindowAdaptor(this); + #ifndef Q_OS_WIN setWindowFlags(Qt::WindowContextHelpButtonHint); #endif @@ -575,6 +581,14 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) } } + if (GeneralSettings::rememberOpenedTabs()) { + KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin")); + KConfig *config = KConfigGui::sessionConfig(); + saveGlobalProperties(config); + savePropertiesInternal(config, 1); + config->sync(); + } + GeneralSettings::setVersion(CurrentDolphinVersion); GeneralSettings::self()->save(); @@ -595,13 +609,13 @@ void DolphinMainWindow::updateNewMenu() { m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown()); m_newFileMenu->checkUpToDate(); - m_newFileMenu->setPopupFiles(activeViewContainer()->url()); + m_newFileMenu->setPopupFiles(QList() << activeViewContainer()->url()); } void DolphinMainWindow::createDirectory() { m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown()); - m_newFileMenu->setPopupFiles(activeViewContainer()->url()); + m_newFileMenu->setPopupFiles(QList() << activeViewContainer()->url()); m_newFileMenu->createDirectory(); } @@ -640,12 +654,12 @@ void DolphinMainWindow::undo() void DolphinMainWindow::cut() { - m_activeViewContainer->view()->cutSelectedItems(); + m_activeViewContainer->view()->cutSelectedItemsToClipboard(); } void DolphinMainWindow::copy() { - m_activeViewContainer->view()->copySelectedItems(); + m_activeViewContainer->view()->copySelectedItemsToClipboard(); } void DolphinMainWindow::paste() @@ -922,7 +936,10 @@ void DolphinMainWindow::compareFiles() command.append("\" \""); command.append(urlB.toDisplayString(QUrl::PreferLocalFile)); command.append('\"'); - KRun::runCommand(command, QStringLiteral("Kompare"), QStringLiteral("kompare"), this); + + KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(command, this); + job->setDesktopName(QStringLiteral("org.kde.kompare")); + job->start(); } void DolphinMainWindow::toggleShowMenuBar() @@ -952,7 +969,7 @@ QPointer DolphinMainWindow::preferredSearchTool() { m_searchTools.clear(); KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames( - &m_searchTools, { "files-find" }, QUrl::fromLocalFile(activeContainerLocalPath()) + &m_searchTools, { "files-find" }, m_activeViewContainer->url() ); QList actions = m_searchTools.actions(); if (actions.isEmpty()) { @@ -1132,6 +1149,8 @@ void DolphinMainWindow::updateControlMenu() // Add "Edit" actions bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) | + addActionToMenu(ac->action(QStringLiteral("copy_to_inactive_split_view")), menu) | + addActionToMenu(ac->action(QStringLiteral("move_to_inactive_split_view")), menu) | addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) | addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu); @@ -1261,7 +1280,7 @@ void DolphinMainWindow::tabCountChanged(int count) void DolphinMainWindow::updateWindowTitle() { - const QString newTitle = m_activeViewContainer->caption(); + const QString newTitle = m_activeViewContainer->captionWindowTitle(); if (windowTitle() != newTitle) { setWindowTitle(newTitle); } @@ -1317,6 +1336,7 @@ void DolphinMainWindow::setupActions() QAction* addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places")); addToPlaces->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new"))); + addToPlaces->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places")); addToPlaces->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder " "to the Places panel.")); connect(addToPlaces, &QAction::triggered, this, &DolphinMainWindow::addToPlaces); @@ -1364,6 +1384,24 @@ void DolphinMainWindow::setupActions() "If the items were added to the clipboard by the Cut " "action they are removed from their old location.") + cutCopyPastePara); + QAction* copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view")); + copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to inactive split view")); + copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from " + "the active view to the inactive split view.")); + copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); + copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to inactive split view")); + actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT + Qt::Key_F5 ); + connect(copyToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::copyToInactiveSplitView); + + QAction* moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view")); + moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to inactive split view")); + moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from " + "the active view to the inactive split view.")); + moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); + moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to inactive split view")); + actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT + Qt::Key_F6 ); + connect(moveToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::moveToInactiveSplitView); + QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); searchAction->setText(i18n("Search...")); searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders")); @@ -1554,6 +1592,12 @@ void DolphinMainWindow::setupActions() openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts"))); actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4); connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal); + + QAction* focusTerminalPanel = actionCollection()->addAction(QStringLiteral("focus_terminal_panel")); + focusTerminalPanel->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel")); + focusTerminalPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels"))); + actionCollection()->setDefaultShortcut(focusTerminalPanel, Qt::CTRL + Qt::SHIFT + Qt::Key_F4); + connect(focusTerminalPanel, &QAction::triggered, this, &DolphinMainWindow::focusTerminalPanel); } #endif @@ -1883,13 +1927,18 @@ void DolphinMainWindow::updateFileAndEditActions() { const KFileItemList list = m_activeViewContainer->view()->selectedItems(); const KActionCollection* col = actionCollection(); + KFileItemListProperties capabilitiesSource(list); + QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); + QAction* copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view")); + QAction* moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_split_view")); if (list.isEmpty()) { stateChanged(QStringLiteral("has_no_selection")); addToPlacesAction->setEnabled(true); - addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer->placesText())); + copyToOtherViewAction->setEnabled(false); + moveToOtherViewAction->setEnabled(false); } else { stateChanged(QStringLiteral("has_selection")); @@ -1899,24 +1948,40 @@ void DolphinMainWindow::updateFileAndEditActions() QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler QAction* showTarget = col->action(QStringLiteral("show_target")); + QAction* duplicateAction = col->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler if (list.length() == 1 && list.first().isDir()) { addToPlacesAction->setEnabled(true); - addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list.first().name())); } else { addToPlacesAction->setEnabled(false); - addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places")); } - KFileItemListProperties capabilities(list); - const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); + if (m_tabWidget->currentTabPage()->splitViewEnabled()) { + DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); + KFileItem capabilitiesDestination; + + if (tabPage->primaryViewActive()) { + capabilitiesDestination = tabPage->secondaryViewContainer()->url(); + } else { + capabilitiesDestination = tabPage->primaryViewContainer()->url(); + } + + copyToOtherViewAction->setEnabled(capabilitiesDestination.isWritable()); + moveToOtherViewAction->setEnabled(capabilitiesSource.supportsMoving() && capabilitiesDestination.isWritable()); + } else { + copyToOtherViewAction->setEnabled(false); + moveToOtherViewAction->setEnabled(false); + } + + const bool enableMoveToTrash = capabilitiesSource.isLocal() && capabilitiesSource.supportsMoving(); - renameAction->setEnabled(capabilities.supportsMoving()); + renameAction->setEnabled(capabilitiesSource.supportsMoving()); moveToTrashAction->setEnabled(enableMoveToTrash); - deleteAction->setEnabled(capabilities.supportsDeleting()); - deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); - cutAction->setEnabled(capabilities.supportsMoving()); + deleteAction->setEnabled(capabilitiesSource.supportsDeleting()); + deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting() && !enableMoveToTrash); + cutAction->setEnabled(capabilitiesSource.supportsMoving()); showTarget->setEnabled(list.length() == 1 && list.at(0).isLink()); + duplicateAction->setEnabled(capabilitiesSource.supportsWriting()); } } @@ -1959,6 +2024,7 @@ void DolphinMainWindow::createControlButton() Q_ASSERT(!m_controlButton); m_controlButton = new QToolButton(this); + m_controlButton->setAccessibleName(i18nc("@action:intoolbar", "Control")); m_controlButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); m_controlButton->setToolTip(i18nc("@action", "Show menu")); m_controlButton->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis); @@ -2286,8 +2352,6 @@ bool DolphinMainWindow::event(QEvent *event) QWhatsThisClickedEvent* whatsThisEvent = dynamic_cast(event); QDesktopServices::openUrl(QUrl(whatsThisEvent->href())); return true; - } else if (event->type() == QEvent::WindowActivate) { - updateOpenPreferredSearchToolAction(); } return KXmlGuiWindow::event(event); } @@ -2304,6 +2368,22 @@ bool DolphinMainWindow::eventFilter(QObject* obj, QEvent* event) return false; } +void DolphinMainWindow::focusTerminalPanel() +{ + if (m_terminalPanel->isVisible()) { + if (m_terminalPanel->terminalHasFocus()) { + m_activeViewContainer->view()->setFocus(Qt::FocusReason::ShortcutFocusReason); + actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel")); + } else { + m_terminalPanel->setFocus(Qt::FocusReason::ShortcutFocusReason); + actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel")); + } + } else { + actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger(); + actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel")); + } +} + DolphinMainWindow::UndoUiInterface::UndoUiInterface() : KIO::FileUndoManager::UiInterface() {