From f6c995cdd0a84a7b9f3494597dd1383bee520b68 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 15 May 2023 14:02:10 +0200 Subject: Bazaar: Follow the Fossil settings setup Change-Id: If711f8a43a6579c72cad1bc98ef24c3fdd83993b Reviewed-by: Orgad Shaneh --- src/plugins/bazaar/bazaarclient.cpp | 30 +++++++++++++----------------- src/plugins/bazaar/bazaarclient.h | 4 +--- src/plugins/bazaar/bazaarplugin.cpp | 15 +++++++-------- src/plugins/bazaar/bazaarsettings.cpp | 14 ++++++++++---- src/plugins/bazaar/bazaarsettings.h | 4 +++- 5 files changed, 34 insertions(+), 33 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp index 0b07bcd9ec..303b7e21c2 100644 --- a/src/plugins/bazaar/bazaarclient.cpp +++ b/src/plugins/bazaar/bazaarclient.cpp @@ -29,13 +29,13 @@ namespace Bazaar::Internal { class BazaarDiffConfig : public VcsBaseEditorConfig { public: - BazaarDiffConfig(BazaarSettings &settings, QToolBar *toolBar) : - VcsBaseEditorConfig(toolBar) + explicit BazaarDiffConfig(QToolBar *toolBar) + : VcsBaseEditorConfig(toolBar) { mapSetting(addToggleButton("-w", Tr::tr("Ignore Whitespace")), - &settings.diffIgnoreWhiteSpace); + &settings().diffIgnoreWhiteSpace); mapSetting(addToggleButton("-B", Tr::tr("Ignore Blank Lines")), - &settings.diffIgnoreBlankLines); + &settings().diffIgnoreBlankLines); } QStringList arguments() const override @@ -54,18 +54,18 @@ public: class BazaarLogConfig : public VcsBaseEditorConfig { public: - BazaarLogConfig(BazaarSettings &settings, QToolBar *toolBar) : - VcsBaseEditorConfig(toolBar) + BazaarLogConfig(QToolBar *toolBar) + : VcsBaseEditorConfig(toolBar) { mapSetting(addToggleButton("--verbose", Tr::tr("Verbose"), Tr::tr("Show files changed in each revision.")), - &settings.logVerbose); + &settings().logVerbose); mapSetting(addToggleButton("--forward", Tr::tr("Forward"), Tr::tr("Show from oldest to newest.")), - &settings.logForward); + &settings().logForward); mapSetting(addToggleButton("--include-merges", Tr::tr("Include Merges"), Tr::tr("Show merged revisions.")), - &settings.logIncludeMerges); + &settings().logIncludeMerges); const QList logChoices = { {Tr::tr("Detailed"), "long"}, @@ -74,18 +74,14 @@ public: {Tr::tr("GNU Change Log"), "gnu-changelog"} }; mapSetting(addChoices(Tr::tr("Format"), { "--log-format=%1" }, logChoices), - &settings.logFormat); + &settings().logFormat); } }; -BazaarClient::BazaarClient(BazaarSettings *settings) : VcsBaseClient(settings) +BazaarClient::BazaarClient() : VcsBaseClient(&Internal::settings()) { - setDiffConfigCreator([settings](QToolBar *toolBar) { - return new BazaarDiffConfig(*settings, toolBar); - }); - setLogConfigCreator([settings](QToolBar *toolBar) { - return new BazaarLogConfig(*settings, toolBar); - }); + setDiffConfigCreator([](QToolBar *toolBar) { return new BazaarDiffConfig(toolBar); }); + setLogConfigCreator([](QToolBar *toolBar) { return new BazaarLogConfig(toolBar); }); } BranchInfo BazaarClient::synchronousBranchQuery(const FilePath &repositoryRoot) const diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h index b84484b687..5b6ce1e6d4 100644 --- a/src/plugins/bazaar/bazaarclient.h +++ b/src/plugins/bazaar/bazaarclient.h @@ -9,12 +9,10 @@ namespace Bazaar::Internal { -class BazaarSettings; - class BazaarClient : public VcsBase::VcsBaseClient { public: - explicit BazaarClient(BazaarSettings *settings); + BazaarClient(); BranchInfo synchronousBranchQuery(const Utils::FilePath &repositoryRoot) const; bool synchronousUncommit(const Utils::FilePath &workingDir, diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 097fca1820..0c2d11b9f3 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -215,9 +215,8 @@ public: void createRepositoryActions(const Core::Context &context); // Variables - BazaarSettings m_settings; - BazaarClient m_client{&m_settings}; - BazaarSettingsPage m_settingPage{&m_settings}; + BazaarClient m_client; + BazaarSettingsPage m_settingPage; VcsSubmitEditorFactory m_submitEditorFactory { submitEditorParameters, @@ -372,7 +371,7 @@ BazaarPluginPrivate::BazaarPluginPrivate() toolsMenu->addMenu(m_bazaarContainer); m_menuAction = m_bazaarContainer->menu()->menuAction(); - connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged); + connect(&settings(), &AspectContainer::applied, this, &IVersionControl::configurationChanged); } void BazaarPluginPrivate::createFileActions(const Context &context) @@ -523,7 +522,7 @@ void BazaarPluginPrivate::logRepository() const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); QStringList extraOptions; - extraOptions += "--limit=" + QString::number(m_settings.logCount()); + extraOptions += "--limit=" + QString::number(settings().logCount()); m_client.log(state.topLevel(), QStringList(), extraOptions); } @@ -705,8 +704,8 @@ void BazaarPluginPrivate::showCommitWidget(const QListsetFields(m_submitRepository, branch, - m_settings.userName.value(), - m_settings.userEmail.value(), status); + settings().userName(), + settings().userEmail(), status); } void BazaarPluginPrivate::diffFromEditorSelected(const QStringList &files) @@ -872,7 +871,7 @@ bool BazaarPluginPrivate::managesFile(const FilePath &workingDirectory, const QS bool BazaarPluginPrivate::isConfigured() const { - const FilePath binary = m_settings.binaryPath.filePath(); + const FilePath binary = settings().binaryPath.filePath(); return !binary.isEmpty() && binary.isExecutableFile(); } diff --git a/src/plugins/bazaar/bazaarsettings.cpp b/src/plugins/bazaar/bazaarsettings.cpp index d76cb782fe..394864ea54 100644 --- a/src/plugins/bazaar/bazaarsettings.cpp +++ b/src/plugins/bazaar/bazaarsettings.cpp @@ -70,15 +70,15 @@ BazaarSettings::BazaarSettings() // BazaarSettingsPage -BazaarSettingsPage::BazaarSettingsPage(BazaarSettings *settings) +BazaarSettingsPage::BazaarSettingsPage() { setId(VcsBase::Constants::VCS_ID_BAZAAR); setDisplayName(Tr::tr("Bazaar")); setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); - setSettings(settings); + setSettings(&settings()); - setLayouter([settings](QWidget *widget) { - BazaarSettings &s = *settings; + setLayouter([](QWidget *widget) { + BazaarSettings &s = settings(); using namespace Layouting; Column { @@ -108,4 +108,10 @@ BazaarSettingsPage::BazaarSettingsPage(BazaarSettings *settings) }); } +BazaarSettings &settings() +{ + static BazaarSettings theSettings; + return theSettings; +} + } // Bazaar::Internal diff --git a/src/plugins/bazaar/bazaarsettings.h b/src/plugins/bazaar/bazaarsettings.h index a10828b42d..971147175a 100644 --- a/src/plugins/bazaar/bazaarsettings.h +++ b/src/plugins/bazaar/bazaarsettings.h @@ -22,10 +22,12 @@ public: Utils::StringAspect logFormat; }; +BazaarSettings &settings(); + class BazaarSettingsPage final : public Core::IOptionsPage { public: - explicit BazaarSettingsPage(BazaarSettings *settings); + BazaarSettingsPage(); }; } // Bazaar::Internal -- cgit v1.2.1