From: Peter Penz Date: Sat, 26 Jul 2008 13:49:50 +0000 (+0000) Subject: Provide a "Quick View" in the Tools menu, which uses the Previewer plasmoid. X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/a07ea82381c53c3b2a2a73d8637a17bf43038940 Provide a "Quick View" in the Tools menu, which uses the Previewer plasmoid. TODO 1: use the D-Bus interface directly instead of using KRun::runCommand() as workaround. TODO 2: a new icon would be necessary CCMAIL: alediaferia@gmail.com svn path=/trunk/KDE/kdebase/apps/; revision=838039 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 95108724e..3c52e2c71 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -201,9 +201,9 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) updateEditActions(); Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0); - int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls().count(); + int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount(); if (m_viewTab[m_tabIndex].secondaryView != 0) { - selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls().count(); + selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedItemsCount(); } QAction* compareFilesAction = actionCollection()->action("compare_files"); @@ -213,6 +213,9 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) compareFilesAction->setEnabled(false); } + const bool activeViewHasSelection = (activeViewContainer()->view()->selectedItemsCount() > 0); + actionCollection()->action("quick_view")->setEnabled(activeViewHasSelection); + m_activeViewContainer->updateStatusBar(); emit selectionChanged(selection); @@ -626,6 +629,22 @@ void DolphinMainWindow::compareFiles() KRun::runCommand(command, "Kompare", "kompare", this); } +void DolphinMainWindow::quickView() +{ + const KUrl::List urls = activeViewContainer()->view()->selectedUrls(); + Q_ASSERT(urls.count() > 0); + + // TODO: this is a quick hack - use QDBus interface directly in future + const QString command = "qdbus org.kde.plasma /Previewer org.kde.Previewer.openFile"; + foreach (const KUrl& url, urls) { + QString openUrlCommand = command; + openUrlCommand.append(" \""); + openUrlCommand.append(url.prettyUrl()); + openUrlCommand.append('"'); + KRun::runCommand(openUrlCommand, 0, 0, this); + } +} + void DolphinMainWindow::toggleShowMenuBar() { const bool visible = menuBar()->isVisible(); @@ -977,6 +996,13 @@ void DolphinMainWindow::setupActions() compareFiles->setEnabled(false); connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles())); + KAction* quickView = actionCollection()->addAction("quick_view"); + quickView->setText(i18nc("@action:inmenu Tools", "Quick View")); + quickView->setIcon(KIcon("view-preview")); + quickView->setShortcut(Qt::Key_Space); + quickView->setEnabled(false); + connect(quickView, SIGNAL(triggered()), this, SLOT(quickView())); + // setup 'Settings' menu m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection()); KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index c4c05bf83..1676afb7e 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -262,6 +262,12 @@ private slots: /** Opens Kompare for 2 selected files. */ void compareFiles(); + /** + * Initiates a preview of the selected files + * on the desktop by the Previewer plasmoid. + */ + void quickView(); + /** * Hides the menu bar if it is visible, makes the menu bar * visible if it is hidden. diff --git a/src/dolphinui.rc b/src/dolphinui.rc index c951f856b..33172416a 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -73,6 +73,7 @@ +