]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'release/20.04'
authorNate Graham <nate@kde.org>
Sun, 24 May 2020 14:26:34 +0000 (08:26 -0600)
committerNate Graham <nate@kde.org>
Sun, 24 May 2020 14:26:34 +0000 (08:26 -0600)
1  2 
src/dolphinmainwindow.cpp

index 668f511ee0eedca94e4648b7a883ed3057f191fb,dd1dcdac5df78a3a579b7b81afd0a4b879a0cff2..d45b77676cd01626471ca4da370d91d629b0dca0
  #include <KActionMenu>
  #include <KAuthorized>
  #include <KConfig>
 +#include <KConfigGui>
  #include <KDualAction>
  #include <KFileItemListProperties>
  #include <KHelpMenu>
 +#include <KIO/CommandLauncherJob>
  #include <KIO/JobUiDelegate>
  #include <KIO/OpenFileManagerWindowJob>
  #include <KJobWidgets>
@@@ -67,6 -65,7 +67,7 @@@
  #include <KShell>
  #include <KStandardAction>
  #include <KStartupInfo>
+ #include <KSycoca>
  #include <KToggleAction>
  #include <KToolBar>
  #include <KToolBarPopupAction>
@@@ -205,7 -204,9 +206,9 @@@ DolphinMainWindow::DolphinMainWindow() 
  
      setupWhatsThis();
  
-     QTimer::singleShot(0, this, &DolphinMainWindow::setupUpdateOpenPreferredSearchToolAction);
+     connect(KSycoca::self(), QOverload<>::of(&KSycoca::databaseChanged), this, &DolphinMainWindow::updateOpenPreferredSearchToolAction);
+     QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction);
  }
  
  DolphinMainWindow::~DolphinMainWindow()
@@@ -581,14 -582,6 +584,14 @@@ void DolphinMainWindow::closeEvent(QClo
          }
      }
  
 +    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();
  
@@@ -654,12 -647,12 +657,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()
@@@ -936,10 -929,7 +939,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()
@@@ -982,29 -972,6 +985,6 @@@ QPointer<QAction> DolphinMainWindow::pr
      return action;
  }
  
- void DolphinMainWindow::setupUpdateOpenPreferredSearchToolAction()
- {
-     QAction* openPreferredSearchTool = actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
-     const QList<QWidget*> widgets = openPreferredSearchTool->associatedWidgets();
-     for (QWidget* widget : widgets) {
-         QMenu* menu = qobject_cast<QMenu*>(widget);
-         if (menu) {
-             connect(menu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction);
-         }
-     }
-     // Update the open_preferred_search_tool action *before* the Configure Shortcuts window is shown,
-     // since this action is then listed in that window and it should be up-to-date when it is displayed.
-     // This update is instantaneous if user made no changes to the search tools in the meantime.
-     // Maybe all KStandardActions should defer calls to their slots, so that we could simply connect() to trigger()?
-     connect(
-         actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings)), &QAction::hovered,
-         this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
-     );
-     updateOpenPreferredSearchToolAction();
- }
  void DolphinMainWindow::updateOpenPreferredSearchToolAction()
  {
      QAction* openPreferredSearchTool = actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
@@@ -1149,8 -1116,6 +1129,8 @@@ void DolphinMainWindow::updateControlMe
  
      // 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);
  
      addActionToMenu(ac->action(QStringLiteral("show_filter_bar")), menu);
      addActionToMenu(ac->action(QStringLiteral("open_preferred_search_tool")), menu);
      addActionToMenu(ac->action(QStringLiteral("open_terminal")), menu);
-     connect(menu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction);
  
      menu->addSeparator();
  
@@@ -1280,7 -1244,7 +1259,7 @@@ void DolphinMainWindow::tabCountChanged
  
  void DolphinMainWindow::updateWindowTitle()
  {
 -    const QString newTitle = m_activeViewContainer->caption();
 +    const QString newTitle = m_activeViewContainer->captionWindowTitle();
      if (windowTitle() != newTitle) {
          setWindowTitle(newTitle);
      }
@@@ -1384,24 -1348,6 +1363,24 @@@ void DolphinMainWindow::setupActions(
          "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
          "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 <emphasis>active</emphasis> 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 <emphasis>active</emphasis> 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"));
@@@ -1927,18 -1873,12 +1906,18 @@@ void DolphinMainWindow::updateFileAndEd
  {
      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);
 +        copyToOtherViewAction->setEnabled(false);
 +        moveToOtherViewAction->setEnabled(false);
      } else {
          stateChanged(QStringLiteral("has_selection"));
  
              addToPlacesAction->setEnabled(false);
          }
  
 -        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(capabilities.supportsWriting());
 +        duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
      }
  }