Fossil: Consolidate optionpage/apply further

Change-Id: I345c6f38421864630d99a45fd2176ba0836536e9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2023-05-15 10:24:35 +02:00
parent fe74e6d43b
commit e6d574ee77
3 changed files with 55 additions and 72 deletions

View File

@@ -190,7 +190,7 @@ public:
FossilSettings m_fossilSettings;
FossilClient m_client{&m_fossilSettings};
OptionsPage optionPage{[this] { configurationChanged(); }, &m_fossilSettings};
OptionsPage optionPage{&m_fossilSettings};
VcsSubmitEditorFactory submitEditorFactory {
submitEditorParameters,
@@ -300,6 +300,9 @@ FossilPluginPrivate::FossilPluginPrivate()
return new FossilJsExtension(&m_fossilSettings);
});
connect(&m_fossilSettings, &AspectContainer::changed,
this, &IVersionControl::configurationChanged);
createMenu(context);
}

View File

@@ -15,8 +15,7 @@
using namespace Utils;
namespace Fossil {
namespace Internal {
namespace Fossil::Internal {
FossilSettings::FossilSettings()
{
@@ -95,35 +94,16 @@ FossilSettings::FossilSettings()
logCount.setLabelText(Tr::tr("Log count:"));
logCount.setToolTip(Tr::tr("The number of recent commit log entries to show. "
"Choose 0 to see all entries."));
};
}
// OptionsPage
class OptionsPageWidget final : public Core::IOptionsPageWidget
{
public:
OptionsPageWidget(const std::function<void()> &onApply, FossilSettings *settings);
void apply() final;
private:
const std::function<void()> m_onApply;
FossilSettings *m_settings;
};
void OptionsPageWidget::apply()
{
if (!m_settings->isDirty())
return;
m_settings->apply();
m_onApply();
}
OptionsPageWidget::OptionsPageWidget(const std::function<void()> &onApply, FossilSettings *settings) :
m_onApply(onApply),
m_settings(settings)
{
FossilSettings &s = *m_settings;
OptionsPageWidget(FossilSettings *settings)
{
FossilSettings &s = *settings;
using namespace Layouting;
@@ -160,15 +140,17 @@ OptionsPageWidget::OptionsPageWidget(const std::function<void()> &onApply, Fossi
st
}.attachTo(this);
}
OptionsPage::OptionsPage(const std::function<void()> &onApply, FossilSettings *settings)
setOnApply([settings] { settings->apply(); });
}
};
OptionsPage::OptionsPage(FossilSettings *settings)
{
setId(Constants::VCS_ID_FOSSIL);
setDisplayName(Tr::tr("Fossil"));
setWidgetCreator([onApply, settings]() { return new OptionsPageWidget(onApply, settings); });
setWidgetCreator([settings] { return new OptionsPageWidget(settings); });
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
}
} // Internal
} // Fossil
} // Fossil::Internal

View File

@@ -6,12 +6,13 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <vcsbase/vcsbaseclientsettings.h>
namespace Fossil {
namespace Internal {
namespace Fossil::Internal {
class FossilSettings : public VcsBase::VcsBaseSettings
{
public:
FossilSettings();
Utils::StringAspect defaultRepoPath;
Utils::StringAspect sslIdentityFile;
Utils::BoolAspect diffIgnoreAllWhiteSpace;
@@ -23,8 +24,6 @@ public:
Utils::BoolAspect timelineVerbose;
Utils::StringAspect timelineItemType;
Utils::BoolAspect disableAutosync;
FossilSettings();
};
struct RepositorySettings
@@ -46,8 +45,7 @@ inline bool operator==(const RepositorySettings &lh, const RepositorySettings &r
class OptionsPage : public Core::IOptionsPage
{
public:
OptionsPage(const std::function<void()> &onApply, FossilSettings *settings);
explicit OptionsPage(FossilSettings *settings);
};
} // namespace Internal
} // namespace Fossil
} // Fossil::Internal