Commit 134e2d5c authored by Han Young's avatar Han Young
Browse files
parent 214cbeaf
Pipeline #198783 passed with stage
in 6 minutes and 17 seconds
......@@ -62,3 +62,4 @@ Dependencies:
- 'on': ['Linux']
'require':
'frameworks/networkmanager-qt': '@latest'
'libraries/polkit-qt-1': '@latest'
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.22)
project(plasma-workspace)
set(PROJECT_VERSION "5.25.80")
......@@ -169,14 +169,58 @@ if(${AppStreamQt_FOUND})
set(HAVE_APPSTREAMQT true)
endif()
find_package(PackageKitQt${QT_MAJOR_VERSION})
set_package_properties(PackageKitQt${QT_MAJOR_VERSION}
PROPERTIES DESCRIPTION "Software Manager integration"
TYPE OPTIONAL
PURPOSE "Used to install additional language packages on demand"
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# 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)
string(COMPARE EQUAL "ubuntu" "${DISTRO_NAME}" SYSTEM_UBUNTU_BASED)
string(FIND "${DISTRO_ID_LIKE}" "ubuntu" FINDINDEX)
if(NOT (FINDINDEX EQUAL -1))
set(SYSTEM_UBUNTU_BASED ON)
endif()
option(UBUNTU_PACKAGEKIT "Install required package for language on Ubuntu Based systems, PackageKitQt5 required" ${SYSTEM_UBUNTU_BASED})
if(UBUNTU_PACKAGEKIT)
set(OS_UBUNTU TRUE)
endif()
set(GLIBC_LOCALE_GEN_DEFAULT ON)
if(UBUNTU_PACKAGEKIT)
set(GLIBC_LOCALE_GEN_DEFAULT OFF)
endif()
option(GLIBC_LOCALE_GEN "Auto generate Glibc locale with locale-gen and /etc/locale.gen" ${GLIBC_LOCALE_GEN_DEFAULT})
if(GLIBC_LOCALE_GEN AND UBUNTU_PACKAGEKIT)
message(FATAL_ERROR "UBUNTU_PACKAGEKIT and GLIBC_LOCALE_GEN both enabled, only UBUNTU_PACKEGKIT will be used")
endif()
if(GLIBC_LOCALE_GEN)
set(GLIBC_LOCALE TRUE)
endif()
if(UBUNTU_PACKAGEKIT OR GLIBC_LOCALE_GEN)
set(REGION_LANG_GENERATE_LOCALE TRUE)
endif()
################## Find libraries ###################
if(REGION_LANG_GENERATE_LOCALE)
find_package(PolkitQt5-1)
set_package_properties(PolkitQt5-1
PROPERTIES DESCRIPTION "DBus interface wrapper for Polkit"
PURPOSE "Communicate with localegen helper in region & lang kcm"
TYPE REQUIRED
)
if(PackageKitQt${QT_MAJOR_VERSION}_FOUND)
set(HAVE_PACKAGEKIT TRUE)
endif()
if(UBUNTU_PACKAGEKIT)
find_package(PackageKitQt${QT_MAJOR_VERSION})
set_package_properties(PackageKitQt${QT_MAJOR_VERSION}
PROPERTIES DESCRIPTION "Software Manager integration"
TYPE OPTIONAL
PURPOSE "Used to install additional language packages on demand"
)
endif()
find_package(KF5ItemModels)
endif()
find_package(ICU COMPONENTS i18n uc)
......
......@@ -11,4 +11,5 @@
#define WORKSPACE_VERSION_STRING "${PROJECT_VERSION}"
#cmakedefine HAVE_PACKAGEKIT "${HAVE_PACKAGEKIT}"
#cmakedefine OS_UBUNTU 1
#cmakedefine GLIBC_LOCALE 1
<?xml version="1.0" ?>
<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN"
"dtd/kdedbx45.dtd" [
<!ENTITY % addindex "IGNORE">
<!ENTITY % English "INCLUDE" > <!-- change language only here -->
]>
<article id="formats" lang="&language;">
<articleinfo>
<title>Formats</title>
<authorgroup>
<author>&Mike.McBride; &Mike.McBride.mail;</author>
<author>&Krishna.Tateneni; &Krishna.Tateneni.mail;</author>
<!-- TRANS:ROLES_OF_TRANSLATORS -->
</authorgroup>
<date>2015-05-18</date>
<releaseinfo>Plasma 5.3</releaseinfo>
<keywordset>
<keyword>KDE</keyword>
<keyword>Systemsettings</keyword>
<keyword>locale</keyword>
<keyword>country</keyword>
<keyword>language</keyword>
<keyword>number</keyword>
<keyword>currency</keyword>
</keywordset>
</articleinfo>
<para>
This module of the &kde; &systemsettings; allows you to select customization
options that depend on the region of the world that you happen to live in.
</para>
<para>
In most cases, you can simply select the region, and all
options will be set in an appropriate manner.
</para>
<para>
On the bottom of this module you can see examples how the settings look
like and which measurement units are used. In addition to numbers, you can see
how currency values, dates, and times in long and short format are displayed.
When you change any of the settings, the preview shows the effects of the
changes before you apply them.
</para>
<para>
The <guilabel>Region</guilabel> drop down box contains the list of available
countries and will initially show your currently selected country. If the
selection shows <quote>Default</quote> then you have not set a country
and are defaulting to the Country set by the system, which will also be shown.
</para>
<para>
In case you need different individual settings enable <guilabel>Detailed Settings</guilabel>
and select the country format for <guilabel>Numbers</guilabel>, <guilabel>Time</guilabel>,
<guilabel>Currency</guilabel>, <guilabel>Measurement Units</guilabel> or
<guilabel>Collation and Sorting</guilabel> rules from the drop down boxes.
</para>
</article>
########### install files ###############
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kcontrol/formats)
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kcontrol/region_language)
......@@ -5,17 +5,18 @@
<!ENTITY % English "INCLUDE" > <!-- change language only here -->
]>
<article id="translations" lang="&language;">
<article id="region_language" lang="&language;">
<articleinfo>
<title>Language</title>
<title>Region And Language</title>
<authorgroup>
<author>&Mike.McBride; &Mike.McBride.mail;</author>
<author>&Krishna.Tateneni; &Krishna.Tateneni.mail;</author>
<author>&Han.Young; &Han.Young.mail;</author>
<!-- TRANS:ROLES_OF_TRANSLATORS -->
</authorgroup>
<date>2021-04-09</date>
<releaseinfo>Plasma 5.20</releaseinfo>
<date>2022-06-23</date>
<releaseinfo>Plasma 5.26</releaseinfo>
<keywordset>
<keyword>KDE</keyword>
......@@ -23,17 +24,20 @@
<keyword>locale</keyword>
<keyword>country</keyword>
<keyword>language</keyword>
<keyword>translation</keyword>
<keyword>Language</keyword>
<keyword>number</keyword>
<keyword>translation</keyword>
<keyword>currency</keyword>
</keywordset>
</articleinfo>
<para>
On this page you can set your preferred languages for the &plasma; Workspace and
On this page you can set your preferred languages and formats for the &plasma; Workspace and
Applications to be displayed in.
</para>
<para>
In most cases, you can simply select the language, and all
options will be set in an appropriate manner.
The &plasma; Workspace and &kde; Applications are written in American English and are
translated into many different languages by teams of volunteers. These
translations need to be installed first before you can choose to use them.
......@@ -43,25 +47,26 @@ languages you want to use.</para>
<para>As &plasma; is build upon the &Qt; libraries, you need the &Qt; translations for the selected
languages as well to have a fully localized &GUI;.</para></note>
<para>
The list shows the localized language names that will
be used when displaying the &plasma; Workspace and Applications. Because not all
of the &plasma; Workspace and Applications may be translated into every language
&plasma; will try to find suitable translations for you by working down the
list until it finds a translation. If
none of your preferred languages have a required translation then the original
American English will be used.
On each selection bar you can see examples how the settings look
like and which measurement units are used. In addition to numbers, you can see
how currency values, dates, and times in long and short format are displayed.
When you change any of the settings, the preview shows the effects of the
changes before you apply them.
</para>
<para>
You can add a language to the main list by clicking the <guibutton>Add languages...</guibutton>
button.
The localized language names of &systemsettings; translations
installed and available on your system are displayed. If the language you want to use is
Clicking on the <guilabel>Add more...</guilabel> button on the language
sub page will show you the list of available
languages and will initially show your currently selected language. If the
selection shows <quote>No Language Configured</quote> then you have not set a country
and are defaulting to the language set by the system, normally C.
If the language you want to use is
not shown in this list then you will need to install it using the usual method
for your system.
Select one or more languages in the list and click <guibutton>Add</guibutton>.
</para>
<para>You can remove a language from the main list by selecting it and then clicking
on the <inlinemediaobject><imageobject><imagedata fileref="list-remove.png" format="PNG"/>
</imageobject></inlinemediaobject> icon. You can change the order of preference in the
......@@ -70,12 +75,20 @@ list by selecting a language and clicking on the <inlinemediaobject><imageobject
</imageobject></inlinemediaobject> icon.
</para>
<para>
In case you need different individual format settings,
you can select the locale for <guilabel>Numbers</guilabel>, <guilabel>Time</guilabel>,
<guilabel>Currency</guilabel> and <guilabel>Measurement Units</guilabel>.
</para>
<note>
<para>
Language and Formats are independent settings. Changing a language does
<emphasis>not</emphasis> automatically change the settings for numbers,
currency &etc; to the corresponding country or region.
Previously, Language and Formats are independent settings. Since &plasma; 5.26, they were
merged into this KCM called Region And Language. Changing a language does
<emphasis>automatically change</emphasis> the settings for numbers,
currency &etc; to the corresponding country or region. However, this change
does not break the old configuration. The configuration file still located
at <emphasis>~/.config/plasma-localerc</emphasis> .
</para>
</note>
</article>
########### install files ###############
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kcontrol/translations)
......@@ -2,7 +2,6 @@ add_subdirectory(krdb)
add_subdirectory(desktoptheme)
add_subdirectory(icons)
add_subdirectory(translations)
if(KUserFeedback_FOUND)
add_subdirectory(feedback)
......@@ -21,7 +20,7 @@ if(FONTCONFIG_FOUND)
endif()
add_subdirectory(autostart)
add_subdirectory(formats)
add_subdirectory(region_language)
add_subdirectory(notifications)
add_subdirectory(nightcolor)
add_subdirectory(users)
# KI18N Translation Domain for this library
add_definitions(-DTRANSLATION_DOMAIN=\"kcmformats\")
set(kcm_formats_PART_SRCS
kcmformats.cpp
localelistmodel.cpp
formatssettings.cpp
exampleutility.cpp
optionsmodel.cpp
)
kconfig_add_kcfg_files(kcm_formats_PART_SRCS formatssettings.kcfgc GENERATE_MOC)
add_library(kcm_formats MODULE ${kcm_formats_PART_SRCS})
target_link_libraries(kcm_formats
Qt::Core
KF5::ConfigCore
KF5::ConfigGui
KF5::CoreAddons
KF5::I18n
KF5::QuickAddons)
if (QT_MAJOR_VERSION EQUAL "6")
target_link_libraries(kcm_formats Qt::Core5Compat) # for QTextCodec
endif()
########### install files ###############
install(TARGETS kcm_formats DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/kcms/systemsettings)
install(FILES kcm_formats.desktop DESTINATION ${KDE_INSTALL_APPDIR})
kpackage_install_package(package kcm_formats kcms)
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/kcmformats.pot
rm -f rc.cpp
/*
kcmformats.cpp
SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org>
SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QCollator>
#include <KAboutData>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KSharedConfig>
#include "formatssettings.h"
#include "kcmformats.h"
#include "localelistmodel.h"
#include "optionsmodel.h"
K_PLUGIN_CLASS_WITH_JSON(KCMFormats, "kcm_formats.json")
KCMFormats::KCMFormats(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KQuickAddons::ManagedConfigModule(parent, data, args)
, m_optionsModel(new OptionsModel(this))
{
KAboutData *aboutData = new KAboutData(QStringLiteral("kcm_formats"),
i18nc("@title", "Formats"),
QStringLiteral("0.1"),
QLatin1String(""),
KAboutLicense::LicenseKey::GPL_V2,
i18nc("@info:credit", "Copyright 2021 Han Young"));
aboutData->addAuthor(i18nc("@info:credit", "Han Young"), i18nc("@info:credit", "Author"), QStringLiteral("hanyoung@protonmail.com"));
setAboutData(aboutData);
setQuickHelp(i18n("You can configure the formats used for time, dates, money and other numbers here."));
qmlRegisterAnonymousType<FormatsSettings>("kcmformats", 1);
qmlRegisterType<LocaleListModel>("LocaleListModel", 1, 0, "LocaleListModel");
qmlRegisterAnonymousType<OptionsModel>("kcmformats_optionsmodel", 1);
}
FormatsSettings *KCMFormats::settings() const
{
return m_optionsModel->settings();
}
OptionsModel *KCMFormats::optionsModel() const
{
return m_optionsModel;
}
QQuickItem *KCMFormats::getSubPage(int index) const
{
return subPage(index);
}
void KCMFormats::unset(const QString &setting)
{
const char *entry;
if (setting == QStringLiteral("lang")) {
entry = "LANG";
settings()->setLang(settings()->defaultLangValue());
} else if (setting == QStringLiteral("numeric")) {
entry = "LC_NUMERIC";
settings()->setNumeric(settings()->defaultNumericValue());
} else if (setting == QStringLiteral("time")) {
entry = "LC_TIME";
settings()->setTime(settings()->defaultTimeValue());
} else if (setting == QStringLiteral("measurement")) {
entry = "LC_MEASUREMENT";
settings()->setMeasurement(settings()->defaultMeasurementValue());
} else {
entry = "LC_MONETARY";
settings()->setMonetary(settings()->defaultMonetaryValue());
}
settings()->config()->group(QStringLiteral("Formats")).deleteEntry(entry);
}
#include "kcmformats.moc"
#include "moc_kcmformats.cpp"
/*
optionsmodel.cpp
SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <KLocalizedString>
#include "exampleutility.cpp"
#include "formatssettings.h"
#include "optionsmodel.h"
OptionsModel::OptionsModel(QObject *parent)
: QAbstractListModel(parent)
, m_settings(new FormatsSettings(this))
{
m_staticNames = {{{i18n("Region"), QStringLiteral("lang")},
{i18n("Numbers"), QStringLiteral("numeric")},
{i18n("Time"), QStringLiteral("time")},
{i18n("Currency"), QStringLiteral("currency")},
{i18n("Measurement"), QStringLiteral("measurement")}}};
connect(m_settings, &FormatsSettings::langChanged, this, &OptionsModel::handleLangChange);
connect(m_settings, &FormatsSettings::numericChanged, this, [this] {
Q_EMIT dataChanged(createIndex(1, 0), createIndex(1, 0), {Subtitle, Example});
});
connect(m_settings, &FormatsSettings::timeChanged, this, [this] {
Q_EMIT dataChanged(createIndex(2, 0), createIndex(2, 0), {Subtitle, Example});
});
connect(m_settings, &FormatsSettings::monetaryChanged, this, [this] {
Q_EMIT dataChanged(createIndex(3, 0), createIndex(3, 0), {Subtitle, Example});
});
connect(m_settings, &FormatsSettings::measurementChanged, this, [this] {
Q_EMIT dataChanged(createIndex(4, 0), createIndex(4, 0), {Subtitle, Example});
});
}
int OptionsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_staticNames.size();
}
QVariant OptionsModel::data(const QModelIndex &index, int role) const
{
const int row = index.row();
if (row < 0 || row >= (int)m_staticNames.size())
return QVariant();
switch (role) {
case Name:
return m_staticNames[row].first;
case Subtitle: {
switch (row) {
case 0:
return m_settings->lang();
case 1:
return m_settings->numeric();
case 2:
return m_settings->time();
case 3:
return m_settings->monetary();
case 4:
return m_settings->measurement();
default:
return QVariant();
}
}
case Example: {
switch (row) {
case 0:
return QString();
case 1:
return numberExample();
case 2:
return timeExample();
case 3:
return currencyExample();
case 4:
return measurementExample();
default:
return QVariant();
}
}
case Page:
return m_staticNames[row].second;
default:
return QVariant();
}
}
QHash<int, QByteArray> OptionsModel::roleNames() const
{
return {{Name, "name"}, {Subtitle, "localeName"}, {Example, "example"}, {Page, "page"}};
}
void OptionsModel::handleLangChange()
{
Q_EMIT dataChanged(createIndex(0, 0), createIndex(0, 0), {Subtitle, Example});
QString defaultVal = i18n("Default");
if (m_settings->numeric() == defaultVal) {
Q_EMIT dataChanged(createIndex(1, 0), createIndex(1, 0), {Subtitle, Example});
}
if (m_settings->time() == defaultVal) {
Q_EMIT dataChanged(createIndex(2, 0), createIndex(2, 0), {Subtitle, Example});
}
if (m_settings->measurement() == defaultVal) {
Q_EMIT dataChanged(createIndex(3, 0), createIndex(3, 0), {Subtitle, Example});
}
if (m_settings->monetary() == defaultVal) {
Q_EMIT dataChanged(createIndex(4, 0), createIndex(4, 0), {Subtitle, Example});
}
}
QString OptionsModel::numberExample() const
{
return Utility::numericExample(localeWithDefault(m_settings->numeric()));
}
QString OptionsModel::timeExample() const
{
return Utility::timeExample(localeWithDefault(m_settings->time()));
}
QString OptionsModel::currencyExample() const
{
return Utility::monetaryExample(localeWithDefault(m_settings->monetary()));
}
QString OptionsModel::measurementExample() const
{
return Utility::measurementExample(localeWithDefault(m_settings->measurement()));
}
QLocale OptionsModel::localeWithDefault(const QString &val) const
{
if (val != i18n("Default")) {
return QLocale(val);
} else {
return QLocale(m_settings->lang());
}
}
FormatsSettings *OptionsModel::settings() const
{
return m_settings;
}
#CMakeLists.txt
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: 2022 Han Young <hanyoung@protonmail.com>
# KI18N Translation Domain for this library
add_definitions(-DTRANSLATION_DOMAIN=\"kcm_regionandlang\")
################## Set sources files #################
set(kcm_regionandlang_PART_SRCS
settingtype.h
kcmregionandlang.cpp
localelistmodel.cpp
exampleutility.cpp
optionsmodel.cpp
languagelistmodel.cpp
localegenerator.cpp
localegeneratorbase.cpp
regionandlangsettings.cpp
)
kconfig_add_kcfg_files(kcm_regionandlang_PART_SRCS regionandlangsettingsbase.kcfgc GENERATE_MOC)
if(GLIBC_LOCALE_GEN)
set(kcm_regionandlang_PART_SRCS
${kcm_regionandlang_PART_SRCS}
localegeneratorglibc.cpp)
endif()
if(UBUNTU_PACKAGEKIT)
set(kcm_regionandlang_PART_SRCS
${kcm_regionandlang_PART_SRCS}
localegeneratorubuntu.cpp)
endif()
ecm_qt_declare_logging_category(
kcm_regionandlang_PART_SRCS
HEADER kcm_regionandlang_debug.h
IDENTIFIER KCM_REGIONANDLANG
CATEGORY_NAME org.kde.kcm_regionandlang
DESCRIPTION "Region and Language KCM"
EXPORT kcm_regionandlang
)
################ Build helper and add additional source files #############
if(REGION_LANG_GENERATE_LOCALE)
add_subdirectory("localegenhelper")
qt5_generate_dbus_interface(
${CMAKE_CURRENT_SOURCE_DIR}/localegenhelper/localegenhelper.h
org.kde.localegenhelper.xml
OPTIONS -s -m
)
qt5_add_dbus_interface(kcm_regionandlang_PART_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.localegenhelper.xml localegenhelperinterface)
endif()
#################### Declare target #######################
kcoreaddons_add_plugin(kcm_regionandlang SOURCES ${kcm_regionandlang_PART_SRCS} INSTALL_NAMESPACE "plasma/kcms/systemsettings")
ecm_qt_install_logging_categories(
EXPORT kcm_regionandlang
DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}"
)
################# Link libraries ####################
target_link_libraries(kcm_regionandlang
Qt::Core