From: Peter Penz Date: Thu, 26 Mar 2009 18:44:36 +0000 (+0000) Subject: Use KNewMenu::createDirectory() instead of KonqOperations::newDir() when F10 has... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/66ef40ec88f5e2d6985b0bb8dd8dca1469a855a1 Use KNewMenu::createDirectory() instead of KonqOperations::newDir() when F10 has been pressed, so that the directory gets automatically selected afterwards. CCMAIL: rahman.duran@gmail.com svn path=/trunk/KDE/kdebase/apps/; revision=945037 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index c2939e59a..35bc8bb86 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -543,6 +543,12 @@ void DolphinMainWindow::updateNewMenu() m_newMenu->setPopupFiles(activeViewContainer()->url()); } +void DolphinMainWindow::createDirectory() +{ + m_newMenu->setPopupFiles(activeViewContainer()->url()); + m_newMenu->createDirectory(); +} + void DolphinMainWindow::quit() { close(); @@ -976,6 +982,7 @@ void DolphinMainWindow::init() setCaption(homeUrl.fileName()); m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar())); + connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory())); ViewProperties props(homeUrl); m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this, m_viewTab[m_tabIndex].splitter, @@ -987,9 +994,9 @@ void DolphinMainWindow::init() view->reload(); m_activeViewContainer->show(); m_actionHandler->setCurrentView(view); - + m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); - connect(this, SIGNAL(urlChanged(const KUrl&)), + connect(this, SIGNAL(urlChanged(const KUrl&)), m_remoteEncoding, SLOT(slotAboutToOpenUrl())); m_tabBar = new KTabBar(this); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 77fc36b58..687eecddf 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -172,6 +172,8 @@ private slots: /** Updates the 'Create New...' sub menu. */ void updateNewMenu(); + void createDirectory(); + /** Shows the error message in the status bar of the active view. */ void showErrorMessage(const QString& message); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index dd590efd5..93bd3ce5d 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -125,6 +125,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); m_actionHandler->setCurrentView(m_view); + connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory())); m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); connect(this, SIGNAL(aboutToOpenURL()), @@ -543,4 +544,10 @@ void DolphinPart::updateProgress(int percent) m_extension->loadingProgress(percent); } +void DolphinPart::createDirectory() +{ + m_newMenu->setPopupFiles(url()); + m_newMenu->createDirectory(); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index e7198d45e..4a030af89 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -198,6 +198,8 @@ private Q_SLOTS: */ void updateProgress(int percent); + void createDirectory(); + private: void createActions(); void createGoAction(const char* name, const char* iconName, diff --git a/src/dolphinviewactionhandler.cpp b/src/dolphinviewactionhandler.cpp index 404c6eae0..88530febf 100644 --- a/src/dolphinviewactionhandler.cpp +++ b/src/dolphinviewactionhandler.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,7 @@ void DolphinViewActionHandler::createActions() newDirAction->setText(i18nc("@action", "Create Folder...")); newDirAction->setShortcut(Qt::Key_F10); newDirAction->setIcon(KIcon("folder-new")); - connect(newDirAction, SIGNAL(triggered()), SLOT(slotCreateDir())); + connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory())); // Edit menu @@ -283,12 +284,6 @@ QActionGroup* DolphinViewActionHandler::createSortByActionGroup() return sortByActionGroup; } -void DolphinViewActionHandler::slotCreateDir() -{ - Q_ASSERT(m_currentView); - KonqOperations::newDir(m_currentView, m_currentView->url()); -} - void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action) { const DolphinView::Mode mode = action->data().value(); diff --git a/src/dolphinviewactionhandler.h b/src/dolphinviewactionhandler.h index 18305d19f..40062de04 100644 --- a/src/dolphinviewactionhandler.h +++ b/src/dolphinviewactionhandler.h @@ -55,7 +55,7 @@ public: * Sets the view that this action handler should work on. */ void setCurrentView(DolphinView* view); - + /** * Returns the view that this action handler should work on. */ @@ -65,11 +65,11 @@ public: * Returns the name of the action for the current viewmode */ QString currentViewModeActionName() const; - + /** * Returns m_actionCollection */ - KActionCollection* actionCollection(); + KActionCollection* actionCollection(); public Q_SLOTS: /** @@ -85,13 +85,14 @@ Q_SIGNALS: */ void actionBeingHandled(); -private Q_SLOTS: /** - * Opens the dialog for creating a directory. Is connected - * with the key shortcut for "new directory" (F10). + * Emitted if the user requested creating a new directory by the F10 key. + * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes + * the method createDirectory of their KNewMenu instance. */ - void slotCreateDir(); + void createDirectory(); +private Q_SLOTS: /** * Emitted when the user requested a change of view mode */