]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Merge branch 'master' into kf6
[dolphin.git] / src / dolphinmainwindow.cpp
index 5061a10afcae788c6c8b9a5ceb94c76f0701bbdf..415f2e8b3700edad1c737372491a64b4b2d56822 100644 (file)
@@ -165,6 +165,10 @@ DolphinMainWindow::DolphinMainWindow()
     connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory);
     connect(m_actionHandler, &DolphinViewActionHandler::selectionModeChangeTriggered, this, &DolphinMainWindow::slotSetSelectionMode);
 
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
+    m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action("create_dir"));
+#endif
+
     m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
     connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
 
@@ -277,6 +281,31 @@ void DolphinMainWindow::openFiles(const QStringList &files, bool splitView)
     openFiles(QUrl::fromStringList(files), splitView);
 }
 
+bool DolphinMainWindow::isOnCurrentDesktop() const
+{
+#if HAVE_X11
+    if (KWindowSystem::isPlatformX11()) {
+        const NET::Properties properties = NET::WMDesktop;
+        KWindowInfo info(this->winId(), properties);
+        return info.isOnCurrentDesktop();
+    }
+#endif
+    return true;
+}
+
+bool DolphinMainWindow::isOnActivity(const QString &activityId) const
+{
+#if HAVE_X11 && HAVE_KACTIVITIES
+    if (KWindowSystem::isPlatformX11()) {
+        const NET::Properties properties = NET::Supported;
+        const NET::Properties2 properties2 = NET::WM2Activities;
+        KWindowInfo info(this->winId(), properties, properties2);
+        return info.activities().contains(activityId);
+    }
+#endif
+    return true;
+}
+
 void DolphinMainWindow::activateWindow(const QString &activationToken)
 {
     window()->setAttribute(Qt::WA_NativeWindow, true);
@@ -522,6 +551,19 @@ void DolphinMainWindow::showTarget()
     });
 }
 
+bool DolphinMainWindow::event(QEvent *event)
+{
+    if (event->type() == QEvent::ShortcutOverride) {
+        const QKeyEvent *keyEvent = static_cast<QKeyEvent *>(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);
@@ -1479,7 +1521,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
@@ -1494,7 +1536,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();
     }
@@ -1697,6 +1739,7 @@ void DolphinMainWindow::setupActions()
         "</para>"));
     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