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);
}
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()
{
/** 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