Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Implement language chooser in text properties dock.

Wolthera van Hövell tot Westerflier01ca588055ce
diff --git a/libs/flake/text/KoWritingSystemUtils.cpp b/libs/flake/text/KoWritingSystemUtils.cpp
index 8e2b0b445e..4cdc4f4cbd 100644
--- a/libs/flake/text/KoWritingSystemUtils.cpp
+++ b/libs/flake/text/KoWritingSystemUtils.cpp
@@ -499,7 +499,7 @@ QLocale KoWritingSystemUtils::localeFromBcp47Locale(const QString &locale)
bool KoWritingSystemUtils::Bcp47Locale::isValid() const
{
- return !languageTags.isEmpty();
+ return !languageTags.isEmpty() && !languageTags.first().isEmpty();
}
QString KoWritingSystemUtils::Bcp47Locale::toPosixLocaleFormat() const
@@ -534,8 +534,12 @@ QString KoWritingSystemUtils::Bcp47Locale::toString() const
QStringList total;
total.append(languageTags);
- total.append(scriptTag);
- total.append(regionTag);
+ if (!scriptTag.isEmpty()) {
+ total.append(scriptTag);
+ }
+ if (!regionTag.isEmpty()) {
+ total.append(regionTag);
+ }
total.append(variantTags);
total.append(extensionTags);
total.append(privateUseTags);
diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp
index 0f1a6ed6c9..dd9650d912 100644
--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp
+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp
@@ -248,6 +248,8 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper
, LAGER_QT(fontFeatureSettingsState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontFeatureSettingsId))}
, LAGER_QT(fontKerning) {textData.zoom(createTextProperty(KoSvgTextProperties::KerningId)).zoom(autoValueToBool)}
, LAGER_QT(fontKerningState) {textData.zoom(propertyModifyState(KoSvgTextProperties::KerningId))}
+ , LAGER_QT(language) {textData.zoom(createTextProperty(KoSvgTextProperties::TextLanguage)).zoom(variant_to<QString>)}
+ , LAGER_QT(languageState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TextLanguage))}
, LAGER_QT(spanSelection) {textData[&KoSvgTextPropertyData::spanSelection]}
{
lager::watch(textData, std::bind(&KoSvgTextPropertiesModel::textPropertyChanged, this));
diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.h b/libs/flake/text/lager/KoSvgTextPropertiesModel.h
index 570a2b2deb..62bde428f7 100644
--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.h
+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.h
@@ -197,6 +197,9 @@ public:
LAGER_QT_CURSOR(bool, fontKerning);
LAGER_QT_CURSOR(PropertyState, fontKerningState);
+ LAGER_QT_CURSOR(QString, language);
+ LAGER_QT_CURSOR(PropertyState, languageState);
+
/// We're selecting a span of text instead of the whole paragraph.
LAGER_QT_CURSOR(bool, spanSelection);
diff --git a/plugins/dockers/textproperties/CMakeLists.txt b/plugins/dockers/textproperties/CMakeLists.txt
index d2e389967b..7d7b00a4fa 100644
--- a/plugins/dockers/textproperties/CMakeLists.txt
+++ b/plugins/dockers/textproperties/CMakeLists.txt
@@ -6,6 +6,7 @@ set(KRITA_TEXTPROPERTIES_SOURCES
KoShapeQtQuickLabel.cpp
TagFilterProxyModelQmlWrapper.cpp
OpenTypeFeatureModel.cpp
+ LocaleHandler.cpp
)
qt_add_resources(KRITA_TEXTPROPERTIES_SOURCES textproperties.qrc)
diff --git a/plugins/dockers/textproperties/LocaleHandler.cpp b/plugins/dockers/textproperties/LocaleHandler.cpp
new file mode 100644
index 0000000000..a8e6585b8f
--- /dev/null
+++ b/plugins/dockers/textproperties/LocaleHandler.cpp
@@ -0,0 +1,314 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+
+#include <text/KoWritingSystemUtils.h>
+#include <KLocalizedString>
+#include <KConfigGroup>
+#include <KSharedConfig>
+
+#include "LocaleHandler.h"
+
+struct LocaleHandler::Private {
+ Private(QObject *parent = nullptr) {
+ allLanguages = new AllLanguagesModel(parent);
+ filteredLanguagesModel = new LanguagesFilterModel(parent);
+ filteredLanguagesModel->setSourceModel(allLanguages);
+ filteredLanguagesModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+
+ favorites = new FavoriteLocaleModel(parent);
+ }
+
+ KoWritingSystemUtils::Bcp47Locale locale;
+ AllLanguagesModel *allLanguages = nullptr;
+ LanguagesFilterModel *filteredLanguagesModel = nullptr;
+ FavoriteLocaleModel *favorites = nullptr;
+};
+
+LocaleHandler::LocaleHandler(QObject *parent)
+ : QObject(parent)
+ , d(new Private(parent))
+{
+
+}
+
+LocaleHandler::~LocaleHandler()
+{
+
+}
+
+QString LocaleHandler::bcp47Tag() const
+{
+ return d->locale.toString();
+}
+
+void LocaleHandler::setBcp47Tag(const QString &newBcp47Tag)
+{
+ if (d->locale.toString() == newBcp47Tag)
+ return;
+ d->locale = KoWritingSystemUtils::parseBcp47Locale(newBcp47Tag);
+
+ d->favorites->addCode(language());
+ emit bcp47TagChanged();
+ emit languageChanged();
+ emit scriptChanged();
+}
+
+QString LocaleHandler::script() const
+{
+ return d->locale.scriptTag;
+}
+
+void LocaleHandler::setScript(const QString &newScript)
+{
+ if (d->locale.scriptTag == newScript)
+ return;
+ d->locale.scriptTag = newScript;
+ emit scriptChanged();
+ emit bcp47TagChanged();
+}
+
+QString LocaleHandler::language() const
+{
+ KoWritingSystemUtils::Bcp47Locale langOnly = d->locale;
+ langOnly.scriptTag.clear();
+ return langOnly.toString();
+}
+
+void LocaleHandler::setLanguage(const QString &newLanguage)
+{
+ KoWritingSystemUtils::Bcp47Locale langOnly = d->locale;
+ langOnly.scriptTag.clear();
+ if (langOnly.toString() == newLanguage)
+ return;
+ langOnly = KoWritingSystemUtils::parseBcp47Locale(newLanguage);
+ langOnly.scriptTag = d->locale.scriptTag;
+ d->locale = langOnly;
+ d->favorites->addCode(langOnly.toString());
+ emit languageChanged();
+ emit bcp47TagChanged();
+}
+
+QVariantList LocaleHandler::scriptModel() const
+{
+ QVariantList model;
+ const QString code = "code";
+ const QString name = "name";
+
+ for (int i = 0; i< int(QLocale::LastScript); i++) {
+ const QLocale::Script script = QLocale::Script(i);
+ QVariantMap map;
+ map.insert(code, KoWritingSystemUtils::scriptTagForQLocaleScript(script));
+ map.insert(name, QLocale::scriptToString(script));
+ model.append(map);
+ }
+ return model;
+}
+
+QAbstractItemModel *LocaleHandler::languagesModel() const
+{
+ return d->filteredLanguagesModel;
+}
+
+QAbstractItemModel *LocaleHandler::favoritesModel() const
+{
+ return d->favorites;
+}
+
+QString LocaleHandler::searchString() const
+{
+ return d->filteredLanguagesModel->filterRegExp().pattern();
+}
+
+void LocaleHandler::setSearchString(const QString &newSearchString)
+{
+ if (d->filteredLanguagesModel->filterRegExp().pattern() == newSearchString)
+ return;
+ d->filteredLanguagesModel->setFilterFixedString(newSearchString);
+ emit searchStringChanged();
+}
+
+bool LocaleHandler::localeValid() const
+{
+ return d->locale.isValid();
+}
+
+struct AllLanguagesModel::Private {
+ Private() {
+ for (int i = 0; i < QLocale::LastLanguage; i++) {
+ const QLocale::Language lang = QLocale::Language(i);
+ const QString langName = QLocale(lang).bcp47Name();
+ if (!locales.contains(langName)) {
+ locales.append(langName);
+ }
+ Q_FOREACH(const QLocale::Country region, QLocale::countriesForLanguage(lang)) {
+ const QLocale locale(lang, region);
+ const QString bcp = locale.bcp47Name().split("_").join("-");
+ if (!locales.contains(bcp)) {
+ locales.append(bcp);
+ }
+ }
+ }
+ }
+
+ QStringList locales;
+};
+
+AllLanguagesModel::AllLanguagesModel(QObject *parent)
+ : QAbstractListModel(parent)
+ , d(new Private())
+{
+
+}
+
+AllLanguagesModel::~AllLanguagesModel()
+{
+
+}
+
+int AllLanguagesModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return d->locales.size();
+}
+
+QVariant AllLanguagesModel::data(const QModelIndex &index, int role) const
+{
+ if (index.isValid()) {
+
+ const QString code = d->locales.at(index.row());
+ if (role == Qt::DisplayRole) {
+ KoWritingSystemUtils::Bcp47Locale bcp47 = KoWritingSystemUtils::parseBcp47Locale(code);
+ const QLocale locale = KoWritingSystemUtils::localeFromBcp47Locale(bcp47);
+ if (bcp47.regionTag.isEmpty()) return QLocale::languageToString(locale.language());
+ return QString("%1, %2").arg(QLocale::languageToString(locale.language())).arg(QLocale::countryToString(locale.country()));
+ } else if (role == Code) {
+ return code;
+ }
+ }
+ return QVariant();
+}
+
+QHash<int, QByteArray> AllLanguagesModel::roleNames() const
+{
+ QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
+ roles[Code] = "code";
+ return roles;
+}
+
+struct FavoriteLocaleModel::Private {
+ Private() {
+ config = KSharedConfig::openConfig()->group("TextProperties");
+ Q_FOREACH(const QString lang, config.readEntry<QStringList>(configKey, KLocalizedString::languages())) {
+ const QLocale locale(lang);
+ const QString code = locale.bcp47Name().split("_").join("-");
+ locales.append(code);
+ }
+ if (locales.isEmpty()) {
+ locales.append("");
+ }
+ favorites = locales;
+ }
+
+ QStringList locales;
+ QStringList favorites;
+ KConfigGroup config;
+
+ const QString configKey = "favoriteLocales";
+};
+FavoriteLocaleModel::FavoriteLocaleModel(QObject *parent)
+ : QAbstractListModel(parent)
+ , d(new Private ())
+{
+ connect(this, SIGNAL(favoritesUpdated()), this, SLOT(updateConfig()));
+}
+
+FavoriteLocaleModel::~FavoriteLocaleModel()
+{
+
+}
+
+int FavoriteLocaleModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return d->locales.size();
+}
+
+QVariant FavoriteLocaleModel::data(const QModelIndex &index, int role) const
+{
+ if (index.isValid()) {
+ const QString code = d->locales.at(index.row());
+ if (role == Qt::DisplayRole) {
+ KoWritingSystemUtils::Bcp47Locale bcp47 = KoWritingSystemUtils::parseBcp47Locale(code);
+ const QLocale locale = KoWritingSystemUtils::localeFromBcp47Locale(bcp47);
+ if (bcp47.regionTag.isEmpty()) return QLocale::languageToString(locale.language());
+ return QString("%1, %2").arg(QLocale::languageToString(locale.language())).arg(QLocale::countryToString(locale.country()));
+ } else if (role == Code) {
+ return code;
+ } else if (role == Favorite) {
+ return d->favorites.contains(code);
+ }
+ }
+ return QVariant();
+}
+
+bool FavoriteLocaleModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!index.isValid()) return false;
+
+ const QString code = d->locales.at(index.row());
+ if (role == Favorite) {
+ const bool fav = value.toBool();
+ if (fav && !d->favorites.contains(code)) {
+ d->favorites.append(code);
+ } else {
+ d->favorites.removeAll(code);
+ }
+ emit dataChanged(index, index, {role});
+ emit favoritesUpdated();
+ return true;
+ }
+ return false;
+}
+
+void FavoriteLocaleModel::addCode(const QString &code)
+{
+ if (!d->locales.contains(code)) {
+ beginInsertRows(QModelIndex(), d->locales.size(), d->locales.size());
+ d->locales.append(code);
+ endInsertRows();
+ }
+}
+
+QHash<int, QByteArray> FavoriteLocaleModel::roleNames() const
+{
+ QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
+ roles[Code] = "code";
+ roles[Favorite] = "favorite";
+ return roles;
+}
+
+void FavoriteLocaleModel::updateConfig()
+{
+ d->config.writeEntry<QStringList>(d->configKey, d->favorites);
+}
+
+LanguagesFilterModel::LanguagesFilterModel(QObject *parent)
+ : QSortFilterProxyModel(parent)
+{
+
+}
+
+bool LanguagesFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+{
+ QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
+ const QString name = sourceModel()->data(idx).toString();
+ const QString code = sourceModel()->data(idx, AllLanguagesModel::Code).toString();
+
+ return (name.contains(filterRegExp()) || code.contains(filterRegExp()));
+}
+
+
diff --git a/plugins/dockers/textproperties/LocaleHandler.h b/plugins/dockers/textproperties/LocaleHandler.h
new file mode 100644
index 0000000000..5e5132b5b8
--- /dev/null
+++ b/plugins/dockers/textproperties/LocaleHandler.h
@@ -0,0 +1,143 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef LOCALEHANDLER_H
+#define LOCALEHANDLER_H
+
+#include <QObject>
+#include <QAbstractListModel>
+#include <QSortFilterProxyModel>
+
+/**
+ * @brief The LocaleHandler class
+ *
+ * This object splits up a BCP47 locale into language and script sections,
+ * and allows editing each.
+ *
+ * It also keeps track of models for script and language.
+ */
+class LocaleHandler : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString bcp47Tag READ bcp47Tag WRITE setBcp47Tag NOTIFY bcp47TagChanged)
+ Q_PROPERTY(QString script READ script WRITE setScript NOTIFY scriptChanged)
+ Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged)
+
+ Q_PROPERTY(QAbstractItemModel *languagesModel READ languagesModel NOTIFY languagesModelChanged)
+ Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged)
+ Q_PROPERTY(QAbstractItemModel *favoritesModel READ favoritesModel NOTIFY favoritesModelChanged)
+
+ Q_PROPERTY(bool localeValid READ localeValid NOTIFY languageChanged)
+
+public:
+ LocaleHandler(QObject *parent = nullptr);
+ ~LocaleHandler();
+
+ QString bcp47Tag() const;
+ void setBcp47Tag(const QString &newBcp47Tag);
+
+ QString script() const;
+ void setScript(const QString &newScript);
+
+ QString language() const;
+ void setLanguage(const QString &newLanguage);
+
+ Q_INVOKABLE QVariantList scriptModel() const;
+
+ QAbstractItemModel *languagesModel() const;
+
+ QAbstractItemModel *favoritesModel() const;
+
+ QString searchString() const;
+ void setSearchString(const QString &newSearchString);
+
+ bool localeValid() const;
+
+Q_SIGNALS:
+
+ void bcp47TagChanged();
+
+ void scriptChanged();
+
+ void languageChanged();
+
+ void languagesModelChanged();
+
+ void favoritesModelChanged();
+
+ void searchStringChanged();
+
+private:
+
+ struct Private;
+ const QScopedPointer<Private> d;
+};
+
+class AllLanguagesModel : public QAbstractListModel {
+ Q_OBJECT
+public:
+ AllLanguagesModel(QObject *parent = nullptr);
+ ~AllLanguagesModel();
+
+ enum Roles {
+ Code = Qt::UserRole+1
+ };
+
+ int rowCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+
+ QHash<int, QByteArray> roleNames() const override;
+private:
+ struct Private;
+ const QScopedPointer<Private> d;
+};
+
+/**
+ * @brief The FavoriteLocaleModel class
+ * This class keeps track of favorite locales from the config.
+ */
+class FavoriteLocaleModel : public QAbstractListModel {
+ Q_OBJECT
+public:
+ FavoriteLocaleModel(QObject *parent = nullptr);
+ ~FavoriteLocaleModel();
+
+ enum Roles {
+ Code = Qt::UserRole + 1,
+ Favorite
+ };
+
+ int rowCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+
+ bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+
+ void addCode(const QString &code);
+
+ QHash<int, QByteArray> roleNames() const override;
+Q_SIGNALS:
+ void favoritesUpdated();
+private Q_SLOTS:
+ void updateConfig();
+private:
+
+
+ struct Private;
+ const QScopedPointer<Private> d;
+};
+
+/**
+ * @brief The LanguagesFilterModel class
+ * class that tests both the name and the code.
+ */
+class LanguagesFilterModel : public QSortFilterProxyModel {
+public:
+ LanguagesFilterModel(QObject *parent = nullptr);
+
+ bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
+};
+
+#endif // LOCALEHANDLER_H
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index 0e67528b5a..ad9c6302d5 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -47,6 +47,7 @@
#include "KoShapeQtQuickLabel.h"
#include "OpenTypeFeatureModel.h"
#include "TagFilterProxyModelQmlWrapper.h"
+#include "LocaleHandler.h"
/// Strange place to put this, do we have a better spot?
KIS_DECLARE_STATIC_INITIALIZER {
@@ -67,6 +68,7 @@ KIS_DECLARE_STATIC_INITIALIZER {
qmlRegisterType<OpenTypeFeatureModel>("org.krita.flake.text", 1, 0, "OpenTypeFeatureModel");
qmlRegisterType<KoShapeQtQuickLabel>("org.krita.flake.text", 1, 0, "KoShapeQtQuickLabel");
qmlRegisterType<TagFilterProxyModelQmlWrapper>("org.krita.flake.text", 1, 0, "TagFilterProxyModelQmlWrapper");
+ qmlRegisterType<LocaleHandler>("org.krita.flake.text", 1, 0, "LocaleHandler");
}
diff --git a/plugins/dockers/textproperties/qml/Language.qml b/plugins/dockers/textproperties/qml/Language.qml
new file mode 100644
index 0000000000..82598ab9e5
--- /dev/null
+++ b/plugins/dockers/textproperties/qml/Language.qml
@@ -0,0 +1,179 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Layouts 1.12
+import QtQuick.Window 2.15
+import org.krita.flake.text 1.0
+
+TextPropertyBase {
+ propertyName: i18nc("@title:group", "Language");
+ propertyType: TextPropertyBase.Mixed;
+ toolTip: i18nc("@info:tooltip",
+ "The language of this text shape. Language affects a number of properties, like glyph shape, upper- and lowercase and line breaking");
+ searchTerms: i18nc("comma separated search terms for the language property, matching is case-insensitive",
+ "language, locale, bcp47");
+
+ LocaleHandler {
+ id: localeHandler;
+ onBcp47TagChanged: {
+ if (!blockSignals) {
+ properties.language = localeHandler.bcp47Tag;
+ }
+ }
+
+ onScriptChanged: scriptCmb.currentIndex = scriptCmb.indexOfValue(script);
+ onLanguageChanged: languageCmb.currentIndex = languageCmb.indexOfValue(language);
+ }
+
+ onPropertiesUpdated: {
+ blockSignals = true;
+ localeHandler.bcp47Tag = properties.language;
+ visible = properties.languageState !== KoSvgTextPropertiesModel.PropertyUnset;
+ blockSignals = false;
+ }
+
+ onEnableProperty: properties.languageState = KoSvgTextPropertiesModel.PropertySet;
+ GridLayout {
+ columns: 2;
+ columnSpacing: columnSpacing;
+ width: parent.width;
+
+ RevertPropertyButton {
+ revertState: properties.languageState;
+ onClicked: properties.languageState = KoSvgTextPropertiesModel.PropertyUnset;
+ }
+
+ ComboBox {
+ id: languageCmb;
+ model: localeHandler.favoritesModel;
+ textRole: "display";
+ valueRole: "code";
+ Layout.fillWidth: true;
+
+ onDisplayTextChanged: {
+ languageTxtEdit.blockSignals = true;
+ languageTxtEdit.text = currentText;
+ languageTxtEdit.blockSignals = false;
+ }
+
+ contentItem: TextField {
+ id: languageTxtEdit;
+ verticalAlignment: Text.AlignVCenter
+ font: languageCmb.font
+ color: languageCmb.palette.text
+ selectionColor: languageCmb.palette.highlight
+ selectedTextColor: languageCmb.palette.highlightedText;
+
+ property bool blockSignals: false;
+
+ onTextChanged: {
+ if (!blockSignals) {
+ localeHandler.searchString = text;
+ if (text !== "") {
+ filterPopup.open();
+ }
+ }
+ }
+
+ onAccepted: {
+ blockSignals = true;
+ localeHandler.searchString = "";
+ filterPopup.close();
+ blockSignals = false;
+ }
+
+ Popup {
+ id: filterPopup;
+ y: -height;
+ x: 0;
+ padding: 0;
+ width: languageTxtEdit.width;
+ height: Math.min(contentItem.implicitHeight, 300);
+
+ contentItem: ListView {
+ id: filteredLanguages;
+ model: localeHandler.languagesModel;
+ width: filterPopup.width;
+ implicitHeight: contentHeight;
+ clip:true;
+
+ delegate: ItemDelegate {
+ required property var model;
+ id: languageDelegate;
+ text: model.display + " ("+model.code+")";
+ width: filterPopup.width;
+ hoverEnabled: true;
+ highlighted: hovered;
+
+ background: Rectangle {
+ color: languageDelegate.highlighted? languageDelegate.palette.highlight: "transparent";
+ }
+ palette: filterPopup.palette;
+
+ onClicked: {
+ localeHandler.language = model.code;
+ languageTxtEdit.accepted();
+ filterPopup.close();
+ }
+ }
+
+ ScrollBar.vertical: ScrollBar {
+ }
+ }
+ }
+
+
+ }
+ delegate: ItemDelegate {
+ id: favoriteDelegate;
+ required property var model;
+ palette: languageCmb.palette;
+
+ width: languageCmb.width;
+ height: contentItem.implicitHeight;
+ hoverEnabled: true;
+ highlighted: hovered;
+
+ contentItem: CheckBox {
+ text: favoriteDelegate.model.display + " ("+favoriteDelegate.model.code+")";
+ checked: favoriteDelegate.model.favorite;
+ onCheckedChanged: favoriteDelegate.model.favorite = checked;
+ palette: favoriteDelegate.palette;
+ }
+
+ background: Rectangle {
+ color: favoriteDelegate.highlighted? favoriteDelegate.palette.highlight: "transparent";
+ }
+ }
+
+ onCurrentValueChanged: localeHandler.language = currentValue;
+ }
+
+ Item {
+ width: 1;
+ height: 1;
+ }
+
+ SqueezedComboBox {
+ id: scriptCmb;
+ model: localeHandler.scriptModel();
+ textRole: "name";
+ valueRole: "code";
+ Layout.fillWidth: true;
+
+ enabled: localeHandler.localeValid;
+
+ PaletteControl {
+ id: scriptPalette;
+ colorGroup: scriptCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;
+ }
+ palette: scriptPalette.palette;
+
+ onCurrentValueChanged: localeHandler.script = currentValue;
+ }
+ }
+}
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index 3a2dae768e..0dfb6cb08c 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -148,6 +148,8 @@ ColumnLayout {
}
AlignmentBaseline {
}
+ Language {
+ }
}
}
}
diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrc
index 7d5177522b..13344b01c2 100644
--- a/plugins/dockers/textproperties/textproperties.qrc
+++ b/plugins/dockers/textproperties/textproperties.qrc
@@ -48,5 +48,6 @@
<file alias="OpenTypeFeatureSettings.qml">qml/OpenTypeFeatureSettings.qml</file>
<file alias="OpenTypeFeatureDelegate.qml">qml/OpenTypeFeatureDelegate.qml</file>
<file alias="FontKerning.qml">qml/FontKerning.qml</file>
+ <file alias="Language.qml">qml/Language.qml</file>
</qresource>
</RCC>