2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-02-01 14:13:54 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-02-01 14:13:54 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-01 14:13:54 +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.
|
2011-02-01 14:13:54 +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.
|
2011-02-21 17:26:56 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
#include "extraencodingsettings.h"
|
2019-07-13 06:27:17 +02:00
|
|
|
#include "behaviorsettingswidget.h"
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
#include <utils/settingsutils.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLatin1String>
|
|
|
|
|
#include <QSettings>
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
// Keep this for compatibility reasons.
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char kGroupPostfix[] = "EditorManager";
|
|
|
|
|
static const char kUtf8BomBehaviorKey[] = "Utf8BomBehavior";
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
|
|
|
|
ExtraEncodingSettings::ExtraEncodingSettings() : m_utf8BomSetting(OnlyKeep)
|
|
|
|
|
{}
|
|
|
|
|
|
2018-11-25 18:52:41 +01:00
|
|
|
ExtraEncodingSettings::~ExtraEncodingSettings() = default;
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
void ExtraEncodingSettings::toSettings(const QString &category, QSettings *s) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(category)
|
|
|
|
|
|
|
|
|
|
Utils::toSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:41:12 +02:00
|
|
|
void ExtraEncodingSettings::fromSettings(const QString &category, QSettings *s)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(category)
|
|
|
|
|
|
|
|
|
|
*this = ExtraEncodingSettings();
|
|
|
|
|
Utils::fromSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:41:12 +02:00
|
|
|
QVariantMap ExtraEncodingSettings::toMap() const
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2021-12-01 15:41:12 +02:00
|
|
|
return {
|
|
|
|
|
{kUtf8BomBehaviorKey, m_utf8BomSetting}
|
|
|
|
|
};
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:41:12 +02:00
|
|
|
void ExtraEncodingSettings::fromMap(const QVariantMap &map)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2021-12-01 15:41:12 +02:00
|
|
|
m_utf8BomSetting = (Utf8BomSetting)map.value(kUtf8BomBehaviorKey, m_utf8BomSetting).toInt();
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ExtraEncodingSettings::equals(const ExtraEncodingSettings &s) const
|
|
|
|
|
{
|
|
|
|
|
return m_utf8BomSetting == s.m_utf8BomSetting;
|
|
|
|
|
}
|
2019-07-13 06:27:17 +02:00
|
|
|
|
|
|
|
|
QStringList ExtraEncodingSettings::lineTerminationModeNames()
|
|
|
|
|
{
|
|
|
|
|
return {BehaviorSettingsWidget::tr("Unix (LF)"),
|
|
|
|
|
BehaviorSettingsWidget::tr("Windows (CRLF)")};
|
|
|
|
|
}
|