]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Move the "Create New" action (for the Edit menu, not for the context menu) to dolphin...
authorDavid Faure <faure@kde.org>
Thu, 5 Jun 2008 19:19:14 +0000 (19:19 +0000)
committerDavid Faure <faure@kde.org>
Thu, 5 Jun 2008 19:19:14 +0000 (19:19 +0000)
it doesn't appear while browsing the web [with a filemanagement profile initially]. The point is to
make the GUI sensible whatever initial profile was selected and hopefully get rid of konq-filemanagement.rc/konq-webbrowsing.rc.

svn path=/trunk/KDE/kdebase/apps/; revision=817326

src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinpart.rc

index 686dde5b877c58ab83314752e78dc8307e58ca82..bca9ee4a6b37c32b11c59f0b89147cb6fea7c501 100644 (file)
 #include <kpropertiesdialog.h>
 #include <ktoggleaction.h>
 #include <kio/netaccess.h>
+#include <ktoolinvocation.h>
 #include <kauthorized.h>
-#include <kshell.h>
+#include <knewmenu.h>
+#include <kmenu.h>
 
 #include <QActionGroup>
 #include <QApplication>
@@ -135,6 +137,12 @@ DolphinPart::~DolphinPart()
 
 void DolphinPart::createActions()
 {
+    // Edit menu
+
+    m_newMenu = new KNewMenu(actionCollection(), widget(), "new_menu");
+    connect(m_newMenu->menu(), SIGNAL(aboutToShow()),
+            this, SLOT(updateNewMenu()));
+
     KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
     editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
     connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
@@ -473,9 +481,6 @@ void DolphinPart::setNameFilter(const QString& nameFilter)
 
 void DolphinPart::slotOpenTerminal()
 {
-    KConfigGroup confGroup(KGlobal::config(), "General"); // set by componentchooser kcm
-    const QString preferredTerminal = confGroup.readPathEntry("TerminalApplication", "konsole");
-
     QString dir(QDir::homePath());
 
     KUrl u(url());
@@ -489,17 +494,15 @@ void DolphinPart::slotOpenTerminal()
         dir = u.path();
     }
 
-    // Compensate for terminal having arguments.
-    QStringList args = KShell::splitArgs(preferredTerminal);
-    if (args.isEmpty()) {
-        return;
-    }
-    const QString prog = args.takeFirst();
-    if (prog == "konsole") {
-        args << "--workdir";
-        args << dir;
-    }
-    QProcess::startDetached(prog, args);
+    KToolInvocation::invokeTerminal(QString(), dir);
+}
+
+void DolphinPart::updateNewMenu()
+{
+    // As requested by KNewMenu :
+    m_newMenu->slotCheckUpToDate();
+    // And set the files that the menu apply on :
+    m_newMenu->setPopupFiles(url());
 }
 
 #include "dolphinpart.moc"
index ac32c5f43581ddb4b4e80fea76ecf739910cce70..6778bb064da6d8ea1b97ab590220e2f6a45f6278 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <kparts/part.h>
 #include <kparts/browserextension.h>
+class KNewMenu;
 class DolphinViewActionHandler;
 class QActionGroup;
 class KAction;
@@ -177,6 +178,11 @@ private Q_SLOTS:
      */
     void slotOpenTerminal();
 
+    /**
+     * Updates the 'Create New...' sub menu, just before it's shown.
+     */
+    void updateNewMenu();
+
 private:
     void createActions();
     void createGoAction(const char* name, const char* iconName,
@@ -190,6 +196,7 @@ private:
     DolphinModel* m_dolphinModel;
     DolphinSortFilterProxyModel* m_proxyModel;
     DolphinPartBrowserExtension* m_extension;
+    KNewMenu* m_newMenu;
     QString m_nameFilter;
     Q_DISABLE_COPY(DolphinPart)
 };
index 6efc50ba94b682dda919bbd0e4926fe3d57406c2..de271b5d6b906a31e0f27ed0529bd5ad661e683c 100644 (file)
@@ -1,7 +1,9 @@
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphinpart" version="7" >
+<kpartgui name="dolphinpart" version="8" >
  <MenuBar>
   <Menu name="edit">
+   <Action name="new_menu"/>
+   <Separator/>
    <Action name="rename"/>
    <Action name="move_to_trash" />
    <Action name="delete"/>