]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Pass application name and icon to KRun
authorKai Uwe Broulik <kde@privat.broulik.de>
Wed, 8 Mar 2017 15:52:15 +0000 (16:52 +0100)
committerKai Uwe Broulik <kde@privat.broulik.de>
Wed, 8 Mar 2017 15:52:15 +0000 (16:52 +0100)
Otherwise this results in the generic executable icon as bouncy cursor.

Differential Revision: https://phabricator.kde.org/D4823

src/dbusinterface.cpp
src/dolphinmainwindow.cpp
src/global.cpp
src/global.h

index 124761ea07df488ec08fd4591d53eab46b51b9bb..37270b7872993ed1f54bc24803f096064545250f 100644 (file)
@@ -41,7 +41,7 @@ void DBusInterface::ShowFolders(const QStringList& uriList, const QString& start
     if (urls.isEmpty()) {
         return;
     }
-    KRun::run(QStringLiteral("dolphin %U"), urls, nullptr);
+    Dolphin::openNewWindow(urls);
 }
 
 void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId)
@@ -51,7 +51,7 @@ void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUp
     if (urls.isEmpty()) {
         return;
     }
-    KRun::run(QStringLiteral("dolphin --select %U"), urls, nullptr);
+    Dolphin::openNewWindow(urls, nullptr, Dolphin::OpenNewWindowFlag::Select);
 }
 
 void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId)
index 185db71936e207aceb50c2407d4e810f07c1a579..2784bd08c2ec29aa43bca31e73600e0d1b503214 100644 (file)
@@ -290,7 +290,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show)
 
 void DolphinMainWindow::openNewMainWindow()
 {
-    KRun::run(QStringLiteral("dolphin %u"), QList<QUrl>(), this);
+    Dolphin::openNewWindow({}, this);
 }
 
 void DolphinMainWindow::openNewActivatedTab()
@@ -331,7 +331,7 @@ void DolphinMainWindow::openInNewWindow()
     }
 
     if (!newWindowUrl.isEmpty()) {
-        KRun::run(QStringLiteral("dolphin %u"), {newWindowUrl}, this);
+        Dolphin::openNewWindow({newWindowUrl}, this);
     }
 }
 
@@ -772,11 +772,9 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
         changeUrl(KIO::upUrl(item.url()));
         break;
 
-    case DolphinContextMenu::OpenParentFolderInNewWindow: {
-
-        KRun::run(QStringLiteral("dolphin %u"), {KIO::upUrl(item.url())}, this);
+    case DolphinContextMenu::OpenParentFolderInNewWindow:
+        Dolphin::openNewWindow({KIO::upUrl(item.url())}, this);
         break;
-    }
 
     case DolphinContextMenu::OpenParentFolderInNewTab:
         openNewTab(KIO::upUrl(item.url()));
index 3d6d7dd5e7b7d4ec6c0f3af89aa9bb967820f59f..20dee00fa73ed384d53375abb7c39521793bdce6 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <QApplication>
+#include <QIcon>
+
+#include <KRun>
+
 #include "global.h"
 #include "dolphindebug.h"
 
@@ -41,3 +46,18 @@ QUrl Dolphin::homeUrl()
 {
     return QUrl::fromUserInput(GeneralSettings::homeUrl(), QString(), QUrl::AssumeLocalFile);
 }
+
+void Dolphin::openNewWindow(const QList<QUrl> &urls, QWidget *window, const OpenNewWindowFlags &flags)
+{
+    QString command = QStringLiteral("dolphin");
+
+    if (flags.testFlag(OpenNewWindowFlag::Select)) {
+        command.append(QLatin1String(" --select"));
+    }
+
+    if (!urls.isEmpty()) {
+        command.append(QLatin1String(" %U"));
+    }
+
+    KRun::run(command, urls, window, qApp->applicationDisplayName(), qApp->windowIcon().name());
+}
index 0ac2e9acb6010d4dac8371f6d621177f9f08a9b5..3b6af43e9732cc9cd0ece4f5a7d69995ecb4c682 100644 (file)
@@ -30,6 +30,17 @@ namespace Dolphin {
      * Returns the home url which is defined in General Settings
      */
     QUrl homeUrl();
+
+    enum class OpenNewWindowFlag {
+        None = 0,
+        Select = 1<<1
+    };
+    Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag)
+
+    /**
+     * Opens a new Dolphin window
+     */
+    void openNewWindow(const QList<QUrl> &urls = {}, QWidget *window = nullptr, const OpenNewWindowFlags &flags = OpenNewWindowFlag::None);
 }
 
 #endif //GLOBAL_H