From: Peter Penz Date: Sat, 28 Jun 2008 18:42:51 +0000 (+0000) Subject: Don't check for "kompare" each time 2 items are selected (thanks to Andreas Scherf... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/c446e29bc39d136c913df87635a5c36b9f077b3e?ds=inline Don't check for "kompare" each time 2 items are selected (thanks to Andreas Scherf). As Albert Astals Cid pointed out it might be nicer to use a menu plugin instead of hardcoding "kompare" (> KDE 4.1). CCMAIL: scherfa@arcor.de svn path=/trunk/KDE/kdebase/apps/; revision=825587 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 57926d33e..14c086339 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -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() { diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 71d7b52d1..db8034139 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -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