diff --git a/src/libs/utils/layoutbuilder.cpp b/src/libs/utils/layoutbuilder.cpp index 5211ecd9932..f9ec0cea781 100644 --- a/src/libs/utils/layoutbuilder.cpp +++ b/src/libs/utils/layoutbuilder.cpp @@ -416,10 +416,11 @@ LayoutBuilder::Space::Space(int space) specialValue = space; } -LayoutBuilder::Title::Title(const QString &title) +LayoutBuilder::Title::Title(const QString &title, BoolAspect *check) { specialType = SpecialType::Title; specialValue = title; + aspect = check; } LayoutBuilder::Span::Span(int span_, const LayoutItem &item) @@ -445,6 +446,12 @@ Group::Group(std::initializer_list items) if (item.specialType == LayoutBuilder::SpecialType::Title) { box->setTitle(item.specialValue.toString()); box->setObjectName(item.specialValue.toString()); + if (auto check = qobject_cast(item.aspect)) { + box->setCheckable(true); + QObject::connect(box, &QGroupBox::clicked, box, [check](bool on) { + check->setValue(on); + }); + } } else { builder.addItem(item); } diff --git a/src/libs/utils/layoutbuilder.h b/src/libs/utils/layoutbuilder.h index 7ea1550ac5f..a258690416e 100644 --- a/src/libs/utils/layoutbuilder.h +++ b/src/libs/utils/layoutbuilder.h @@ -39,6 +39,7 @@ QT_END_NAMESPACE namespace Utils { class BaseAspect; +class BoolAspect; class QTCREATOR_UTILS_EXPORT LayoutBuilder { @@ -141,7 +142,7 @@ public: class QTCREATOR_UTILS_EXPORT Title : public LayoutItem { public: - explicit Title(const QString &title); + explicit Title(const QString &title, BoolAspect *check = nullptr); }; protected: diff --git a/src/plugins/subversion/CMakeLists.txt b/src/plugins/subversion/CMakeLists.txt index 4d225e57827..816d0089e98 100644 --- a/src/plugins/subversion/CMakeLists.txt +++ b/src/plugins/subversion/CMakeLists.txt @@ -2,7 +2,6 @@ add_qtc_plugin(Subversion PLUGIN_DEPENDS Core DiffEditor TextEditor VcsBase SOURCES annotationhighlighter.cpp annotationhighlighter.h - settingspage.cpp settingspage.h settingspage.ui subversionclient.cpp subversionclient.h subversionconstants.h subversioneditor.cpp subversioneditor.h diff --git a/src/plugins/subversion/settingspage.cpp b/src/plugins/subversion/settingspage.cpp deleted file mode 100644 index 2ee4aaad5c4..00000000000 --- a/src/plugins/subversion/settingspage.cpp +++ /dev/null @@ -1,114 +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 "subversionclient.h" -#include "subversionplugin.h" -#include "subversionsettings.h" - -#include "ui_settingspage.h" - -#include -#include -#include -#include - -#include - -using namespace Utils; -using namespace VcsBase; - -namespace Subversion { -namespace Internal { - -class SubversionSettingsPageWidget final : public Core::IOptionsPageWidget -{ - Q_DECLARE_TR_FUNCTIONS(Subversion::Internal::SettingsPageWidget) - -public: - SubversionSettingsPageWidget(const std::function &onApply, SubversionSettings *settings); - - void apply() final; - -private: - Ui::SettingsPage m_ui; - std::function m_onApply; - SubversionSettings *m_settings; -}; - -SubversionSettingsPageWidget::SubversionSettingsPageWidget(const std::function &onApply, - SubversionSettings *settings) - : m_onApply(onApply), m_settings(settings) -{ - m_ui.setupUi(this); - m_ui.pathChooser->setExpectedKind(PathChooser::ExistingCommand); - m_ui.pathChooser->setHistoryCompleter(QLatin1String("Subversion.Command.History")); - m_ui.pathChooser->setPromptDialogTitle(tr("Subversion Command")); - - SubversionSettings &s = *m_settings; - m_ui.pathChooser->setFilePath(s.binaryPath()); - m_ui.usernameLineEdit->setText(s.stringValue(SubversionSettings::userKey)); - m_ui.passwordLineEdit->setText(s.stringValue(SubversionSettings::passwordKey)); - m_ui.userGroupBox->setChecked(s.boolValue(SubversionSettings::useAuthenticationKey)); - m_ui.timeOutSpinBox->setValue(s.intValue(SubversionSettings::timeoutKey)); - m_ui.promptToSubmitCheckBox->setChecked(s.boolValue(SubversionSettings::promptOnSubmitKey)); - m_ui.spaceIgnorantAnnotationCheckBox->setChecked( - s.boolValue(SubversionSettings::spaceIgnorantAnnotationKey)); - m_ui.logCountSpinBox->setValue(s.intValue(SubversionSettings::logCountKey)); -} - -void SubversionSettingsPageWidget::apply() -{ - SubversionSettings rc = *m_settings; - rc.setValue(SubversionSettings::binaryPathKey, m_ui.pathChooser->rawPath()); - rc.setValue(SubversionSettings::useAuthenticationKey, m_ui.userGroupBox->isChecked()); - rc.setValue(SubversionSettings::userKey, m_ui.usernameLineEdit->text()); - rc.setValue(SubversionSettings::passwordKey, m_ui.passwordLineEdit->text()); - rc.setValue(SubversionSettings::timeoutKey, m_ui.timeOutSpinBox->value()); - if (rc.stringValue(SubversionSettings::userKey).isEmpty()) - rc.setValue(SubversionSettings::useAuthenticationKey, false); - rc.setValue(SubversionSettings::promptOnSubmitKey, m_ui.promptToSubmitCheckBox->isChecked()); - rc.setValue(SubversionSettings::spaceIgnorantAnnotationKey, - m_ui.spaceIgnorantAnnotationCheckBox->isChecked()); - rc.setValue(SubversionSettings::logCountKey, m_ui.logCountSpinBox->value()); - - if (rc == *m_settings) - return; - - *m_settings = rc; - m_onApply(); -} - -SubversionSettingsPage::SubversionSettingsPage(const std::function &onApply, SubversionSettings *settings) -{ - setId(VcsBase::Constants::VCS_ID_SUBVERSION); - setDisplayName(SubversionSettingsPageWidget::tr("Subversion")); - setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); - setWidgetCreator([onApply, settings] { return new SubversionSettingsPageWidget(onApply, settings); }); -} - -} // Internal -} // Subversion diff --git a/src/plugins/subversion/settingspage.h b/src/plugins/subversion/settingspage.h deleted file mode 100644 index 9778dfb2c42..00000000000 --- a/src/plugins/subversion/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 Subversion { -namespace Internal { - -class SubversionSettings; - -class SubversionSettingsPage final : public Core::IOptionsPage -{ -public: - SubversionSettingsPage(const std::function &onApply, SubversionSettings *settings); -}; - -} // namespace Subversion -} // namespace Internal diff --git a/src/plugins/subversion/settingspage.ui b/src/plugins/subversion/settingspage.ui deleted file mode 100644 index f2a9bc06918..00000000000 --- a/src/plugins/subversion/settingspage.ui +++ /dev/null @@ -1,180 +0,0 @@ - - - Subversion::Internal::SettingsPage - - - - 0 - 0 - 665 - 359 - - - - - - - Configuration - - - - QFormLayout::ExpandingFieldsGrow - - - - - Subversion command: - - - - - - - - - - - - - Authentication - - - true - - - - QFormLayout::ExpandingFieldsGrow - - - - - Username: - - - - - - - - - - Password: - - - - - - - QLineEdit::Password - - - - - - - - - - Miscellaneous - - - - - - Log count: - - - - - - - 10000 - - - 1000 - - - - - - - Timeout: - - - - - - - s - - - 1 - - - 360 - - - 30 - - - - - - - Qt::Horizontal - - - - 127 - 20 - - - - - - - - Prompt on submit - - - - - - - Ignore whitespace changes in annotation - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 - - editingFinished() - browsingFinished() - -
-
- - -
diff --git a/src/plugins/subversion/subversion.pro b/src/plugins/subversion/subversion.pro index b24824e43e9..4bc77a5ba63 100644 --- a/src/plugins/subversion/subversion.pro +++ b/src/plugins/subversion/subversion.pro @@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri) HEADERS += annotationhighlighter.h \ subversionplugin.h \ subversionclient.h \ - settingspage.h \ subversioneditor.h \ subversionsubmiteditor.h \ subversionsettings.h \ @@ -12,9 +11,6 @@ HEADERS += annotationhighlighter.h \ SOURCES += annotationhighlighter.cpp \ subversionplugin.cpp \ subversionclient.cpp \ - settingspage.cpp \ subversioneditor.cpp \ subversionsubmiteditor.cpp \ subversionsettings.cpp - -FORMS += settingspage.ui diff --git a/src/plugins/subversion/subversion.qbs b/src/plugins/subversion/subversion.qbs index 4ae10db96ba..3c36fa8bcce 100644 --- a/src/plugins/subversion/subversion.qbs +++ b/src/plugins/subversion/subversion.qbs @@ -14,9 +14,6 @@ QtcPlugin { files: [ "annotationhighlighter.cpp", "annotationhighlighter.h", - "settingspage.cpp", - "settingspage.h", - "settingspage.ui", "subversionclient.cpp", "subversionclient.h", "subversionconstants.h", diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index a8c0428e1a2..6ed9a8e50ae 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -60,16 +60,16 @@ class SubversionLogConfig : public VcsBaseEditorConfig { Q_OBJECT public: - SubversionLogConfig(VcsBaseClientSettings &settings, QToolBar *toolBar) : + SubversionLogConfig(SubversionSettings &settings, QToolBar *toolBar) : VcsBaseEditorConfig(toolBar) { - mapSetting(addToggleButton(QLatin1String("--verbose"), tr("Verbose"), + mapSetting(addToggleButton("--verbose", tr("Verbose"), tr("Show files changed in each revision")), - settings.boolPointer(SubversionSettings::logVerboseKey)); + &settings.logVerbose); } }; -SubversionClient::SubversionClient(SubversionSettings *settings) : VcsBaseClient(settings) +SubversionClient::SubversionClient(SubversionSettings *settings) : VcsBaseClient(nullptr, settings) { setLogConfigCreator([settings](QToolBar *toolBar) { return new SubversionLogConfig(*settings, toolBar); @@ -83,7 +83,7 @@ bool SubversionClient::doCommit(const QString &repositoryRoot, { const QStringList svnExtraOptions = QStringList(extraOptions) - << SubversionClient::addAuthenticationOptions(settings()) + << SubversionClient::addAuthenticationOptions(static_cast(baseSettings())) << QLatin1String(Constants::NON_INTERACTIVE_OPTION) << QLatin1String("--encoding") << QLatin1String("UTF-8") << QLatin1String("--file") << commitMessageFile; @@ -117,13 +117,13 @@ Id SubversionClient::vcsEditorKind(VcsCommandTag cmd) const } // Add authorization options to the command line arguments. -QStringList SubversionClient::addAuthenticationOptions(const VcsBaseClientSettings &settings) +QStringList SubversionClient::addAuthenticationOptions(const SubversionSettings &settings) { - if (!static_cast(settings).hasAuthentication()) + if (!settings.hasAuthentication()) return QStringList(); - const QString userName = settings.stringValue(SubversionSettings::userKey); - const QString password = settings.stringValue(SubversionSettings::passwordKey); + const QString userName = settings.userName.value(); + const QString password = settings.password.value(); if (userName.isEmpty()) return QStringList(); @@ -260,13 +260,14 @@ SubversionDiffEditorController *SubversionClient::findOrCreateDiffEditor(const Q const QString &title, const QString &workingDirectory) { + auto &settings = static_cast(baseSettings()); IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); auto controller = qobject_cast( DiffEditorController::controller(document)); if (!controller) { - controller = new SubversionDiffEditorController(document, addAuthenticationOptions(settings())); - controller->setVcsBinary(settings().binaryPath()); - controller->setVcsTimeoutS(settings().vcsTimeoutS()); + controller = new SubversionDiffEditorController(document, addAuthenticationOptions(settings)); + controller->setVcsBinary(settings.binaryPath.filePath()); + controller->setVcsTimeoutS(settings.timeout.value()); controller->setProcessEnvironment(processEnvironment()); controller->setWorkingDirectory(workingDirectory); } @@ -295,10 +296,10 @@ void SubversionClient::log(const QString &workingDir, const QStringList &extraOptions, bool enableAnnotationContextMenu) { - const auto logCount = settings().intValue(SubversionSettings::logCountKey); - QStringList svnExtraOptions = - QStringList(extraOptions) - << SubversionClient::addAuthenticationOptions(settings()); + auto &settings = static_cast(baseSettings()); + const int logCount = settings.logCount.value(); + QStringList svnExtraOptions = extraOptions; + svnExtraOptions.append(SubversionClient::addAuthenticationOptions(settings)); if (logCount > 0) svnExtraOptions << QLatin1String("-l") << QString::number(logCount); diff --git a/src/plugins/subversion/subversionclient.h b/src/plugins/subversion/subversionclient.h index 705efbc2731..7d7ec85b366 100644 --- a/src/plugins/subversion/subversionclient.h +++ b/src/plugins/subversion/subversionclient.h @@ -64,7 +64,7 @@ public: void describe(const QString &workingDirectory, int changeNumber, const QString &title); // Add authorization options to the command line arguments. - static QStringList addAuthenticationOptions(const VcsBase::VcsBaseClientSettings &settings); + static QStringList addAuthenticationOptions(const SubversionSettings &settings); QString synchronousTopic(const QString &repository) const; diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 3beb8d28fc0..bdf7400b8d9 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -25,7 +25,6 @@ #include "subversionplugin.h" -#include "settingspage.h" #include "subversioneditor.h" #include "subversionsubmiteditor.h" @@ -592,8 +591,7 @@ bool SubversionPluginPrivate::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(SubversionSettings::promptOnSubmitKey), - !m_submitActionTriggered); + this, nullptr, !m_submitActionTriggered, true, &m_settings.promptOnSubmit); m_submitActionTriggered = false; switch (answer) { case VcsBaseSubmitEditor::SubmitCanceled: @@ -691,7 +689,7 @@ void SubversionPluginPrivate::revertAll() args << SubversionClient::addAuthenticationOptions(m_settings); args << QLatin1String("--recursive") << state.topLevel(); const SubversionResponse revertResponse - = runSvn(state.topLevel(), args, m_settings.vcsTimeoutS(), + = runSvn(state.topLevel(), args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (revertResponse.error) QMessageBox::warning(ICore::dialogParent(), title, @@ -710,7 +708,7 @@ void SubversionPluginPrivate::revertCurrentFile() args.push_back(SubversionClient::escapeFile(state.relativeCurrentFile())); const SubversionResponse diffResponse - = runSvn(state.currentFileTopLevel(), args, m_settings.vcsTimeoutS(), 0); + = runSvn(state.currentFileTopLevel(), args, m_settings.timeout.value(), 0); if (diffResponse.error) return; @@ -731,7 +729,7 @@ void SubversionPluginPrivate::revertCurrentFile() args << SubversionClient::escapeFile(state.relativeCurrentFile()); const SubversionResponse revertResponse - = runSvn(state.currentFileTopLevel(), args, m_settings.vcsTimeoutS(), + = runSvn(state.currentFileTopLevel(), args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (!revertResponse.error) @@ -797,7 +795,7 @@ void SubversionPluginPrivate::startCommit(const QString &workingDir, const QStri args += SubversionClient::escapeFiles(files); const SubversionResponse response - = runSvn(workingDir, args, m_settings.vcsTimeoutS(), 0); + = runSvn(workingDir, args, m_settings.timeout.value(), 0); if (response.error) return; @@ -877,7 +875,7 @@ void SubversionPluginPrivate::svnStatus(const QString &workingDir, const QString if (!relativePath.isEmpty()) args.append(SubversionClient::escapeFile(relativePath)); VcsOutputWindow::setRepository(workingDir); - runSvn(workingDir, args, m_settings.vcsTimeoutS(), + runSvn(workingDir, args, m_settings.timeout.value(), VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage); VcsOutputWindow::clearRepository(); } @@ -904,7 +902,7 @@ void SubversionPluginPrivate::svnUpdate(const QString &workingDir, const QString if (!relativePath.isEmpty()) args.append(relativePath); const SubversionResponse response - = runSvn(workingDir, args, 10 * m_settings.vcsTimeoutS(), + = runSvn(workingDir, args, 10 * m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (!response.error) emit repositoryChanged(workingDir); @@ -926,7 +924,7 @@ void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const QStringList args(QLatin1String("annotate")); args << SubversionClient::addAuthenticationOptions(m_settings); - if (m_settings.boolValue(SubversionSettings::spaceIgnorantAnnotationKey)) + if (m_settings.spaceIgnorantAnnotation.value()) args << QLatin1String("-x") << QLatin1String("-uw"); if (!revision.isEmpty()) args << QLatin1String("-r") << revision; @@ -934,7 +932,7 @@ void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const args.append(QDir::toNativeSeparators(SubversionClient::escapeFile(file))); const SubversionResponse response - = runSvn(workingDir, args, m_settings.vcsTimeoutS(), + = runSvn(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ForceCLocale, codec); if (response.error) return; @@ -1019,7 +1017,7 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir, QTextCodec *outputCodec) const { SubversionResponse response; - if (m_settings.binaryPath().isEmpty()) { + if (m_settings.binaryPath.value().isEmpty()) { response.error = true; response.message =tr("No subversion executable specified."); return response; @@ -1030,7 +1028,7 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir, response.error = sp_resp.result != SynchronousProcessResponse::Finished; if (response.error) - response.message = sp_resp.exitMessage(m_settings.binaryPath().toString(), timeOutS); + response.message = sp_resp.exitMessage(m_settings.binaryPath.value(), timeOutS); response.stdErr = sp_resp.stdErr(); response.stdOut = sp_resp.stdOut(); return response; @@ -1093,7 +1091,7 @@ bool SubversionPluginPrivate::vcsAdd(const QString &workingDir, const QString &r << SubversionClient::addAuthenticationOptions(m_settings) << QLatin1String("--parents") << file; const SubversionResponse response - = runSvn(workingDir, args, m_settings.vcsTimeoutS(), + = runSvn(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return !response.error; } @@ -1108,7 +1106,7 @@ bool SubversionPluginPrivate::vcsDelete(const QString &workingDir, const QString << QLatin1String("--force") << file; const SubversionResponse response - = runSvn(workingDir, args, m_settings.vcsTimeoutS(), + = runSvn(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return !response.error; } @@ -1120,7 +1118,7 @@ bool SubversionPluginPrivate::vcsMove(const QString &workingDir, const QString & args << QDir::toNativeSeparators(SubversionClient::escapeFile(from)) << QDir::toNativeSeparators(SubversionClient::escapeFile(to)); const SubversionResponse response - = runSvn(workingDir, args, m_settings.vcsTimeoutS(), + = runSvn(workingDir, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut | VcsCommand::FullySynchronously); return !response.error; @@ -1149,7 +1147,7 @@ bool SubversionPluginPrivate::vcsCheckout(const QString &directory, const QByteA args << QLatin1String(tempUrl.toEncoded()) << directory; const SubversionResponse response - = runSvn(directory, args, 10 * m_settings.vcsTimeoutS(), VcsCommand::SshPasswordPrompt); + = runSvn(directory, args, 10 * m_settings.timeout.value(), VcsCommand::SshPasswordPrompt); return !response.error; } @@ -1184,7 +1182,7 @@ bool SubversionPluginPrivate::managesFile(const QString &workingDirectory, const args << SubversionClient::addAuthenticationOptions(m_settings) << QDir::toNativeSeparators(SubversionClient::escapeFile(fileName)); SubversionResponse response - = runSvn(workingDirectory, args, m_settings.vcsTimeoutS(), 0); + = runSvn(workingDirectory, args, m_settings.timeout.value(), 0); return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?'); } @@ -1220,7 +1218,7 @@ bool SubversionPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileNa bool SubversionPluginPrivate::isConfigured() const { - const Utils::FilePath binary = m_settings.binaryPath(); + const FilePath binary = m_settings.binaryPath.filePath(); if (binary.isEmpty()) return false; QFileInfo fi = binary.toFileInfo(); @@ -1293,7 +1291,7 @@ Core::ShellCommand *SubversionPluginPrivate::createInitialCheckoutCommand(const args << extraArgs << url << localName; auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment()); - command->addJob({m_settings.binaryPath(), args}, -1); + command->addJob({m_settings.binaryPath.filePath(), args}, -1); return command; } diff --git a/src/plugins/subversion/subversionsettings.cpp b/src/plugins/subversion/subversionsettings.cpp index 18c47e61d92..4820410ee53 100644 --- a/src/plugins/subversion/subversionsettings.cpp +++ b/src/plugins/subversion/subversionsettings.cpp @@ -25,38 +25,152 @@ #include "subversionsettings.h" +#include "subversionclient.h" +#include "subversionplugin.h" + +#include +#include + #include #include +#include +#include + +#include #include +using namespace Utils; +using namespace VcsBase; + namespace Subversion { namespace Internal { -const QLatin1String SubversionSettings::useAuthenticationKey("Authentication"); -const QLatin1String SubversionSettings::userKey("User"); -const QLatin1String SubversionSettings::passwordKey("Password"); -const QLatin1String SubversionSettings::spaceIgnorantAnnotationKey("SpaceIgnorantAnnotation"); -const QLatin1String SubversionSettings::diffIgnoreWhiteSpaceKey("DiffIgnoreWhiteSpace"); -const QLatin1String SubversionSettings::logVerboseKey("LogVerbose"); +// SubversionSettings SubversionSettings::SubversionSettings() { - setSettingsGroup(QLatin1String("Subversion")); - declareKey(binaryPathKey, QLatin1String("svn" QTC_HOST_EXE_SUFFIX)); - declareKey(logCountKey, 1000); - declareKey(useAuthenticationKey, false); - declareKey(userKey, QString()); - declareKey(passwordKey, QString()); - declareKey(spaceIgnorantAnnotationKey, true); - declareKey(diffIgnoreWhiteSpaceKey, false); - declareKey(logVerboseKey, false); + setAutoApply(false); + setSettingsGroup("Subversion"); + + registerAspect(&binaryPath); + binaryPath.setDisplayStyle(StringAspect::PathChooserDisplay); + binaryPath.setExpectedKind(PathChooser::ExistingCommand); + binaryPath.setHistoryCompleter("Subversion.Command.History"); + binaryPath.setDefaultValue("svn" QTC_HOST_EXE_SUFFIX); + binaryPath.setDisplayName(tr("Subversion Command")); + binaryPath.setLabelText(tr("Subversion command:")); + + registerAspect(&useAuthentication); + useAuthentication.setSettingsKey("Authentication"); + useAuthentication.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); + + registerAspect(&userName); + userName.setSettingsKey("User"); + userName.setDisplayStyle(StringAspect::LineEditDisplay); + userName.setLabelText(tr("Username:")); + + registerAspect(&password); + password.setSettingsKey("Password"); + password.setDisplayStyle(StringAspect::LineEditDisplay); + password.setLabelText(tr("Password:")); + + registerAspect(&spaceIgnorantAnnotation); + spaceIgnorantAnnotation.setSettingsKey("SpaceIgnorantAnnotation"); + spaceIgnorantAnnotation.setDefaultValue(true); + spaceIgnorantAnnotation.setLabelText(tr("Ignore whitespace changes in annotation")); + + registerAspect(&diffIgnoreWhiteSpace); + diffIgnoreWhiteSpace.setSettingsKey("DiffIgnoreWhiteSpace"); + + registerAspect(&logVerbose); + logVerbose.setSettingsKey("LogVerbose"); + + registerAspect(&logCount); + logCount.setDefaultValue(1000); + logCount.setLabelText(tr("Log count:")); + + registerAspect(&timeout); + timeout.setLabelText(tr("Timeout:")); + timeout.setSuffix(tr("s")); + + registerAspect(&promptOnSubmit); + promptOnSubmit.setLabelText(tr("Prompt on submit")); + + QObject::connect(&useAuthentication, &BaseAspect::changed, [this] { + userName.setEnabled(useAuthentication.value()); + password.setEnabled(useAuthentication.value()); + }); } bool SubversionSettings::hasAuthentication() const { - return boolValue(useAuthenticationKey) && !stringValue(userKey).isEmpty(); + return useAuthentication.value() && !userName.value().isEmpty(); } -} // namespace Internal -} // namespace Subversion +// SubversionSettingsPage + +class SubversionSettingsPageWidget final : public Core::IOptionsPageWidget +{ + Q_DECLARE_TR_FUNCTIONS(Subversion::Internal::SettingsPageWidget) + +public: + SubversionSettingsPageWidget(const std::function &onApply, SubversionSettings *settings); + + void apply() final; + +private: + std::function m_onApply; + SubversionSettings *m_settings; +}; + +SubversionSettingsPageWidget::SubversionSettingsPageWidget(const std::function &onApply, + SubversionSettings *settings) + : m_onApply(onApply), m_settings(settings) +{ + SubversionSettings &s = *m_settings; + + using namespace Layouting; + Break nl; + + Column { + Group { + Title(tr("Configuration")), + s.binaryPath + }, + + Group { + Title(tr("Authentication"), &s.useAuthentication), + Form { + s.userName, nl, + s.password, + } + }, + + Group { + Title(tr("Miscellaneous")), + Row { s.logCount, s.timeout, Stretch() }, nl, + s.promptOnSubmit, nl, + s.spaceIgnorantAnnotation, + }, + + Stretch() + }.attachTo(this); +} + +void SubversionSettingsPageWidget::apply() +{ + m_settings->apply(); + m_onApply(); +} + +SubversionSettingsPage::SubversionSettingsPage(const std::function &onApply, SubversionSettings *settings) +{ + setId(VcsBase::Constants::VCS_ID_SUBVERSION); + setDisplayName(SubversionSettingsPageWidget::tr("Subversion")); + setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); + setWidgetCreator([onApply, settings] { return new SubversionSettingsPageWidget(onApply, settings); }); +} + +} // Internal +} // Subversion diff --git a/src/plugins/subversion/subversionsettings.h b/src/plugins/subversion/subversionsettings.h index 6b54c24c007..893ad979eab 100644 --- a/src/plugins/subversion/subversionsettings.h +++ b/src/plugins/subversion/subversionsettings.h @@ -25,23 +25,32 @@ #pragma once +#include #include namespace Subversion { namespace Internal { -class SubversionSettings : public VcsBase::VcsBaseClientSettings +class SubversionSettings : public VcsBase::VcsBaseSettings +{ + Q_DECLARE_TR_FUNCTIONS(Subversion::Internal::SubversionSettings) + +public: + SubversionSettings(); + + bool hasAuthentication() const; + + Utils::BoolAspect useAuthentication; + Utils::StringAspect password; + Utils::BoolAspect spaceIgnorantAnnotation; + Utils::BoolAspect diffIgnoreWhiteSpace; + Utils::BoolAspect logVerbose; +}; + +class SubversionSettingsPage final : public Core::IOptionsPage { public: - static const QLatin1String useAuthenticationKey; - static const QLatin1String userKey; - static const QLatin1String passwordKey; - static const QLatin1String spaceIgnorantAnnotationKey; - static const QLatin1String diffIgnoreWhiteSpaceKey; - static const QLatin1String logVerboseKey; - - SubversionSettings(); - bool hasAuthentication() const; + SubversionSettingsPage(const std::function &onApply, SubversionSettings *settings); }; } // namespace Internal