From: David Faure Date: Mon, 21 Jan 2008 19:31:07 +0000 (+0000) Subject: forwardport 764429: X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/e3da86af95dd620f62c1acc245b7bf98769a94fd?ds=sidebyside forwardport 764429: Revert the moving of the action to the DolphinView instance, this doesn't work with splitted views. (Each view would need its own action collection, but then DolphinView would have to become a KXMLGUIClient, and the GUI would flicker when switching views). Instead, use the same solution as the other shared actions: static method in DolphinView (for now), slot in the mainwindow (and for the more complex actions than this one, shared code in DolphinView) svn path=/trunk/KDE/kdebase/apps/; revision=764436 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index e0386467e..8948a53a9 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -422,6 +423,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) } } +void DolphinMainWindow::createDir() +{ + const KUrl& url = m_activeViewContainer->view()->url(); + KonqOperations::newDir(this, url); +} + void DolphinMainWindow::updateNewMenu() { m_newMenu->slotCheckUpToDate(); @@ -985,6 +992,9 @@ void DolphinMainWindow::setupActions() connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); + KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); + connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); + KAction* newWindow = actionCollection()->addAction("new_window"); newWindow->setIcon(KIcon("window-new")); newWindow->setText(i18nc("@action:inmenu File", "New &Window")); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index f757520c3..e99add896 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -163,6 +163,12 @@ protected: virtual void readProperties(const KConfigGroup& group); private slots: + /** + * Opens the dialog for creating a directory. Is connected + * with the key shortcut for "new directory" (F10). + */ + void createDir(); + /** Updates the 'Create New...' sub menu. */ void updateNewMenu(); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 235f176cd..2c4c1eaa3 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -70,8 +70,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi KUrl(), m_dirLister, m_dolphinModel, - m_proxyModel, - actionCollection()); + m_proxyModel); setWidget(m_view); setXMLFile("dolphinpart.rc"); @@ -147,6 +146,9 @@ void DolphinPart::createActions() // Go menu + KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); + connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); + QActionGroup* goActionGroup = new QActionGroup(this); connect(goActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotGoTriggered(QAction*))); @@ -424,4 +426,9 @@ void DolphinPart::slotProperties() } } +void DolphinPart::createDir() +{ + KonqOperations::newDir(m_view, url()); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 3e3c73f66..04161b6be 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -130,6 +130,12 @@ private Q_SLOTS: */ void slotProperties(); + /** + * Opens the dialog for creating a directory. Is connected + * with the key shortcut for "new directory" (F10). + */ + void createDir(); + private: void createActions(); void createGoAction(const char* name, const char* iconName, diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 819420210..bd5be2109 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -19,8 +19,6 @@ ***************************************************************************/ #include "dolphinview.h" -#include -#include #include #include @@ -30,6 +28,7 @@ #include #include +#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include "dolphindropcontroller.h" @@ -62,8 +62,7 @@ DolphinView::DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, DolphinModel* dolphinModel, - DolphinSortFilterProxyModel* proxyModel, - KActionCollection* actionCollection) : + DolphinSortFilterProxyModel* proxyModel) : QWidget(parent), m_active(true), m_showPreview(false), @@ -123,16 +122,6 @@ DolphinView::DolphinView(QWidget* parent, applyViewProperties(url); m_topLayout->addWidget(itemView()); - - Q_ASSERT(actionCollection != 0); - if (actionCollection->action("create_dir") == 0) { - // This action doesn't appear in the GUI, it's for the shortcut only. - // KNewMenu takes care of the GUI stuff. - KAction* newDirAction = actionCollection->addAction("create_dir"); - newDirAction->setText(i18n("Create Folder...")); - connect(newDirAction, SIGNAL(triggered()), SLOT(createDir())); - newDirAction->setShortcut(Qt::Key_F10); - } } DolphinView::~DolphinView() @@ -1037,11 +1026,6 @@ void DolphinView::slotDeleteFileFinished(KJob* job) } } -void DolphinView::createDir() -{ - KonqOperations::newDir(this, url()); -} - void DolphinView::cutSelectedItems() { QMimeData* mimeData = new QMimeData(); @@ -1151,4 +1135,14 @@ KAction* DolphinView::createDeleteAction(KActionCollection* collection) return deleteAction; } +KAction* DolphinView::createNewDirAction(KActionCollection* collection) +{ + // This action doesn't appear in the GUI, it's for the shortcut only. + // KNewMenu takes care of the GUI stuff. + KAction* newDirAction = collection->addAction("create_dir"); + newDirAction->setText(i18n("Create Folder...")); + newDirAction->setShortcut(Qt::Key_F10); + return newDirAction; +} + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index b42f57007..44efbc438 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -126,14 +126,12 @@ public: * @param proxyModel Used proxy model which specifies the sorting. The * model is not owned by the view and won't get * deleted. - * @param actionCollection Action collection which contains the menu actions. */ DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, DolphinModel* dolphinModel, - DolphinSortFilterProxyModel* proxyModel, - KActionCollection* actionCollection); + DolphinSortFilterProxyModel* proxyModel); virtual ~DolphinView(); @@ -362,6 +360,12 @@ public: */ static KAction* createDeleteAction(KActionCollection* collection); + /** + * Creates the "new directory" action. + * This code is here to share it between the mainwindow and the part + */ + static KAction* createNewDirAction(KActionCollection* collection); + /** * Returns the action name corresponding to the current view mode */ @@ -594,12 +598,6 @@ private slots: */ void slotDeleteFileFinished(KJob* job); - /** - * Opens the dialog for creating a directory. Is connected - * with the key shortcut for "new directory" (F10). - */ - void createDir(); - private: void loadDirectory(const KUrl& url, bool reload = false); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 1059f0f9a..e6966affb 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -115,8 +115,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, url, m_dirLister, m_dolphinModel, - m_proxyModel, - mainWindow->actionCollection()); + m_proxyModel); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),