forked from qt-creator/qt-creator
Vcs: Pass settings handles to settings pages more directly
Change-Id: I5fdec80de5678dd544713fc18335cbd805d7b9f4 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -220,7 +220,7 @@ CvsPluginPrivate::CvsPluginPrivate()
|
|||||||
|
|
||||||
m_client = new CvsClient(&m_settings);
|
m_client = new CvsClient(&m_settings);
|
||||||
|
|
||||||
new SettingsPage(versionControl(), this);
|
new SettingsPage(versionControl(), &m_settings, this);
|
||||||
|
|
||||||
new VcsSubmitEditorFactory(&submitParameters,
|
new VcsSubmitEditorFactory(&submitParameters,
|
||||||
[]() { return new CvsSubmitEditor(&submitParameters); }, this);
|
[]() { return new CvsSubmitEditor(&submitParameters); }, this);
|
||||||
|
@@ -87,8 +87,8 @@ void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s)
|
|||||||
m_ui.describeByCommitIdCheckBox->setChecked(s.boolValue(CvsSettings::describeByCommitIdKey));
|
m_ui.describeByCommitIdCheckBox->setChecked(s.boolValue(CvsSettings::describeByCommitIdKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsPage::SettingsPage(Core::IVersionControl *control, QObject *parent) :
|
SettingsPage::SettingsPage(Core::IVersionControl *control, CvsSettings *settings, QObject *parent) :
|
||||||
VcsClientOptionsPage(control, CvsPluginPrivate::instance()->client(), parent)
|
VcsClientOptionsPage(control, settings, parent)
|
||||||
{
|
{
|
||||||
setId(VcsBase::Constants::VCS_ID_CVS);
|
setId(VcsBase::Constants::VCS_ID_CVS);
|
||||||
setDisplayName(SettingsPageWidget::tr("CVS"));
|
setDisplayName(SettingsPageWidget::tr("CVS"));
|
||||||
|
@@ -30,10 +30,12 @@
|
|||||||
namespace Cvs {
|
namespace Cvs {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class CvsSettings;
|
||||||
|
|
||||||
class SettingsPage final : public VcsBase::VcsClientOptionsPage
|
class SettingsPage final : public VcsBase::VcsClientOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SettingsPage(Core::IVersionControl *control, QObject *parent);
|
SettingsPage(Core::IVersionControl *control, CvsSettings *settings, QObject *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Cvs
|
} // namespace Cvs
|
||||||
|
@@ -772,7 +772,7 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD
|
|||||||
|
|
||||||
// ---------------- GitClient
|
// ---------------- GitClient
|
||||||
|
|
||||||
GitClient::GitClient() : VcsBase::VcsBaseClientImpl(new GitSettings),
|
GitClient::GitClient(GitSettings *settings) : VcsBase::VcsBaseClientImpl(settings),
|
||||||
m_cachedGitVersion(0),
|
m_cachedGitVersion(0),
|
||||||
m_disableEditor(false)
|
m_disableEditor(false)
|
||||||
{
|
{
|
||||||
|
@@ -136,7 +136,7 @@ public:
|
|||||||
PushAction m_pushAction = NoPush;
|
PushAction m_pushAction = NoPush;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit GitClient();
|
explicit GitClient(GitSettings *settings);
|
||||||
|
|
||||||
Utils::FilePath vcsBinary() const override;
|
Utils::FilePath vcsBinary() const override;
|
||||||
unsigned gitVersion(QString *errorMessage = nullptr) const;
|
unsigned gitVersion(QString *errorMessage = nullptr) const;
|
||||||
|
@@ -319,13 +319,13 @@ GitPluginPrivate::GitPluginPrivate()
|
|||||||
|
|
||||||
Context context(Constants::GIT_CONTEXT);
|
Context context(Constants::GIT_CONTEXT);
|
||||||
|
|
||||||
m_gitClient = new GitClient;
|
m_gitClient = new GitClient(&m_settings);
|
||||||
|
|
||||||
auto vc = new GitVersionControl(m_gitClient);
|
auto vc = new GitVersionControl(m_gitClient);
|
||||||
initializeVcs(vc, context);
|
initializeVcs(vc, context);
|
||||||
|
|
||||||
// Create the settings Page
|
// Create the settings Page
|
||||||
auto settingsPage = new SettingsPage(vc, this);
|
auto settingsPage = new SettingsPage(vc, &m_settings, this);
|
||||||
connect(settingsPage, &SettingsPage::settingsChanged,
|
connect(settingsPage, &SettingsPage::settingsChanged,
|
||||||
this, &GitPluginPrivate::updateRepositoryBrowserAction);
|
this, &GitPluginPrivate::updateRepositoryBrowserAction);
|
||||||
|
|
||||||
|
@@ -197,6 +197,7 @@ private:
|
|||||||
Utils::ParameterAction *m_applyCurrentFilePatchAction = nullptr;
|
Utils::ParameterAction *m_applyCurrentFilePatchAction = nullptr;
|
||||||
Gerrit::Internal::GerritPlugin *m_gerritPlugin = nullptr;
|
Gerrit::Internal::GerritPlugin *m_gerritPlugin = nullptr;
|
||||||
|
|
||||||
|
GitSettings m_settings;
|
||||||
GitClient *m_gitClient = nullptr;
|
GitClient *m_gitClient = nullptr;
|
||||||
QPointer<StashDialog> m_stashDialog;
|
QPointer<StashDialog> m_stashDialog;
|
||||||
QPointer<BranchViewFactory> m_branchViewFactory;
|
QPointer<BranchViewFactory> m_branchViewFactory;
|
||||||
|
@@ -123,8 +123,8 @@ void SettingsPageWidget::updateNoteField()
|
|||||||
|
|
||||||
// -------- SettingsPage
|
// -------- SettingsPage
|
||||||
|
|
||||||
SettingsPage::SettingsPage(Core::IVersionControl *control, QObject *parent) :
|
SettingsPage::SettingsPage(Core::IVersionControl *control, GitSettings *settings, QObject *parent) :
|
||||||
VcsClientOptionsPage(control, GitPluginPrivate::client(), parent)
|
VcsClientOptionsPage(control, settings, parent)
|
||||||
{
|
{
|
||||||
setId(VcsBase::Constants::VCS_ID_GIT);
|
setId(VcsBase::Constants::VCS_ID_GIT);
|
||||||
setDisplayName(SettingsPageWidget::tr("Git"));
|
setDisplayName(SettingsPageWidget::tr("Git"));
|
||||||
|
@@ -30,10 +30,12 @@
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class GitSettings;
|
||||||
|
|
||||||
class SettingsPage final : public VcsBase::VcsClientOptionsPage
|
class SettingsPage final : public VcsBase::VcsClientOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SettingsPage(Core::IVersionControl *control, QObject *parent);
|
SettingsPage(Core::IVersionControl *control, GitSettings *settings, QObject *parent);
|
||||||
void apply() final;
|
void apply() final;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -96,8 +96,8 @@ void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s)
|
|||||||
m_ui.logCountSpinBox->setValue(s.intValue(SubversionSettings::logCountKey));
|
m_ui.logCountSpinBox->setValue(s.intValue(SubversionSettings::logCountKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsPage::SettingsPage(Core::IVersionControl *control, QObject *parent) :
|
SettingsPage::SettingsPage(Core::IVersionControl *control, SubversionSettings *settings, QObject *parent) :
|
||||||
VcsClientOptionsPage(control, SubversionPluginPrivate::instance()->client(), parent)
|
VcsClientOptionsPage(control, settings, parent)
|
||||||
{
|
{
|
||||||
setId(VcsBase::Constants::VCS_ID_SUBVERSION);
|
setId(VcsBase::Constants::VCS_ID_SUBVERSION);
|
||||||
setDisplayName(SettingsPageWidget::tr("Subversion"));
|
setDisplayName(SettingsPageWidget::tr("Subversion"));
|
||||||
|
@@ -30,10 +30,12 @@
|
|||||||
namespace Subversion {
|
namespace Subversion {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class SubversionSettings;
|
||||||
|
|
||||||
class SettingsPage final : public VcsBase::VcsClientOptionsPage
|
class SettingsPage final : public VcsBase::VcsClientOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SettingsPage(Core::IVersionControl *control, QObject *parent);
|
SettingsPage(Core::IVersionControl *control, SubversionSettings *settings, QObject *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Subversion
|
} // namespace Subversion
|
||||||
|
@@ -231,7 +231,7 @@ SubversionPluginPrivate::SubversionPluginPrivate() :
|
|||||||
|
|
||||||
m_client = new SubversionClient(&m_settings);
|
m_client = new SubversionClient(&m_settings);
|
||||||
|
|
||||||
new SettingsPage(versionControl(), this);
|
new SettingsPage(versionControl(), &m_settings, this);
|
||||||
|
|
||||||
new VcsSubmitEditorFactory(&submitParameters,
|
new VcsSubmitEditorFactory(&submitParameters,
|
||||||
[]() { return new SubversionSubmitEditor(&submitParameters); }, this);
|
[]() { return new SubversionSubmitEditor(&submitParameters); }, this);
|
||||||
|
@@ -46,12 +46,12 @@ namespace VcsBase {
|
|||||||
|
|
||||||
VcsClientOptionsPageWidget::VcsClientOptionsPageWidget() = default;
|
VcsClientOptionsPageWidget::VcsClientOptionsPageWidget() = default;
|
||||||
|
|
||||||
VcsClientOptionsPage::VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientImpl *client,
|
VcsClientOptionsPage::VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientSettings *settings,
|
||||||
QObject *parent) :
|
QObject *parent) :
|
||||||
Core::IOptionsPage(parent),
|
Core::IOptionsPage(parent),
|
||||||
m_client(client)
|
m_settings(settings)
|
||||||
{
|
{
|
||||||
QTC_CHECK(m_client);
|
QTC_CHECK(m_settings);
|
||||||
connect(this, &VcsClientOptionsPage::settingsChanged,
|
connect(this, &VcsClientOptionsPage::settingsChanged,
|
||||||
control, &Core::IVersionControl::configurationChanged);
|
control, &Core::IVersionControl::configurationChanged);
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ VcsClientOptionsPageWidget *VcsClientOptionsPage::widget()
|
|||||||
if (!m_widget)
|
if (!m_widget)
|
||||||
m_widget = m_factory();
|
m_widget = m_factory();
|
||||||
QTC_ASSERT(m_widget, return nullptr);
|
QTC_ASSERT(m_widget, return nullptr);
|
||||||
m_widget->setSettings(m_client->settings());
|
m_widget->setSettings(*m_settings);
|
||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,9 +76,8 @@ void VcsClientOptionsPage::apply()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(m_widget, return);
|
QTC_ASSERT(m_widget, return);
|
||||||
const VcsBaseClientSettings newSettings = m_widget->settings();
|
const VcsBaseClientSettings newSettings = m_widget->settings();
|
||||||
VcsBaseClientSettings &s = m_client->settings();
|
if (*m_settings != newSettings) {
|
||||||
if (s != newSettings) {
|
*m_settings = newSettings;
|
||||||
s = newSettings;
|
|
||||||
emit settingsChanged();
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,16 +31,12 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace Core { class IVersionControl; }
|
namespace Core { class IVersionControl; }
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
class VcsBaseClientImpl;
|
|
||||||
|
|
||||||
class VCSBASE_EXPORT VcsClientOptionsPageWidget : public Core::IOptionsPageWidget
|
class VCSBASE_EXPORT VcsClientOptionsPageWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -61,7 +57,7 @@ class VCSBASE_EXPORT VcsClientOptionsPage : public Core::IOptionsPage
|
|||||||
public:
|
public:
|
||||||
using WidgetFactory = std::function<VcsClientOptionsPageWidget *()>;
|
using WidgetFactory = std::function<VcsClientOptionsPageWidget *()>;
|
||||||
|
|
||||||
explicit VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientImpl *client, QObject *parent = nullptr);
|
explicit VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientSettings *settings, QObject *parent = nullptr);
|
||||||
|
|
||||||
VcsClientOptionsPageWidget *widget() override;
|
VcsClientOptionsPageWidget *widget() override;
|
||||||
void apply() override;
|
void apply() override;
|
||||||
@@ -76,7 +72,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
WidgetFactory m_factory;
|
WidgetFactory m_factory;
|
||||||
VcsClientOptionsPageWidget *m_widget = nullptr;
|
VcsClientOptionsPageWidget *m_widget = nullptr;
|
||||||
VcsBaseClientImpl *const m_client;
|
VcsBaseClientSettings *const m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
Reference in New Issue
Block a user