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