2009-11-02 18:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Brian McGillion
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
#include "mercurialsettings.h"
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Mercurial::Internal;
|
|
|
|
|
|
|
|
|
|
MercurialSettings::MercurialSettings()
|
|
|
|
|
{
|
|
|
|
|
readSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::binary() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return bin;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::application() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return app;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QStringList MercurialSettings::standardArguments() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return standardArgs;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::userName() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return user;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::email() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return mail;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
int MercurialSettings::logCount() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return m_logCount;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
int MercurialSettings::timeout() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
//return timeout is in Ms
|
|
|
|
|
return m_timeout * 1000;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
int MercurialSettings::timeoutSeconds() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
//return timeout in seconds (as the user specifies on the options page
|
|
|
|
|
return m_timeout;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
bool MercurialSettings::prompt() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return m_prompt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::writeSettings(const QString &application, const QString &userName,
|
|
|
|
|
const QString &email, int logCount, int timeout, bool prompt)
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
if (settings) {
|
2009-11-03 16:38:39 +01:00
|
|
|
settings->beginGroup(QLatin1String("Mercurial"));
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALPATH), application);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALUSERNAME), userName);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALEMAIL), email);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALLOGCOUNT), logCount);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALTIMEOUT), timeout);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALPROMPTSUBMIT), prompt);
|
2009-09-15 13:03:13 +03:00
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app = application;
|
|
|
|
|
user = userName;
|
|
|
|
|
mail = email;
|
|
|
|
|
m_logCount = logCount;
|
|
|
|
|
m_timeout = timeout;
|
|
|
|
|
m_prompt = prompt;
|
|
|
|
|
setBinAndArgs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::readSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
if (settings) {
|
2009-11-03 16:38:39 +01:00
|
|
|
settings->beginGroup(QLatin1String("Mercurial"));
|
|
|
|
|
app = settings->value(QLatin1String(Constants::MERCURIALPATH),
|
|
|
|
|
QLatin1String(Constants::MERCURIALDEFAULT)).toString();
|
|
|
|
|
user = settings->value(QLatin1String(Constants::MERCURIALUSERNAME), QString()).toString();
|
|
|
|
|
mail = settings->value(QLatin1String(Constants::MERCURIALEMAIL), QString()).toString();
|
|
|
|
|
m_logCount = settings->value(QLatin1String(Constants::MERCURIALLOGCOUNT), 0).toInt();
|
|
|
|
|
m_timeout = settings->value(QLatin1String(Constants::MERCURIALTIMEOUT), 30).toInt();
|
|
|
|
|
m_prompt = settings->value(QLatin1String(Constants::MERCURIALPROMPTSUBMIT), true).toBool();
|
2009-09-15 13:03:13 +03:00
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setBinAndArgs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::setBinAndArgs()
|
|
|
|
|
{
|
|
|
|
|
standardArgs.clear();
|
|
|
|
|
bin = app;
|
|
|
|
|
}
|