forked from qt-creator/qt-creator
Mercurial: Use the new AspectContainer::applied signal
Change-Id: I5c3a60b316f74b4c1fd96d5ddd955f31f18d3010 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -196,8 +196,7 @@ private:
|
|||||||
// Variables
|
// Variables
|
||||||
MercurialSettings m_settings;
|
MercurialSettings m_settings;
|
||||||
MercurialClient m_client{&m_settings};
|
MercurialClient m_client{&m_settings};
|
||||||
|
MercurialSettingsPage m_settingsPage{&m_settings};
|
||||||
OptionsPage m_optionsPage{[this] { configurationChanged(); }, &m_settings};
|
|
||||||
|
|
||||||
Core::CommandLocator *m_commandLocator = nullptr;
|
Core::CommandLocator *m_commandLocator = nullptr;
|
||||||
Core::ActionContainer *m_mercurialContainer = nullptr;
|
Core::ActionContainer *m_mercurialContainer = nullptr;
|
||||||
@@ -282,6 +281,8 @@ MercurialPluginPrivate::MercurialPluginPrivate()
|
|||||||
m_commandLocator->setDescription(tr("Triggers a Mercurial version control operation."));
|
m_commandLocator->setDescription(tr("Triggers a Mercurial version control operation."));
|
||||||
|
|
||||||
createMenu(context);
|
createMenu(context);
|
||||||
|
|
||||||
|
connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MercurialPluginPrivate::createMenu(const Core::Context &context)
|
void MercurialPluginPrivate::createMenu(const Core::Context &context)
|
||||||
|
|||||||
@@ -66,68 +66,45 @@ MercurialSettings::MercurialSettings()
|
|||||||
diffIgnoreBlankLines.setSettingsKey("diffIgnoreBlankLines");
|
diffIgnoreBlankLines.setSettingsKey("diffIgnoreBlankLines");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionpage
|
// MercurialSettingsPage
|
||||||
|
|
||||||
class OptionsPageWidget final : public Core::IOptionsPageWidget
|
MercurialSettingsPage::MercurialSettingsPage(MercurialSettings *settings)
|
||||||
{
|
|
||||||
Q_DECLARE_TR_FUNCTIONS(Mercurial::Internal::OptionsPageWidget)
|
|
||||||
|
|
||||||
public:
|
|
||||||
OptionsPageWidget(const std::function<void()> &onApply, MercurialSettings *settings);
|
|
||||||
void apply() final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::function<void()> m_onApply;
|
|
||||||
MercurialSettings *m_settings;
|
|
||||||
};
|
|
||||||
|
|
||||||
OptionsPageWidget::OptionsPageWidget(const std::function<void()> &onApply, MercurialSettings *settings)
|
|
||||||
: m_onApply(onApply), m_settings(settings)
|
|
||||||
{
|
|
||||||
MercurialSettings &s = *settings;
|
|
||||||
using namespace Layouting;
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Group {
|
|
||||||
Title(tr("Configuration")),
|
|
||||||
Row { s.binaryPath }
|
|
||||||
},
|
|
||||||
|
|
||||||
Group {
|
|
||||||
Title(tr("User")),
|
|
||||||
Form {
|
|
||||||
s.userName,
|
|
||||||
s.userEmail
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
Group {
|
|
||||||
Title(tr("Miscellaneous")),
|
|
||||||
Row {
|
|
||||||
s.logCount,
|
|
||||||
s.timeout,
|
|
||||||
Stretch()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Stretch()
|
|
||||||
|
|
||||||
}.attachTo(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionsPageWidget::apply()
|
|
||||||
{
|
|
||||||
if (!m_settings->isDirty())
|
|
||||||
return;
|
|
||||||
m_settings->apply();
|
|
||||||
m_onApply();
|
|
||||||
}
|
|
||||||
|
|
||||||
OptionsPage::OptionsPage(const std::function<void()> &onApply, MercurialSettings *settings)
|
|
||||||
{
|
{
|
||||||
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
|
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
|
||||||
setDisplayName(OptionsPageWidget::tr("Mercurial"));
|
setDisplayName(MercurialSettings::tr("Mercurial"));
|
||||||
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
||||||
setWidgetCreator([onApply, settings] { return new OptionsPageWidget(onApply, settings); });
|
setSettings(m_settings);
|
||||||
|
|
||||||
|
setLayouter([settings](QWidget *widget) {
|
||||||
|
MercurialSettings &s = *settings;
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
Title(MercurialSettings::tr("Configuration")),
|
||||||
|
Row { s.binaryPath }
|
||||||
|
},
|
||||||
|
|
||||||
|
Group {
|
||||||
|
Title(MercurialSettings::tr("User")),
|
||||||
|
Form {
|
||||||
|
s.userName,
|
||||||
|
s.userEmail
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Group {
|
||||||
|
Title(MercurialSettings::tr("Miscellaneous")),
|
||||||
|
Row {
|
||||||
|
s.logCount,
|
||||||
|
s.timeout,
|
||||||
|
Stretch()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Stretch()
|
||||||
|
|
||||||
|
}.attachTo(widget);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ public:
|
|||||||
MercurialSettings();
|
MercurialSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsPage final : public Core::IOptionsPage
|
class MercurialSettingsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OptionsPage(const std::function<void()> &onApply, MercurialSettings *settings);
|
explicit MercurialSettingsPage(MercurialSettings *settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user