┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/dolphin_versioncontrolsettings.kcfg4
-rw-r--r--src/settings/servicessettingspage.cpp79
-rw-r--r--src/settings/servicessettingspage.h15
3 files changed, 91 insertions, 7 deletions
diff --git a/src/settings/dolphin_versioncontrolsettings.kcfg b/src/settings/dolphin_versioncontrolsettings.kcfg
index 4f55a9a03..4fd5400e5 100644
--- a/src/settings/dolphin_versioncontrolsettings.kcfg
+++ b/src/settings/dolphin_versioncontrolsettings.kcfg
@@ -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>
diff --git a/src/settings/servicessettingspage.cpp b/src/settings/servicessettingspage.cpp
index a5e19725a..726239dbc 100644
--- a/src/settings/servicessettingspage.cpp
+++ b/src/settings/servicessettingspage.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Peter Penz <[email protected]> *
+ * Copyright (C) 2009-2010 by Peter Penz <[email protected]> *
* *
* 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();
diff --git a/src/settings/servicessettingspage.h b/src/settings/servicessettingspage.h
index 9a3832e70..d2787e09b 100644
--- a/src/settings/servicessettingspage.h
+++ b/src/settings/servicessettingspage.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Peter Penz <[email protected]> *
+ * Copyright (C) 2009-2010 by Peter Penz <[email protected]> *
* *
* 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