]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Provide a "Quick View" in the Tools menu, which uses the Previewer plasmoid.
authorPeter Penz <peter.penz19@gmail.com>
Sat, 26 Jul 2008 13:49:50 +0000 (13:49 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 26 Jul 2008 13:49:50 +0000 (13:49 +0000)
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

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinui.rc

index 95108724ee4b520e23c8447411c8d83b74d6d5a6..3c52e2c710075d285d40a1b42630f12b613dbb4b 100644 (file)
@@ -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());
index c4c05bf83fa0ec0e316c710c0d6614512c51a59a..1676afb7e1e49e3560f8d7c80444993e50a6223e 100644 (file)
@@ -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.
index c951f856b6df6c2245a9a883e0950cc2e1a6ce41..33172416aaa83da9ac53d99638f09e18ead972b0 100644 (file)
@@ -73,6 +73,7 @@
     <Action name="find_file" />
     <Action name="show_filter_bar" />
     <Action name="compare_files" />
+    <Action name="quick_view" />
   </Menu>
 </MenuBar>
 <State name="new_file" >