2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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>
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
{
|
|
|
|
|
const QByteArray envSetting = qgetenv("SSH_ASKPASS");
|
|
|
|
|
if (!envSetting.isEmpty())
|
|
|
|
|
return QString::fromLocal8Bit(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 {
|
|
|
|
|
Row { s.lineWrap, s.lineWrapWidth, Stretch() },
|
|
|
|
|
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-03-23 13:57:54 +01:00
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
|
QStringList toAdd = Core::VcsManager::additionalToolsPath();
|
|
|
|
|
env.appendOrSetPath(toAdd.join(HostOsInfo::pathListSeparator()));
|
|
|
|
|
m_page->settings().sshPasswordPrompt.setEnvironment(env);
|
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();
|
|
|
|
|
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
|