2009-03-19 17:40:01 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
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"
|
|
|
|
|
#include "nicknamedialog.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>
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
|
|
|
|
|
namespace VCSBase {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// ------------------ VCSBaseSettingsWidget
|
|
|
|
|
|
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);
|
2009-10-05 11:06:05 +02:00
|
|
|
m_ui->nickNameFieldsFileChooser->setExpectedKind(Utils::PathChooser::File);
|
|
|
|
|
m_ui->nickNameMailMapChooser->setExpectedKind(Utils::PathChooser::File);
|
2010-09-23 17:28:18 +02:00
|
|
|
m_ui->sshPromptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
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-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(' ');
|
|
|
|
|
QString rc = m_ui->submitMessageCheckScriptLabel->text();
|
|
|
|
|
rc += blank;
|
|
|
|
|
rc += m_ui->nickNameMailMapLabel->text();
|
|
|
|
|
rc += blank;
|
|
|
|
|
rc += m_ui->nickNameFieldsFileLabel->text();
|
2009-11-20 12:56:49 +01:00
|
|
|
rc.remove(QLatin1Char('&')); // Strip buddy markers.
|
2009-11-19 17:47:13 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-19 17:40:01 +01:00
|
|
|
// --------------- VCSBaseSettingsPage
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonOptionsPage::CommonOptionsPage(QObject *parent) :
|
2010-04-12 16:52:09 +02:00
|
|
|
VCSBaseOptionsPage(parent)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
m_settings.fromSettings(Core::ICore::instance()->settings());
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonOptionsPage::updateNickNames()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonOptionsPage::~CommonOptionsPage()
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QString CommonOptionsPage::id() const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
return QLatin1String(Constants::VCS_COMMON_SETTINGS_ID);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QString CommonOptionsPage::displayName() const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2009-11-27 16:12:12 +01:00
|
|
|
return 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;
|
|
|
|
|
m_settings.toSettings(Core::ICore::instance()->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
|
|
|
|
|
} // namespace VCSBase
|