From 78b4449692208599dd40f1fb64978e645eae7352 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 16 Mar 2021 16:55:02 +0100 Subject: [PATCH] CVS: Aspectify settings Change-Id: Ib5170405b33b3e521470407065e85c95dad6163b Reviewed-by: Orgad Shaneh --- src/plugins/cvs/CMakeLists.txt | 1 - src/plugins/cvs/cvs.pro | 4 - src/plugins/cvs/cvs.qbs | 3 - src/plugins/cvs/cvsplugin.cpp | 72 +++++----- src/plugins/cvs/cvssettings.cpp | 128 +++++++++++++---- src/plugins/cvs/cvssettings.h | 24 ++-- src/plugins/cvs/settingspage.cpp | 101 -------------- src/plugins/cvs/settingspage.h | 42 ------ src/plugins/cvs/settingspage.ui | 144 -------------------- src/plugins/vcsbase/vcsbaseclient.cpp | 4 +- src/plugins/vcsbase/vcsbaseclient.h | 3 +- src/plugins/vcsbase/vcsbasesubmiteditor.cpp | 24 ++-- src/plugins/vcsbase/vcsbasesubmiteditor.h | 7 +- 13 files changed, 181 insertions(+), 376 deletions(-) delete mode 100644 src/plugins/cvs/settingspage.cpp delete mode 100644 src/plugins/cvs/settingspage.h delete mode 100644 src/plugins/cvs/settingspage.ui diff --git a/src/plugins/cvs/CMakeLists.txt b/src/plugins/cvs/CMakeLists.txt index 2498cc9e94c..2612f9a795a 100644 --- a/src/plugins/cvs/CMakeLists.txt +++ b/src/plugins/cvs/CMakeLists.txt @@ -7,5 +7,4 @@ add_qtc_plugin(CVS cvssettings.cpp cvssettings.h cvssubmiteditor.cpp cvssubmiteditor.h cvsutils.cpp cvsutils.h - settingspage.cpp settingspage.h settingspage.ui ) diff --git a/src/plugins/cvs/cvs.pro b/src/plugins/cvs/cvs.pro index c7b84d117db..03f59129abd 100644 --- a/src/plugins/cvs/cvs.pro +++ b/src/plugins/cvs/cvs.pro @@ -2,7 +2,6 @@ include(../../qtcreatorplugin.pri) HEADERS += annotationhighlighter.h \ cvsplugin.h \ - settingspage.h \ cvseditor.h \ cvssubmiteditor.h \ cvssettings.h \ @@ -10,10 +9,7 @@ HEADERS += annotationhighlighter.h \ SOURCES += annotationhighlighter.cpp \ cvsplugin.cpp \ - settingspage.cpp \ cvseditor.cpp \ cvssubmiteditor.cpp \ cvssettings.cpp \ cvsutils.cpp - -FORMS += settingspage.ui diff --git a/src/plugins/cvs/cvs.qbs b/src/plugins/cvs/cvs.qbs index f86c0144a61..cbc1dbaa0f2 100644 --- a/src/plugins/cvs/cvs.qbs +++ b/src/plugins/cvs/cvs.qbs @@ -23,8 +23,5 @@ QtcPlugin { "cvssubmiteditor.h", "cvsutils.cpp", "cvsutils.h", - "settingspage.cpp", - "settingspage.h", - "settingspage.ui", ] } diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 8361111bda8..6598be1a33d 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "cvsplugin.h" -#include "settingspage.h" #include "cvseditor.h" #include "cvssubmiteditor.h" #include "cvsutils.h" @@ -170,32 +169,31 @@ static inline bool messageBoxQuestion(const QString &title, const QString &quest class CvsDiffConfig : public VcsBaseEditorConfig { public: - CvsDiffConfig(VcsBaseClientSettings &settings, QToolBar *toolBar) : + CvsDiffConfig(CvsSettings &settings, QToolBar *toolBar) : VcsBaseEditorConfig(toolBar), m_settings(settings) { - mapSetting(addToggleButton(QLatin1String("-w"), CvsPlugin::tr("Ignore Whitespace")), - settings.boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey)); - mapSetting(addToggleButton(QLatin1String("-B"), CvsPlugin::tr("Ignore Blank Lines")), - settings.boolPointer(CvsSettings::diffIgnoreBlankLinesKey)); + mapSetting(addToggleButton("-w", CvsPlugin::tr("Ignore Whitespace")), + &settings.diffIgnoreWhiteSpace); + mapSetting(addToggleButton("-B", CvsPlugin::tr("Ignore Blank Lines")), + &settings.diffIgnoreBlankLines); } QStringList arguments() const override { - QStringList args; - args = m_settings.stringValue(CvsSettings::diffOptionsKey).split(' ', SkipEmptyParts); + QStringList args = m_settings.diffOptions.value().split(' ', SkipEmptyParts); args += VcsBaseEditorConfig::arguments(); return args; } private: - VcsBaseClientSettings &m_settings; + CvsSettings &m_settings; }; class CvsClient : public VcsBaseClient { public: - explicit CvsClient(CvsSettings *settings) : VcsBaseClient(settings) + explicit CvsClient(CvsSettings *settings) : VcsBaseClient(nullptr, settings) { setDiffConfigCreator([settings](QToolBar *toolBar) { return new CvsDiffConfig(*settings, toolBar); @@ -413,7 +411,7 @@ bool CvsPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) con bool CvsPluginPrivate::isConfigured() const { - const Utils::FilePath binary = m_settings.binaryPath(); + const Utils::FilePath binary = m_settings.binaryPath.filePath(); if (binary.isEmpty()) return false; QFileInfo fi = binary.toFileInfo(); @@ -491,7 +489,7 @@ Core::ShellCommand *CvsPluginPrivate::createInitialCheckoutCommand(const QString auto command = new VcsBase::VcsCommand(baseDirectory.toString(), QProcessEnvironment::systemEnvironment()); command->setDisplayName(tr("CVS Checkout")); - command->addJob({m_settings.binaryPath(), m_settings.addOptions(args)}, -1); + command->addJob({m_settings.binaryPath.filePath(), m_settings.addOptions(args)}, -1); return command; } @@ -766,8 +764,10 @@ bool CvsPluginPrivate::submitEditorAboutToClose() // Prompt user. Force a prompt unless submit was actually invoked (that // is, the editor was closed or shutdown). const VcsBaseSubmitEditor::PromptSubmitResult answer = editor->promptSubmit( - this, m_settings.boolPointer(CvsSettings::promptOnSubmitKey), - !m_submitActionTriggered); + this, nullptr, + !m_submitActionTriggered, + true, + &m_settings.promptOnSubmit); m_submitActionTriggered = false; switch (answer) { case VcsBaseSubmitEditor::SubmitCanceled: @@ -873,7 +873,7 @@ void CvsPluginPrivate::revertAll() QStringList args; args << QLatin1String("update") << QLatin1String("-C") << state.topLevel(); const CvsResponse revertResponse = - runCvs(state.topLevel(), args, m_settings.vcsTimeoutS(), + runCvs(state.topLevel(), args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (revertResponse.result == CvsResponse::Ok) emit repositoryChanged(state.topLevel()); @@ -889,7 +889,7 @@ void CvsPluginPrivate::revertCurrentFile() QStringList args; args << QLatin1String("diff") << state.relativeCurrentFile(); const CvsResponse diffResponse = - runCvs(state.currentFileTopLevel(), args, m_settings.vcsTimeoutS(), 0); + runCvs(state.currentFileTopLevel(), args, m_settings.timeout.value(), 0); switch (diffResponse.result) { case CvsResponse::Ok: return; // Not modified, diff exit code 0 @@ -911,7 +911,7 @@ void CvsPluginPrivate::revertCurrentFile() args.clear(); args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile(); const CvsResponse revertResponse = - runCvs(state.currentFileTopLevel(), args, m_settings.vcsTimeoutS(), + runCvs(state.currentFileTopLevel(), args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (revertResponse.result == CvsResponse::Ok) emit filesChanged(QStringList(state.currentFile())); @@ -976,7 +976,7 @@ void CvsPluginPrivate::startCommit(const QString &workingDir, const QString &fil // where we are, so, have stdout/stderr channels merged. QStringList args = QStringList(QLatin1String("status")); const CvsResponse response = - runCvs(workingDir, args, m_settings.vcsTimeoutS(), VcsCommand::MergeOutputChannels); + runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::MergeOutputChannels); if (response.result != CvsResponse::Ok) return; // Get list of added/modified/deleted files and purge out undesired ones @@ -1022,7 +1022,7 @@ bool CvsPluginPrivate::commit(const QString &messageFile, args << QLatin1String("-F") << messageFile; args.append(fileList); const CvsResponse response = - runCvs(m_commitRepository, args, 10 * m_settings.vcsTimeoutS(), + runCvs(m_commitRepository, args, 10 * m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return response.result == CvsResponse::Ok ; } @@ -1060,7 +1060,7 @@ void CvsPluginPrivate::filelog(const QString &workingDir, args << QLatin1String("log"); args.append(file); const CvsResponse response = - runCvs(workingDir, args, m_settings.vcsTimeoutS(), + runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt, codec); if (response.result != CvsResponse::Ok) return; @@ -1101,7 +1101,7 @@ bool CvsPluginPrivate::update(const QString &topLevel, const QString &file) if (!file.isEmpty()) args.append(file); const CvsResponse response = - runCvs(topLevel, args, 10 * m_settings.vcsTimeoutS(), + runCvs(topLevel, args, 10 * m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); const bool ok = response.result == CvsResponse::Ok; if (ok) @@ -1148,7 +1148,7 @@ bool CvsPluginPrivate::edit(const QString &topLevel, const QStringList &files) QStringList args(QLatin1String("edit")); args.append(files); const CvsResponse response = - runCvs(topLevel, args, m_settings.vcsTimeoutS(), + runCvs(topLevel, args, m_settings.timeout.value(), VcsCommand::ShowStdOut | VcsCommand::SshPasswordPrompt); return response.result == CvsResponse::Ok; } @@ -1160,7 +1160,7 @@ bool CvsPluginPrivate::diffCheckModified(const QString &topLevel, const QStringL QStringList args(QLatin1String("-q")); args << QLatin1String("diff"); args.append(files); - const CvsResponse response = runCvs(topLevel, args, m_settings.vcsTimeoutS(), 0); + const CvsResponse response = runCvs(topLevel, args, m_settings.timeout.value(), 0); if (response.result == CvsResponse::OtherError) return false; *modified = response.result == CvsResponse::NonNullExitCode; @@ -1188,7 +1188,7 @@ bool CvsPluginPrivate::unedit(const QString &topLevel, const QStringList &files) args.append(QLatin1String("-y")); args.append(files); const CvsResponse response = - runCvs(topLevel, args, m_settings.vcsTimeoutS(), + runCvs(topLevel, args, m_settings.timeout.value(), VcsCommand::ShowStdOut | VcsCommand::SshPasswordPrompt); return response.result == CvsResponse::Ok; } @@ -1207,7 +1207,7 @@ void CvsPluginPrivate::annotate(const QString &workingDir, const QString &file, args << QLatin1String("-r") << revision; args << file; const CvsResponse response = - runCvs(workingDir, args, m_settings.vcsTimeoutS(), + runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt, codec); if (response.result != CvsResponse::Ok) return; @@ -1236,7 +1236,7 @@ bool CvsPluginPrivate::status(const QString &topLevel, const QString &file, cons if (!file.isEmpty()) args.append(file); const CvsResponse response = - runCvs(topLevel, args, m_settings.vcsTimeoutS(), 0); + runCvs(topLevel, args, m_settings.timeout.value(), 0); const bool ok = response.result == CvsResponse::Ok; if (ok) showOutputInEditor(title, response.stdOut, commandLogEditorParameters.id, topLevel, nullptr); @@ -1311,7 +1311,7 @@ bool CvsPluginPrivate::describe(const QString &toplevel, const QString &file, co QStringList args; args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file; const CvsResponse logResponse = - runCvs(toplevel, args, m_settings.vcsTimeoutS(), VcsCommand::SshPasswordPrompt); + runCvs(toplevel, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt); if (logResponse.result != CvsResponse::Ok) { *errorMessage = logResponse.message; return false; @@ -1321,7 +1321,7 @@ bool CvsPluginPrivate::describe(const QString &toplevel, const QString &file, co *errorMessage = tr("Parsing of the log output failed."); return false; } - if (m_settings.boolValue(CvsSettings::describeByCommitIdKey)) { + if (m_settings.describeByCommitId.value()) { // Run a log command over the repo, filtering by the commit date // and commit id, collecting all files touched by the commit. const QString commitId = fileLog.front().revisions.front().commitId; @@ -1333,7 +1333,7 @@ bool CvsPluginPrivate::describe(const QString &toplevel, const QString &file, co args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS); const CvsResponse repoLogResponse = - runCvs(toplevel, args, 10 * m_settings.vcsTimeoutS(), VcsCommand::SshPasswordPrompt); + runCvs(toplevel, args, 10 * m_settings.timeout.value(), VcsCommand::SshPasswordPrompt); if (repoLogResponse.result != CvsResponse::Ok) { *errorMessage = repoLogResponse.message; return false; @@ -1370,7 +1370,7 @@ bool CvsPluginPrivate::describe(const QString &repositoryPath, QStringList args(QLatin1String("log")); args << (QLatin1String("-r") + it->revisions.front().revision) << it->file; const CvsResponse logResponse = - runCvs(repositoryPath, args, m_settings.vcsTimeoutS(), VcsCommand::SshPasswordPrompt); + runCvs(repositoryPath, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt); if (logResponse.result != CvsResponse::Ok) { *errorMessage = logResponse.message; return false; @@ -1383,11 +1383,11 @@ bool CvsPluginPrivate::describe(const QString &repositoryPath, if (!isFirstRevision(revision)) { const QString previousRev = previousRevision(revision); QStringList args(QLatin1String("diff")); - args << m_settings.stringValue(CvsSettings::diffOptionsKey) + args << m_settings.diffOptions.value() << QLatin1String("-r") << previousRev << QLatin1String("-r") << it->revisions.front().revision << it->file; const CvsResponse diffResponse = - runCvs(repositoryPath, args, m_settings.vcsTimeoutS(), 0, codec); + runCvs(repositoryPath, args, m_settings.timeout.value(), 0, codec); switch (diffResponse.result) { case CvsResponse::Ok: case CvsResponse::NonNullExitCode: // Diff exit code != 0 @@ -1435,7 +1435,7 @@ CvsResponse CvsPluginPrivate::runCvs(const QString &workingDirectory, unsigned flags, QTextCodec *outputCodec) const { - const FilePath executable = m_settings.binaryPath(); + const FilePath executable = m_settings.binaryPath.filePath(); CvsResponse response; if (executable.isEmpty()) { response.result = CvsResponse::OtherError; @@ -1494,7 +1494,7 @@ bool CvsPluginPrivate::vcsAdd(const QString &workingDir, const QString &rawFileN QStringList args; args << QLatin1String("add") << rawFileName; const CvsResponse response = - runCvs(workingDir, args, m_settings.vcsTimeoutS(), + runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return response.result == CvsResponse::Ok; } @@ -1504,7 +1504,7 @@ bool CvsPluginPrivate::vcsDelete(const QString &workingDir, const QString &rawFi QStringList args; args << QLatin1String("remove") << QLatin1String("-f") << rawFileName; const CvsResponse response = - runCvs(workingDir, args, m_settings.vcsTimeoutS(), + runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return response.result == CvsResponse::Ok; } @@ -1545,7 +1545,7 @@ bool CvsPluginPrivate::managesFile(const QString &workingDirectory, const QStrin QStringList args; args << QLatin1String("status") << fileName; const CvsResponse response = - runCvs(workingDirectory, args, m_settings.vcsTimeoutS(), VcsCommand::SshPasswordPrompt); + runCvs(workingDirectory, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt); if (response.result != CvsResponse::Ok) return false; return !response.stdOut.contains(QLatin1String("Status: Unknown")); diff --git a/src/plugins/cvs/cvssettings.cpp b/src/plugins/cvs/cvssettings.cpp index 2f3c2897f0c..e95f35de25a 100644 --- a/src/plugins/cvs/cvssettings.cpp +++ b/src/plugins/cvs/cvssettings.cpp @@ -25,40 +25,62 @@ #include "cvssettings.h" -#include -#include +#include -#include -#include +#include +#include + +#include + +using namespace Utils; +using namespace VcsBase; namespace Cvs { namespace Internal { -const QLatin1String CvsSettings::cvsRootKey("Root"); -const QLatin1String CvsSettings::diffOptionsKey("DiffOptions"); -const QLatin1String CvsSettings::describeByCommitIdKey("DescribeByCommitId"); -const QLatin1String CvsSettings::diffIgnoreWhiteSpaceKey("DiffIgnoreWhiteSpace"); -const QLatin1String CvsSettings::diffIgnoreBlankLinesKey("DiffIgnoreBlankLines"); +// CvsSettings CvsSettings::CvsSettings() { - setSettingsGroup(QLatin1String("CVS")); - declareKey(binaryPathKey, QLatin1String("cvs" QTC_HOST_EXE_SUFFIX)); - declareKey(cvsRootKey, QString()); - declareKey(diffOptionsKey, QLatin1String("-du")); - declareKey(describeByCommitIdKey, true); - declareKey(diffIgnoreWhiteSpaceKey, false); - declareKey(diffIgnoreBlankLinesKey, false); -} + setSettingsGroup("CVS"); -int CvsSettings::timeOutMs() const -{ - return 1000 * intValue(timeoutKey); + registerAspect(&binaryPath); + binaryPath.setDefaultValue("cvs" QTC_HOST_EXE_SUFFIX); + binaryPath.setDisplayStyle(StringAspect::PathChooserDisplay); + binaryPath.setExpectedKind(PathChooser::ExistingCommand); + binaryPath.setHistoryCompleter(QLatin1String("Cvs.Command.History")); + binaryPath.setDisplayName(tr("CVS Command")); + binaryPath.setLabelText(tr("CVS command:")); + + registerAspect(&cvsRoot); + cvsRoot.setDisplayStyle(StringAspect::LineEditDisplay); + cvsRoot.setSettingsKey("Root"); + cvsRoot.setLabelText(tr("CVS root:")); + + registerAspect(&diffOptions); + diffOptions.setDisplayStyle(StringAspect::LineEditDisplay); + diffOptions.setSettingsKey("DiffOptions"); + diffOptions.setDefaultValue("-du"); + diffOptions.setLabelText("Diff options:"); + + registerAspect(&describeByCommitId); + describeByCommitId.setSettingsKey("DescribeByCommitId"); + describeByCommitId.setDefaultValue(true); + describeByCommitId.setLabelText(tr("Describe all files matching commit id")); + describeByCommitId.setToolTip(tr("When checked, all files touched by a commit will be " + "displayed when clicking on a revision number in the annotation view " + "(retrieved via commit ID). Otherwise, only the respective file will be displayed.")); + + registerAspect(&diffIgnoreWhiteSpace); + diffIgnoreWhiteSpace.setSettingsKey("DiffIgnoreWhiteSpace"); + + registerAspect(&diffIgnoreBlankLines); + diffIgnoreBlankLines.setSettingsKey("DiffIgnoreBlankLines"); } QStringList CvsSettings::addOptions(const QStringList &args) const { - const QString cvsRoot = stringValue(cvsRootKey); + const QString cvsRoot = this->cvsRoot.value(); if (cvsRoot.isEmpty()) return args; @@ -69,5 +91,65 @@ QStringList CvsSettings::addOptions(const QStringList &args) const return rc; } -} // namespace Internal -} // namespace Cvs +// CvsSettingsPage + +class CvsSettingsPageWidget final : public Core::IOptionsPageWidget +{ + Q_DECLARE_TR_FUNCTIONS(Cvs::Internal::SettingsPageWidget) + +public: + CvsSettingsPageWidget(const std::function & onApply, CvsSettings *settings); + + void apply() final; + +private: + std::function m_onApply; + CvsSettings *m_settings; +}; + +CvsSettingsPageWidget::CvsSettingsPageWidget(const std::function &onApply, CvsSettings *settings) + : m_onApply(onApply), m_settings(settings) +{ + CvsSettings &s = *settings; + using namespace Layouting; + const Break nl; + + Column { + Group { + Title(tr("Configuration")), + Form { + s.binaryPath, nl, + s.cvsRoot + } + }, + Group { + Title(tr("Miscellaneous")), + Form { + s.timeout, nl, + s.diffOptions, + }, + s.promptOnSubmit, + s.describeByCommitId, + }, + Stretch() + }.attachTo(this); +} + +void CvsSettingsPageWidget::apply() +{ + if (m_settings->isDirty()) { + m_settings->apply(); + m_onApply(); + } +} + +CvsSettingsPage::CvsSettingsPage(const std::function &onApply, CvsSettings *settings) +{ + setId(VcsBase::Constants::VCS_ID_CVS); + setDisplayName(CvsSettingsPageWidget::tr("CVS")); + setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); + setWidgetCreator([onApply, settings] { return new CvsSettingsPageWidget(onApply, settings); }); +} + +} // Internal +} // Cvs diff --git a/src/plugins/cvs/cvssettings.h b/src/plugins/cvs/cvssettings.h index 1294e33bf20..391300d4a77 100644 --- a/src/plugins/cvs/cvssettings.h +++ b/src/plugins/cvs/cvssettings.h @@ -25,26 +25,34 @@ #pragma once +#include + #include namespace Cvs { namespace Internal { -class CvsSettings : public VcsBase::VcsBaseClientSettings +class CvsSettings : public VcsBase::VcsBaseSettings { + Q_DECLARE_TR_FUNCTIONS(Cvs::Internal::SettingsPage) + public: - static const QLatin1String cvsRootKey; - static const QLatin1String diffOptionsKey; - static const QLatin1String describeByCommitIdKey; - static const QLatin1String diffIgnoreWhiteSpaceKey; - static const QLatin1String diffIgnoreBlankLinesKey; + Utils::StringAspect cvsRoot; + Utils::StringAspect diffOptions; + Utils::BoolAspect diffIgnoreWhiteSpace; + Utils::BoolAspect diffIgnoreBlankLines; + Utils::BoolAspect describeByCommitId; CvsSettings(); - int timeOutMs() const; - QStringList addOptions(const QStringList &args) const; }; +class CvsSettingsPage final : public Core::IOptionsPage +{ +public: + CvsSettingsPage(const std::function &onApply, CvsSettings *settings); +}; + } // namespace Internal } // namespace Cvs diff --git a/src/plugins/cvs/settingspage.cpp b/src/plugins/cvs/settingspage.cpp deleted file mode 100644 index 82f9cad8863..00000000000 --- a/src/plugins/cvs/settingspage.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** 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 "settingspage.h" - -#include "cvssettings.h" -#include "ui_settingspage.h" - -#include -#include -#include - -#include - -using namespace Utils; -using namespace VcsBase; - -namespace Cvs { -namespace Internal { - -class CvsSettingsPageWidget final : public Core::IOptionsPageWidget -{ - Q_DECLARE_TR_FUNCTIONS(Cvs::Internal::SettingsPageWidget) - -public: - CvsSettingsPageWidget(const std::function & onApply, CvsSettings *settings); - - void apply() final; - -private: - Ui::SettingsPage m_ui; - std::function m_onApply; - CvsSettings *m_settings; -}; - -CvsSettingsPageWidget::CvsSettingsPageWidget(const std::function &onApply, CvsSettings *settings) - : m_onApply(onApply), m_settings(settings) -{ - m_ui.setupUi(this); - m_ui.commandPathChooser->setExpectedKind(PathChooser::ExistingCommand); - m_ui.commandPathChooser->setHistoryCompleter(QLatin1String("Cvs.Command.History")); - m_ui.commandPathChooser->setPromptDialogTitle(tr("CVS Command")); - - const VcsBaseClientSettings &s = *settings; - m_ui.commandPathChooser->setFilePath(s.binaryPath()); - m_ui.rootLineEdit->setText(s.stringValue(CvsSettings::cvsRootKey)); - m_ui.diffOptionsLineEdit->setText(s.stringValue(CvsSettings::diffOptionsKey)); - m_ui.timeOutSpinBox->setValue(s.intValue(CvsSettings::timeoutKey)); - m_ui.promptToSubmitCheckBox->setChecked(s.boolValue(CvsSettings::promptOnSubmitKey)); - m_ui.describeByCommitIdCheckBox->setChecked(s.boolValue(CvsSettings::describeByCommitIdKey)); -} - -void CvsSettingsPageWidget::apply() -{ - CvsSettings rc = *m_settings; - rc.setValue(CvsSettings::binaryPathKey, m_ui.commandPathChooser->rawPath()); - rc.setValue(CvsSettings::cvsRootKey, m_ui.rootLineEdit->text()); - rc.setValue(CvsSettings::diffOptionsKey, m_ui.diffOptionsLineEdit->text()); - rc.setValue(CvsSettings::timeoutKey, m_ui.timeOutSpinBox->value()); - rc.setValue(CvsSettings::promptOnSubmitKey, m_ui.promptToSubmitCheckBox->isChecked()); - rc.setValue(CvsSettings::describeByCommitIdKey, m_ui.describeByCommitIdCheckBox->isChecked()); - - if (rc == *m_settings) - return; - - *m_settings = rc; - m_onApply(); -} - -CvsSettingsPage::CvsSettingsPage(const std::function &onApply, CvsSettings *settings) -{ - setId(VcsBase::Constants::VCS_ID_CVS); - setDisplayName(CvsSettingsPageWidget::tr("CVS")); - setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); - setWidgetCreator([onApply, settings] { return new CvsSettingsPageWidget(onApply, settings); }); -} - -} // Internal -} // Cvs diff --git a/src/plugins/cvs/settingspage.h b/src/plugins/cvs/settingspage.h deleted file mode 100644 index 8e64ec7841d..00000000000 --- a/src/plugins/cvs/settingspage.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** 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 Cvs { -namespace Internal { - -class CvsSettings; - -class CvsSettingsPage final : public Core::IOptionsPage -{ -public: - CvsSettingsPage(const std::function &onApply, CvsSettings *settings); -}; - -} // namespace Cvs -} // namespace Internal diff --git a/src/plugins/cvs/settingspage.ui b/src/plugins/cvs/settingspage.ui deleted file mode 100644 index 08395ca627f..00000000000 --- a/src/plugins/cvs/settingspage.ui +++ /dev/null @@ -1,144 +0,0 @@ - - - Cvs::Internal::SettingsPage - - - - 0 - 0 - 447 - 281 - - - - - - - Configuration - - - - QFormLayout::ExpandingFieldsGrow - - - - - CVS command: - - - - - - - - - - CVS root: - - - - - - - - - - - - - Miscellaneous - - - - QFormLayout::ExpandingFieldsGrow - - - - - Diff options: - - - - - - - - - - Prompt on submit - - - - - - - When checked, all files touched by a commit will be displayed when clicking on a revision number in the annotation view (retrieved via commit ID). Otherwise, only the respective file will be displayed. - - - Describe all files matching commit id - - - - - - - Timeout: - - - - - - - s - - - 1 - - - 360 - - - 30 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 - - editingFinished() - browsingFinished() - -
-
- - rootLineEdit - timeOutSpinBox - diffOptionsLineEdit - promptToSubmitCheckBox - describeByCommitIdCheckBox - - - -
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 4a478c0afba..816a7c7ba0d 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -267,8 +267,8 @@ void VcsBaseClientImpl::saveSettings() m_baseSettings->writeSettings(Core::ICore::settings()); } -VcsBaseClient::VcsBaseClient(VcsBaseClientSettings *settings) : - VcsBaseClientImpl(settings) +VcsBaseClient::VcsBaseClient(VcsBaseClientSettings *settings, VcsBaseSettings *baseSettings) : + VcsBaseClientImpl(settings, baseSettings) { qRegisterMetaType(); } diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index 5c1b0eee188..e7d6853b522 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -148,7 +148,8 @@ public: QString file; }; - explicit VcsBaseClient(VcsBaseClientSettings *settings); + explicit VcsBaseClient(VcsBaseClientSettings *settings, + VcsBaseSettings *baseSettings = nullptr); virtual bool synchronousCreateRepository(const QString &workingDir, const QStringList &extraOptions = QStringList()); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index e4feb29ca0a..d3c283da2a4 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -514,12 +514,13 @@ static QString withUnusedMnemonic(QString string, const QList &ot VcsBaseSubmitEditor::PromptSubmitResult VcsBaseSubmitEditor::promptSubmit(VcsBasePluginPrivate *plugin, - bool *promptSetting, + bool *promptSettingOld, bool forcePrompt, - bool canCommitOnFailure) + bool canCommitOnFailure, + BoolAspect *promptSetting) { - bool dummySetting = false; - if (!promptSetting) + BoolAspect dummySetting; + if (!promptSetting && !promptSettingOld) promptSetting = &dummySetting; auto submitWidget = static_cast(this->widget()); @@ -530,7 +531,8 @@ VcsBaseSubmitEditor::PromptSubmitResult QString errorMessage; - const bool prompt = forcePrompt || *promptSetting; + const bool value = promptSettingOld ? *promptSettingOld : promptSetting->value(); + const bool prompt = forcePrompt || value; // Pop up a message depending on whether the check succeeded and the // user wants to be prompted @@ -552,9 +554,9 @@ VcsBaseSubmitEditor::PromptSubmitResult } mb.setText(message); mb.setCheckBoxText(tr("Prompt to %1").arg(commitName.toLower())); - mb.setChecked(*promptSetting); + mb.setChecked(value); // Provide check box to turn off prompt ONLY if it was not forced - mb.setCheckBoxVisible(*promptSetting && !forcePrompt); + mb.setCheckBoxVisible(value && !forcePrompt); QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close | QDialogButtonBox::Cancel; if (canCommit || canCommitOnFailure) buttons |= QDialogButtonBox::Ok; @@ -570,8 +572,12 @@ VcsBaseSubmitEditor::PromptSubmitResult commitButton->setText(withUnusedMnemonic(commitName, {cancelButton, mb.button(QDialogButtonBox::Close)})); } - if (mb.exec() == QDialog::Accepted) - *promptSetting = mb.isChecked(); + if (mb.exec() == QDialog::Accepted) { + if (promptSettingOld) + *promptSettingOld = mb.isChecked(); + else + promptSetting->setValue(mb.isChecked()); + } QAbstractButton *chosen = mb.clickedButton(); if (!chosen || chosen == cancelButton) return SubmitCanceled; diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h index 8e60e39ff78..3524de46661 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.h +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h @@ -29,6 +29,8 @@ #include +#include + #include QT_BEGIN_NAMESPACE @@ -85,9 +87,10 @@ public: // prompt setting. The user can uncheck it from the message box. enum PromptSubmitResult { SubmitConfirmed, SubmitCanceled, SubmitDiscarded }; PromptSubmitResult promptSubmit(VcsBasePluginPrivate *plugin, - bool *promptSetting, + bool *promptSettingOld, bool forcePrompt = false, - bool canCommitOnFailure = true); + bool canCommitOnFailure = true, + Utils::BoolAspect *promptSetting = nullptr); QAbstractItemView::SelectionMode fileListSelectionMode() const; void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);