2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
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 "commonvcssettings.h"
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QDebug>
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
static const char settingsGroupC[] = "VCS";
|
|
|
|
|
static const char nickNameMailMapKeyC[] = "NickNameMailMap";
|
|
|
|
|
static const char nickNameFieldListFileKeyC[] = "NickNameFieldListFile";
|
|
|
|
|
static const char submitMessageCheckScriptKeyC[] = "SubmitMessageCheckScript";
|
|
|
|
|
static const char lineWrapKeyC[] = "LineWrap";
|
|
|
|
|
static const char lineWrapWidthKeyC[] = "LineWrapWidth";
|
|
|
|
|
static const char sshPasswordPromptKeyC[] = "SshPasswordPrompt";
|
2009-03-20 14:20:28 +01:00
|
|
|
|
|
|
|
|
static const int lineWrapWidthDefault = 72;
|
|
|
|
|
static const bool lineWrapDefault = true;
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-05-25 09:38:41 +02:00
|
|
|
// Return default for the ssh-askpass command (default to environment)
|
|
|
|
|
static inline QString sshPasswordPromptDefault()
|
|
|
|
|
{
|
|
|
|
|
const QByteArray envSetting = qgetenv("SSH_ASKPASS");
|
|
|
|
|
if (!envSetting.isEmpty())
|
|
|
|
|
return QString::fromLocal8Bit(envSetting);
|
2012-08-23 15:53:58 +02:00
|
|
|
if (Utils::HostOsInfo::isWindowsHost())
|
|
|
|
|
return QLatin1String("win-ssh-askpass");
|
2010-05-25 09:38:41 +02:00
|
|
|
return QLatin1String("ssh-askpass");
|
|
|
|
|
}
|
2010-05-21 17:46:00 +02:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2009-03-19 17:40:01 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonVcsSettings::CommonVcsSettings() :
|
2010-05-25 09:38:41 +02:00
|
|
|
sshPasswordPrompt(sshPasswordPromptDefault()),
|
2009-03-20 14:20:28 +01:00
|
|
|
lineWrap(lineWrapDefault),
|
|
|
|
|
lineWrapWidth(lineWrapWidthDefault)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-19 15:34:59 +01:00
|
|
|
void CommonVcsSettings::toSettings(Utils::QtcSettings *s) const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2021-02-16 14:51:16 +01:00
|
|
|
s->beginGroup(settingsGroupC);
|
|
|
|
|
s->setValueWithDefault(nickNameMailMapKeyC, nickNameMailMap);
|
|
|
|
|
s->setValueWithDefault(nickNameFieldListFileKeyC, nickNameFieldListFile);
|
|
|
|
|
s->setValueWithDefault(submitMessageCheckScriptKeyC, submitMessageCheckScript);
|
|
|
|
|
s->setValueWithDefault(lineWrapKeyC, lineWrap, lineWrapDefault);
|
|
|
|
|
s->setValueWithDefault(lineWrapWidthKeyC, lineWrapWidth, lineWrapWidthDefault);
|
|
|
|
|
s->setValueWithDefault(sshPasswordPromptKeyC, sshPasswordPrompt, sshPasswordPromptDefault());
|
2009-03-19 17:40:01 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonVcsSettings::fromSettings(QSettings *s)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
nickNameMailMap = s->value(QLatin1String(nickNameMailMapKeyC), QString()).toString();
|
|
|
|
|
nickNameFieldListFile = s->value(QLatin1String(nickNameFieldListFileKeyC), QString()).toString();
|
|
|
|
|
submitMessageCheckScript = s->value(QLatin1String(submitMessageCheckScriptKeyC), QString()).toString();
|
2009-03-20 14:20:28 +01:00
|
|
|
lineWrap = s->value(QLatin1String(lineWrapKeyC), lineWrapDefault).toBool();
|
|
|
|
|
lineWrapWidth = s->value(QLatin1String(lineWrapWidthKeyC), lineWrapWidthDefault).toInt();
|
2010-05-25 09:38:41 +02:00
|
|
|
sshPasswordPrompt = s->value(QLatin1String(sshPasswordPromptKeyC), sshPasswordPromptDefault()).toString();
|
2009-03-19 17:40:01 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
bool CommonVcsSettings::equals(const CommonVcsSettings &rhs) const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2009-06-19 16:34:38 +02:00
|
|
|
return lineWrap == rhs.lineWrap
|
2009-03-20 14:20:28 +01:00
|
|
|
&& lineWrapWidth == rhs.lineWrapWidth
|
2009-03-19 17:40:01 +01:00
|
|
|
&& nickNameMailMap == rhs.nickNameMailMap
|
|
|
|
|
&& nickNameFieldListFile == rhs.nickNameFieldListFile
|
2010-05-21 17:46:00 +02:00
|
|
|
&& submitMessageCheckScript == rhs.submitMessageCheckScript
|
2014-04-17 12:47:38 +02:00
|
|
|
&& sshPasswordPrompt == rhs.sshPasswordPrompt;
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QDebug operator<<(QDebug d,const CommonVcsSettings& s)
|
2009-03-20 14:20:28 +01:00
|
|
|
{
|
2009-06-19 16:34:38 +02:00
|
|
|
d.nospace() << " lineWrap=" << s.lineWrap
|
2009-03-20 14:20:28 +01:00
|
|
|
<< " lineWrapWidth=" << s.lineWrapWidth
|
|
|
|
|
<< " nickNameMailMap='" << s.nickNameMailMap
|
|
|
|
|
<< "' nickNameFieldListFile='" << s.nickNameFieldListFile
|
2010-05-21 17:46:00 +02:00
|
|
|
<< "'submitMessageCheckScript='" << s.submitMessageCheckScript
|
|
|
|
|
<< "'sshPasswordPrompt='" << s.sshPasswordPrompt
|
|
|
|
|
<< "'\n";
|
2009-03-20 14:20:28 +01:00
|
|
|
return d;
|
|
|
|
|
}
|
2010-04-12 16:34:21 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|