]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Don't check for "kompare" each time 2 items are selected (thanks to Andreas Scherf...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 28 Jun 2008 18:42:51 +0000 (18:42 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 28 Jun 2008 18:42:51 +0000 (18:42 +0000)
CCMAIL: scherfa@arcor.de

svn path=/trunk/KDE/kdebase/apps/; revision=825587

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index 57926d33ec9901f7f2fe61b3046119b1d22108dc..14c086339576a2f4a24e1d4403762c2044073ba0 100644 (file)
@@ -209,8 +209,7 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
 
     QAction* compareFilesAction = actionCollection()->action("compare_files");
     if (selectedUrlsCount == 2) {
-        const bool kompareInstalled = !KGlobal::dirs()->findExe("kompare").isEmpty();
-        compareFilesAction->setEnabled(selectedUrlsCount == 2 && kompareInstalled);
+        compareFilesAction->setEnabled(isKompareInstalled());
     } else {
         compareFilesAction->setEnabled(false);
     }
@@ -1210,6 +1209,19 @@ QString DolphinMainWindow::tabName(const KUrl& url) const
     return name;
 }
 
+bool DolphinMainWindow::isKompareInstalled() const
+{
+    static bool initialized = false;
+    static bool installed = false;
+    if (!initialized) {
+        // TODO: maybe replace this approach later by using a menu
+        // plugin like kdiff3plugin.cpp
+        installed = !KGlobal::dirs()->findExe("kompare").isEmpty();
+        initialized = true;
+    }
+    return installed;
+}
+
 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
     KIO::FileUndoManager::UiInterface()
 {
index 71d7b52d187cbbfa6d45005fae280b8f8c9311a9..db8034139876310055742ed308d6bf38ac1032b9 100644 (file)
@@ -383,6 +383,8 @@ private:
     /** Returns the name of the tab for the URL \a url. */
     QString tabName(const KUrl& url) const;
 
+    bool isKompareInstalled() const;
+
 private:
     /**
      * Implements a custom error handling for the undo manager. This