CVS: Aspectify settings

Change-Id: Ib5170405b33b3e521470407065e85c95dad6163b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2021-03-16 16:55:02 +01:00
parent 8d6cb35b74
commit 78b4449692
13 changed files with 181 additions and 376 deletions

View File

@@ -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
)

View File

@@ -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

View File

@@ -23,8 +23,5 @@ QtcPlugin {
"cvssubmiteditor.h",
"cvsutils.cpp",
"cvsutils.h",
"settingspage.cpp",
"settingspage.h",
"settingspage.ui",
]
}

View File

@@ -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"));

View File

@@ -25,40 +25,62 @@
#include "cvssettings.h"
#include <utils/environment.h>
#include <utils/hostosinfo.h>
#include <coreplugin/icore.h>
#include <QSettings>
#include <QTextStream>
#include <utils/layoutbuilder.h>
#include <utils/pathchooser.h>
#include <vcsbase/vcsbaseconstants.h>
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<void()> & onApply, CvsSettings *settings);
void apply() final;
private:
std::function<void()> m_onApply;
CvsSettings *m_settings;
};
CvsSettingsPageWidget::CvsSettingsPageWidget(const std::function<void()> &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<void()> &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

View File

@@ -25,26 +25,34 @@
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
#include <vcsbase/vcsbaseclientsettings.h>
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<void()> &onApply, CvsSettings *settings);
};
} // namespace Internal
} // namespace Cvs

View File

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

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 Cvs {
namespace Internal {
class CvsSettings;
class CvsSettingsPage final : public Core::IOptionsPage
{
public:
CvsSettingsPage(const std::function<void()> &onApply, CvsSettings *settings);
};
} // namespace Cvs
} // namespace Internal

View File

@@ -1,144 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Cvs::Internal::SettingsPage</class>
<widget class="QWidget" name="Cvs::Internal::SettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>447</width>
<height>281</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="configGroupBox">
<property name="title">
<string>Configuration</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="commandLabel">
<property name="text">
<string>CVS command:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Utils::PathChooser" name="commandPathChooser" native="true"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="rootLabel">
<property name="text">
<string>CVS root:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="rootLineEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="miscGroupBox">
<property name="title">
<string>Miscellaneous</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="diffOptionsLabel">
<property name="text">
<string>Diff options:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="diffOptionsLineEdit"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="promptToSubmitCheckBox">
<property name="text">
<string>Prompt on submit</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="describeByCommitIdCheckBox">
<property name="toolTip">
<string>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.</string>
</property>
<property name="text">
<string>Describe all files matching commit id</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="timeOutLabel">
<property name="text">
<string>Timeout:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<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>
</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>
<tabstops>
<tabstop>rootLineEdit</tabstop>
<tabstop>timeOutSpinBox</tabstop>
<tabstop>diffOptionsLineEdit</tabstop>
<tabstop>promptToSubmitCheckBox</tabstop>
<tabstop>describeByCommitIdCheckBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -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<QVariant>();
}

View File

@@ -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());

View File

@@ -514,12 +514,13 @@ static QString withUnusedMnemonic(QString string, const QList<QPushButton *> &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<SubmitEditorWidget *>(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;

View File

@@ -29,6 +29,8 @@
#include <coreplugin/editormanager/ieditor.h>
#include <utils/aspects.h>
#include <QAbstractItemView>
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);