2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
#include "extraencodingsettings.h"
|
2023-01-17 18:02:43 +01:00
|
|
|
|
2019-07-13 06:27:17 +02:00
|
|
|
#include "behaviorsettingswidget.h"
|
2023-01-17 18:02:43 +01:00
|
|
|
#include "texteditortr.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()
|
|
|
|
|
{
|
2023-01-17 18:02:43 +01:00
|
|
|
return {Tr::tr("Unix (LF)"), Tr::tr("Windows (CRLF)")};
|
2019-07-13 06:27:17 +02:00
|
|
|
}
|