┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-07-26 13:49:50 +0000
committerPeter Penz <[email protected]>2008-07-26 13:49:50 +0000
commita07ea82381c53c3b2a2a73d8637a17bf43038940 (patch)
tree13e802484b6c17345f92fd44b5de95dc9ce7f552 /src
parentd337ece6df43337eff338758ace5204937a000b7 (diff)
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: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=838039
Diffstat (limited to 'src')
-rw-r--r--src/dolphinmainwindow.cpp30
-rw-r--r--src/dolphinmainwindow.h6
-rw-r--r--src/dolphinui.rc1
3 files changed, 35 insertions, 2 deletions
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
@@ -263,6 +263,12 @@ private slots:
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 @@
<Action name="find_file" />
<Action name="show_filter_bar" />
<Action name="compare_files" />
+ <Action name="quick_view" />
</Menu>
</MenuBar>
<State name="new_file" >