forked from qt-creator/qt-creator
Vcs: Move handling of settings from VcsBaseClient to VcsBaseClientImpl
... and update users of that functionality accordingly. Unexpected plus: Now every supported VCS actually saves their setting when requested. Change-Id: I02db7b2ce14e5f52d26409b2a01aea290c2a294a Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "clonewizard.h"
|
||||
#include "clonewizardpage.h"
|
||||
#include "mercurialclient.h"
|
||||
#include "mercurialplugin.h"
|
||||
#include "mercurialsettings.h"
|
||||
|
||||
@@ -74,7 +75,7 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
if (!cwp)
|
||||
return 0;
|
||||
|
||||
const MercurialSettings &settings = MercurialPlugin::settings();
|
||||
const VcsBaseClientSettings &settings = MercurialPlugin::client()->settings();
|
||||
|
||||
QString path = cwp->path();
|
||||
QString directory = cwp->directory();
|
||||
|
||||
@@ -58,25 +58,20 @@ class MercurialDiffParameterWidget : public VcsBaseEditorParameterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MercurialDiffParameterWidget(MercurialSettings *settings, QWidget *parent = 0) :
|
||||
MercurialDiffParameterWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) :
|
||||
VcsBaseEditorParameterWidget(parent)
|
||||
{
|
||||
mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")),
|
||||
settings->boolPointer(MercurialSettings::diffIgnoreWhiteSpaceKey));
|
||||
settings.boolPointer(MercurialSettings::diffIgnoreWhiteSpaceKey));
|
||||
mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")),
|
||||
settings->boolPointer(MercurialSettings::diffIgnoreBlankLinesKey));
|
||||
settings.boolPointer(MercurialSettings::diffIgnoreBlankLinesKey));
|
||||
}
|
||||
};
|
||||
|
||||
MercurialClient::MercurialClient(MercurialSettings *settings) :
|
||||
VcsBaseClient(settings)
|
||||
MercurialClient::MercurialClient() :
|
||||
VcsBaseClient(new MercurialSettings)
|
||||
{
|
||||
setDiffParameterWidgetCreator([=] { return new MercurialDiffParameterWidget(settings); });
|
||||
}
|
||||
|
||||
MercurialSettings *MercurialClient::settings() const
|
||||
{
|
||||
return dynamic_cast<MercurialSettings *>(VcsBaseClient::settings());
|
||||
setDiffParameterWidgetCreator([this] { return new MercurialDiffParameterWidget(settings()); });
|
||||
}
|
||||
|
||||
bool MercurialClient::manifestSync(const QString &repository, const QString &relativeFilename)
|
||||
|
||||
@@ -42,9 +42,7 @@ class MercurialClient : public VcsBase::VcsBaseClient
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MercurialClient(MercurialSettings *settings);
|
||||
|
||||
MercurialSettings *settings() const;
|
||||
MercurialClient();
|
||||
|
||||
bool synchronousClone(const QString &workingDir,
|
||||
const QString &srcLocation,
|
||||
|
||||
@@ -98,7 +98,7 @@ bool MercurialControl::managesFile(const QString &workingDirectory, const QStrin
|
||||
|
||||
bool MercurialControl::isConfigured() const
|
||||
{
|
||||
const Utils::FileName binary = mercurialClient->settings()->binaryPath();
|
||||
const Utils::FileName binary = mercurialClient->vcsBinary();
|
||||
if (binary.isEmpty())
|
||||
return false;
|
||||
QFileInfo fi = binary.toFileInfo();
|
||||
@@ -186,10 +186,5 @@ void MercurialControl::changed(const QVariant &v)
|
||||
}
|
||||
}
|
||||
|
||||
void MercurialControl::emitConfigurationChanged()
|
||||
{
|
||||
emit configurationChanged();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Mercurial
|
||||
|
||||
@@ -70,7 +70,6 @@ public slots:
|
||||
// files changed signals according to the variant's type:
|
||||
// String -> repository, StringList -> files
|
||||
void changed(const QVariant&);
|
||||
void emitConfigurationChanged();
|
||||
|
||||
private:
|
||||
MercurialClient *mercurialClient;
|
||||
|
||||
@@ -136,12 +136,11 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
{
|
||||
Core::Context context(Constants::MERCURIAL_CONTEXT);
|
||||
|
||||
m_client = new MercurialClient(&mercurialSettings);
|
||||
m_client = new MercurialClient;
|
||||
initializeVcs(new MercurialControl(m_client), context);
|
||||
|
||||
optionsPage = new OptionsPage();
|
||||
addAutoReleasedObject(optionsPage);
|
||||
mercurialSettings.readSettings(core->settings());
|
||||
|
||||
connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant)));
|
||||
connect(m_client, SIGNAL(needUpdate()), this, SLOT(update()));
|
||||
@@ -176,19 +175,6 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
return true;
|
||||
}
|
||||
|
||||
const MercurialSettings &MercurialPlugin::settings()
|
||||
{
|
||||
return m_instance->mercurialSettings;
|
||||
}
|
||||
|
||||
void MercurialPlugin::setSettings(const MercurialSettings &settings)
|
||||
{
|
||||
if (settings != m_instance->mercurialSettings) {
|
||||
m_instance->mercurialSettings = settings;
|
||||
static_cast<MercurialControl *>(m_instance->versionControl())->emitConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void MercurialPlugin::createMenu(const Core::Context &context)
|
||||
{
|
||||
// Create menu item for Mercurial
|
||||
|
||||
@@ -75,9 +75,6 @@ public:
|
||||
static MercurialPlugin *instance() { return m_instance; }
|
||||
static MercurialClient *client() { return m_instance->m_client; }
|
||||
|
||||
static const MercurialSettings &settings();
|
||||
static void setSettings(const MercurialSettings &settings);
|
||||
|
||||
private slots:
|
||||
// File menu action slots
|
||||
void addCurrentFile();
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "optionspage.h"
|
||||
|
||||
#include "mercurialclient.h"
|
||||
#include "mercurialsettings.h"
|
||||
#include "mercurialplugin.h"
|
||||
|
||||
@@ -38,6 +40,8 @@
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace VcsBase;
|
||||
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
@@ -50,9 +54,9 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent) :
|
||||
m_ui.commandChooser->setPromptDialogTitle(tr("Mercurial Command"));
|
||||
}
|
||||
|
||||
MercurialSettings OptionsPageWidget::settings() const
|
||||
VcsBaseClientSettings OptionsPageWidget::settings() const
|
||||
{
|
||||
MercurialSettings s = MercurialPlugin::settings();
|
||||
MercurialSettings s;
|
||||
s.setValue(MercurialSettings::binaryPathKey, m_ui.commandChooser->rawPath());
|
||||
s.setValue(MercurialSettings::userNameKey, m_ui.defaultUsernameLineEdit->text().trimmed());
|
||||
s.setValue(MercurialSettings::userEmailKey, m_ui.defaultEmailLineEdit->text().trimmed());
|
||||
@@ -61,7 +65,7 @@ MercurialSettings OptionsPageWidget::settings() const
|
||||
return s;
|
||||
}
|
||||
|
||||
void OptionsPageWidget::setSettings(const MercurialSettings &s)
|
||||
void OptionsPageWidget::setSettings(const VcsBaseClientSettings &s)
|
||||
{
|
||||
m_ui.commandChooser->setPath(s.stringValue(MercurialSettings::binaryPathKey));
|
||||
m_ui.defaultUsernameLineEdit->setText(s.stringValue(MercurialSettings::userNameKey));
|
||||
@@ -80,7 +84,7 @@ QWidget *OptionsPage::widget()
|
||||
{
|
||||
if (!optionsPageWidget)
|
||||
optionsPageWidget = new OptionsPageWidget;
|
||||
optionsPageWidget->setSettings(MercurialPlugin::settings());
|
||||
optionsPageWidget->setSettings(MercurialPlugin::client()->settings());
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
@@ -88,13 +92,15 @@ void OptionsPage::apply()
|
||||
{
|
||||
if (!optionsPageWidget)
|
||||
return;
|
||||
const MercurialSettings newSettings = optionsPageWidget->settings();
|
||||
if (newSettings != MercurialPlugin::settings()) {
|
||||
//assume success and emit signal that settings are changed;
|
||||
MercurialPlugin::setSettings(newSettings);
|
||||
newSettings.writeSettings(Core::ICore::settings());
|
||||
|
||||
const VcsBaseClientSettings newSettings = optionsPageWidget->settings();
|
||||
VcsBaseClientSettings &s = MercurialPlugin::instance()->client()->settings();
|
||||
if (s != newSettings) {
|
||||
s = newSettings;
|
||||
s.writeSettings(Core::ICore::settings());
|
||||
emit settingsChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OptionsPage::finish()
|
||||
|
||||
@@ -38,11 +38,13 @@
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
|
||||
namespace VcsBase {
|
||||
class VcsBaseClientSettings;
|
||||
} // namespace VcsBase
|
||||
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
class MercurialSettings;
|
||||
|
||||
class OptionsPageWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -50,8 +52,8 @@ class OptionsPageWidget : public QWidget
|
||||
public:
|
||||
explicit OptionsPageWidget(QWidget *parent = 0);
|
||||
|
||||
MercurialSettings settings() const;
|
||||
void setSettings(const MercurialSettings &s);
|
||||
VcsBase::VcsBaseClientSettings settings() const;
|
||||
void setSettings(const VcsBase::VcsBaseClientSettings &s);
|
||||
|
||||
private:
|
||||
Ui::OptionsPage m_ui;
|
||||
|
||||
Reference in New Issue
Block a user