diff --git a/CMakeLists.txt b/CMakeLists.txt index 547af983a..ec82ad599 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,31 @@ if(${AppStreamQt_FOUND}) set(HAVE_APPSTREAMQT true) endif() + +# Region & Language KCM +find_package(KF5ItemModels) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + # notes for packager: + # This is the macro definition part of Region & Language KCM + # Depending on your distributions, the KCM behaves differently + # For Ubuntu based systems, this KCM uses "check-language-support" and PackageKit + # to install relevant fonts and packages + # You should enable option UBUNTU_PACKAGEKIT (it's auto detected though) + # + # For Glibc systems that don't come with pre-generated locales, such as ArchLinux + # This KCM uses "/etc/locale.gen" and "locale-gen" to generate configured locales + # and display a note to let user install fonts themselves if required + # You shouldn't required to do anything in this case + # + # For Glibc systems that come with pre-generated locales, such as Fedora and openSUSE + # a note to let user install fonts themselves if required is displayed + # You should enable GLIBC_LOCALE_GENERATED option + # + # For non-glibc systems such as VoidLinux and *BSD + # A warning of configure locale manually is displayed (although the relevant ENVs are set by Plasma) + # You should disable GLIBC_LOCALE_GEN option + + # find out if the build system is Ubuntu based cmake_host_system_information(RESULT DISTRO_NAME QUERY DISTRIB_ID) cmake_host_system_information(RESULT DISTRO_ID_LIKE QUERY DISTRIB_ID_LIKE) @@ -201,6 +225,14 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(REGION_LANG_GENERATE_LOCALE TRUE) endif() + option(GLIBC_LOCALE_GENERATED "Systems that don't require locale generation. Such as openSUSE or Fedora" OFF) + if(GLIBC_LOCALE_GENERATED) + set(LOCALE_GENERATED TRUE) + endif() + if(REGION_LANG_GENERATE_LOCALE AND GLIBC_LOCALE_GENERATED) + message(FATAL_ERROR "(UBUNTU_PACKAGEKIT || GLIBC_LOCALE_GEN) and GLIBC_LOCALE_GENERATED both enabled") + endif() + ################## Find libraries ################### if(REGION_LANG_GENERATE_LOCALE) find_package(PolkitQt5-1) @@ -220,8 +252,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") ) endif() - - find_package(KF5ItemModels) endif() find_package(ICU COMPONENTS i18n uc) diff --git a/config-workspace.h.cmake b/config-workspace.h.cmake index 079d84cab..d7cf5fe7e 100644 --- a/config-workspace.h.cmake +++ b/config-workspace.h.cmake @@ -13,3 +13,4 @@ #cmakedefine OS_UBUNTU 1 #cmakedefine GLIBC_LOCALE 1 +#cmakedefine LOCALE_GENERATED 1 diff --git a/kcms/region_language/CMakeLists.txt b/kcms/region_language/CMakeLists.txt index df3215128..82edbe728 100644 --- a/kcms/region_language/CMakeLists.txt +++ b/kcms/region_language/CMakeLists.txt @@ -14,6 +14,7 @@ set(kcm_regionandlang_PART_SRCS languagelistmodel.cpp localegenerator.cpp localegeneratorbase.cpp + localegeneratorgeneratedglibc.cpp regionandlangsettings.cpp ) kconfig_add_kcfg_files(kcm_regionandlang_PART_SRCS regionandlangsettingsbase.kcfgc GENERATE_MOC) diff --git a/kcms/region_language/localegenerator.cpp b/kcms/region_language/localegenerator.cpp index 09dc988ef..2da02617a 100644 --- a/kcms/region_language/localegenerator.cpp +++ b/kcms/region_language/localegenerator.cpp @@ -11,6 +11,8 @@ #include "localegeneratorbase.h" +#include "localegeneratorgeneratedglibc.h" + #ifdef OS_UBUNTU #include "localegeneratorubuntu.h" #elif GLIBC_LOCALE @@ -23,6 +25,8 @@ LocaleGeneratorBase *LocaleGenerator::getGenerator() static LocaleGeneratorUbuntu singleton; #elif GLIBC_LOCALE static LocaleGeneratorGlibc singleton; +#elif LOCALE_GENERATED + static LocaleGeneratorGeneratedGlibc singleton; #else static LocaleGeneratorBase singleton; #endif diff --git a/kcms/region_language/localegeneratorgeneratedglibc.cpp b/kcms/region_language/localegeneratorgeneratedglibc.cpp new file mode 100644 index 000000000..bd06daea5 --- /dev/null +++ b/kcms/region_language/localegeneratorgeneratedglibc.cpp @@ -0,0 +1,13 @@ +/* + localegeneratorgeneratedglibc.cpp + SPDX-FileCopyrightText: 2022 Han Young + + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#include "localegeneratorgeneratedglibc.h" + +void LocaleGeneratorGeneratedGlibc::localesGenerate(const QStringList &list) +{ + Q_UNUSED(list) + Q_EMIT needsFont(); +} diff --git a/kcms/region_language/localegeneratorgeneratedglibc.h b/kcms/region_language/localegeneratorgeneratedglibc.h new file mode 100644 index 000000000..720c4a179 --- /dev/null +++ b/kcms/region_language/localegeneratorgeneratedglibc.h @@ -0,0 +1,17 @@ +/* + localegeneratorgeneratedglibc.h + SPDX-FileCopyrightText: 2022 Han Young + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#pragma once +#include "localegeneratorbase.h" + +class LocaleGeneratorGeneratedGlibc : public LocaleGeneratorBase +{ + Q_OBJECT +public: + using LocaleGeneratorBase::LocaleGeneratorBase; + void localesGenerate(const QStringList &list) override; +}; diff --git a/kcms/region_language/localegeneratorglibc.cpp b/kcms/region_language/localegeneratorglibc.cpp index bbb96a0d7..f1191d809 100644 --- a/kcms/region_language/localegeneratorglibc.cpp +++ b/kcms/region_language/localegeneratorglibc.cpp @@ -24,7 +24,7 @@ void LocaleGeneratorGlibc::localesGenerate(const QStringList &list) if (!QFile::exists(QStringLiteral("/etc/locale.gen"))) { // When locale.gen is not present we assume that to mean that no generation is necessary, meaning we are done. // e.g. fedora, centos and derivates - Q_EMIT success(); + Q_EMIT needsFont(); return; } qCDebug(KCM_REGIONANDLANG) << "send polkit request";