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
views/viewproperties.cpp
views/zoomlevelinfo.cpp
dolphinremoveaction.cpp
+ dolphinnewfilemenu.cpp
)
if(HAVE_NEPOMUK)
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"));
virtual void keyPressEvent(QKeyEvent *ev);
virtual void keyReleaseEvent(QKeyEvent *ev);
-signals:
- void errorMessage(const QString& error);
-
private:
void openTrashContextMenu();
void openTrashItemContextMenu();
#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"
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());
{
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) {
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"));
#include <KIO/Job>
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection* collection, QObject* parent) :
- KNewFileMenu(collection, "create_new", parent)
+ KNewFileMenu(collection, "new_menu", parent)
{
DolphinNewFileMenuObserver::instance().attach(this);
}
#include <KNewFileMenu>
+#include "libdolphin_export.h"
+
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
#include <KIO/NetAccess>
#include <KToolInvocation>
#include <kauthorized.h>
-#include <KNewFileMenu>
#include <KMenu>
#include <KInputDialog>
#include <KProtocolInfo>
#include "dolphinpart_ext.h"
#endif
+#include "dolphinnewfilemenu.h"
#include "views/dolphinview.h"
#include "views/dolphinviewactionhandler.h"
#include "views/dolphinnewfilemenuobserver.h"
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)));
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()));
#include <QItemSelectionModel>
-class KNewFileMenu;
+class DolphinNewFileMenu;
class DolphinViewActionHandler;
class QActionGroup;
class KAction;
DolphinViewActionHandler* m_actionHandler;
DolphinRemoteEncoding* m_remoteEncoding;
DolphinPartBrowserExtension* m_extension;
- KNewFileMenu* m_newFileMenu;
+ DolphinNewFileMenu* m_newFileMenu;
KAction* m_findFileAction;
KAction* m_openTerminalAction;
QString m_nameFilter;
<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" />
#include "dolphinnewfilemenuobserver.h"
#include <KGlobal>
-#include <KNewFileMenu>
+#include "dolphinnewfilemenu.h"
class DolphinNewFileMenuObserverSingleton
{
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() :
#include "libdolphin_export.h"
-class KNewFileMenu;
+class DolphinNewFileMenu;
class KUrl;
/**
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();