From ea431eede1e5deada06e1cc89ef92775de7bc01e Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 19 Mar 2021 16:07:25 +0100 Subject: [PATCH] Fossil: Aspectify settings Change-Id: I090cf3c63cd705220abb09e5d58eef89e9b55147 Reviewed-by: Orgad Shaneh --- plugins/fossil/CMakeLists.txt | 1 - plugins/fossil/fossil.pro | 3 - plugins/fossil/fossil.qbs | 1 - plugins/fossil/fossilclient.cpp | 57 ++--- plugins/fossil/fossilclient.h | 2 + plugins/fossil/fossilcommitwidget.cpp | 3 +- plugins/fossil/fossilplugin.cpp | 17 +- plugins/fossil/fossilplugin.h | 7 - plugins/fossil/fossilsettings.cpp | 192 +++++++++++++--- plugins/fossil/fossilsettings.h | 31 ++- plugins/fossil/optionspage.cpp | 103 --------- plugins/fossil/optionspage.h | 42 ---- plugins/fossil/optionspage.ui | 229 -------------------- plugins/fossil/wizard/fossiljsextension.cpp | 12 +- 14 files changed, 227 insertions(+), 473 deletions(-) delete mode 100644 plugins/fossil/optionspage.cpp delete mode 100644 plugins/fossil/optionspage.h delete mode 100644 plugins/fossil/optionspage.ui diff --git a/plugins/fossil/CMakeLists.txt b/plugins/fossil/CMakeLists.txt index 6bcd629025c..ad94bb90ab5 100644 --- a/plugins/fossil/CMakeLists.txt +++ b/plugins/fossil/CMakeLists.txt @@ -23,7 +23,6 @@ add_qtc_plugin(Fossil fossileditor.cpp fossileditor.h fossilplugin.cpp fossilplugin.h fossilsettings.cpp fossilsettings.h - optionspage.cpp optionspage.h optionspage.ui pullorpushdialog.cpp pullorpushdialog.h pullorpushdialog.ui revertdialog.ui revisioninfo.cpp revisioninfo.h diff --git a/plugins/fossil/fossil.pro b/plugins/fossil/fossil.pro index bdec45dfa07..c423ad164b2 100644 --- a/plugins/fossil/fossil.pro +++ b/plugins/fossil/fossil.pro @@ -8,7 +8,6 @@ include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri) SOURCES += \ fossilclient.cpp \ fossilplugin.cpp \ - optionspage.cpp \ fossilsettings.cpp \ commiteditor.cpp \ fossilcommitwidget.cpp \ @@ -23,7 +22,6 @@ HEADERS += \ fossilclient.h \ constants.h \ fossilplugin.h \ - optionspage.h \ fossilsettings.h \ commiteditor.h \ fossilcommitwidget.h \ @@ -35,7 +33,6 @@ HEADERS += \ revisioninfo.h \ wizard/fossiljsextension.h FORMS += \ - optionspage.ui \ revertdialog.ui \ fossilcommitpanel.ui \ pullorpushdialog.ui \ diff --git a/plugins/fossil/fossil.qbs b/plugins/fossil/fossil.qbs index 69730c93cf2..e89b69171e3 100644 --- a/plugins/fossil/fossil.qbs +++ b/plugins/fossil/fossil.qbs @@ -15,7 +15,6 @@ QtcPlugin { "constants.h", "fossilclient.cpp", "fossilclient.h", "fossilplugin.cpp", "fossilplugin.h", - "optionspage.cpp", "optionspage.h", "optionspage.ui", "fossilsettings.cpp", "fossilsettings.h", "commiteditor.cpp", "commiteditor.h", "fossilcommitwidget.cpp", "fossilcommitwidget.h", diff --git a/plugins/fossil/fossilclient.cpp b/plugins/fossil/fossilclient.cpp index 1fe14574d28..398eb9fb6fd 100644 --- a/plugins/fossil/fossilclient.cpp +++ b/plugins/fossil/fossilclient.cpp @@ -36,9 +36,7 @@ #include #include #include -#include #include -#include #include #include @@ -67,15 +65,14 @@ public: { QTC_ASSERT(client, return); - VcsBase::VcsBaseClientSettings &settings = client->settings(); FossilClient::SupportedFeatures features = client->supportedFeatures(); addReloadButton(); if (features.testFlag(FossilClient::DiffIgnoreWhiteSpaceFeature)) { mapSetting(addToggleButton("-w", tr("Ignore All Whitespace")), - settings.boolPointer(FossilSettings::diffIgnoreAllWhiteSpaceKey)); + &client->settings().diffIgnoreAllWhiteSpace); mapSetting(addToggleButton("--strip-trailing-cr", tr("Strip Trailing CR")), - settings.boolPointer(FossilSettings::diffStripTrailingCRKey)); + &client->settings().diffStripTrailingCR); } } }; @@ -91,20 +88,20 @@ public: { QTC_ASSERT(client, return); - VcsBase::VcsBaseClientSettings &settings = client->settings(); + FossilSettings &settings = client->settings(); FossilClient::SupportedFeatures features = client->supportedFeatures(); if (features.testFlag(FossilClient::AnnotateBlameFeature)) { mapSetting(addToggleButton("|BLAME|", tr("Show Committers")), - settings.boolPointer(FossilSettings::annotateShowCommittersKey)); + &settings.annotateShowCommitters); } // Force listVersions setting to false by default. // This way the annotated line number would not get offset by the version list. - settings.setValue(FossilSettings::annotateListVersionsKey, false); + settings.annotateListVersions.setValue(false); mapSetting(addToggleButton("--log", tr("List Versions")), - settings.boolPointer(FossilSettings::annotateListVersionsKey)); + &settings.annotateListVersions); } }; @@ -141,7 +138,7 @@ public: void addLineageComboBox() { - VcsBase::VcsBaseClientSettings &settings = m_client->settings(); + FossilSettings &settings = m_client->settings(); // ancestors/descendants filter // This is a positional argument not an option. @@ -156,22 +153,22 @@ public: ChoiceItem(tr("Unfiltered"), "") }; mapSetting(addChoices(tr("Lineage"), QStringList("|LINEAGE|%1|current"), lineageFilterChoices), - settings.stringPointer(FossilSettings::timelineLineageFilterKey)); + &settings.timelineLineageFilter); } void addVerboseToggleButton() { - VcsBase::VcsBaseClientSettings &settings = m_client->settings(); + FossilSettings &settings = m_client->settings(); // show files mapSetting(addToggleButton("-showfiles", tr("Verbose"), tr("Show files changed in each revision")), - settings.boolPointer(FossilSettings::timelineVerboseKey)); + &settings.timelineVerbose); } void addItemTypeComboBox() { - VcsBase::VcsBaseClientSettings &settings = m_client->settings(); + FossilSettings &settings = m_client->settings(); // option: -t const QList itemTypeChoices = { @@ -188,7 +185,7 @@ public: // Fossil expects separate arguments for option and value ( i.e. "-t" "all") // so we need to handle the splitting explicitly in arguments(). mapSetting(addChoices(tr("Item Types"), QStringList("-t %1"), itemTypeChoices), - settings.stringPointer(FossilSettings::timelineItemTypeKey)); + &settings.timelineItemType); } QStringList arguments() const final @@ -244,16 +241,22 @@ QString FossilClient::makeVersionString(unsigned version) .arg(versionPart(version)); } -FossilClient::FossilClient(FossilSettings *settings) : VcsBase::VcsBaseClient(settings) +FossilClient::FossilClient(FossilSettings *settings) + : VcsBase::VcsBaseClient(settings), m_settings(settings) { setDiffConfigCreator([this](QToolBar *toolBar) { return new FossilDiffConfig(this, toolBar); }); } +FossilSettings &FossilClient::settings() const +{ + return *m_settings; +} + unsigned int FossilClient::synchronousBinaryVersion() const { - if (settings().binaryPath().isEmpty()) + if (settings().binaryPath.value().isEmpty()) return 0; QStringList args("version"); @@ -282,7 +285,7 @@ QList FossilClient::branchListFromOutput(const QString &output, cons // Branch list format: // " branch-name" // "* current-branch" - return Utils::transform(output.split('\n', Utils::SkipEmptyParts), [=](const QString& l) { + return Utils::transform(output.split('\n', Qt::SkipEmptyParts), [=](const QString &l) { const QString &name = l.mid(2); QTC_ASSERT(!name.isEmpty(), return BranchInfo()); const BranchInfo::BranchFlags flags = (l.startsWith("* ") ? defaultFlags | BranchInfo::Current : defaultFlags); @@ -395,9 +398,9 @@ RevisionInfo FossilClient::synchronousRevisionQuery(const QString &workingDirect const QString hashToken = QString::fromUtf8(supportedFeatures().testFlag(InfoHashFeature) ? "hash: " : "uuid: "); - for (const QString &l : output.split('\n', Utils::SkipEmptyParts)) { + for (const QString &l : output.split('\n', Qt::SkipEmptyParts)) { if (l.startsWith("checkout: ", Qt::CaseInsensitive) - || l.startsWith(hashToken, Qt::CaseInsensitive)) { + || l.startsWith("uuid: ", Qt::CaseInsensitive)) { const QRegularExpressionMatch idMatch = idRx.match(l); QTC_ASSERT(idMatch.hasMatch(), return RevisionInfo()); revisionId = idMatch.captured(1); @@ -446,7 +449,7 @@ QStringList FossilClient::synchronousTagQuery(const QString &workingDirectory, c const QString output = sanitizeFossilOutput(response.stdOut()); - return output.split('\n', Utils::SkipEmptyParts); + return output.split('\n', Qt::SkipEmptyParts); } RepositorySettings FossilClient::synchronousSettingsQuery(const QString &workingDirectory) @@ -458,7 +461,7 @@ RepositorySettings FossilClient::synchronousSettingsQuery(const QString &working repoSettings.user = synchronousUserDefaultQuery(workingDirectory); if (repoSettings.user.isEmpty()) - repoSettings.user = settings().stringValue(FossilSettings::userNameKey); + repoSettings.user = settings().userName.value(); const QStringList args("settings"); @@ -468,12 +471,12 @@ RepositorySettings FossilClient::synchronousSettingsQuery(const QString &working const QString output = sanitizeFossilOutput(response.stdOut()); - for (const QString &line : output.split('\n', Utils::SkipEmptyParts)) { + for (const QString &line : output.split('\n', Qt::SkipEmptyParts)) { // parse settings line: // <(local|global)> // Fossil properties are case-insensitive; force them to lower-case. // Values may be in mixed-case; force lower-case for fixed values. - const QStringList fields = line.split(' ', Utils::SkipEmptyParts); + const QStringList fields = line.split(' ', Qt::SkipEmptyParts); const QString property = fields.at(0).toLower(); const QString value = (fields.size() >= 3 ? fields.at(2) : QString()); @@ -636,8 +639,8 @@ bool FossilClient::synchronousCreateRepository(const QString &workingDirectory, // use the configured default user for admin const QString repoName = QDir(workingDirectory).dirName().simplified(); - const QString repoPath = settings().stringValue(FossilSettings::defaultRepoPathKey); - const QString adminUser = settings().stringValue(FossilSettings::userNameKey); + const QString repoPath = settings().defaultRepoPath.value(); + const QString adminUser = settings().userName.value(); if (repoName.isEmpty() || repoPath.isEmpty()) return false; @@ -855,7 +858,7 @@ unsigned int FossilClient::binaryVersion() const static unsigned int cachedBinaryVersion = 0; static QString cachedBinaryPath; - const QString currentBinaryPath = settings().binaryPath().toString(); + const QString currentBinaryPath = settings().binaryPath.value(); if (currentBinaryPath.isEmpty()) return 0; diff --git a/plugins/fossil/fossilclient.h b/plugins/fossil/fossilclient.h index 8cc64ae1911..75618932fa5 100644 --- a/plugins/fossil/fossilclient.h +++ b/plugins/fossil/fossilclient.h @@ -64,6 +64,7 @@ public: static QString makeVersionString(unsigned version); explicit FossilClient(FossilSettings *settings); + FossilSettings &settings() const; unsigned int synchronousBinaryVersion() const; BranchInfo synchronousCurrentBranch(const QString &workingDirectory); @@ -130,6 +131,7 @@ private: VcsBase::VcsBaseEditorConfig *createLogEditor(VcsBase::VcsBaseEditorWidget *editor); friend class FossilPluginPrivate; + FossilSettings *m_settings = nullptr; }; Q_DECLARE_OPERATORS_FOR_FLAGS(FossilClient::SupportedFeatures) diff --git a/plugins/fossil/fossilcommitwidget.cpp b/plugins/fossil/fossilcommitwidget.cpp index d1994dba789..d53ac59c102 100644 --- a/plugins/fossil/fossilcommitwidget.cpp +++ b/plugins/fossil/fossilcommitwidget.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -123,7 +122,7 @@ QStringList FossilCommitWidget::tags() const return QStringList(); tagsText.replace(',', ' '); - const QStringList tags = tagsText.split(' ', Utils::SkipEmptyParts); + const QStringList tags = tagsText.split(' ', Qt::SkipEmptyParts); return tags; } diff --git a/plugins/fossil/fossilplugin.cpp b/plugins/fossil/fossilplugin.cpp index 09e43575dbb..46df19e9bf1 100644 --- a/plugins/fossil/fossilplugin.cpp +++ b/plugins/fossil/fossilplugin.cpp @@ -26,7 +26,6 @@ #include "fossilplugin.h" #include "constants.h" #include "fossilclient.h" -#include "optionspage.h" #include "fossilcommitwidget.h" #include "fossileditor.h" #include "pullorpushdialog.h" @@ -54,10 +53,8 @@ #include #include -#include #include #include -#include #include #include @@ -437,10 +434,10 @@ void FossilPluginPrivate::logCurrentFile() QTC_ASSERT(state.hasFile(), return); FossilClient::SupportedFeatures features = m_client.supportedFeatures(); QStringList extraOptions; - extraOptions << "-n" << QString::number(m_client.settings().intValue(FossilSettings::logCountKey)); + extraOptions << "-n" << QString::number(m_client.settings().logCount.value()); if (features.testFlag(FossilClient::TimelineWidthFeature)) - extraOptions << "-W" << QString::number(m_client.settings().intValue(FossilSettings::timelineWidthKey)); + extraOptions << "-W" << QString::number(m_client.settings().timelineWidth.value()); // disable annotate context menu for older client versions, used to be supported for current revision only bool enableAnnotationContextMenu = features.testFlag(FossilClient::AnnotateRevisionFeature); @@ -520,10 +517,10 @@ void FossilPluginPrivate::logRepository() QTC_ASSERT(state.hasTopLevel(), return); FossilClient::SupportedFeatures features = m_client.supportedFeatures(); QStringList extraOptions; - extraOptions << "-n" << QString::number(m_client.settings().intValue(FossilSettings::logCountKey)); + extraOptions << "-n" << QString::number(m_client.settings().logCount.value()); if (features.testFlag(FossilClient::TimelineWidthFeature)) - extraOptions << "-W" << QString::number(m_client.settings().intValue(FossilSettings::timelineWidthKey)); + extraOptions << "-W" << QString::number(m_client.settings().timelineWidth.value()); m_client.log(state.topLevel(), QStringList(), extraOptions); } @@ -616,7 +613,7 @@ bool FossilPluginPrivate::pullOrPush(FossilPluginPrivate::SyncMode mode) QTC_ASSERT(state.hasTopLevel(), return false); PullOrPushDialog dialog(pullOrPushMode, Core::ICore::dialogParent()); - dialog.setLocalBaseDirectory(m_client.settings().stringValue(FossilSettings::defaultRepoPathKey)); + dialog.setLocalBaseDirectory(m_client.settings().defaultRepoPath.value()); const QString defaultURL(m_client.synchronousGetRepositoryURL(state.topLevel())); dialog.setDefaultRemoteLocation(defaultURL); if (dialog.exec() != QDialog::Accepted) @@ -835,7 +832,7 @@ bool FossilPluginPrivate::submitEditorAboutToClose() //rewrite entries of the form 'file => newfile' to 'newfile' because //this would mess the commit command for (QStringList::iterator iFile = files.begin(); iFile != files.end(); ++iFile) { - const QStringList parts = iFile->split(" => ", Utils::SkipEmptyParts); + const QStringList parts = iFile->split(" => ", Qt::SkipEmptyParts); if (!parts.isEmpty()) *iFile = parts.last(); } @@ -932,7 +929,7 @@ bool FossilPluginPrivate::isConfigured() const return false; // Local repositories default path must be set and exist - const QString repoPath = m_client.settings().stringValue(FossilSettings::defaultRepoPathKey); + const QString repoPath = m_client.settings().defaultRepoPath.value(); if (repoPath.isEmpty()) return false; diff --git a/plugins/fossil/fossilplugin.h b/plugins/fossil/fossilplugin.h index e8257eb854c..436f2372b9a 100644 --- a/plugins/fossil/fossilplugin.h +++ b/plugins/fossil/fossilplugin.h @@ -31,17 +31,10 @@ #include #include -namespace Core { -class ActionContainer; -class CommandLocator; -} // namespace Core - namespace Fossil { namespace Internal { -class OptionsPage; class FossilClient; -class FossilEditorWidget; class FossilPlugin final : public ExtensionSystem::IPlugin { diff --git a/plugins/fossil/fossilsettings.cpp b/plugins/fossil/fossilsettings.cpp index 8866d065afe..fc5d63b9d94 100644 --- a/plugins/fossil/fossilsettings.cpp +++ b/plugins/fossil/fossilsettings.cpp @@ -24,47 +24,179 @@ ****************************************************************************/ #include "fossilsettings.h" -#include "constants.h" -#include +#include "constants.h" +#include "fossilclient.h" + +#include + +#include +#include + +#include + +using namespace Utils; namespace Fossil { namespace Internal { -const QString FossilSettings::defaultRepoPathKey("defaultRepoPath"); -const QString FossilSettings::sslIdentityFileKey("sslIdentityFile"); -const QString FossilSettings::diffIgnoreAllWhiteSpaceKey("diffIgnoreAllWhiteSpace"); -const QString FossilSettings::diffStripTrailingCRKey("diffStripTrailingCR"); -const QString FossilSettings::annotateShowCommittersKey("annotateShowCommitters"); -const QString FossilSettings::annotateListVersionsKey("annotateListVersions"); -const QString FossilSettings::timelineWidthKey("timelineWidth"); -const QString FossilSettings::timelineLineageFilterKey("timelineLineageFilter"); -const QString FossilSettings::timelineVerboseKey("timelineVerbose"); -const QString FossilSettings::timelineItemTypeKey("timelineItemType"); -const QString FossilSettings::disableAutosyncKey("disableAutosync"); - FossilSettings::FossilSettings() { setSettingsGroup(Constants::FOSSIL); - // Override default binary path - declareKey(binaryPathKey, Constants::FOSSILDEFAULT); - declareKey(defaultRepoPathKey, ""); - declareKey(sslIdentityFileKey, ""); - declareKey(diffIgnoreAllWhiteSpaceKey, false); - declareKey(diffStripTrailingCRKey, false); - declareKey(annotateShowCommittersKey, false); - declareKey(annotateListVersionsKey, false); - declareKey(timelineWidthKey, 0); - declareKey(timelineLineageFilterKey, ""); - declareKey(timelineVerboseKey, false); - declareKey(timelineItemTypeKey, "all"); - declareKey(disableAutosyncKey, true); -} + setAutoApply(false); + + registerAspect(&binaryPath); + binaryPath.setDisplayStyle(StringAspect::PathChooserDisplay); + binaryPath.setExpectedKind(PathChooser::ExistingCommand); + binaryPath.setDefaultValue(Constants::FOSSILDEFAULT); + binaryPath.setDisplayName(tr("Fossil Command")); + binaryPath.setHistoryCompleter("Fossil.Command.History"); + binaryPath.setLabelText(tr("Command:")); + + registerAspect(&defaultRepoPath); + defaultRepoPath.setSettingsKey("defaultRepoPath"); + defaultRepoPath.setDisplayStyle(StringAspect::PathChooserDisplay); + defaultRepoPath.setExpectedKind(PathChooser::Directory); + defaultRepoPath.setDisplayName(tr("Fossil Repositories")); + defaultRepoPath.setLabelText(tr("Default path:")); + defaultRepoPath.setToolTip(tr("Directory to store local repositories by default.")); + + registerAspect(&userName); + userName.setDisplayStyle(StringAspect::LineEditDisplay); + userName.setLabelText(tr("Default user:")); + userName.setToolTip(tr("Existing user to become an author of changes made to the repository.")); + + registerAspect(&sslIdentityFile); + sslIdentityFile.setSettingsKey("sslIdentityFile"); + sslIdentityFile.setDisplayStyle(StringAspect::PathChooserDisplay); + sslIdentityFile.setExpectedKind(PathChooser::File); + sslIdentityFile.setDisplayName(tr("SSL/TLS Identity Key")); + sslIdentityFile.setLabelText(tr("SSL/TLS identity:")); + sslIdentityFile.setToolTip(tr("SSL/TLS client identity key to use if requested by the server.")); + + registerAspect(&diffIgnoreAllWhiteSpace); + diffIgnoreAllWhiteSpace.setSettingsKey("diffIgnoreAllWhiteSpace"); + + registerAspect(&diffStripTrailingCR); + diffStripTrailingCR.setSettingsKey("diffStripTrailingCR"); + + registerAspect(&annotateShowCommitters); + annotateShowCommitters.setSettingsKey("annotateShowCommitters"); + + registerAspect(&annotateListVersions); + annotateListVersions.setSettingsKey("annotateListVersions"); + + registerAspect(&timelineWidth); + timelineWidth.setSettingsKey("timelineWidth"); + timelineWidth.setLabelText(tr("Log width:")); + timelineWidth.setToolTip(tr("The width of log entry line (>20). " + "Choose 0 to see a single line per entry.")); + + registerAspect(&timelineLineageFilter); + timelineLineageFilter.setSettingsKey("timelineLineageFilter"); + + registerAspect(&timelineVerbose); + timelineVerbose.setSettingsKey("timelineVerbose"); + + registerAspect(&timelineItemType); + timelineItemType.setDefaultValue("all"); + timelineItemType.setSettingsKey("timelineItemType"); + + registerAspect(&disableAutosync); + disableAutosync.setSettingsKey("disableAutosync"); + disableAutosync.setDefaultValue(true); + disableAutosync.setLabelText(tr("Disable auto-sync")); + disableAutosync.setToolTip(tr("Disable automatic pull prior to commit or update and " + "automatic push after commit or tag or branch creation.")); + + registerAspect(&timeout); + timeout.setLabelText(tr("Timeout:")); + timeout.setSuffix(tr("s")); + + registerAspect(&logCount); + logCount.setLabelText(tr("Log count:")); + logCount.setToolTip(tr("The number of recent commit log entries to show. " + "Choose 0 to see all entries.")); +}; RepositorySettings::RepositorySettings() : autosync(AutosyncOn) { } -} // namespace Internal -} // namespace Fossil +// OptionsPage + +class OptionsPageWidget final : public Core::IOptionsPageWidget +{ + Q_DECLARE_TR_FUNCTIONS(Fossil::Internal::OptionsPageWidget) + +public: + OptionsPageWidget(const std::function &onApply, FossilSettings *settings); + void apply() final; + +private: + const std::function m_onApply; + FossilSettings *m_settings; +}; + +void OptionsPageWidget::apply() +{ + if (!m_settings->isDirty()) + return; + + m_settings->apply(); + m_onApply(); +} + +OptionsPageWidget::OptionsPageWidget(const std::function &onApply, FossilSettings *settings) : + m_onApply(onApply), + m_settings(settings) +{ + FossilSettings &s = *m_settings; + + using namespace Layouting; + const Break nl; + + Column { + Group { + Title(tr("Configuration")), + Row { s.binaryPath } + }, + + Group { + Title(tr("Local Repositories")), + Row { s.defaultRepoPath } + }, + Group { + Title(tr("User")), + Form { + s.userName, nl, + s.sslIdentityFile + } + }, + + Group { + Title(tr("Miscellaneous")), + Row { + s.logCount, + s.timelineWidth, + s.timeout, + Stretch() + }, + s.disableAutosync + }, + Stretch() + + }.attachTo(this); +} + +OptionsPage::OptionsPage(const std::function &onApply, FossilSettings *settings) +{ + setId(Constants::VCS_ID_FOSSIL); + setDisplayName(OptionsPageWidget::tr("Fossil")); + setWidgetCreator([onApply, settings]() { return new OptionsPageWidget(onApply, settings); }); + setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); +} + +} // Internal +} // Fossil diff --git a/plugins/fossil/fossilsettings.h b/plugins/fossil/fossilsettings.h index 8314eb3cf58..e686c8fc389 100644 --- a/plugins/fossil/fossilsettings.h +++ b/plugins/fossil/fossilsettings.h @@ -25,25 +25,26 @@ #pragma once +#include #include namespace Fossil { namespace Internal { -class FossilSettings : public VcsBase::VcsBaseClientSettings +class FossilSettings : public VcsBase::VcsBaseSettings { public: - static const QString defaultRepoPathKey; - static const QString sslIdentityFileKey; - static const QString diffIgnoreAllWhiteSpaceKey; - static const QString diffStripTrailingCRKey; - static const QString annotateShowCommittersKey; - static const QString annotateListVersionsKey; - static const QString timelineWidthKey; - static const QString timelineLineageFilterKey; - static const QString timelineVerboseKey; - static const QString timelineItemTypeKey; - static const QString disableAutosyncKey; + Utils::StringAspect defaultRepoPath; + Utils::StringAspect sslIdentityFile; + Utils::BoolAspect diffIgnoreAllWhiteSpace; + Utils::BoolAspect diffStripTrailingCR; + Utils::BoolAspect annotateShowCommitters; + Utils::BoolAspect annotateListVersions; + Utils::IntegerAspect timelineWidth; + Utils::StringAspect timelineLineageFilter; + Utils::BoolAspect timelineVerbose; + Utils::StringAspect timelineItemType; + Utils::BoolAspect disableAutosync; FossilSettings(); }; @@ -66,5 +67,11 @@ inline bool operator== (const RepositorySettings &lh, const RepositorySettings & && lh.sslIdentityFile == rh.sslIdentityFile); } +class OptionsPage : public Core::IOptionsPage +{ +public: + OptionsPage(const std::function &onApply, FossilSettings *settings); +}; + } // namespace Internal } // namespace Fossil diff --git a/plugins/fossil/optionspage.cpp b/plugins/fossil/optionspage.cpp deleted file mode 100644 index ad42130e66a..00000000000 --- a/plugins/fossil/optionspage.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2018 Artur Shepilko -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "optionspage.h" -#include "constants.h" -#include "fossilclient.h" -#include "fossilsettings.h" -#include "fossilplugin.h" -#include "ui_optionspage.h" - -#include -#include -#include - -namespace Fossil { -namespace Internal { - -class OptionsPageWidget final : public Core::IOptionsPageWidget -{ - Q_DECLARE_TR_FUNCTIONS(Fossil::Internal::OptionsPageWidget) - -public: - OptionsPageWidget(const std::function &onApply, FossilSettings *settings); - void apply() final; - -private: - Ui::OptionsPage m_ui; - const std::function m_onApply; - FossilSettings *m_settings; -}; - -void OptionsPageWidget::apply() -{ - FossilSettings s = *m_settings; - s.setValue(FossilSettings::binaryPathKey, m_ui.commandChooser->rawPath()); - s.setValue(FossilSettings::defaultRepoPathKey, m_ui.defaultRepoPathChooser->path()); - s.setValue(FossilSettings::userNameKey, m_ui.defaultUsernameLineEdit->text().trimmed()); - s.setValue(FossilSettings::sslIdentityFileKey, m_ui.sslIdentityFilePathChooser->path()); - s.setValue(FossilSettings::logCountKey, m_ui.logEntriesCount->value()); - s.setValue(FossilSettings::timelineWidthKey, m_ui.logEntriesWidth->value()); - s.setValue(FossilSettings::timeoutKey, m_ui.timeout->value()); - s.setValue(FossilSettings::disableAutosyncKey, m_ui.disableAutosyncCheckBox->isChecked()); - if (*m_settings == s) - return; - - *m_settings = s; - m_onApply(); -} - -OptionsPageWidget::OptionsPageWidget(const std::function &onApply, FossilSettings *settings) : - m_onApply(onApply), - m_settings(settings) -{ - m_ui.setupUi(this); - m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_ui.commandChooser->setPromptDialogTitle(tr("Fossil Command")); - m_ui.commandChooser->setHistoryCompleter("Fossil.Command.History"); - m_ui.commandChooser->setPath(m_settings->stringValue(FossilSettings::binaryPathKey)); - m_ui.defaultRepoPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); - m_ui.defaultRepoPathChooser->setPromptDialogTitle(tr("Fossil Repositories")); - m_ui.defaultRepoPathChooser->setPath(m_settings->stringValue(FossilSettings::defaultRepoPathKey)); - m_ui.sslIdentityFilePathChooser->setExpectedKind(Utils::PathChooser::File); - m_ui.sslIdentityFilePathChooser->setPromptDialogTitle(tr("SSL/TLS Identity Key")); - m_ui.sslIdentityFilePathChooser->setPath(m_settings->stringValue(FossilSettings::sslIdentityFileKey)); - m_ui.defaultUsernameLineEdit->setText(m_settings->stringValue(FossilSettings::userNameKey)); - m_ui.logEntriesCount->setValue(m_settings->intValue(FossilSettings::logCountKey)); - m_ui.logEntriesWidth->setValue(m_settings->intValue(FossilSettings::timelineWidthKey)); - m_ui.timeout->setValue(m_settings->intValue(FossilSettings::timeoutKey)); - m_ui.disableAutosyncCheckBox->setChecked(m_settings->boolValue(FossilSettings::disableAutosyncKey)); -} - -OptionsPage::OptionsPage(const std::function &onApply, FossilSettings *settings) -{ - setId(Constants::VCS_ID_FOSSIL); - setDisplayName(OptionsPageWidget::tr("Fossil")); - setWidgetCreator([onApply, settings]() { return new OptionsPageWidget(onApply, settings); }); - setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); -} - -} // Internal -} // Fossil diff --git a/plugins/fossil/optionspage.h b/plugins/fossil/optionspage.h deleted file mode 100644 index 411b005df4b..00000000000 --- a/plugins/fossil/optionspage.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2018 Artur Shepilko -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -namespace Fossil { -namespace Internal { - -class FossilSettings; - -class OptionsPage : public Core::IOptionsPage -{ -public: - OptionsPage(const std::function &onApply, FossilSettings *settings); -}; - -} // namespace Internal -} // namespace Fossil diff --git a/plugins/fossil/optionspage.ui b/plugins/fossil/optionspage.ui deleted file mode 100644 index e14e845cb51..00000000000 --- a/plugins/fossil/optionspage.ui +++ /dev/null @@ -1,229 +0,0 @@ - - - Fossil::Internal::OptionsPage - - - - 0 - 0 - 649 - 336 - - - - - - - - - - Configuration - - - - QFormLayout::ExpandingFieldsGrow - - - - - Command: - - - - - - - - - - - - - Local Repositories - - - - - - Directory to store local repositories by default. - - - Default path: - - - - - - - Directory to store local repositories by default. - - - - - - - - - - User - - - - QFormLayout::ExpandingFieldsGrow - - - - - Default user: - - - - - - - Existing user to become an author of changes made to the repository. - - - - - - - SSL/TLS identity: - - - - - - - SSL/TLS client identity key to use if requested by the server. - - - - - - - - - - Miscellaneous - - - - - - Log count: - - - - - - - The number of recent commit log entries to show. Choose 0 to see all entries. - - - 1000 - - - 300 - - - - - - - Log width: - - - - - - - The width of log entry line (>20). Choose 0 to see a single line per entry. - - - 300 - - - 0 - - - - - - - Timeout: - - - - - - - s - - - 360 - - - 30 - - - - - - - Qt::Horizontal - - - - 213 - 20 - - - - - - - - Disable automatic pull prior to commit or update and automatic push after commit or tag or branch creation. - - - Disable auto-sync - - - false - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 - - editingFinished() - browsingFinished() - -
-
- - -
diff --git a/plugins/fossil/wizard/fossiljsextension.cpp b/plugins/fossil/wizard/fossiljsextension.cpp index c8fdf18c651..701c55d9224 100644 --- a/plugins/fossil/wizard/fossiljsextension.cpp +++ b/plugins/fossil/wizard/fossiljsextension.cpp @@ -48,7 +48,7 @@ public: } Utils::Id m_vscId; - VcsBase::VcsBaseClientSettings *m_settings; + FossilSettings *m_settings; }; @@ -59,7 +59,7 @@ void FossilJsExtension::parseArgOptions(const QStringList &args, QMap 1 ? opt[1] : QString()); } } @@ -90,7 +90,7 @@ QString FossilJsExtension::defaultAdminUser() const if (!isConfigured()) return QString(); - return d->m_settings->stringValue(FossilSettings::userNameKey); + return d->m_settings->userName.value(); } QString FossilJsExtension::defaultSslIdentityFile() const @@ -98,7 +98,7 @@ QString FossilJsExtension::defaultSslIdentityFile() const if (!isConfigured()) return QString(); - return d->m_settings->stringValue(FossilSettings::sslIdentityFileKey); + return d->m_settings->sslIdentityFile.value(); } QString FossilJsExtension::defaultLocalRepoPath() const @@ -106,7 +106,7 @@ QString FossilJsExtension::defaultLocalRepoPath() const if (!isConfigured()) return QString(); - return d->m_settings->stringValue(FossilSettings::defaultRepoPathKey); + return d->m_settings->defaultRepoPath.value(); } bool FossilJsExtension::defaultDisableAutosync() const @@ -114,7 +114,7 @@ bool FossilJsExtension::defaultDisableAutosync() const if (!isConfigured()) return false; - return d->m_settings->boolValue(FossilSettings::disableAutosyncKey); + return d->m_settings->disableAutosync.value(); } } // namespace Internal