Warning, file /plasma/plasma-workspace/kcms/region_language/kcmregionandlang.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     kcmregionandlang.h
0003     SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org>
0004     SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
0005     SPDX-FileCopyrightText: 2023 Serenity Cybersecurity, LLC <license@futurecrew.ru>
0006                                  Author: Gleb Popov <arrowd@FreeBSD.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include <optional>
0014 #include <unordered_map>
0015 
0016 #include "config-workspace.h"
0017 #include "settingtype.h"
0018 
0019 #include <KConfigGroup>
0020 #include <KQuickManagedConfigModule>
0021 #include <QProcess>
0022 
0023 class RegionAndLangSettings;
0024 class OptionsModel;
0025 class LocaleGeneratorBase;
0026 
0027 class KCMRegionAndLang : public KQuickManagedConfigModule
0028 {
0029     Q_OBJECT
0030     Q_PROPERTY(RegionAndLangSettings *settings READ settings CONSTANT)
0031     Q_PROPERTY(OptionsModel *optionsModel READ optionsModel CONSTANT)
0032     Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
0033 
0034 public:
0035     explicit KCMRegionAndLang(QObject *parent, const KPluginMetaData &data);
0036     void save() override;
0037 
0038     RegionAndLangSettings *settings() const;
0039 
0040     OptionsModel *optionsModel() const;
0041     bool enabled() const;
0042 #ifdef GLIBC_LOCALE
0043     std::optional<QString> toGlibcLocale(const QString &lang);
0044 #endif
0045     Q_INVOKABLE void unset(KCM_RegionAndLang::SettingType setting) const;
0046     Q_INVOKABLE void reboot();
0047 
0048 public Q_SLOTS:
0049     void load() override;
0050 
0051 Q_SIGNALS:
0052     void saveClicked();
0053     void takeEffectNextTime();
0054     void startGenerateLocale();
0055     void generateFinished();
0056     void requireInstallFont();
0057     void enabledChanged();
0058     void encountedError(const QString &reason);
0059     void userHasToGenerateManually(const QString &reason);
0060 
0061 private Q_SLOTS:
0062     void saveToConfigFile();
0063 
0064 private:
0065 #ifdef GLIBC_LOCALE
0066     std::unordered_map<QString, QString> constructGlibcLocaleMap();
0067 #endif
0068     static QString failedFindLocalesMessage();
0069     static QString localeFileDirPath();
0070     static QString toUTF8Locale(const QString &locale);
0071 
0072     RegionAndLangSettings *m_settings;
0073     OptionsModel *m_optionsModel;
0074     LocaleGeneratorBase *m_generator = nullptr;
0075     QProcess *m_localectl = nullptr;
0076     bool m_enabled = false;
0077 };