2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
#include "commonvcssettings.h"
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
#include "vcsbaseconstants.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/iversioncontrol.h>
|
|
|
|
|
#include <coreplugin/vcsmanager.h>
|
|
|
|
|
|
2021-11-09 18:20:14 +01:00
|
|
|
#include <utils/algorithm.h>
|
2021-03-23 13:57:54 +01:00
|
|
|
#include <utils/environment.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2021-03-23 13:57:54 +01:00
|
|
|
#include <utils/layoutbuilder.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2021-03-23 13:57:54 +01:00
|
|
|
#include <QPushButton>
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
using namespace Utils;
|
2009-03-20 14:20:28 +01:00
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
namespace VcsBase {
|
|
|
|
|
namespace Internal {
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-05-25 09:38:41 +02:00
|
|
|
// Return default for the ssh-askpass command (default to environment)
|
2021-03-23 13:57:54 +01:00
|
|
|
static QString sshPasswordPromptDefault()
|
2010-05-25 09:38:41 +02:00
|
|
|
{
|
2022-08-24 14:54:30 +02:00
|
|
|
const QString envSetting = qtcEnvironmentVariable("SSH_ASKPASS");
|
2010-05-25 09:38:41 +02:00
|
|
|
if (!envSetting.isEmpty())
|
2022-08-24 14:54:30 +02:00
|
|
|
return envSetting;
|
2021-03-23 13:57:54 +01:00
|
|
|
if (HostOsInfo::isWindowsHost())
|
2012-08-23 15:53:58 +02:00
|
|
|
return QLatin1String("win-ssh-askpass");
|
2010-05-25 09:38:41 +02:00
|
|
|
return QLatin1String("ssh-askpass");
|
|
|
|
|
}
|
2010-05-21 17:46:00 +02:00
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
CommonVcsSettings::CommonVcsSettings()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2021-03-23 13:57:54 +01:00
|
|
|
setSettingsGroup("VCS");
|
|
|
|
|
setAutoApply(false);
|
|
|
|
|
|
|
|
|
|
registerAspect(&nickNameMailMap);
|
|
|
|
|
nickNameMailMap.setSettingsKey("NickNameMailMap");
|
|
|
|
|
nickNameMailMap.setDisplayStyle(StringAspect::PathChooserDisplay);
|
|
|
|
|
nickNameMailMap.setExpectedKind(PathChooser::File);
|
|
|
|
|
nickNameMailMap.setHistoryCompleter("Vcs.NickMap.History");
|
|
|
|
|
nickNameMailMap.setLabelText(tr("User/&alias configuration file:"));
|
|
|
|
|
nickNameMailMap.setToolTip(tr("A file listing nicknames in a 4-column mailmap format:\n"
|
|
|
|
|
"'name <email> alias <email>'."));
|
|
|
|
|
|
|
|
|
|
registerAspect(&nickNameFieldListFile);
|
|
|
|
|
nickNameFieldListFile.setSettingsKey("NickNameFieldListFile");
|
|
|
|
|
nickNameFieldListFile.setDisplayStyle(StringAspect::PathChooserDisplay);
|
|
|
|
|
nickNameFieldListFile.setExpectedKind(PathChooser::File);
|
|
|
|
|
nickNameFieldListFile.setHistoryCompleter("Vcs.NickFields.History");
|
|
|
|
|
nickNameFieldListFile.setLabelText(tr("User &fields configuration file:"));
|
|
|
|
|
nickNameFieldListFile.setToolTip(tr("A simple file containing lines with field names like "
|
|
|
|
|
"\"Reviewed-By:\" which will be added below the submit editor."));
|
|
|
|
|
|
|
|
|
|
registerAspect(&submitMessageCheckScript);
|
|
|
|
|
submitMessageCheckScript.setSettingsKey("SubmitMessageCheckScript");
|
|
|
|
|
submitMessageCheckScript.setDisplayStyle(StringAspect::PathChooserDisplay);
|
|
|
|
|
submitMessageCheckScript.setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
submitMessageCheckScript.setHistoryCompleter("Vcs.MessageCheckScript.History");
|
|
|
|
|
submitMessageCheckScript.setLabelText(tr("Submit message &check script:"));
|
|
|
|
|
submitMessageCheckScript.setToolTip(tr("An executable which is called with the submit message "
|
|
|
|
|
"in a temporary file as first argument. It should return with an exit != 0 and a message "
|
|
|
|
|
"on standard error to indicate failure."));
|
|
|
|
|
|
|
|
|
|
registerAspect(&sshPasswordPrompt);
|
|
|
|
|
sshPasswordPrompt.setSettingsKey("SshPasswordPrompt");
|
|
|
|
|
sshPasswordPrompt.setDisplayStyle(StringAspect::PathChooserDisplay);
|
|
|
|
|
sshPasswordPrompt.setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
sshPasswordPrompt.setHistoryCompleter("Vcs.SshPrompt.History");
|
|
|
|
|
sshPasswordPrompt.setDefaultValue(sshPasswordPromptDefault());
|
|
|
|
|
sshPasswordPrompt.setLabelText(tr("&SSH prompt command:"));
|
|
|
|
|
sshPasswordPrompt.setToolTip(tr("Specifies a command that is executed to graphically prompt "
|
|
|
|
|
"for a password,\nshould a repository require SSH-authentication "
|
|
|
|
|
"(see documentation on SSH and the environment variable SSH_ASKPASS)."));
|
|
|
|
|
|
|
|
|
|
registerAspect(&lineWrap);
|
|
|
|
|
lineWrap.setSettingsKey("LineWrap");
|
2021-03-24 16:46:47 +01:00
|
|
|
lineWrap.setDefaultValue(true);
|
2021-03-23 13:57:54 +01:00
|
|
|
lineWrap.setLabelText(tr("Wrap submit message at:"));
|
|
|
|
|
|
|
|
|
|
registerAspect(&lineWrapWidth);
|
|
|
|
|
lineWrapWidth.setSettingsKey("LineWrapWidth");
|
|
|
|
|
lineWrapWidth.setSuffix(tr(" characters"));
|
2021-03-24 16:46:47 +01:00
|
|
|
lineWrapWidth.setDefaultValue(72);
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
// CommonSettingsWidget
|
|
|
|
|
|
|
|
|
|
class CommonSettingsWidget final : public Core::IOptionsPageWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CommonSettingsWidget(CommonOptionsPage *page);
|
|
|
|
|
|
|
|
|
|
void apply() final;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void updatePath();
|
|
|
|
|
CommonOptionsPage *m_page;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CommonSettingsWidget::CommonSettingsWidget(CommonOptionsPage *page)
|
|
|
|
|
: m_page(page)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2021-03-23 13:57:54 +01:00
|
|
|
CommonVcsSettings &s = m_page->settings();
|
|
|
|
|
|
|
|
|
|
auto cacheResetButton = new QPushButton(CommonVcsSettings::tr("Reset VCS Cache"));
|
|
|
|
|
cacheResetButton->setToolTip(CommonVcsSettings::tr("Reset information about which "
|
|
|
|
|
"version control system handles which directory."));
|
|
|
|
|
|
|
|
|
|
updatePath();
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
Column {
|
2022-07-22 18:54:04 +02:00
|
|
|
Row { s.lineWrap, s.lineWrapWidth, st },
|
2021-03-23 13:57:54 +01:00
|
|
|
Form {
|
|
|
|
|
s.submitMessageCheckScript,
|
|
|
|
|
s.nickNameMailMap,
|
|
|
|
|
s.nickNameFieldListFile,
|
|
|
|
|
s.sshPasswordPrompt,
|
|
|
|
|
{}, cacheResetButton
|
|
|
|
|
}
|
|
|
|
|
}.attachTo(this);
|
|
|
|
|
|
|
|
|
|
connect(Core::VcsManager::instance(), &Core::VcsManager::configurationChanged,
|
|
|
|
|
this, &CommonSettingsWidget::updatePath);
|
|
|
|
|
connect(cacheResetButton, &QPushButton::clicked,
|
|
|
|
|
Core::VcsManager::instance(), &Core::VcsManager::clearVersionControlCache);
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
void CommonSettingsWidget::updatePath()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2021-08-03 15:12:24 +02:00
|
|
|
EnvironmentChange change;
|
2021-11-10 16:28:53 +01:00
|
|
|
change.addAppendToPath(Core::VcsManager::additionalToolsPath());
|
2021-08-03 15:12:24 +02:00
|
|
|
m_page->settings().sshPasswordPrompt.setEnvironmentChange(change);
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
void CommonSettingsWidget::apply()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2021-03-23 13:57:54 +01:00
|
|
|
CommonVcsSettings &s = m_page->settings();
|
|
|
|
|
if (s.isDirty()) {
|
|
|
|
|
s.apply();
|
2021-03-24 18:39:21 +01:00
|
|
|
s.writeSettings(Core::ICore::settings());
|
2021-03-23 13:57:54 +01:00
|
|
|
emit m_page->settingsChanged();
|
|
|
|
|
}
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
// CommonOptionsPage
|
|
|
|
|
|
|
|
|
|
CommonOptionsPage::CommonOptionsPage()
|
2009-03-20 14:20:28 +01:00
|
|
|
{
|
2021-03-23 13:57:54 +01:00
|
|
|
m_settings.readSettings(Core::ICore::settings());
|
|
|
|
|
|
|
|
|
|
setId(Constants::VCS_COMMON_SETTINGS_ID);
|
|
|
|
|
setDisplayName(QCoreApplication::translate("VcsBase", Constants::VCS_COMMON_SETTINGS_NAME));
|
|
|
|
|
setCategory(Constants::VCS_SETTINGS_CATEGORY);
|
|
|
|
|
// The following act as blueprint for other pages in the same category:
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("VcsBase", "Version Control"));
|
|
|
|
|
setCategoryIconPath(":/vcsbase/images/settingscategory_vcs.png");
|
|
|
|
|
setWidgetCreator([this] { return new CommonSettingsWidget(this); });
|
2009-03-20 14:20:28 +01:00
|
|
|
}
|
2010-04-12 16:34:21 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|