2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/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
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt 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>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#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"));
|
2011-03-24 15:44:39 +01:00
|
|
|
const QString patchToolTip = tr("Command used for reverting diff chunks");
|
|
|
|
|
m_ui->patchCommandLabel->setToolTip(patchToolTip);
|
|
|
|
|
m_ui->patchChooser->setToolTip(patchToolTip);
|
|
|
|
|
m_ui->patchChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2013-11-25 14:39:07 +01:00
|
|
|
m_ui->patchChooser->setHistoryCompleter(QLatin1String("Vcs.PatchCommand.History"));
|
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();
|
2011-03-24 15:44:39 +01:00
|
|
|
rc.patchCommand = m_ui->patchChooser->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);
|
2011-03-24 15:44:39 +01:00
|
|
|
m_ui->patchChooser->setPath(s.patchCommand);
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QString CommonSettingsWidget::searchKeyWordMatchString() const
|
2009-11-19 17:47:13 +01:00
|
|
|
{
|
|
|
|
|
const QChar blank = QLatin1Char(' ');
|
2010-12-01 14:35:36 +01:00
|
|
|
QString rc = m_ui->lineWrapCheckBox->text()
|
|
|
|
|
+ blank + m_ui->submitMessageCheckScriptLabel->text()
|
|
|
|
|
+ blank + m_ui->nickNameMailMapLabel->text()
|
|
|
|
|
+ blank + m_ui->nickNameFieldsFileLabel->text()
|
|
|
|
|
+ blank + m_ui->sshPromptLabel->text()
|
2012-10-17 21:52:42 +02:00
|
|
|
+ blank + m_ui->patchCommandLabel->text()
|
2010-12-01 14:35:36 +01:00
|
|
|
;
|
2009-11-20 12:56:49 +01:00
|
|
|
rc.remove(QLatin1Char('&')); // Strip buddy markers.
|
2009-11-19 17:47:13 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QWidget *CommonOptionsPage::createPage(QWidget *parent)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2010-04-12 16:34:21 +02:00
|
|
|
m_widget = new CommonSettingsWidget(parent);
|
2009-03-19 17:40:01 +01:00
|
|
|
m_widget->setSettings(m_settings);
|
2009-11-20 12:56:49 +01:00
|
|
|
if (m_searchKeyWords.isEmpty())
|
|
|
|
|
m_searchKeyWords = m_widget->searchKeyWordMatchString();
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
bool CommonOptionsPage::matches(const QString &key) const
|
2009-11-19 17:47:13 +01:00
|
|
|
{
|
|
|
|
|
return m_searchKeyWords.contains(key, Qt::CaseInsensitive);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
} // namespace Internal
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|