1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "commonsettingspage.h"
35 #include "vcsbaseconstants.h"
36 #include "nicknamedialog.h"
38 #include "ui_commonsettingspage.h"
40 #include <coreplugin/icore.h>
41 #include <extensionsystem/pluginmanager.h>
43 #include <QtCore/QDebug>
44 #include <QtCore/QCoreApplication>
45 #include <QtGui/QMessageBox>
50 // ------------------ VCSBaseSettingsWidget
52 CommonSettingsWidget::CommonSettingsWidget(QWidget *parent) :
54 m_ui(new Ui::CommonSettingsPage)
57 m_ui->submitMessageCheckScriptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
58 m_ui->nickNameFieldsFileChooser->setExpectedKind(Utils::PathChooser::File);
59 m_ui->nickNameMailMapChooser->setExpectedKind(Utils::PathChooser::File);
60 m_ui->sshPromptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
63 CommonSettingsWidget::~CommonSettingsWidget()
68 CommonVcsSettings CommonSettingsWidget::settings() const
71 rc.nickNameMailMap = m_ui->nickNameMailMapChooser->path();
72 rc.nickNameFieldListFile = m_ui->nickNameFieldsFileChooser->path();
73 rc.submitMessageCheckScript = m_ui->submitMessageCheckScriptChooser->path();
74 rc.lineWrap= m_ui->lineWrapCheckBox->isChecked();
75 rc.lineWrapWidth = m_ui->lineWrapSpinBox->value();
76 rc.sshPasswordPrompt = m_ui->sshPromptChooser->path();
80 void CommonSettingsWidget::setSettings(const CommonVcsSettings &s)
82 m_ui->nickNameMailMapChooser->setPath(s.nickNameMailMap);
83 m_ui->nickNameFieldsFileChooser->setPath(s.nickNameFieldListFile);
84 m_ui->submitMessageCheckScriptChooser->setPath(s.submitMessageCheckScript);
85 m_ui->lineWrapCheckBox->setChecked(s.lineWrap);
86 m_ui->lineWrapSpinBox->setValue(s.lineWrapWidth);
87 m_ui->sshPromptChooser->setPath(s.sshPasswordPrompt);
90 QString CommonSettingsWidget::searchKeyWordMatchString() const
92 const QChar blank = QLatin1Char(' ');
93 QString rc = m_ui->lineWrapCheckBox->text()
94 + blank + m_ui->submitMessageCheckScriptLabel->text()
95 + blank + m_ui->nickNameMailMapLabel->text()
96 + blank + m_ui->nickNameFieldsFileLabel->text()
97 + blank + m_ui->sshPromptLabel->text()
99 rc.remove(QLatin1Char('&')); // Strip buddy markers.
103 // --------------- VCSBaseSettingsPage
104 CommonOptionsPage::CommonOptionsPage(QObject *parent) :
105 VCSBaseOptionsPage(parent)
107 m_settings.fromSettings(Core::ICore::instance()->settings());
110 void CommonOptionsPage::updateNickNames()
114 CommonOptionsPage::~CommonOptionsPage()
118 QString CommonOptionsPage::id() const
120 return QLatin1String(Constants::VCS_COMMON_SETTINGS_ID);
123 QString CommonOptionsPage::displayName() const
125 return QCoreApplication::translate("VCSBase", Constants::VCS_COMMON_SETTINGS_NAME);
128 QWidget *CommonOptionsPage::createPage(QWidget *parent)
130 m_widget = new CommonSettingsWidget(parent);
131 m_widget->setSettings(m_settings);
132 if (m_searchKeyWords.isEmpty())
133 m_searchKeyWords = m_widget->searchKeyWordMatchString();
137 void CommonOptionsPage::apply()
140 const CommonVcsSettings newSettings = m_widget->settings();
141 if (newSettings != m_settings) {
142 m_settings = newSettings;
143 m_settings.toSettings(Core::ICore::instance()->settings());
144 emit settingsChanged(m_settings);
149 bool CommonOptionsPage::matches(const QString &key) const
151 return m_searchKeyWords.contains(key, Qt::CaseInsensitive);
154 } // namespace Internal
155 } // namespace VCSBase