2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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 "commonsettingspage.h"
|
2009-03-19 17:40:01 +01:00
|
|
|
#include "vcsbaseconstants.h"
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
#include "ui_commonsettingspage.h"
|
2009-03-19 17:40:01 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2015-03-04 15:51:32 +01:00
|
|
|
#include <coreplugin/iversioncontrol.h>
|
2014-03-05 12:43:38 +01:00
|
|
|
#include <coreplugin/vcsmanager.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/hostosinfo.h>
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2009-03-19 17:40:01 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
// ------------------ VcsBaseSettingsWidget
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonSettingsWidget::CommonSettingsWidget(QWidget *parent) :
|
2009-03-19 17:40:01 +01:00
|
|
|
QWidget(parent),
|
2010-04-12 16:34:21 +02:00
|
|
|
m_ui(new Ui::CommonSettingsPage)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
2010-09-23 17:28:18 +02:00
|
|
|
m_ui->submitMessageCheckScriptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2013-11-25 14:39:07 +01:00
|
|
|
m_ui->submitMessageCheckScriptChooser->setHistoryCompleter(QLatin1String("Vcs.MessageCheckScript.History"));
|
2009-10-05 11:06:05 +02:00
|
|
|
m_ui->nickNameFieldsFileChooser->setExpectedKind(Utils::PathChooser::File);
|
2013-11-25 14:39:07 +01:00
|
|
|
m_ui->nickNameFieldsFileChooser->setHistoryCompleter(QLatin1String("Vcs.NickFields.History"));
|
2009-10-05 11:06:05 +02:00
|
|
|
m_ui->nickNameMailMapChooser->setExpectedKind(Utils::PathChooser::File);
|
2013-11-25 14:39:07 +01:00
|
|
|
m_ui->nickNameMailMapChooser->setHistoryCompleter(QLatin1String("Vcs.NickMap.History"));
|
2010-09-23 17:28:18 +02:00
|
|
|
m_ui->sshPromptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2013-11-25 14:39:07 +01:00
|
|
|
m_ui->sshPromptChooser->setHistoryCompleter(QLatin1String("Vcs.SshPrompt.History"));
|
2014-03-05 12:43:38 +01:00
|
|
|
|
|
|
|
|
updatePath();
|
|
|
|
|
|
2015-03-04 15:51:32 +01:00
|
|
|
connect(Core::VcsManager::instance(), &Core::VcsManager::configurationChanged,
|
|
|
|
|
this, &CommonSettingsWidget::updatePath);
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonSettingsWidget::~CommonSettingsWidget()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonVcsSettings CommonSettingsWidget::settings() const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonVcsSettings rc;
|
2009-03-19 17:40:01 +01:00
|
|
|
rc.nickNameMailMap = m_ui->nickNameMailMapChooser->path();
|
|
|
|
|
rc.nickNameFieldListFile = m_ui->nickNameFieldsFileChooser->path();
|
|
|
|
|
rc.submitMessageCheckScript = m_ui->submitMessageCheckScriptChooser->path();
|
2009-03-20 14:20:28 +01:00
|
|
|
rc.lineWrap= m_ui->lineWrapCheckBox->isChecked();
|
|
|
|
|
rc.lineWrapWidth = m_ui->lineWrapSpinBox->value();
|
2010-05-21 17:46:00 +02:00
|
|
|
rc.sshPasswordPrompt = m_ui->sshPromptChooser->path();
|
2009-03-19 17:40:01 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonSettingsWidget::setSettings(const CommonVcsSettings &s)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
m_ui->nickNameMailMapChooser->setPath(s.nickNameMailMap);
|
|
|
|
|
m_ui->nickNameFieldsFileChooser->setPath(s.nickNameFieldListFile);
|
|
|
|
|
m_ui->submitMessageCheckScriptChooser->setPath(s.submitMessageCheckScript);
|
2009-03-20 14:20:28 +01:00
|
|
|
m_ui->lineWrapCheckBox->setChecked(s.lineWrap);
|
|
|
|
|
m_ui->lineWrapSpinBox->setValue(s.lineWrapWidth);
|
2010-05-21 17:46:00 +02:00
|
|
|
m_ui->sshPromptChooser->setPath(s.sshPasswordPrompt);
|
2009-11-19 17:47:13 +01:00
|
|
|
}
|
|
|
|
|
|
2014-03-05 12:43:38 +01:00
|
|
|
void CommonSettingsWidget::updatePath()
|
|
|
|
|
{
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
QStringList toAdd = Core::VcsManager::additionalToolsPath();
|
2014-08-23 01:19:53 +02:00
|
|
|
env.appendOrSetPath(toAdd.join(Utils::HostOsInfo::pathListSeparator()));
|
2014-03-05 12:43:38 +01:00
|
|
|
m_ui->sshPromptChooser->setEnvironment(env);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
// --------------- VcsBaseSettingsPage
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonOptionsPage::CommonOptionsPage(QObject *parent) :
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsBaseOptionsPage(parent)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
m_settings.fromSettings(Core::ICore::settings());
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2013-01-16 15:22:58 +01:00
|
|
|
setId(Constants::VCS_COMMON_SETTINGS_ID);
|
2012-05-22 11:17:13 +02:00
|
|
|
setDisplayName(QCoreApplication::translate("VcsBase", Constants::VCS_COMMON_SETTINGS_NAME));
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-03 14:17:03 +01:00
|
|
|
QWidget *CommonOptionsPage::widget()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
if (!m_widget) {
|
|
|
|
|
m_widget = new CommonSettingsWidget;
|
|
|
|
|
m_widget->setSettings(m_settings);
|
|
|
|
|
}
|
2009-03-19 17:40:01 +01:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonOptionsPage::apply()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
if (m_widget) {
|
2010-04-12 16:34:21 +02:00
|
|
|
const CommonVcsSettings newSettings = m_widget->settings();
|
2009-03-19 17:40:01 +01:00
|
|
|
if (newSettings != m_settings) {
|
|
|
|
|
m_settings = newSettings;
|
2012-01-24 15:36:40 +01:00
|
|
|
m_settings.toSettings(Core::ICore::settings());
|
2009-03-20 14:20:28 +01:00
|
|
|
emit settingsChanged(m_settings);
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 14:17:03 +01:00
|
|
|
void CommonOptionsPage::finish()
|
2009-11-19 17:47:13 +01:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
delete m_widget;
|
2009-11-19 17:47:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
} // namespace Internal
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|