]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
Fixed regression when refactoring the Information Panel: Don't forget to give a visua...
[dolphin.git] / src / dolphinviewcontainer.cpp
index 9da51a60c2a7424ee662a71cd4a4f5f7040f4c6f..d8f90f3576f8a28cf729c4bf4c33ccf12c58c6bd 100644 (file)
 #include <kmimetyperesolver.h>
 #include <knewmenu.h>
 #include <konqmimedata.h>
-#include <konq_fileitemcapabilities.h>
+#include <kfileitemlistproperties.h>
 #include <konq_operations.h>
+#include <kshell.h>
 #include <kurl.h>
+#include <kurlcombobox.h>
 #include <krun.h>
 
 #include "dolphinmodel.h"
@@ -87,11 +89,15 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
             this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
     connect(m_urlNavigator, SIGNAL(activated()),
             this, SLOT(activate()));
+    connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+            this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
 
     const GeneralSettings* settings = DolphinSettings::instance().generalSettings();
     m_urlNavigator->setUrlEditable(settings->editableUrl());
     m_urlNavigator->setShowFullPath(settings->showFullPath());
     m_urlNavigator->setHomeUrl(settings->homeUrl());
+    KUrlComboBox* editor = m_urlNavigator->editor();
+    editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
 
     m_dirLister = new DolphinDirLister();
     m_dirLister->setAutoUpdate(true);
@@ -149,6 +155,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
 
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             this, SLOT(restoreView(const KUrl&)));
+    connect(m_urlNavigator, SIGNAL(historyChanged()),
+            this, SLOT(slotHistoryChanged()));
 
     m_statusBar = new DolphinStatusBar(this, m_view);
 
@@ -180,8 +188,8 @@ DolphinViewContainer::~DolphinViewContainer()
 
 void DolphinViewContainer::setUrl(const KUrl& newUrl)
 {
-    m_urlNavigator->setUrl(newUrl);
     if (newUrl != m_urlNavigator->url()) {
+        m_urlNavigator->setUrl(newUrl);
         // Temporary disable the 'File'->'Create New...' menu until
         // the write permissions can be checked in a fast way at
         // DolphinViewContainer::slotDirListerCompleted().
@@ -276,7 +284,7 @@ void DolphinViewContainer::slotDirListerCompleted()
         // it is unclear whether writing is supported
         m_isFolderWritable = true;
     } else {
-        KonqFileItemCapabilities capabilities(KFileItemList() << item);
+        KFileItemListProperties capabilities(KFileItemList() << item);
         m_isFolderWritable = capabilities.supportsWriting();
     }
 
@@ -396,12 +404,18 @@ void DolphinViewContainer::restoreView(const KUrl& url)
             const QString browser = config.readEntry("BrowserApplication");
             if (!browser.isEmpty()) {
                 app = browser;
+                if (app.startsWith('!')) {
+                    // a literal command has been configured, remove the '!' prefix
+                    app = app.mid(1);
+                }
             }
         } else {
             showErrorMessage(i18nc("@info:status",
                                    "Protocol not supported by Dolphin, Konqueror has been launched"));
         }
-        const QString command = app + ' ' + url.pathOrUrl();
+
+        QString secureUrl = KShell::quoteArg(url.pathOrUrl());
+        const QString command = app + ' ' + secureUrl;
         KRun::runCommand(command, app, app, this);
     } else {
         showErrorMessage(i18nc("@info:status", "Invalid protocol"));
@@ -433,6 +447,24 @@ void DolphinViewContainer::requestFocus()
     m_view->setFocus();
 }
 
+void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
+{
+    DolphinSettings& settings = DolphinSettings::instance();
+    settings.generalSettings()->setUrlCompletionMode(completion);
+    settings.save();
+}
+
+void DolphinViewContainer::slotHistoryChanged()
+{
+    const int index = m_urlNavigator->historyIndex();
+    if (index > 0) {
+        // The "Go Forward" action is enabled. Try to mark
+        // the previous directory as active item:
+        const KUrl url = m_urlNavigator->historyUrl(index - 1);
+        m_view->activateItem(url);
+    }
+}
+
 void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
 {
     KUrl url = item.targetUrl();