2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 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"
|
2023-01-13 11:03:09 +01:00
|
|
|
#include "vcsbasetr.h"
|
2021-03-23 13:57:54 +01:00
|
|
|
|
2023-07-18 12:14:21 +02:00
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
2021-03-23 13:57:54 +01:00
|
|
|
#include <coreplugin/vcsmanager.h>
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
2023-06-01 14:30:06 +02:00
|
|
|
using namespace Core;
|
2021-03-23 13:57:54 +01:00
|
|
|
using namespace Utils;
|
2009-03-20 14:20:28 +01:00
|
|
|
|
2023-05-26 09:41:47 +02:00
|
|
|
namespace VcsBase::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
|
|
|
|
2023-06-01 14:30:06 +02:00
|
|
|
CommonVcsSettings &commonSettings()
|
|
|
|
|
{
|
2023-07-18 12:14:21 +02:00
|
|
|
static CommonVcsSettings settings;
|
|
|
|
|
return settings;
|
2023-06-01 14:30:06 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 13:57:54 +01:00
|
|
|
CommonVcsSettings::CommonVcsSettings()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2023-07-18 12:14:21 +02:00
|
|
|
setAutoApply(false);
|
2021-03-23 13:57:54 +01:00
|
|
|
setSettingsGroup("VCS");
|
|
|
|
|
|
|
|
|
|
nickNameMailMap.setSettingsKey("NickNameMailMap");
|
|
|
|
|
nickNameMailMap.setExpectedKind(PathChooser::File);
|
|
|
|
|
nickNameMailMap.setHistoryCompleter("Vcs.NickMap.History");
|
2023-01-18 09:38:35 +01:00
|
|
|
nickNameMailMap.setLabelText(Tr::tr("User/&alias configuration file:"));
|
|
|
|
|
nickNameMailMap.setToolTip(Tr::tr("A file listing nicknames in a 4-column mailmap format:\n"
|
2021-03-23 13:57:54 +01:00
|
|
|
"'name <email> alias <email>'."));
|
|
|
|
|
|
|
|
|
|
nickNameFieldListFile.setSettingsKey("NickNameFieldListFile");
|
|
|
|
|
nickNameFieldListFile.setExpectedKind(PathChooser::File);
|
|
|
|
|
nickNameFieldListFile.setHistoryCompleter("Vcs.NickFields.History");
|
2023-01-18 09:38:35 +01:00
|
|
|
nickNameFieldListFile.setLabelText(Tr::tr("User &fields configuration file:"));
|
|
|
|
|
nickNameFieldListFile.setToolTip(Tr::tr("A simple file containing lines with field names like "
|
2021-03-23 13:57:54 +01:00
|
|
|
"\"Reviewed-By:\" which will be added below the submit editor."));
|
|
|
|
|
|
|
|
|
|
submitMessageCheckScript.setSettingsKey("SubmitMessageCheckScript");
|
|
|
|
|
submitMessageCheckScript.setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
submitMessageCheckScript.setHistoryCompleter("Vcs.MessageCheckScript.History");
|
2023-01-18 09:38:35 +01:00
|
|
|
submitMessageCheckScript.setLabelText(Tr::tr("Submit message &check script:"));
|
|
|
|
|
submitMessageCheckScript.setToolTip(Tr::tr("An executable which is called with the submit message "
|
2021-03-23 13:57:54 +01:00
|
|
|
"in a temporary file as first argument. It should return with an exit != 0 and a message "
|
|
|
|
|
"on standard error to indicate failure."));
|
|
|
|
|
|
|
|
|
|
sshPasswordPrompt.setSettingsKey("SshPasswordPrompt");
|
|
|
|
|
sshPasswordPrompt.setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
sshPasswordPrompt.setHistoryCompleter("Vcs.SshPrompt.History");
|
2023-06-29 16:45:11 +02:00
|
|
|
sshPasswordPrompt.setDefaultValue(FilePath::fromUserInput(sshPasswordPromptDefault()));
|
2023-01-18 09:38:35 +01:00
|
|
|
sshPasswordPrompt.setLabelText(Tr::tr("&SSH prompt command:"));
|
|
|
|
|
sshPasswordPrompt.setToolTip(Tr::tr("Specifies a command that is executed to graphically prompt "
|
2021-03-23 13:57:54 +01:00
|
|
|
"for a password,\nshould a repository require SSH-authentication "
|
|
|
|
|
"(see documentation on SSH and the environment variable SSH_ASKPASS)."));
|
|
|
|
|
|
|
|
|
|
lineWrap.setSettingsKey("LineWrap");
|
2021-03-24 16:46:47 +01:00
|
|
|
lineWrap.setDefaultValue(true);
|
2023-01-18 09:38:35 +01:00
|
|
|
lineWrap.setLabelText(Tr::tr("Wrap submit message at:"));
|
2021-03-23 13:57:54 +01:00
|
|
|
|
|
|
|
|
lineWrapWidth.setSettingsKey("LineWrapWidth");
|
2023-01-18 09:38:35 +01:00
|
|
|
lineWrapWidth.setSuffix(Tr::tr(" characters"));
|
2021-03-24 16:46:47 +01:00
|
|
|
lineWrapWidth.setDefaultValue(72);
|
2023-05-08 13:06:14 +02:00
|
|
|
|
2023-06-01 14:30:06 +02:00
|
|
|
setLayouter([this] {
|
2023-05-08 13:06:14 +02:00
|
|
|
using namespace Layouting;
|
2023-06-01 14:30:06 +02:00
|
|
|
return Column {
|
|
|
|
|
Row { lineWrap, lineWrapWidth, st },
|
2023-05-08 13:06:14 +02:00
|
|
|
Form {
|
2023-06-01 14:30:06 +02:00
|
|
|
submitMessageCheckScript, br,
|
|
|
|
|
nickNameMailMap, br,
|
|
|
|
|
nickNameFieldListFile, br,
|
|
|
|
|
sshPasswordPrompt, br,
|
|
|
|
|
empty,
|
|
|
|
|
PushButton {
|
|
|
|
|
text(Tr::tr("Reset VCS Cache")),
|
|
|
|
|
tooltip(Tr::tr("Reset information about which "
|
|
|
|
|
"version control system handles which directory.")),
|
|
|
|
|
onClicked(&VcsManager::clearVersionControlCache)
|
|
|
|
|
}
|
2023-05-08 13:06:14 +02:00
|
|
|
}
|
2023-06-01 14:30:06 +02:00
|
|
|
};
|
|
|
|
|
});
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2023-06-01 14:30:06 +02:00
|
|
|
auto updatePath = [this] {
|
|
|
|
|
Environment env;
|
|
|
|
|
env.appendToPath(VcsManager::additionalToolsPath());
|
|
|
|
|
sshPasswordPrompt.setEnvironment(env);
|
|
|
|
|
};
|
2021-03-23 13:57:54 +01:00
|
|
|
|
2023-06-01 14:30:06 +02:00
|
|
|
updatePath();
|
|
|
|
|
connect(VcsManager::instance(), &VcsManager::configurationChanged, this, updatePath);
|
2021-03-23 13:57:54 +01:00
|
|
|
|
2023-06-01 14:30:06 +02:00
|
|
|
readSettings();
|
2009-03-20 14:20:28 +01:00
|
|
|
}
|
2010-04-12 16:34:21 +02:00
|
|
|
|
2023-07-18 12:14:21 +02:00
|
|
|
// CommonVcsSettingsPage
|
|
|
|
|
|
|
|
|
|
class CommonVcsSettingsPage final : public Core::IOptionsPage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CommonVcsSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::VCS_COMMON_SETTINGS_ID);
|
|
|
|
|
setDisplayName(Tr::tr("General"));
|
|
|
|
|
setCategory(Constants::VCS_SETTINGS_CATEGORY);
|
|
|
|
|
// The following act as blueprint for other pages in the same category:
|
|
|
|
|
setDisplayCategory(Tr::tr("Version Control"));
|
|
|
|
|
setCategoryIconPath(":/vcsbase/images/settingscategory_vcs.png");
|
|
|
|
|
setSettingsProvider([] { return &commonSettings(); });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CommonVcsSettingsPage settingsPage;
|
|
|
|
|
|
2023-05-26 09:41:47 +02:00
|
|
|
} // VcsBase::Internal
|