forked from qt-creator/qt-creator
Bazaar: Use the new AspectContainer::applied signal
Also, remove unused BazaarSettings::sameUserId() Change-Id: Ie3e39f2dff506932a2b6ef0a3dbffae9e40db64c Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -205,8 +205,7 @@ public:
|
||||
// Variables
|
||||
BazaarSettings m_settings;
|
||||
BazaarClient m_client{&m_settings};
|
||||
|
||||
OptionsPage m_optionsPage{[this] { configurationChanged(); }, &m_settings};
|
||||
BazaarSettingsPage m_settingPage{&m_settings};
|
||||
|
||||
VcsSubmitEditorFactory m_submitEditorFactory {
|
||||
submitEditorParameters,
|
||||
@@ -337,6 +336,8 @@ BazaarPluginPrivate::BazaarPluginPrivate()
|
||||
ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||
toolsMenu->addMenu(m_bazaarContainer);
|
||||
m_menuAction = m_bazaarContainer->menu()->menuAction();
|
||||
|
||||
connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged);
|
||||
}
|
||||
|
||||
void BazaarPluginPrivate::createFileActions(const Context &context)
|
||||
|
||||
@@ -91,75 +91,45 @@ BazaarSettings::BazaarSettings()
|
||||
timeout.setSuffix(tr("s"));
|
||||
}
|
||||
|
||||
bool BazaarSettings::sameUserId(const BazaarSettings &other) const
|
||||
{
|
||||
return userName.value() == other.userName.value()
|
||||
&& userEmail.value() == other.userEmail.value();
|
||||
}
|
||||
// BazaarSettingsPage
|
||||
|
||||
// OptionsPage
|
||||
|
||||
class OptionsPageWidget final : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Bazaar::Internal::OptionsPageWidget)
|
||||
|
||||
public:
|
||||
OptionsPageWidget(const std::function<void()> &onApply, BazaarSettings *settings);
|
||||
|
||||
void apply() final;
|
||||
|
||||
private:
|
||||
const std::function<void()> m_onApply;
|
||||
BazaarSettings *m_settings;
|
||||
};
|
||||
|
||||
void OptionsPageWidget::apply()
|
||||
{
|
||||
if (!m_settings->isDirty())
|
||||
return;
|
||||
m_settings->apply();
|
||||
m_onApply();
|
||||
}
|
||||
|
||||
OptionsPageWidget::OptionsPageWidget(const std::function<void(void)> &onApply, BazaarSettings *settings)
|
||||
: m_onApply(onApply), m_settings(settings)
|
||||
{
|
||||
BazaarSettings &s = *m_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);
|
||||
}
|
||||
|
||||
OptionsPage::OptionsPage(const std::function<void(void)> &onApply, BazaarSettings *settings)
|
||||
BazaarSettingsPage::BazaarSettingsPage(BazaarSettings *settings)
|
||||
{
|
||||
setId(VcsBase::Constants::VCS_ID_BAZAAR);
|
||||
setDisplayName(OptionsPageWidget::tr("Bazaar"));
|
||||
setWidgetCreator([onApply, settings] { return new OptionsPageWidget(onApply, settings); });
|
||||
setDisplayName(BazaarSettings::tr("Bazaar"));
|
||||
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
||||
setSettings(settings);
|
||||
|
||||
setLayouter([settings](QWidget *widget) {
|
||||
BazaarSettings &s = *settings;
|
||||
using namespace Layouting;
|
||||
|
||||
Column {
|
||||
Group {
|
||||
Title(BazaarSettings::tr("Configuration")),
|
||||
Row { s.binaryPath }
|
||||
},
|
||||
|
||||
Group {
|
||||
Title(BazaarSettings::tr("User")),
|
||||
Form {
|
||||
s.userName,
|
||||
s.userEmail
|
||||
}
|
||||
},
|
||||
|
||||
Group {
|
||||
Title(BazaarSettings::tr("Miscellaneous")),
|
||||
Row {
|
||||
s.logCount,
|
||||
s.timeout,
|
||||
Stretch()
|
||||
}
|
||||
},
|
||||
Stretch()
|
||||
|
||||
}.attachTo(widget);
|
||||
});
|
||||
}
|
||||
|
||||
} // Internal
|
||||
|
||||
@@ -27,31 +27,28 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
|
||||
#include <vcsbase/vcsbaseclientsettings.h>
|
||||
|
||||
namespace Bazaar {
|
||||
namespace Internal {
|
||||
|
||||
class BazaarSettings : public VcsBase::VcsBaseSettings
|
||||
class BazaarSettings final : public VcsBase::VcsBaseSettings
|
||||
{
|
||||
public:
|
||||
BazaarSettings();
|
||||
|
||||
Utils::BoolAspect diffIgnoreWhiteSpace;
|
||||
Utils::BoolAspect diffIgnoreBlankLines;
|
||||
Utils::BoolAspect logVerbose;
|
||||
Utils::BoolAspect logForward;
|
||||
Utils::BoolAspect logIncludeMerges;
|
||||
Utils::StringAspect logFormat;
|
||||
|
||||
BazaarSettings();
|
||||
bool sameUserId(const BazaarSettings &other) const;
|
||||
};
|
||||
|
||||
class OptionsPage final : public Core::IOptionsPage
|
||||
class BazaarSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
OptionsPage(const std::function<void()> &onApply, BazaarSettings *settings);
|
||||
explicit BazaarSettingsPage(BazaarSettings *settings);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user