┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-01-26 00:55:49 +0000
committerPeter Penz <[email protected]>2007-01-26 00:55:49 +0000
commit5840fcede7178c80d137f589110d09ee20a99483 (patch)
tree5c746f68645608d051dce82f7bdf77d6d7427d17
parentd52282f8a2a727ad332d4cceeeaa6b79af9267c1 (diff)
Do a custom error handling in for the 'Create New...' submenu. Thanks to David for adjusting KNewMenu :-)
svn path=/trunk/playground/utils/dolphin/; revision=627220
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/dolphindirlister.cpp4
-rw-r--r--src/dolphindirlister.h2
-rw-r--r--src/dolphinmainwindow.cpp4
-rw-r--r--src/dolphinmainwindow.h20
-rw-r--r--src/dolphinnewmenu.cpp50
-rw-r--r--src/dolphinnewmenu.h55
7 files changed, 120 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 175f31f51..6a16c4901 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,6 +15,7 @@ set(dolphin_SRCS
detailsviewsettingspage.cpp
dolphinapplication.cpp
dolphinmainwindow.cpp
+ dolphinnewmenu.cpp
dolphinview.cpp
dolphinstatusbar.cpp
dolphindirlister.cpp
diff --git a/src/dolphindirlister.cpp b/src/dolphindirlister.cpp
index e1be8d8ba..8da962b18 100644
--- a/src/dolphindirlister.cpp
+++ b/src/dolphindirlister.cpp
@@ -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());
}
diff --git a/src/dolphindirlister.h b/src/dolphindirlister.h
index 6ee4dc600..98793727c 100644
--- a/src/dolphindirlister.h
+++ b/src/dolphindirlister.h
@@ -25,7 +25,7 @@
/**
* @brief Extends the class KDirLister by emitting an error
- * signal containing text.
+ * signal containing text.
*
* @author Peter Penz
*/
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index eae9ca31a..e4fcc6a97 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -24,6 +24,7 @@
#include <assert.h>
#include "dolphinapplication.h"
+#include "dolphinnewmenu.h"
#include "dolphinsettings.h"
#include "dolphinsettingsdialog.h"
#include "dolphinstatusbar.h"
@@ -52,7 +53,6 @@
#include <klocale.h>
#include <kmenu.h>
#include <kmessagebox.h>
-#include <knewmenu.h>
#include <konqmimedata.h>
#include <kpropertiesdialog.h>
#include <kprotocolinfo.h>
@@ -937,7 +937,7 @@ void DolphinMainWindow::loadSettings()
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
- m_newMenu = new KNewMenu(actionCollection(), this, "create_new");
+ m_newMenu = new DolphinNewMenu(this);
KMenu* menu = m_newMenu->menu();
menu->setTitle(i18n("Create New..."));
menu->setIcon(SmallIcon("filenew"));
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 6052ec5ba..2d11480a9 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -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
index 000000000..8592c30ad
--- /dev/null
+++ b/src/dolphinnewmenu.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz *
+ * *
+ * 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
index 000000000..cca7b8e37
--- /dev/null
+++ b/src/dolphinnewmenu.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz *
+ * *
+ * 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