mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Cut the ropes between DolphinMainWindow and DolphinNewFileMenu. Error handling is now done via signals.
REVIEW: 111989
This commit is contained in:
parent
b6477f4e65
commit
804e83f893
|
@ -196,7 +196,7 @@ void DolphinContextMenu::openItemContextMenu()
|
|||
if (m_selectedItems.count() == 1) {
|
||||
if (m_fileInfo.isDir()) {
|
||||
// setup 'Create New' menu
|
||||
DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow);
|
||||
DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), this);
|
||||
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
||||
newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown());
|
||||
newFileMenu->checkUpToDate();
|
||||
|
@ -204,6 +204,7 @@ 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,6 +95,9 @@ protected:
|
|||
virtual void keyPressEvent(QKeyEvent *ev);
|
||||
virtual void keyReleaseEvent(QKeyEvent *ev);
|
||||
|
||||
signals:
|
||||
void errorMessage(const QString& error);
|
||||
|
||||
private:
|
||||
void openTrashContextMenu();
|
||||
void openTrashItemContextMenu();
|
||||
|
|
|
@ -1297,6 +1297,8 @@ 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) {
|
||||
|
@ -1482,13 +1484,15 @@ DolphinViewContainer* DolphinMainWindow::createViewContainer(const KUrl& url, QW
|
|||
void DolphinMainWindow::setupActions()
|
||||
{
|
||||
// setup 'File' menu
|
||||
m_newFileMenu = new DolphinNewFileMenu(this);
|
||||
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
||||
KMenu* menu = m_newFileMenu->menu();
|
||||
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
|
||||
menu->setIcon(KIcon("document-new"));
|
||||
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"));
|
||||
|
|
|
@ -20,17 +20,13 @@
|
|||
|
||||
#include "dolphinnewfilemenu.h"
|
||||
|
||||
#include "dolphinmainwindow.h"
|
||||
#include "dolphinviewcontainer.h"
|
||||
#include "views/dolphinnewfilemenuobserver.h"
|
||||
#include "views/dolphinview.h"
|
||||
|
||||
#include <KActionCollection>
|
||||
#include <KIO/Job>
|
||||
|
||||
DolphinNewFileMenu::DolphinNewFileMenu(DolphinMainWindow* parent) :
|
||||
KNewFileMenu(parent->actionCollection(), "create_new", parent),
|
||||
m_mainWin(parent)
|
||||
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection* collection, QObject* parent) :
|
||||
KNewFileMenu(collection, "create_new", parent)
|
||||
{
|
||||
DolphinNewFileMenuObserver::instance().attach(this);
|
||||
}
|
||||
|
@ -43,8 +39,7 @@ DolphinNewFileMenu::~DolphinNewFileMenu()
|
|||
void DolphinNewFileMenu::slotResult(KJob* job)
|
||||
{
|
||||
if (job->error()) {
|
||||
DolphinViewContainer* container = m_mainWin->activeViewContainer();
|
||||
container->showMessage(job->errorString(), DolphinViewContainer::Error);
|
||||
emit errorMessage(job->errorString());
|
||||
} else {
|
||||
KNewFileMenu::slotResult(job);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <KNewFileMenu>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class KJob;
|
||||
|
||||
/**
|
||||
|
@ -39,15 +38,15 @@ class DolphinNewFileMenu : public KNewFileMenu
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DolphinNewFileMenu(DolphinMainWindow* parent);
|
||||
DolphinNewFileMenu(KActionCollection* collection, QObject* parent);
|
||||
virtual ~DolphinNewFileMenu();
|
||||
|
||||
signals:
|
||||
void errorMessage(const QString& error);
|
||||
|
||||
protected slots:
|
||||
/** @see KNewFileMenu::slotResult() */
|
||||
virtual void slotResult(KJob* job);
|
||||
|
||||
private:
|
||||
DolphinMainWindow* m_mainWin;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue