]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / dolphinmainwindow.cpp
index 3c52e2c710075d285d40a1b42630f12b613dbb4b..78e5ab31c3759acb717378689002515dcfd8c7f0 100644 (file)
@@ -75,6 +75,7 @@
 #include <kurl.h>
 #include <kurlcombobox.h>
 
+#include <QDBusMessage>
 #include <QKeyEvent>
 #include <QClipboard>
 #include <QLineEdit>
@@ -277,6 +278,8 @@ void DolphinMainWindow::openNewTab(const KUrl& url)
     viewTab.primaryView->view()->reload();
 
     m_viewTab.append(viewTab);
+    
+    actionCollection()->action("close_tab")->setEnabled(true);
 }
 
 void DolphinMainWindow::toggleActiveView()
@@ -634,14 +637,10 @@ 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";
+    QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.plasma", "/Previewer", "", "openFile");
     foreach (const KUrl& url, urls) {
-        QString openUrlCommand = command;
-        openUrlCommand.append(" \"");
-        openUrlCommand.append(url.prettyUrl());
-        openUrlCommand.append('"');
-        KRun::runCommand(openUrlCommand, 0, 0, this);
+        msg.setArguments(QList<QVariant>() << url.prettyUrl());
+        QDBusConnection::sessionBus().send(msg);
     }
 }
 
@@ -703,7 +702,7 @@ void DolphinMainWindow::closeTab(int index)
     if (index == m_tabIndex) {
         // The tab that should be closed is the active tab. Activate the
         // previous tab before closing the tab.
-        setActiveTab((index > 0) ? index - 1 : 1);
+        m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
     }
 
     // delete tab
@@ -726,6 +725,7 @@ void DolphinMainWindow::closeTab(int index)
     // closing the last tab is not possible
     if (m_viewTab.count() == 1) {
         m_tabBar->removeTab(0);
+        actionCollection()->action("close_tab")->setEnabled(false);
     } else {
         m_tabBar->blockSignals(false);
     }
@@ -774,6 +774,11 @@ void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons butt
     }
 }
 
+void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& canDecode)
+{
+    canDecode = KUrl::List::canDecode(event->mimeData());
+}
+
 void DolphinMainWindow::init()
 {
     DolphinSettings& settings = DolphinSettings::instance();
@@ -818,6 +823,8 @@ void DolphinMainWindow::init()
             this, SLOT(openTabContextMenu(int, const QPoint&)));
     connect(m_tabBar, SIGNAL(newTabRequest()),
             this, SLOT(openNewTab()));
+    connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
+            this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
     m_tabBar->blockSignals(true);  // signals get unblocked after at least 2 tabs are open
 
     QWidget* centralWidget = new QWidget(this);
@@ -832,10 +839,8 @@ void DolphinMainWindow::init()
     setupDockWidgets();
 
     setupGUI(Keys | Save | Create | ToolBar);
-    createGUI();
 
     stateChanged("new_file");
-    setAutoSaveSettings();
 
     QClipboard* clipboard = QApplication::clipboard();
     connect(clipboard, SIGNAL(dataChanged()),
@@ -848,6 +853,9 @@ void DolphinMainWindow::init()
     }
     updateViewActions();
 
+    QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
+    showFilterBarAction->setChecked(generalSettings->filterBar());
+
     if (firstRun) {
         // assure a proper default size if Dolphin runs the first time
         resize(750, 500);
@@ -915,6 +923,7 @@ void DolphinMainWindow::setupActions()
 
     QAction* closeTab = new QAction(KIcon("tab-close"), i18nc("@action:inmenu File", "Close Tab"), this);
     closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
+    closeTab->setEnabled(false);
     connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
     actionCollection()->addAction("close_tab", closeTab);
 
@@ -999,7 +1008,7 @@ void DolphinMainWindow::setupActions()
     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->setShortcut(Qt::CTRL + Qt::Key_Return);
     quickView->setEnabled(false);
     connect(quickView, SIGNAL(triggered()), this, SLOT(quickView()));