]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Do a custom error handling in for the 'Create New...' submenu. Thanks to David for...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 26 Jan 2007 00:55:49 +0000 (00:55 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 26 Jan 2007 00:55:49 +0000 (00:55 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=627220

src/CMakeLists.txt
src/dolphindirlister.cpp
src/dolphindirlister.h
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinnewmenu.cpp [new file with mode: 0644]
src/dolphinnewmenu.h [new file with mode: 0644]

index 175f31f51421c6859c37bbbc44f157f8a59cf040..6a16c4901076ef72ae9cacb419facd94d9da107b 100644 (file)
@@ -15,6 +15,7 @@ set(dolphin_SRCS
    detailsviewsettingspage.cpp
    dolphinapplication.cpp
    dolphinmainwindow.cpp
+   dolphinnewmenu.cpp
    dolphinview.cpp
    dolphinstatusbar.cpp
    dolphindirlister.cpp
index e1be8d8badcfe7cf2bebdccb7d4da95cf377931b..8da962b18ad9c5f5e3859ea30ee3674982957983 100644 (file)
@@ -21,9 +21,6 @@
 #include "dolphindirlister.h"
 #include <kio/jobclasses.h>
 
-// TODO:
-#include <stdio.h>
-
 DolphinDirLister::DolphinDirLister() :
     KDirLister()
 {
@@ -35,7 +32,6 @@ DolphinDirLister::~DolphinDirLister()
 
 void DolphinDirLister::handleError(KIO::Job* job)
 {
-    // TODO: some error texts should be adjusted manually
     emit errorMessage(job->errorString());
 }
 
index 6ee4dc600e9026d222ec48078e7c96d2d222e6cc..98793727ce2689762a61b6d6daf51fb3e58c5124 100644 (file)
@@ -25,7 +25,7 @@
 
 /**
  * @brief Extends the class KDirLister by emitting an error
- * signal containing text.
+ *        signal containing text.
  *
  * @author Peter Penz
  */
index eae9ca31a567320da638a05662df06265e411af3..e4fcc6a9718980df6d237c54a35f878942afa134 100644 (file)
@@ -24,6 +24,7 @@
 #include <assert.h>\r
 \r
 #include "dolphinapplication.h"\r
+#include "dolphinnewmenu.h"\r
 #include "dolphinsettings.h"\r
 #include "dolphinsettingsdialog.h"\r
 #include "dolphinstatusbar.h"\r
@@ -52,7 +53,6 @@
 #include <klocale.h>\r
 #include <kmenu.h>\r
 #include <kmessagebox.h>\r
-#include <knewmenu.h>\r
 #include <konqmimedata.h>\r
 #include <kpropertiesdialog.h>\r
 #include <kprotocolinfo.h>\r
@@ -937,7 +937,7 @@ void DolphinMainWindow::loadSettings()
 void DolphinMainWindow::setupActions()\r
 {\r
     // setup 'File' menu\r
-    m_newMenu = new KNewMenu(actionCollection(), this, "create_new");\r
+    m_newMenu = new DolphinNewMenu(this);\r
     KMenu* menu = m_newMenu->menu();\r
     menu->setTitle(i18n("Create New..."));\r
     menu->setIcon(SmallIcon("filenew"));\r
index 6052ec5baf5395fd36ecbdce7c709830ac3e3579..2d11480a9e1542edac5503c7b0255324027f98e1 100644 (file)
@@ -351,10 +351,6 @@ private:
     void connectViewSignals(int viewIndex);
 
 private:
-    KNewMenu* m_newMenu;
-    QSplitter* m_splitter;
-    DolphinView* m_activeView;
-
     /**
      * DolphinMainWindowsupports only one or two views, which
      * are handled internally as primary and secondary view.
@@ -364,17 +360,14 @@ private:
         PrimaryIdx = 0,
         SecondaryIdx = 1
     };
-    DolphinView* m_view[SecondaryIdx + 1];
-
-    /// remember pending undo operations until they are finished
-    QList<KonqOperations::Operation> m_undoOperations;
 
     /**
      * Implements a custom error handling for the undo manager. This
      * assures that all errors are shown in the status bar of Dolphin
      * instead as modal error dialog with an OK button.
      */
-    class UndoUiInterface : public KonqUndoManager::UiInterface {
+    class UndoUiInterface : public KonqUndoManager::UiInterface
+    {
     public:
         UndoUiInterface(DolphinMainWindow* mainWin);
         virtual ~UndoUiInterface();
@@ -383,6 +376,15 @@ private:
     private:
         DolphinMainWindow* m_mainWin;
     };
+
+    KNewMenu* m_newMenu;
+    QSplitter* m_splitter;
+    DolphinView* m_activeView;
+
+    DolphinView* m_view[SecondaryIdx + 1];
+
+    /// remember pending undo operations until they are finished
+    QList<KonqOperations::Operation> m_undoOperations;
 };
 
 #endif // _DOLPHIN_H_
diff --git a/src/dolphinnewmenu.cpp b/src/dolphinnewmenu.cpp
new file mode 100644 (file)
index 0000000..8592c30
--- /dev/null
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz                                      *
+ *   peter.penz@gmx.at                                                     *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "dolphinnewmenu.h"
+#include "dolphinmainwindow.h"
+#include "dolphinstatusbar.h"
+#include "dolphinview.h"
+
+#include <kactioncollection.h>
+#include <kio/job.h>
+
+DolphinNewMenu::DolphinNewMenu(DolphinMainWindow* mainWin) :
+    KNewMenu(mainWin->actionCollection(), mainWin, "create_new"),
+    m_mainWin(mainWin)
+{
+}
+
+DolphinNewMenu::~DolphinNewMenu()
+{
+}
+
+void DolphinNewMenu::slotResult(KJob* job)
+{
+    if (job->error()) {
+        DolphinStatusBar* statusBar = m_mainWin->activeView()->statusBar();
+        statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
+    }
+    else {
+        KNewMenu::slotResult(job);
+    }
+}
+
+#include "dolphinnewmenu.moc"
diff --git a/src/dolphinnewmenu.h b/src/dolphinnewmenu.h
new file mode 100644 (file)
index 0000000..cca7b8e
--- /dev/null
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz                                      *
+ *   peter.penz@gmx.at                                                     *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef DOLPHINNEWMENU_H
+#define DOLPHINNEWMENU_H
+
+//class KActionCollection;  // TODO: only required temporary because of
+                          // missing forward declaration in knewmenu.h
+#include <knewmenu.h>
+
+class DolphinMainWindow;
+class KJob;
+
+/**
+ * @brief Represents the 'Create New...' sub menu for the File menu
+ *        and the context menu.
+ *
+ * The only difference to KNewMenu is the custom error handling.
+ * All errors are shown in the status bar of Dolphin
+ * instead as modal error dialog with an OK button.
+ */
+class DolphinNewMenu : public KNewMenu
+{
+Q_OBJECT
+
+public:
+    DolphinNewMenu(DolphinMainWindow* mainWin);
+    virtual ~DolphinNewMenu();
+
+protected slots:
+    /** @see KNewMenu::slotResult() */
+    virtual void slotResult(KJob* job);
+
+private:
+    DolphinMainWindow* m_mainWin;
+};
+
+#endif