mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Replaced all KNewFileMenu usages in DolphinPart by DolphinNewFileMenu.
Removed all signal-slot-connections related to DolphinNewFileMenu->errorMessage(QString) in DolphinMainWindow and DolphinContextMenu and replaced it by a better solution. Now we make use of the already existing DolphinNewFileMenuObserver singleton class to achieve a better error handling, because every newly created DolphinContextMenu instance registers himself by DolphinNewFileMenuObserver and we use this to connect the errorMessage(QString) signal of every DolphinContextMenu instance to the errorMessage(QString) signal of the DolphinNewFileMenuObserver singleton class. So we need only one connection from DolphinNewFileMenuObserver to DolphinMainWindow (or to DolphinPart) to collect all error messages thrown by every DolphinNewFileMenu instance. REVIEW: 112178
This commit is contained in:
parent
a451281a46
commit
dd16a11dfd
11 changed files with 28 additions and 23 deletions
|
@ -92,6 +92,7 @@ set(dolphinprivate_LIB_SRCS
|
|||
views/viewproperties.cpp
|
||||
views/zoomlevelinfo.cpp
|
||||
dolphinremoveaction.cpp
|
||||
dolphinnewfilemenu.cpp
|
||||
)
|
||||
|
||||
if(HAVE_NEPOMUK)
|
||||
|
|
|
@ -204,7 +204,6 @@ void DolphinContextMenu::openItemContextMenu()
|
|||
newFileMenu->setEnabled(selectedItemsProps.supportsWriting());
|
||||
connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
|
||||
connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
|
||||
connect(newFileMenu, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
|
||||
|
||||
KMenu* menu = newFileMenu->menu();
|
||||
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
|
||||
|
|
|
@ -95,9 +95,6 @@ protected:
|
|||
virtual void keyPressEvent(QKeyEvent *ev);
|
||||
virtual void keyReleaseEvent(QKeyEvent *ev);
|
||||
|
||||
signals:
|
||||
void errorMessage(const QString& error);
|
||||
|
||||
private:
|
||||
void openTrashContextMenu();
|
||||
void openTrashItemContextMenu();
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "views/dolphinremoteencoding.h"
|
||||
#include "views/draganddrophelper.h"
|
||||
#include "views/viewproperties.h"
|
||||
#include "views/dolphinnewfilemenuobserver.h"
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#include "panels/terminal/terminalpanel.h"
|
||||
|
@ -126,6 +127,9 @@ DolphinMainWindow::DolphinMainWindow() :
|
|||
ViewTab& viewTab = m_viewTab[m_tabIndex];
|
||||
viewTab.wasActive = true; // The first opened tab is automatically active
|
||||
|
||||
connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
|
||||
this, SLOT(showErrorMessage(QString)));
|
||||
|
||||
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
|
||||
undoManager->setUiInterface(new UndoUiInterface());
|
||||
|
||||
|
@ -1297,8 +1301,6 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
|
|||
{
|
||||
QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
|
||||
contextMenu.data()->setCustomActions(customActions);
|
||||
connect(contextMenu.data(), SIGNAL(errorMessage(QString)),
|
||||
this, SLOT(showErrorMessage(QString)));
|
||||
const DolphinContextMenu::Command command = contextMenu.data()->open();
|
||||
|
||||
switch (command) {
|
||||
|
@ -1491,8 +1493,6 @@ void DolphinMainWindow::setupActions()
|
|||
m_newFileMenu->setDelayed(false);
|
||||
connect(menu, SIGNAL(aboutToShow()),
|
||||
this, SLOT(updateNewMenu()));
|
||||
connect(m_newFileMenu, SIGNAL(errorMessage(QString)),
|
||||
this, SLOT(showErrorMessage(QString)));
|
||||
|
||||
KAction* newWindow = actionCollection()->addAction("new_window");
|
||||
newWindow->setIcon(KIcon("window-new"));
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <KIO/Job>
|
||||
|
||||
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection* collection, QObject* parent) :
|
||||
KNewFileMenu(collection, "create_new", parent)
|
||||
KNewFileMenu(collection, "new_menu", parent)
|
||||
{
|
||||
DolphinNewFileMenuObserver::instance().attach(this);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <KNewFileMenu>
|
||||
|
||||
#include "libdolphin_export.h"
|
||||
|
||||
class KJob;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +35,7 @@ class KJob;
|
|||
* All errors are shown in the status bar of Dolphin
|
||||
* instead as modal error dialog with an OK button.
|
||||
*/
|
||||
class DolphinNewFileMenu : public KNewFileMenu
|
||||
class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenu : public KNewFileMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <KIO/NetAccess>
|
||||
#include <KToolInvocation>
|
||||
#include <kauthorized.h>
|
||||
#include <KNewFileMenu>
|
||||
#include <KMenu>
|
||||
#include <KInputDialog>
|
||||
#include <KProtocolInfo>
|
||||
|
@ -47,6 +46,7 @@
|
|||
#include "dolphinpart_ext.h"
|
||||
#endif
|
||||
|
||||
#include "dolphinnewfilemenu.h"
|
||||
#include "views/dolphinview.h"
|
||||
#include "views/dolphinviewactionhandler.h"
|
||||
#include "views/dolphinnewfilemenuobserver.h"
|
||||
|
@ -79,6 +79,9 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
|
|||
m_view->setTabsForFilesEnabled(true);
|
||||
setWidget(m_view);
|
||||
|
||||
connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
|
||||
this, SLOT(slotErrorMessage(QString)));
|
||||
|
||||
connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
|
||||
connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
|
||||
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
|
||||
|
@ -160,16 +163,14 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
|
|||
|
||||
DolphinPart::~DolphinPart()
|
||||
{
|
||||
DolphinNewFileMenuObserver::instance().detach(m_newFileMenu);
|
||||
}
|
||||
|
||||
void DolphinPart::createActions()
|
||||
{
|
||||
// Edit menu
|
||||
|
||||
m_newFileMenu = new KNewFileMenu(actionCollection(), "new_menu", this);
|
||||
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
||||
m_newFileMenu->setParentWidget(widget());
|
||||
DolphinNewFileMenuObserver::instance().attach(m_newFileMenu);
|
||||
connect(m_newFileMenu->menu(), SIGNAL(aboutToShow()),
|
||||
this, SLOT(updateNewMenu()));
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
class KNewFileMenu;
|
||||
class DolphinNewFileMenu;
|
||||
class DolphinViewActionHandler;
|
||||
class QActionGroup;
|
||||
class KAction;
|
||||
|
@ -244,7 +244,7 @@ private:
|
|||
DolphinViewActionHandler* m_actionHandler;
|
||||
DolphinRemoteEncoding* m_remoteEncoding;
|
||||
DolphinPartBrowserExtension* m_extension;
|
||||
KNewFileMenu* m_newFileMenu;
|
||||
DolphinNewFileMenu* m_newFileMenu;
|
||||
KAction* m_findFileAction;
|
||||
KAction* m_openTerminalAction;
|
||||
QString m_nameFilter;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<kpartgui name="dolphin" version="14">
|
||||
<MenuBar>
|
||||
<Menu name="file">
|
||||
<Action name="create_new" />
|
||||
<Action name="new_menu" />
|
||||
<Action name="new_window" />
|
||||
<Action name="new_tab" />
|
||||
<Action name="close_tab" />
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "dolphinnewfilemenuobserver.h"
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KNewFileMenu>
|
||||
#include "dolphinnewfilemenu.h"
|
||||
|
||||
class DolphinNewFileMenuObserverSingleton
|
||||
{
|
||||
|
@ -34,20 +34,24 @@ DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance()
|
|||
return s_DolphinNewFileMenuObserver->instance;
|
||||
}
|
||||
|
||||
void DolphinNewFileMenuObserver::attach(const KNewFileMenu* menu)
|
||||
void DolphinNewFileMenuObserver::attach(const DolphinNewFileMenu* menu)
|
||||
{
|
||||
connect(menu, SIGNAL(fileCreated(KUrl)),
|
||||
this, SIGNAL(itemCreated(KUrl)));
|
||||
connect(menu, SIGNAL(directoryCreated(KUrl)),
|
||||
this, SIGNAL(itemCreated(KUrl)));
|
||||
connect(menu, SIGNAL(errorMessage(QString)),
|
||||
this, SIGNAL(errorMessage(QString)));
|
||||
}
|
||||
|
||||
void DolphinNewFileMenuObserver::detach(const KNewFileMenu* menu)
|
||||
void DolphinNewFileMenuObserver::detach(const DolphinNewFileMenu* menu)
|
||||
{
|
||||
disconnect(menu, SIGNAL(fileCreated(KUrl)),
|
||||
this, SIGNAL(itemCreated(KUrl)));
|
||||
disconnect(menu, SIGNAL(directoryCreated(KUrl)),
|
||||
this, SIGNAL(itemCreated(KUrl)));
|
||||
disconnect(menu, SIGNAL(errorMessage(QString)),
|
||||
this, SIGNAL(errorMessage(QString)));
|
||||
}
|
||||
|
||||
DolphinNewFileMenuObserver::DolphinNewFileMenuObserver() :
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "libdolphin_export.h"
|
||||
|
||||
class KNewFileMenu;
|
||||
class DolphinNewFileMenu;
|
||||
class KUrl;
|
||||
|
||||
/**
|
||||
|
@ -40,11 +40,12 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenuObserver : public QObject
|
|||
|
||||
public:
|
||||
static DolphinNewFileMenuObserver& instance();
|
||||
void attach(const KNewFileMenu* menu);
|
||||
void detach(const KNewFileMenu* menu);
|
||||
void attach(const DolphinNewFileMenu* menu);
|
||||
void detach(const DolphinNewFileMenu* menu);
|
||||
|
||||
signals:
|
||||
void itemCreated(const KUrl& url);
|
||||
void errorMessage(const QString& error);
|
||||
|
||||
private:
|
||||
DolphinNewFileMenuObserver();
|
||||
|
|
Loading…
Reference in a new issue