forked from qt-creator/qt-creator
Change-Id: I28aa68e25c53c3a4d1c370074d7b3318944dc45a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#include "extraencodingsettings.h"
|
|
|
|
#include "behaviorsettingswidget.h"
|
|
#include "texteditortr.h"
|
|
|
|
#include <utils/settingsutils.h>
|
|
|
|
#include <QLatin1String>
|
|
#include <QSettings>
|
|
|
|
// Keep this for compatibility reasons.
|
|
static const char kGroupPostfix[] = "EditorManager";
|
|
static const char kUtf8BomBehaviorKey[] = "Utf8BomBehavior";
|
|
|
|
using namespace TextEditor;
|
|
|
|
ExtraEncodingSettings::ExtraEncodingSettings() : m_utf8BomSetting(OnlyKeep)
|
|
{}
|
|
|
|
ExtraEncodingSettings::~ExtraEncodingSettings() = default;
|
|
|
|
void ExtraEncodingSettings::toSettings(const QString &category, QSettings *s) const
|
|
{
|
|
Q_UNUSED(category)
|
|
|
|
Utils::toSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
|
}
|
|
|
|
void ExtraEncodingSettings::fromSettings(const QString &category, QSettings *s)
|
|
{
|
|
Q_UNUSED(category)
|
|
|
|
*this = ExtraEncodingSettings();
|
|
Utils::fromSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
|
}
|
|
|
|
QVariantMap ExtraEncodingSettings::toMap() const
|
|
{
|
|
return {
|
|
{kUtf8BomBehaviorKey, m_utf8BomSetting}
|
|
};
|
|
}
|
|
|
|
void ExtraEncodingSettings::fromMap(const QVariantMap &map)
|
|
{
|
|
m_utf8BomSetting = (Utf8BomSetting)map.value(kUtf8BomBehaviorKey, m_utf8BomSetting).toInt();
|
|
}
|
|
|
|
bool ExtraEncodingSettings::equals(const ExtraEncodingSettings &s) const
|
|
{
|
|
return m_utf8BomSetting == s.m_utf8BomSetting;
|
|
}
|
|
|
|
QStringList ExtraEncodingSettings::lineTerminationModeNames()
|
|
{
|
|
return {Tr::tr("Unix (LF)"), Tr::tr("Windows (CRLF)")};
|
|
}
|