1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

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
This commit is contained in:
Peter Penz 2007-01-26 00:55:49 +00:00
parent d52282f8a2
commit 5840fcede7
7 changed files with 120 additions and 16 deletions

View File

@ -15,6 +15,7 @@ set(dolphin_SRCS
detailsviewsettingspage.cpp
dolphinapplication.cpp
dolphinmainwindow.cpp
dolphinnewmenu.cpp
dolphinview.cpp
dolphinstatusbar.cpp
dolphindirlister.cpp

View 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());
}

View File

@ -25,7 +25,7 @@
/**
* @brief Extends the class KDirLister by emitting an error
* signal containing text.
* signal containing text.
*
* @author Peter Penz
*/

View File

@ -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"));

View 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_

50
src/dolphinnewmenu.cpp Normal file
View File

@ -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"

55
src/dolphinnewmenu.h Normal file
View File

@ -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