Subversion: Aspectify settings

Change-Id: I60a563511fce2e6487e8050541cedb086b0ab4e1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2021-03-18 18:23:21 +01:00
parent 4a2a0f1037
commit 62974b0ad9
13 changed files with 197 additions and 411 deletions

View File

@@ -416,10 +416,11 @@ LayoutBuilder::Space::Space(int space)
specialValue = space; specialValue = space;
} }
LayoutBuilder::Title::Title(const QString &title) LayoutBuilder::Title::Title(const QString &title, BoolAspect *check)
{ {
specialType = SpecialType::Title; specialType = SpecialType::Title;
specialValue = title; specialValue = title;
aspect = check;
} }
LayoutBuilder::Span::Span(int span_, const LayoutItem &item) LayoutBuilder::Span::Span(int span_, const LayoutItem &item)
@@ -445,6 +446,12 @@ Group::Group(std::initializer_list<LayoutItem> items)
if (item.specialType == LayoutBuilder::SpecialType::Title) { if (item.specialType == LayoutBuilder::SpecialType::Title) {
box->setTitle(item.specialValue.toString()); box->setTitle(item.specialValue.toString());
box->setObjectName(item.specialValue.toString()); box->setObjectName(item.specialValue.toString());
if (auto check = qobject_cast<BoolAspect *>(item.aspect)) {
box->setCheckable(true);
QObject::connect(box, &QGroupBox::clicked, box, [check](bool on) {
check->setValue(on);
});
}
} else { } else {
builder.addItem(item); builder.addItem(item);
} }

View File

@@ -39,6 +39,7 @@ QT_END_NAMESPACE
namespace Utils { namespace Utils {
class BaseAspect; class BaseAspect;
class BoolAspect;
class QTCREATOR_UTILS_EXPORT LayoutBuilder class QTCREATOR_UTILS_EXPORT LayoutBuilder
{ {
@@ -141,7 +142,7 @@ public:
class QTCREATOR_UTILS_EXPORT Title : public LayoutItem class QTCREATOR_UTILS_EXPORT Title : public LayoutItem
{ {
public: public:
explicit Title(const QString &title); explicit Title(const QString &title, BoolAspect *check = nullptr);
}; };
protected: protected:

View File

@@ -2,7 +2,6 @@ add_qtc_plugin(Subversion
PLUGIN_DEPENDS Core DiffEditor TextEditor VcsBase PLUGIN_DEPENDS Core DiffEditor TextEditor VcsBase
SOURCES SOURCES
annotationhighlighter.cpp annotationhighlighter.h annotationhighlighter.cpp annotationhighlighter.h
settingspage.cpp settingspage.h settingspage.ui
subversionclient.cpp subversionclient.h subversionclient.cpp subversionclient.h
subversionconstants.h subversionconstants.h
subversioneditor.cpp subversioneditor.h subversioneditor.cpp subversioneditor.h

View File

@@ -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 <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <vcsbase/vcsbaseconstants.h>
#include <utils/pathchooser.h>
#include <QCoreApplication>
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<void()> &onApply, SubversionSettings *settings);
void apply() final;
private:
Ui::SettingsPage m_ui;
std::function<void()> m_onApply;
SubversionSettings *m_settings;
};
SubversionSettingsPageWidget::SubversionSettingsPageWidget(const std::function<void()> &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<void()> &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

View File

@@ -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 <coreplugin/dialogs/ioptionspage.h>
namespace Subversion {
namespace Internal {
class SubversionSettings;
class SubversionSettingsPage final : public Core::IOptionsPage
{
public:
SubversionSettingsPage(const std::function<void()> &onApply, SubversionSettings *settings);
};
} // namespace Subversion
} // namespace Internal

View File

@@ -1,180 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Subversion::Internal::SettingsPage</class>
<widget class="QWidget" name="Subversion::Internal::SettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>665</width>
<height>359</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>Configuration</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="commandLabel">
<property name="text">
<string>Subversion command:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Utils::PathChooser" name="pathChooser" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="userGroupBox">
<property name="title">
<string>Authentication</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="usernameLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="passwordLineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="miscGroupBox">
<property name="title">
<string>Miscellaneous</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="logCountLabel">
<property name="text">
<string>Log count:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="logCountSpinBox">
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="timeOutLabel">
<property name="text">
<string>Timeout:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="timeOutSpinBox">
<property name="suffix">
<string>s</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>360</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>127</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="promptToSubmitCheckBox">
<property name="text">
<string>Prompt on submit</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<widget class="QCheckBox" name="spaceIgnorantAnnotationCheckBox">
<property name="text">
<string>Ignore whitespace changes in annotation</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
<slots>
<signal>editingFinished()</signal>
<signal>browsingFinished()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
HEADERS += annotationhighlighter.h \ HEADERS += annotationhighlighter.h \
subversionplugin.h \ subversionplugin.h \
subversionclient.h \ subversionclient.h \
settingspage.h \
subversioneditor.h \ subversioneditor.h \
subversionsubmiteditor.h \ subversionsubmiteditor.h \
subversionsettings.h \ subversionsettings.h \
@@ -12,9 +11,6 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \ SOURCES += annotationhighlighter.cpp \
subversionplugin.cpp \ subversionplugin.cpp \
subversionclient.cpp \ subversionclient.cpp \
settingspage.cpp \
subversioneditor.cpp \ subversioneditor.cpp \
subversionsubmiteditor.cpp \ subversionsubmiteditor.cpp \
subversionsettings.cpp subversionsettings.cpp
FORMS += settingspage.ui

View File

@@ -14,9 +14,6 @@ QtcPlugin {
files: [ files: [
"annotationhighlighter.cpp", "annotationhighlighter.cpp",
"annotationhighlighter.h", "annotationhighlighter.h",
"settingspage.cpp",
"settingspage.h",
"settingspage.ui",
"subversionclient.cpp", "subversionclient.cpp",
"subversionclient.h", "subversionclient.h",
"subversionconstants.h", "subversionconstants.h",

View File

@@ -60,16 +60,16 @@ class SubversionLogConfig : public VcsBaseEditorConfig
{ {
Q_OBJECT Q_OBJECT
public: public:
SubversionLogConfig(VcsBaseClientSettings &settings, QToolBar *toolBar) : SubversionLogConfig(SubversionSettings &settings, QToolBar *toolBar) :
VcsBaseEditorConfig(toolBar) VcsBaseEditorConfig(toolBar)
{ {
mapSetting(addToggleButton(QLatin1String("--verbose"), tr("Verbose"), mapSetting(addToggleButton("--verbose", tr("Verbose"),
tr("Show files changed in each revision")), 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) { setLogConfigCreator([settings](QToolBar *toolBar) {
return new SubversionLogConfig(*settings, toolBar); return new SubversionLogConfig(*settings, toolBar);
@@ -83,7 +83,7 @@ bool SubversionClient::doCommit(const QString &repositoryRoot,
{ {
const QStringList svnExtraOptions = const QStringList svnExtraOptions =
QStringList(extraOptions) QStringList(extraOptions)
<< SubversionClient::addAuthenticationOptions(settings()) << SubversionClient::addAuthenticationOptions(static_cast<SubversionSettings &>(baseSettings()))
<< QLatin1String(Constants::NON_INTERACTIVE_OPTION) << QLatin1String(Constants::NON_INTERACTIVE_OPTION)
<< QLatin1String("--encoding") << QLatin1String("UTF-8") << QLatin1String("--encoding") << QLatin1String("UTF-8")
<< QLatin1String("--file") << commitMessageFile; << QLatin1String("--file") << commitMessageFile;
@@ -117,13 +117,13 @@ Id SubversionClient::vcsEditorKind(VcsCommandTag cmd) const
} }
// Add authorization options to the command line arguments. // Add authorization options to the command line arguments.
QStringList SubversionClient::addAuthenticationOptions(const VcsBaseClientSettings &settings) QStringList SubversionClient::addAuthenticationOptions(const SubversionSettings &settings)
{ {
if (!static_cast<const SubversionSettings &>(settings).hasAuthentication()) if (!settings.hasAuthentication())
return QStringList(); return QStringList();
const QString userName = settings.stringValue(SubversionSettings::userKey); const QString userName = settings.userName.value();
const QString password = settings.stringValue(SubversionSettings::passwordKey); const QString password = settings.password.value();
if (userName.isEmpty()) if (userName.isEmpty())
return QStringList(); return QStringList();
@@ -260,13 +260,14 @@ SubversionDiffEditorController *SubversionClient::findOrCreateDiffEditor(const Q
const QString &title, const QString &title,
const QString &workingDirectory) const QString &workingDirectory)
{ {
auto &settings = static_cast<SubversionSettings &>(baseSettings());
IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title);
auto controller = qobject_cast<SubversionDiffEditorController *>( auto controller = qobject_cast<SubversionDiffEditorController *>(
DiffEditorController::controller(document)); DiffEditorController::controller(document));
if (!controller) { if (!controller) {
controller = new SubversionDiffEditorController(document, addAuthenticationOptions(settings())); controller = new SubversionDiffEditorController(document, addAuthenticationOptions(settings));
controller->setVcsBinary(settings().binaryPath()); controller->setVcsBinary(settings.binaryPath.filePath());
controller->setVcsTimeoutS(settings().vcsTimeoutS()); controller->setVcsTimeoutS(settings.timeout.value());
controller->setProcessEnvironment(processEnvironment()); controller->setProcessEnvironment(processEnvironment());
controller->setWorkingDirectory(workingDirectory); controller->setWorkingDirectory(workingDirectory);
} }
@@ -295,10 +296,10 @@ void SubversionClient::log(const QString &workingDir,
const QStringList &extraOptions, const QStringList &extraOptions,
bool enableAnnotationContextMenu) bool enableAnnotationContextMenu)
{ {
const auto logCount = settings().intValue(SubversionSettings::logCountKey); auto &settings = static_cast<SubversionSettings &>(baseSettings());
QStringList svnExtraOptions = const int logCount = settings.logCount.value();
QStringList(extraOptions) QStringList svnExtraOptions = extraOptions;
<< SubversionClient::addAuthenticationOptions(settings()); svnExtraOptions.append(SubversionClient::addAuthenticationOptions(settings));
if (logCount > 0) if (logCount > 0)
svnExtraOptions << QLatin1String("-l") << QString::number(logCount); svnExtraOptions << QLatin1String("-l") << QString::number(logCount);

View File

@@ -64,7 +64,7 @@ public:
void describe(const QString &workingDirectory, int changeNumber, const QString &title); void describe(const QString &workingDirectory, int changeNumber, const QString &title);
// Add authorization options to the command line arguments. // 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; QString synchronousTopic(const QString &repository) const;

View File

@@ -25,7 +25,6 @@
#include "subversionplugin.h" #include "subversionplugin.h"
#include "settingspage.h"
#include "subversioneditor.h" #include "subversioneditor.h"
#include "subversionsubmiteditor.h" #include "subversionsubmiteditor.h"
@@ -592,8 +591,7 @@ bool SubversionPluginPrivate::submitEditorAboutToClose()
// Prompt user. Force a prompt unless submit was actually invoked (that // Prompt user. Force a prompt unless submit was actually invoked (that
// is, the editor was closed or shutdown). // is, the editor was closed or shutdown).
const VcsBaseSubmitEditor::PromptSubmitResult answer = editor->promptSubmit( const VcsBaseSubmitEditor::PromptSubmitResult answer = editor->promptSubmit(
this, m_settings.boolPointer(SubversionSettings::promptOnSubmitKey), this, nullptr, !m_submitActionTriggered, true, &m_settings.promptOnSubmit);
!m_submitActionTriggered);
m_submitActionTriggered = false; m_submitActionTriggered = false;
switch (answer) { switch (answer) {
case VcsBaseSubmitEditor::SubmitCanceled: case VcsBaseSubmitEditor::SubmitCanceled:
@@ -691,7 +689,7 @@ void SubversionPluginPrivate::revertAll()
args << SubversionClient::addAuthenticationOptions(m_settings); args << SubversionClient::addAuthenticationOptions(m_settings);
args << QLatin1String("--recursive") << state.topLevel(); args << QLatin1String("--recursive") << state.topLevel();
const SubversionResponse revertResponse const SubversionResponse revertResponse
= runSvn(state.topLevel(), args, m_settings.vcsTimeoutS(), = runSvn(state.topLevel(), args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (revertResponse.error) if (revertResponse.error)
QMessageBox::warning(ICore::dialogParent(), title, QMessageBox::warning(ICore::dialogParent(), title,
@@ -710,7 +708,7 @@ void SubversionPluginPrivate::revertCurrentFile()
args.push_back(SubversionClient::escapeFile(state.relativeCurrentFile())); args.push_back(SubversionClient::escapeFile(state.relativeCurrentFile()));
const SubversionResponse diffResponse const SubversionResponse diffResponse
= runSvn(state.currentFileTopLevel(), args, m_settings.vcsTimeoutS(), 0); = runSvn(state.currentFileTopLevel(), args, m_settings.timeout.value(), 0);
if (diffResponse.error) if (diffResponse.error)
return; return;
@@ -731,7 +729,7 @@ void SubversionPluginPrivate::revertCurrentFile()
args << SubversionClient::escapeFile(state.relativeCurrentFile()); args << SubversionClient::escapeFile(state.relativeCurrentFile());
const SubversionResponse revertResponse const SubversionResponse revertResponse
= runSvn(state.currentFileTopLevel(), args, m_settings.vcsTimeoutS(), = runSvn(state.currentFileTopLevel(), args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (!revertResponse.error) if (!revertResponse.error)
@@ -797,7 +795,7 @@ void SubversionPluginPrivate::startCommit(const QString &workingDir, const QStri
args += SubversionClient::escapeFiles(files); args += SubversionClient::escapeFiles(files);
const SubversionResponse response const SubversionResponse response
= runSvn(workingDir, args, m_settings.vcsTimeoutS(), 0); = runSvn(workingDir, args, m_settings.timeout.value(), 0);
if (response.error) if (response.error)
return; return;
@@ -877,7 +875,7 @@ void SubversionPluginPrivate::svnStatus(const QString &workingDir, const QString
if (!relativePath.isEmpty()) if (!relativePath.isEmpty())
args.append(SubversionClient::escapeFile(relativePath)); args.append(SubversionClient::escapeFile(relativePath));
VcsOutputWindow::setRepository(workingDir); VcsOutputWindow::setRepository(workingDir);
runSvn(workingDir, args, m_settings.vcsTimeoutS(), runSvn(workingDir, args, m_settings.timeout.value(),
VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage); VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
VcsOutputWindow::clearRepository(); VcsOutputWindow::clearRepository();
} }
@@ -904,7 +902,7 @@ void SubversionPluginPrivate::svnUpdate(const QString &workingDir, const QString
if (!relativePath.isEmpty()) if (!relativePath.isEmpty())
args.append(relativePath); args.append(relativePath);
const SubversionResponse response const SubversionResponse response
= runSvn(workingDir, args, 10 * m_settings.vcsTimeoutS(), = runSvn(workingDir, args, 10 * m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (!response.error) if (!response.error)
emit repositoryChanged(workingDir); emit repositoryChanged(workingDir);
@@ -926,7 +924,7 @@ void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const
QStringList args(QLatin1String("annotate")); QStringList args(QLatin1String("annotate"));
args << SubversionClient::addAuthenticationOptions(m_settings); args << SubversionClient::addAuthenticationOptions(m_settings);
if (m_settings.boolValue(SubversionSettings::spaceIgnorantAnnotationKey)) if (m_settings.spaceIgnorantAnnotation.value())
args << QLatin1String("-x") << QLatin1String("-uw"); args << QLatin1String("-x") << QLatin1String("-uw");
if (!revision.isEmpty()) if (!revision.isEmpty())
args << QLatin1String("-r") << revision; args << QLatin1String("-r") << revision;
@@ -934,7 +932,7 @@ void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const
args.append(QDir::toNativeSeparators(SubversionClient::escapeFile(file))); args.append(QDir::toNativeSeparators(SubversionClient::escapeFile(file)));
const SubversionResponse response const SubversionResponse response
= runSvn(workingDir, args, m_settings.vcsTimeoutS(), = runSvn(workingDir, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ForceCLocale, codec); VcsCommand::SshPasswordPrompt | VcsCommand::ForceCLocale, codec);
if (response.error) if (response.error)
return; return;
@@ -1019,7 +1017,7 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir,
QTextCodec *outputCodec) const QTextCodec *outputCodec) const
{ {
SubversionResponse response; SubversionResponse response;
if (m_settings.binaryPath().isEmpty()) { if (m_settings.binaryPath.value().isEmpty()) {
response.error = true; response.error = true;
response.message =tr("No subversion executable specified."); response.message =tr("No subversion executable specified.");
return response; return response;
@@ -1030,7 +1028,7 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir,
response.error = sp_resp.result != SynchronousProcessResponse::Finished; response.error = sp_resp.result != SynchronousProcessResponse::Finished;
if (response.error) 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.stdErr = sp_resp.stdErr();
response.stdOut = sp_resp.stdOut(); response.stdOut = sp_resp.stdOut();
return response; return response;
@@ -1093,7 +1091,7 @@ bool SubversionPluginPrivate::vcsAdd(const QString &workingDir, const QString &r
<< SubversionClient::addAuthenticationOptions(m_settings) << SubversionClient::addAuthenticationOptions(m_settings)
<< QLatin1String("--parents") << file; << QLatin1String("--parents") << file;
const SubversionResponse response const SubversionResponse response
= runSvn(workingDir, args, m_settings.vcsTimeoutS(), = runSvn(workingDir, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
return !response.error; return !response.error;
} }
@@ -1108,7 +1106,7 @@ bool SubversionPluginPrivate::vcsDelete(const QString &workingDir, const QString
<< QLatin1String("--force") << file; << QLatin1String("--force") << file;
const SubversionResponse response const SubversionResponse response
= runSvn(workingDir, args, m_settings.vcsTimeoutS(), = runSvn(workingDir, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
return !response.error; return !response.error;
} }
@@ -1120,7 +1118,7 @@ bool SubversionPluginPrivate::vcsMove(const QString &workingDir, const QString &
args << QDir::toNativeSeparators(SubversionClient::escapeFile(from)) args << QDir::toNativeSeparators(SubversionClient::escapeFile(from))
<< QDir::toNativeSeparators(SubversionClient::escapeFile(to)); << QDir::toNativeSeparators(SubversionClient::escapeFile(to));
const SubversionResponse response const SubversionResponse response
= runSvn(workingDir, args, m_settings.vcsTimeoutS(), = runSvn(workingDir, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut
| VcsCommand::FullySynchronously); | VcsCommand::FullySynchronously);
return !response.error; return !response.error;
@@ -1149,7 +1147,7 @@ bool SubversionPluginPrivate::vcsCheckout(const QString &directory, const QByteA
args << QLatin1String(tempUrl.toEncoded()) << directory; args << QLatin1String(tempUrl.toEncoded()) << directory;
const SubversionResponse response 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; return !response.error;
} }
@@ -1184,7 +1182,7 @@ bool SubversionPluginPrivate::managesFile(const QString &workingDirectory, const
args << SubversionClient::addAuthenticationOptions(m_settings) args << SubversionClient::addAuthenticationOptions(m_settings)
<< QDir::toNativeSeparators(SubversionClient::escapeFile(fileName)); << QDir::toNativeSeparators(SubversionClient::escapeFile(fileName));
SubversionResponse response 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('?'); return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?');
} }
@@ -1220,7 +1218,7 @@ bool SubversionPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileNa
bool SubversionPluginPrivate::isConfigured() const bool SubversionPluginPrivate::isConfigured() const
{ {
const Utils::FilePath binary = m_settings.binaryPath(); const FilePath binary = m_settings.binaryPath.filePath();
if (binary.isEmpty()) if (binary.isEmpty())
return false; return false;
QFileInfo fi = binary.toFileInfo(); QFileInfo fi = binary.toFileInfo();
@@ -1293,7 +1291,7 @@ Core::ShellCommand *SubversionPluginPrivate::createInitialCheckoutCommand(const
args << extraArgs << url << localName; args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment()); 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; return command;
} }

View File

@@ -25,38 +25,152 @@
#include "subversionsettings.h" #include "subversionsettings.h"
#include "subversionclient.h"
#include "subversionplugin.h"
#include <coreplugin/icore.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h>
#include <utils/pathchooser.h>
#include <vcsbase/vcsbaseconstants.h>
#include <QSettings> #include <QSettings>
using namespace Utils;
using namespace VcsBase;
namespace Subversion { namespace Subversion {
namespace Internal { namespace Internal {
const QLatin1String SubversionSettings::useAuthenticationKey("Authentication"); // SubversionSettings
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::SubversionSettings()
{ {
setSettingsGroup(QLatin1String("Subversion")); setAutoApply(false);
declareKey(binaryPathKey, QLatin1String("svn" QTC_HOST_EXE_SUFFIX)); setSettingsGroup("Subversion");
declareKey(logCountKey, 1000);
declareKey(useAuthenticationKey, false); registerAspect(&binaryPath);
declareKey(userKey, QString()); binaryPath.setDisplayStyle(StringAspect::PathChooserDisplay);
declareKey(passwordKey, QString()); binaryPath.setExpectedKind(PathChooser::ExistingCommand);
declareKey(spaceIgnorantAnnotationKey, true); binaryPath.setHistoryCompleter("Subversion.Command.History");
declareKey(diffIgnoreWhiteSpaceKey, false); binaryPath.setDefaultValue("svn" QTC_HOST_EXE_SUFFIX);
declareKey(logVerboseKey, false); 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 bool SubversionSettings::hasAuthentication() const
{ {
return boolValue(useAuthenticationKey) && !stringValue(userKey).isEmpty(); return useAuthentication.value() && !userName.value().isEmpty();
} }
} // namespace Internal // SubversionSettingsPage
} // namespace Subversion
class SubversionSettingsPageWidget final : public Core::IOptionsPageWidget
{
Q_DECLARE_TR_FUNCTIONS(Subversion::Internal::SettingsPageWidget)
public:
SubversionSettingsPageWidget(const std::function<void()> &onApply, SubversionSettings *settings);
void apply() final;
private:
std::function<void()> m_onApply;
SubversionSettings *m_settings;
};
SubversionSettingsPageWidget::SubversionSettingsPageWidget(const std::function<void()> &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<void()> &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

View File

@@ -25,23 +25,32 @@
#pragma once #pragma once
#include <coreplugin/dialogs/ioptionspage.h>
#include <vcsbase/vcsbaseclientsettings.h> #include <vcsbase/vcsbaseclientsettings.h>
namespace Subversion { namespace Subversion {
namespace Internal { 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: public:
static const QLatin1String useAuthenticationKey; SubversionSettingsPage(const std::function<void()> &onApply, SubversionSettings *settings);
static const QLatin1String userKey;
static const QLatin1String passwordKey;
static const QLatin1String spaceIgnorantAnnotationKey;
static const QLatin1String diffIgnoreWhiteSpaceKey;
static const QLatin1String logVerboseKey;
SubversionSettings();
bool hasAuthentication() const;
}; };
} // namespace Internal } // namespace Internal