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++
Fix saving/loading favourite languages in the text property docker.
Wolthera van Hövell tot Westerflier8aca53cba7ba
diff --git a/plugins/dockers/textproperties/LocaleHandler.cpp b/plugins/dockers/textproperties/LocaleHandler.cppindex 381605a9c6..912899e310 100644--- a/plugins/dockers/textproperties/LocaleHandler.cpp+++ b/plugins/dockers/textproperties/LocaleHandler.cpp@@ -225,7 +225,6 @@ FavoriteLocaleModel::FavoriteLocaleModel(QObject *parent): QAbstractListModel(parent), d(new Private ()){- connect(this, SIGNAL(favoritesUpdated()), this, SLOT(updateConfig()));}FavoriteLocaleModel::~FavoriteLocaleModel()@@ -256,22 +255,34 @@ QVariant FavoriteLocaleModel::data(const QModelIndex &index, int role) const}return QVariant();}-+#include <QDebug>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);+ bool updated = false;++ if (fav) {+ if (!d->favorites.contains(code)) {+ d->favorites.append(code);+ updated = true;+ }} else {- d->favorites.removeAll(code);+ const int i = d->favorites.indexOf(code);+ if (i > 0) {+ d->favorites.removeAt(i);+ updated = true;+ }+ }+ if (updated) {+ updateConfig();+ emit dataChanged(index, index, {role});+ return true;}- emit dataChanged(index, index, {role});- emit favoritesUpdated();- return true;}return false;}diff --git a/plugins/dockers/textproperties/qml/Language.qml b/plugins/dockers/textproperties/qml/Language.qmlindex 0b233fc07b..292c3df61b 100644--- a/plugins/dockers/textproperties/qml/Language.qml+++ b/plugins/dockers/textproperties/qml/Language.qml@@ -130,7 +130,7 @@ TextPropertyBase {}- delegate: CheckDelegate {+ delegate: ItemDelegate {id: favoriteDelegate;required property var model;required property var index;@@ -141,13 +141,31 @@ TextPropertyBase {highlighted: hovered;text: model.display + " ("+favoriteDelegate.model.code+")";- checked: favoriteDelegate.model.favorite;++ contentItem: RowLayout {+ CheckBox {+ Component.onCompleted: {+ checked = favoriteDelegate.model.favorite;+ }+ onCheckedChanged: favoriteDelegate.model.favorite = checked;+ palette: favoriteDelegate.palette;+ hoverEnabled: true;+ padding: 0;+ }+ Label {+ text: favoriteDelegate.model.display + " ("+favoriteDelegate.model.code+")";+ palette: favoriteDelegate.palette;+ color: favoriteDelegate.highlighted? palette.highlightedText: palette.text;+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter;+ Layout.fillWidth: true;+ }+ }background: Rectangle {color: favoriteDelegate.highlighted? favoriteDelegate.palette.highlight: "transparent";}-onClicked: languageCmb.currentIndex = index;+}onCurrentValueChanged: localeHandler.language = currentValue;