mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Invert default behavior regarding loading of version control plugins: Only load plugins that have been explicitly enabled by the user instead of loading all plugins per default.
Most users won't use version control plugins at all and there is no need in wasting memory and performance. A user interface has been added in the "Services" settings for version control plugins. The user interface is only shown, if at least one plugin is available on the system. svn path=/trunk/KDE/kdebase/apps/; revision=1111101
This commit is contained in:
parent
f9dd574600
commit
a20edc49bd
|
@ -142,6 +142,7 @@ kde4_add_kcfg_files(dolphin_SRCS
|
|||
panels/folders/dolphin_folderspanelsettings.kcfgc
|
||||
panels/information/dolphin_informationpanelsettings.kcfgc
|
||||
search/dolphin_searchsettings.kcfgc
|
||||
settings/dolphin_versioncontrolsettings.kcfgc
|
||||
)
|
||||
|
||||
if(Nepomuk_FOUND)
|
||||
|
@ -239,7 +240,8 @@ kde4_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
|
|||
settings/dolphin_generalsettings.kcfgc)
|
||||
|
||||
kde4_add_kcfg_files(kcm_dolphinservices_PART_SRCS
|
||||
settings/dolphin_generalsettings.kcfgc)
|
||||
settings/dolphin_generalsettings.kcfgc
|
||||
settings/dolphin_versioncontrolsettings.kcfgc)
|
||||
|
||||
kde4_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
|
||||
settings/dolphin_generalsettings.kcfgc)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<kcfg>
|
||||
<kcfgfile name="dolphinrc"/>
|
||||
<group name="VersionControl">
|
||||
<entry name="disabledPlugins" type="String">
|
||||
<label>Disabled plugins</label>
|
||||
<entry name="enabledPlugins" type="StringList">
|
||||
<label>Enabled plugins</label>
|
||||
<default></default>
|
||||
</entry>
|
||||
</group>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
|
||||
* Copyright (C) 2009-2010 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -19,26 +19,34 @@
|
|||
|
||||
#include "servicessettingspage.h"
|
||||
|
||||
#include "dolphin_versioncontrolsettings.h"
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kdesktopfileactions.h>
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <knewstuff3/knewstuffbutton.h>
|
||||
#include <kservice.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QEvent>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
|
||||
SettingsPageBase(parent),
|
||||
m_initialized(false),
|
||||
m_servicesList(0)
|
||||
m_servicesList(0),
|
||||
m_vcsGroupBox(0),
|
||||
m_vcsPluginsMap(),
|
||||
m_enabledVcsPlugins()
|
||||
{
|
||||
QVBoxLayout* topLayout = new QVBoxLayout(this);
|
||||
|
||||
|
@ -56,11 +64,19 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
|
|||
KNS3::Button* downloadButton = new KNS3::Button(i18nc("@action:button", "Download New Services..."),
|
||||
"servicemenu.knsrc",
|
||||
this);
|
||||
connect(downloadButton, SIGNAL(dialogFinished(const Entry::List&)), this, SLOT(loadServices()));
|
||||
connect(downloadButton, SIGNAL(dialogFinished(KNS3::Entry::List)), this, SLOT(loadServices()));
|
||||
|
||||
m_vcsGroupBox = new QGroupBox(i18nc("@title:group", "Version Control Systems"), this);
|
||||
// Only show the version control group box, if a version
|
||||
// control system could be found (see loadVersionControlSystems())
|
||||
m_vcsGroupBox->hide();
|
||||
|
||||
topLayout->addWidget(label);
|
||||
topLayout->addWidget(m_servicesList);
|
||||
topLayout->addWidget(downloadButton);
|
||||
topLayout->addWidget(m_vcsGroupBox);
|
||||
|
||||
m_enabledVcsPlugins = VersionControlSettings::enabledPlugins();
|
||||
}
|
||||
|
||||
ServicesSettingsPage::~ServicesSettingsPage()
|
||||
|
@ -69,6 +85,7 @@ ServicesSettingsPage::~ServicesSettingsPage()
|
|||
|
||||
void ServicesSettingsPage::applySettings()
|
||||
{
|
||||
// Apply service menu settings
|
||||
KConfig config("kservicemenurc", KConfig::NoGlobals);
|
||||
KConfigGroup showGroup = config.group("Show");
|
||||
|
||||
|
@ -81,6 +98,27 @@ void ServicesSettingsPage::applySettings()
|
|||
}
|
||||
|
||||
showGroup.sync();
|
||||
|
||||
// Apply version control settings
|
||||
QStringList enabledPlugins;
|
||||
QMap<QString, QCheckBox*>::const_iterator it = m_vcsPluginsMap.constBegin();
|
||||
while (it != m_vcsPluginsMap.constEnd()) {
|
||||
if (it.value()->isChecked()) {
|
||||
enabledPlugins.append(it.key());
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
if (m_enabledVcsPlugins != enabledPlugins) {
|
||||
VersionControlSettings::setEnabledPlugins(enabledPlugins);
|
||||
VersionControlSettings::self()->writeConfig();
|
||||
|
||||
KMessageBox::information(window(),
|
||||
i18nc("@info", "Dolphin must be restarted to apply the "
|
||||
"updated version control systems settings."),
|
||||
QString(), // default title
|
||||
QLatin1String("ShowVcsRestartInformation"));
|
||||
}
|
||||
}
|
||||
|
||||
void ServicesSettingsPage::restoreDefaults()
|
||||
|
@ -96,6 +134,7 @@ bool ServicesSettingsPage::event(QEvent* event)
|
|||
{
|
||||
if ((event->type() == QEvent::Polish) && !m_initialized) {
|
||||
QMetaObject::invokeMethod(this, "loadServices", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, "loadVersionControlSystems", Qt::QueuedConnection);
|
||||
m_initialized = true;
|
||||
}
|
||||
return SettingsPageBase::event(event);
|
||||
|
@ -130,6 +169,38 @@ void ServicesSettingsPage::loadServices()
|
|||
}
|
||||
}
|
||||
|
||||
void ServicesSettingsPage::loadVersionControlSystems()
|
||||
{
|
||||
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
|
||||
|
||||
// Create a checkbox for each available version control plugin
|
||||
const KService::List pluginServices = KServiceTypeTrader::self()->query("FileViewVersionControlPlugin");
|
||||
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
|
||||
const QString pluginName = (*it)->name();
|
||||
QCheckBox* checkBox = new QCheckBox(pluginName, m_vcsGroupBox);
|
||||
checkBox->setChecked(enabledPlugins.contains(pluginName));
|
||||
connect(checkBox, SIGNAL(clicked()), this, SIGNAL(changed()));
|
||||
connect(checkBox, SIGNAL(clicked()), this, SLOT(feffi()));
|
||||
m_vcsPluginsMap.insert(pluginName, checkBox);
|
||||
}
|
||||
|
||||
// Add the checkboxes into a grid layout of 2 columns
|
||||
QGridLayout* layout = new QGridLayout(m_vcsGroupBox);
|
||||
const int maxRows = (m_vcsPluginsMap.count() + 1) / 2;
|
||||
|
||||
int index = 0;
|
||||
QMap<QString, QCheckBox*>::const_iterator it = m_vcsPluginsMap.constBegin();
|
||||
while (it != m_vcsPluginsMap.constEnd()) {
|
||||
const int column = index / maxRows;
|
||||
const int row = index % maxRows;
|
||||
layout->addWidget(it.value(), row, column);
|
||||
++it;
|
||||
++index;
|
||||
}
|
||||
|
||||
m_vcsGroupBox->setVisible(!m_vcsPluginsMap.isEmpty());
|
||||
}
|
||||
|
||||
bool ServicesSettingsPage::isInServicesList(const QString& service) const
|
||||
{
|
||||
const int count = m_servicesList->count();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
|
||||
* Copyright (C) 2009-2010 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -21,6 +21,11 @@
|
|||
|
||||
#include <settings/settingspagebase.h>
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
class QCheckBox;
|
||||
class QGroupBox;
|
||||
class QListWidget;
|
||||
|
||||
/**
|
||||
|
@ -49,11 +54,19 @@ private slots:
|
|||
*/
|
||||
void loadServices();
|
||||
|
||||
/**
|
||||
* Loads installed version control systems.
|
||||
*/
|
||||
void loadVersionControlSystems();
|
||||
|
||||
bool isInServicesList(const QString& service) const;
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
QListWidget* m_servicesList;
|
||||
QGroupBox* m_vcsGroupBox;
|
||||
QMap<QString, QCheckBox*> m_vcsPluginsMap;
|
||||
QStringList m_enabledVcsPlugins;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -141,16 +141,7 @@ void VersionControlObserver::verifyDirectory()
|
|||
}
|
||||
|
||||
m_plugin = searchPlugin(versionControlUrl);
|
||||
const bool foundVersionInfo = (m_plugin != 0);
|
||||
if (!foundVersionInfo && m_versionedDirectory) {
|
||||
// Version control systems like Git provide the version information
|
||||
// file only in the root directory. Check whether the version information file can
|
||||
// be found in one of the parent directories.
|
||||
|
||||
// TODO...
|
||||
}
|
||||
|
||||
if (foundVersionInfo) {
|
||||
if (m_plugin != 0) {
|
||||
if (!m_versionedDirectory) {
|
||||
m_versionedDirectory = true;
|
||||
|
||||
|
@ -275,7 +266,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
|
|||
static QList<KVersionControlPlugin*> plugins;
|
||||
|
||||
if (!pluginsAvailable) {
|
||||
// a searching for plugins has already been done, but no
|
||||
// A searching for plugins has already been done, but no
|
||||
// plugins are installed
|
||||
return 0;
|
||||
}
|
||||
|
@ -283,12 +274,11 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
|
|||
if (plugins.isEmpty()) {
|
||||
// No searching for plugins has been done yet. Query the KServiceTypeTrader for
|
||||
// all fileview version control plugins and remember them in 'plugins'.
|
||||
const QString disabledPlugins = VersionControlSettings::disabledPlugins();
|
||||
const QStringList disabledPluginsList = disabledPlugins.split(',');
|
||||
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
|
||||
|
||||
const KService::List pluginServices = KServiceTypeTrader::self()->query("FileViewVersionControlPlugin");
|
||||
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
|
||||
if (!disabledPluginsList.contains((*it)->name())) {
|
||||
if (enabledPlugins.contains((*it)->name())) {
|
||||
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>();
|
||||
Q_ASSERT(plugin != 0);
|
||||
plugins.append(plugin);
|
||||
|
@ -300,15 +290,36 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
|
|||
}
|
||||
}
|
||||
|
||||
// verify whether the current directory contains revision information
|
||||
// Verify whether the current directory contains revision information
|
||||
// like .svn, .git, ...
|
||||
foreach (KVersionControlPlugin* plugin, plugins) {
|
||||
KUrl fileUrl = directory;
|
||||
// Use the KDirLister cache to check for .svn, .git, ... files
|
||||
KUrl dirUrl(directory);
|
||||
KUrl fileUrl = dirUrl;
|
||||
fileUrl.addPath(plugin->fileName());
|
||||
const KFileItem item = m_dirLister->findByUrl(fileUrl);
|
||||
if (!item.isNull()) {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
// Version control systems like Git provide the version information
|
||||
// file only in the root directory. Check whether the version information file can
|
||||
// be found in one of the parent directories. For performance reasons this
|
||||
// step is only done, if the previous directory was marked as versioned by
|
||||
// m_versionedDirectory. Drawback: Until e. g. Git is recognized, the root directory
|
||||
// must be shown at least once.
|
||||
if (m_versionedDirectory) {
|
||||
KUrl upUrl = dirUrl.upUrl();
|
||||
while (upUrl != dirUrl) {
|
||||
const QString filePath = dirUrl.pathOrUrl(KUrl::AddTrailingSlash) + plugin->fileName();
|
||||
QFileInfo file(filePath);
|
||||
if (file.exists()) {
|
||||
return plugin;
|
||||
}
|
||||
dirUrl = upUrl;
|
||||
upUrl = dirUrl.upUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -60,7 +60,7 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
|||
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(view->model());
|
||||
m_toolTipManager = new ToolTipManager(view, proxyModel);
|
||||
|
||||
connect(viewModeController, SIGNAL(hideToolTip()),
|
||||
connect(dolphinViewController, SIGNAL(hideToolTip()),
|
||||
m_toolTipManager, SLOT(hideTip()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue