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++

Make TagFilterProxyModelQmlWrapper generic and implement basic style preset view.

Wolthera van Hövell tot Westerflierde3e3cf2e528
diff --git a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp
index 462c0b672f..fec68deca1 100644
--- a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp
+++ b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.cpp
@@ -18,20 +18,28 @@
struct TagFilterProxyModelQmlWrapper::Private {
Private(QObject *parent = nullptr)
- : tagFilterProxyModel(new FontFamilyTagFilterModel(parent))
- , tagModel(new KisTagModel(ResourceType::FontFamilies, parent))
+ : parent(parent)
, compressor(KisSignalCompressor(100, KisSignalCompressor::POSTPONE, parent))
{
- allResourceModel = KisResourceModelProvider::resourceModel(ResourceType::FontFamilies);
+ }
+
+ void setupNewResourceType() {
+ tagFilterProxyModel = resourceType == ResourceType::FontFamilies? new FontFamilyTagFilterModel(parent)
+ : new KisTagFilterResourceProxyModel(resourceType, parent);
+ tagModel = new KisTagModel(resourceType, parent);
+ allResourceModel = KisResourceModelProvider::resourceModel(resourceType);
tagFilterProxyModel->sort(KisAbstractResourceModel::Name);
tagFilterProxyModel->setTagFilter(tagModel->tagForIndex(tagModel->index(0, 0)));
}
- FontFamilyTagFilterModel *tagFilterProxyModel {nullptr};
+
+ QObject *parent;
+ KisTagFilterResourceProxyModel *tagFilterProxyModel {nullptr};
KisAllResourcesModel *allResourceModel {nullptr};
KisTagModel *tagModel {nullptr};
KisSignalCompressor compressor;
QString currentSearchText;
KoResourceSP currentResource;
+ QString resourceType;
};
TagFilterProxyModelQmlWrapper::TagFilterProxyModelQmlWrapper(QObject *parent)
@@ -56,8 +64,33 @@ QAbstractItemModel *TagFilterProxyModelQmlWrapper::tagModel() const
return d->tagModel;
}
+QString TagFilterProxyModelQmlWrapper::resourceType() const
+{
+ return d->resourceType;
+}
+
+void TagFilterProxyModelQmlWrapper::setResourceType(const QString &type)
+{
+ if (d->resourceType == type) return;
+
+ d->resourceType = type;
+ d->setupNewResourceType();
+ d->currentSearchText = "";
+ d->currentResource.reset();
+
+ emit resourceTypeChanged();
+ emit tagModelChanged();
+ emit modelChanged();
+ emit searchTextChanged();
+ emit searchInTagChanged();
+ emit activeTagChanged();
+ emit modelSortUpdated();
+ emit currentResourceChanged();
+}
+
void TagFilterProxyModelQmlWrapper::tagActivated(const int &row)
{
+ if (!d->tagModel || !d->tagFilterProxyModel) return;
QModelIndex idx = d->tagModel->index(row, 0);
if (idx.isValid()) {
KisTagSP tag = d->tagModel->tagForIndex(idx);
@@ -69,6 +102,7 @@ void TagFilterProxyModelQmlWrapper::tagActivated(const int &row)
int TagFilterProxyModelQmlWrapper::currentTag() const
{
+ if (!d->tagModel) return 0;
return d->tagModel->indexForTag(d->tagFilterProxyModel->currentTagFilter()).row();
}
@@ -89,6 +123,7 @@ void TagFilterProxyModelQmlWrapper::setSearchText(const QString &text)
void TagFilterProxyModelQmlWrapper::setSearchInTag(const bool &newSearchInTag)
{
+ if (!d->tagFilterProxyModel) return;
if (d->tagFilterProxyModel->filterInCurrentTag() != newSearchInTag) {
d->tagFilterProxyModel->setFilterInCurrentTag(newSearchInTag);
emit searchInTagChanged();
@@ -97,11 +132,13 @@ void TagFilterProxyModelQmlWrapper::setSearchInTag(const bool &newSearchInTag)
bool TagFilterProxyModelQmlWrapper::searchInTag()
{
+ if (! d->tagFilterProxyModel) return false;
return d->tagFilterProxyModel->filterInCurrentTag();
}
void TagFilterProxyModelQmlWrapper::addNewTag(const QString &newTagName, const int &resourceIndex)
{
+ if (!d->tagModel || !d->tagFilterProxyModel) return;
KisTagSP tagsp = d->tagModel->tagForUrl(newTagName);
QModelIndex resourceIdx = d->tagFilterProxyModel->index(resourceIndex, 0);
if (tagsp.isNull()) {
@@ -119,6 +156,7 @@ void TagFilterProxyModelQmlWrapper::addNewTag(const QString &newTagName, const i
void TagFilterProxyModelQmlWrapper::tagResource(const int &tagIndex, const int &resourceIndex)
{
+ if (!d->tagModel || !d->tagFilterProxyModel) return;
QModelIndex idx = d->tagModel->index(tagIndex, 0);
QModelIndex resourceIdx = d->tagFilterProxyModel->index(resourceIndex, 0);
KisTagSP tagsp;
@@ -133,6 +171,7 @@ void TagFilterProxyModelQmlWrapper::tagResource(const int &tagIndex, const int &
void TagFilterProxyModelQmlWrapper::untagResource(const int &tagIndex, const int &resourceIndex)
{
+ if (!d->tagModel || !d->tagFilterProxyModel) return;
QModelIndex idx = d->tagModel->index(tagIndex, 0);
QModelIndex resourceIdx = d->tagFilterProxyModel->index(resourceIndex, 0);
KisTagSP tagsp;
@@ -170,6 +209,7 @@ QString TagFilterProxyModelQmlWrapper::localizedNameFromMetadata(
QVariantMap TagFilterProxyModelQmlWrapper::metadataForIndex(const int &resourceIndex) const
{
+ if (!d->tagFilterProxyModel) return QVariantMap();
QModelIndex resourceIdx = d->tagFilterProxyModel->index(resourceIndex, 0);
// NOTE: KisTagFilterProxyModel has this weird thing where it switches between source models depending
// on whether filtering by tag happens. This somehow causes index() to not always work.
@@ -197,6 +237,7 @@ QString TagFilterProxyModelQmlWrapper::localizedSampleFromMetadata(const QMap<QS
QVariantList TagFilterProxyModelQmlWrapper::taggedResourceModel (const int &resourceIndex) const
{
QVariantList taggedResourceModel;
+ if (!d->tagModel || !d->tagFilterProxyModel) return taggedResourceModel;
QModelIndex resourceIdx = d->tagFilterProxyModel->index(resourceIndex, 0);
KisTagSP tagsp;
for (int i = 0; i< d->tagModel->rowCount(); i++) {
@@ -216,6 +257,7 @@ QVariantList TagFilterProxyModelQmlWrapper::taggedResourceModel (const int &reso
bool TagFilterProxyModelQmlWrapper::showResourceTagged(const int &tagIndex, const int &resourceIndex) const
{
+ if (!d->tagModel || !d->tagFilterProxyModel) return false;
QModelIndex idx = d->tagModel->index(tagIndex, 0);
QModelIndex resourceIdx = d->tagFilterProxyModel->index(resourceIndex, 0);
KisTagSP tagsp;
@@ -235,11 +277,13 @@ bool TagFilterProxyModelQmlWrapper::showResourceTagged(const int &tagIndex, cons
int TagFilterProxyModelQmlWrapper::currentIndex() const
{
+ if (!d->tagFilterProxyModel) return -1;
return d->tagFilterProxyModel->indexForResource(d->currentResource).row();
}
void TagFilterProxyModelQmlWrapper::setCurrentIndex(const int &index)
{
+ if (!d->tagFilterProxyModel) return;
QModelIndex resourceIdx = d->tagFilterProxyModel->index(index, 0);
if (!resourceIdx.isValid()) return;
KoResourceSP newResource = d->tagFilterProxyModel->resourceForIndex(resourceIdx);
@@ -251,6 +295,7 @@ void TagFilterProxyModelQmlWrapper::setCurrentIndex(const int &index)
void TagFilterProxyModelQmlWrapper::setResourceToFileName(const QString &filename)
{
+ if (!d->allResourceModel) return;
KoResourceSP resource = d->currentResource;
QVector<KoResourceSP> resources = d->allResourceModel->resourcesForFilename(filename);
if (!resources.isEmpty()) {
@@ -267,8 +312,14 @@ QString TagFilterProxyModelQmlWrapper::resourceFilename()
return d->currentResource? d->currentResource->filename(): "";
}
+KoResourceSP TagFilterProxyModelQmlWrapper::currentResource() const
+{
+ return d->currentResource;
+}
+
void TagFilterProxyModelQmlWrapper::setSearchTextOnModel()
{
+ if (!d->tagFilterProxyModel) return;
d->tagFilterProxyModel->setSearchText(d->currentSearchText);
emit modelSortUpdated();
}
diff --git a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h
index c2d9a6f5e7..1393ae1e20 100644
--- a/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h
+++ b/plugins/dockers/textproperties/TagFilterProxyModelQmlWrapper.h
@@ -22,11 +22,14 @@ class TagFilterProxyModelQmlWrapper : public QObject
Q_PROPERTY(QAbstractItemModel *model READ model NOTIFY modelChanged)
Q_PROPERTY(QAbstractItemModel *tagModel READ tagModel NOTIFY tagModelChanged)
+ Q_PROPERTY(QString resourceType READ resourceType WRITE setResourceType NOTIFY resourceTypeChanged)
+
Q_PROPERTY(QString searchText READ searchText WRITE setSearchText NOTIFY searchTextChanged)
Q_PROPERTY(int currentTag READ currentTag WRITE tagActivated NOTIFY activeTagChanged)
Q_PROPERTY(bool searchInTag READ searchInTag WRITE setSearchInTag NOTIFY searchInTagChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentResourceChanged)
Q_PROPERTY(QString resourceFilename READ resourceFilename NOTIFY currentResourceChanged)
+ Q_PROPERTY(KoResourceSP currentResource READ currentResource NOTIFY currentResourceChanged)
public:
TagFilterProxyModelQmlWrapper(QObject *parent = nullptr);
~TagFilterProxyModelQmlWrapper();
@@ -38,6 +41,9 @@ public:
/// Associated tagmodel
QAbstractItemModel *tagModel() const;
+ QString resourceType() const;
+ void setResourceType(const QString &type);
+
/// Select tag at row in tag model.
void tagActivated(const int &row);
/// Return row of current tag in tag model.
@@ -86,6 +92,8 @@ public:
QString resourceFilename();
+ KoResourceSP currentResource() const;
+
Q_SIGNALS:
void modelChanged();
void searchTextChanged();
@@ -94,6 +102,7 @@ Q_SIGNALS:
void modelSortUpdated();
void currentResourceChanged();
void tagModelChanged();
+ void resourceTypeChanged();
private Q_SLOTS:
/// Slot to set the search text on the model via a signal compressor.
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cpp
index 28d233dae7..a1ad71f11d 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp
+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp
@@ -41,6 +41,7 @@
#include <text/lager/FontVariantNumericModel.h>
#include <text/lager/FontVariantEastAsianModel.h>
#include <resources/KoFontFamily.h>
+#include <resources/KoCssStylePreset.h>
#include <lager/state.hpp>
#include "FontStyleModel.h"
@@ -334,4 +335,17 @@ QString TextPropertiesDock::wwsFontFamilyName(QString familyName)
}
return name.value();
}
+
+void TextPropertiesDock::applyPreset(KoResourceSP resource)
+{
+ KoCssStylePresetSP preset = resource.staticCast<KoCssStylePreset>();
+ if (!preset) return;
+ KoSvgTextPropertyData textData = d->textModel->textData.get();
+ KoSvgTextProperties properties = preset->properties();
+ Q_FOREACH(KoSvgTextProperties::PropertyId p, properties.properties()) {
+ textData.commonProperties.setProperty(p, properties.property(p));
+ }
+ d->textModel->textData.set(textData);
+}
+
#include "TextPropertiesDock.moc"
diff --git a/plugins/dockers/textproperties/TextPropertiesDock.h b/plugins/dockers/textproperties/TextPropertiesDock.h
index 8bf3d55648..d9b72c784f 100644
--- a/plugins/dockers/textproperties/TextPropertiesDock.h
+++ b/plugins/dockers/textproperties/TextPropertiesDock.h
@@ -12,6 +12,7 @@
#include <QPointer>
#include <kis_canvas2.h>
+#include <KoResource.h>
class KoDialog;
class QQuickWidget;
@@ -39,6 +40,8 @@ public Q_SLOTS:
void callModalTextPropertyConfigDialog();
+ void applyPreset(KoResourceSP resource);
+
private:
QPointer<KisCanvas2> m_canvas;
QQuickWidget *m_quickWidget {0};
diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
index 7e984f9cdd..d3630e04e7 100644
--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
@@ -6,6 +6,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.12
+import QtQuick.Window 2.15
import org.krita.flake.text 1.0
Button {
@@ -16,7 +17,14 @@ Button {
property TagFilterProxyModelQmlWrapper modelWrapper : TagFilterProxyModelQmlWrapper{
id: modelWrapperId;
+ resourceType: "fontfamilies";
};
+
+ /// Ideally we'd have the max popup height be Window-height - y-pos-of-item-to-window.
+ /// But that's pretty hard to calculate (map to global is screen relative, but there's
+ /// no way to get window.y relative to screen), so we'll just use 300 as the maximum.
+ property int maxPopupHeight: Math.min(Window.height, 300) - height*3;
+
text: modelWrapper.resourceFilename;
property int highlightedIndex;
onClicked: {
@@ -43,7 +51,7 @@ Button {
property string sample: familyCmb.modelWrapper.localizedSampleFromMetadata(meta, locales, "");
/// When updating the model wrapper, the "model" doesn't always update on the delegate, so we need to manually load
/// the metadata from the modelwrapper.
- width: fontResourceView.listWidth;
+ width: ListView.view.width;
highlighted: familyCmb.highlightedIndex === model.index;
Component.onCompleted: {
@@ -195,180 +203,16 @@ Button {
y: familyCmb.height - 1;
x: familyCmb.width - width;
width: contentWidth;
- height: contentHeight;
+ height: Math.min(contentItem.implicitHeight, familyCmb.maxPopupHeight - topMargin - bottomMargin)
padding: 2;
palette: familyCmb.palette;
- contentItem:
- ColumnLayout {
- id: fontResourceView;
- clip:true;
- property alias fontModel : view.model;
- property alias tagModel: tagFilter.model;
- property alias listWidth : view.width;
- fontModel: familyCmb.modelWrapper.model;
- tagModel: familyCmb.modelWrapper.tagModel;
-
- RowLayout {
- id: tagAndConfig;
-
- ComboBox {
- id: tagFilter;
- textRole: "display";
- Layout.fillWidth: true;
- currentIndex: familyCmb.modelWrapper.currentTag;
- onActivated: familyCmb.modelWrapper.currentTag = currentIndex;
- }
-
- Button {
- id: tagMenuButton;
- icon.source: "qrc:///light_bookmarks.svg";
- text: i18nc("@label:button", "Tag");
- onClicked: hideShowMenu();
- function hideShowMenu() {
- if (!tagActionsContextMenu.visible) {
- tagActionsContextMenu.resourceIndex = familyCmb.highlightedIndex;
- tagActionsContextMenu.popup(tagMenuButton,
- tagActionsContextMenu.width - tagMenuButton.width,
- tagMenuButton.height - 1);
- } else {
- tagActionsContextMenu.dismiss();
- }
- }
-
- //--- Tag Setup ---//
- Menu {
- id: tagActionsContextMenu;
-
- palette: familyCmb.palette;
- property int resourceIndex: -1;
- property alias resourceName: resourceLabel.text;
- property var resourceTaggedModel : [];
- enabled: resourceIndex >= 0;
- onResourceIndexChanged: {
- resourceName = modelWrapper.localizedNameFromMetadata(modelWrapper.metadataForIndex(tagActionsContextMenu.resourceIndex), locales, resourceName);
- updateResourceTaggedModel();
- }
- function updateResourceTaggedModel() {
- resourceTaggedModel = modelWrapper.taggedResourceModel(tagActionsContextMenu.resourceIndex);
- }
- function updateAndDismiss() {
- updateResourceTaggedModel();
- dismiss();
- }
-
- modal: true;
- closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
- Label {
- id: resourceLabel;
- }
-
- Menu {
- id: assignToTag;
- title: i18nc("@title:menu", "Assign to Tag");
- height: contentChildren.height;
- ListView {
- id: tagAddView;
- model: tagActionsContextMenu.resourceTaggedModel;
- height: contentHeight;
- width: parent.width;
-
- delegate: ItemDelegate {
- width: tagAddView.width;
- text: modelData.name;
- visible: modelData.visible && !modelData.enabled;
- height: visible? implicitContentHeight: 0;
-
- onClicked: {
- modelWrapper.tagResource(modelData.value, tagActionsContextMenu.resourceIndex);
- tagActionsContextMenu.updateAndDismiss();
- }
- }
- }
- MenuSeparator {}
- RowLayout {
- TextField {
- id: newTagName;
- placeholderText: i18nc("@info:placeholder", "New Tag Name...");
- Layout.fillWidth: true;
- }
- ToolButton {
- icon.source: "qrc:///light_list-add.svg";
- icon.color: palette.text;
- onClicked: {
- modelWrapper.addNewTag(newTagName.text, tagActionsContextMenu.resourceIndex);
- newTagName.text = "";
- tagActionsContextMenu.updateAndDismiss();
- }
- }
- }
-
- }
- MenuSeparator {}
- Action {
- enabled: modelWrapper.showResourceTagged(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);
- id: removeFromThisTag;
- text: i18nc("@action:inmenu", "Remove from this tag");
- icon.source: "qrc:///16_light_list-remove.svg";
- onTriggered: modelWrapper.untagResource(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);
- }
-
- Menu {
- id: removeFromTag;
- title: i18nc("@title:menu", "Remove from other tag");
- ListView {
- id: tagRemoveView;
- model: tagActionsContextMenu.resourceTaggedModel;
- height: contentHeight;
- width: parent.width;
- delegate: ItemDelegate {
- width: tagRemoveView.width;
- text: modelData.name;
- visible: modelData.visible && modelData.enabled;
- height: visible? implicitContentHeight: 0;
- onClicked: {
- modelWrapper.untagResource(modelData.value, tagActionsContextMenu.resourceIndex);
- tagActionsContextMenu.updateAndDismiss()
- }
- }
- }
- }
- }
- }
- }
- Frame {
- Layout.minimumHeight: font.pixelSize*3;
- Layout.preferredHeight: 300;
- Layout.maximumHeight: 500;
- Layout.fillWidth: true;
- clip: true;
- ListView {
- anchors.fill: parent;
- id: view;
- currentIndex: familyCmb.modelWrapper.currentIndex;
- delegate: fontDelegate;
- ScrollBar.vertical: ScrollBar {
- }
- }
- }
- RowLayout {
- Layout.preferredHeight: childrenRect.height;
- TextField {
- id: search;
- placeholderText: i18nc("@info:placeholder", "Search...");
- Layout.fillWidth: true;
- text: modelWrapper.searchText;
- onTextEdited: modelWrapper.searchText = text;
- }
- CheckBox {
- id: opticalSizeCbx
- text: i18nc("@option:check", "Search in tag")
- onCheckedChanged: modelWrapper.searchInTag = checked;
- checked: modelWrapper.searchInTag;
- }
- }
+ contentItem: ResourceView {
+ id: resourceView;
+ modelWrapper: familyCmb.modelWrapper;
+ resourceDelegate: fontDelegate;
+ palette: familyCmbPopup.palette;
}
-
}
}
diff --git a/plugins/dockers/textproperties/qml/ResourceView.qml b/plugins/dockers/textproperties/qml/ResourceView.qml
new file mode 100644
index 0000000000..562c219427
--- /dev/null
+++ b/plugins/dockers/textproperties/qml/ResourceView.qml
@@ -0,0 +1,197 @@
+/*
+ * SPDX-FileCopyrightText: 2025 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.15
+import org.krita.flake.text 1.0
+
+Control {
+ id: control;
+ property TagFilterProxyModelQmlWrapper modelWrapper: TagFilterProxyModelQmlWrapper{
+ id: modelWrapperId;
+ };
+ property alias resourceType : modelWrapperId.resourceType;
+ property alias currentIndex : modelWrapperId.currentIndex;
+ property alias currentResource : modelWrapperId.currentResource;
+
+ property alias resourceDelegate : view.delegate;
+
+
+ contentItem: ColumnLayout {
+ id: resourceView;
+ clip:true;
+ anchors.fill: parent;
+ property alias resourceModel : view.model;
+ property alias tagModel: tagFilter.model;
+ resourceModel: modelWrapper.model;
+ tagModel: modelWrapper.tagModel;
+
+ RowLayout {
+ id: tagAndConfig;
+
+ ComboBox {
+ id: tagFilter;
+ textRole: "display";
+ Layout.fillWidth: true;
+ currentIndex: modelWrapper.currentTag;
+ onActivated: modelWrapper.currentTag = currentIndex;
+ palette: control.palette;
+ }
+
+ Button {
+ id: tagMenuButton;
+ icon.source: "qrc:///light_bookmarks.svg";
+ icon.color: palette.text;
+ text: i18nc("@label:button", "Tag");
+ onClicked: hideShowMenu();
+ palette: control.palette;
+ function hideShowMenu() {
+ if (!tagActionsContextMenu.visible) {
+ tagActionsContextMenu.resourceIndex = familyCmb.highlightedIndex;
+ tagActionsContextMenu.popup(tagMenuButton,
+ tagActionsContextMenu.width - tagMenuButton.width,
+ tagMenuButton.height - 1);
+ } else {
+ tagActionsContextMenu.dismiss();
+ }
+ }
+
+ //--- Tag Setup ---//
+ Menu {
+ id: tagActionsContextMenu;
+
+ palette: control.palette;
+ property int resourceIndex: -1;
+ property alias resourceName: resourceLabel.text;
+ property var resourceTaggedModel : [];
+ enabled: resourceIndex >= 0;
+ onResourceIndexChanged: {
+ resourceName = modelWrapper.localizedNameFromMetadata(modelWrapper.metadataForIndex(tagActionsContextMenu.resourceIndex), locales, resourceName);
+ updateResourceTaggedModel();
+ }
+ function updateResourceTaggedModel() {
+ resourceTaggedModel = modelWrapper.taggedResourceModel(tagActionsContextMenu.resourceIndex);
+ }
+ function updateAndDismiss() {
+ updateResourceTaggedModel();
+ dismiss();
+ }
+
+ modal: true;
+ closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
+ Label {
+ id: resourceLabel;
+ }
+
+ Menu {
+ id: assignToTag;
+ title: i18nc("@title:menu", "Assign to Tag");
+ height: contentChildren.height;
+ ListView {
+ id: tagAddView;
+ model: tagActionsContextMenu.resourceTaggedModel;
+ height: contentHeight;
+ width: parent.width;
+
+ delegate: ItemDelegate {
+ width: tagAddView.width;
+ text: modelData.name;
+ visible: modelData.visible && !modelData.enabled;
+ height: visible? implicitContentHeight: 0;
+
+ onClicked: {
+ modelWrapper.tagResource(modelData.value, tagActionsContextMenu.resourceIndex);
+ tagActionsContextMenu.updateAndDismiss();
+ }
+ }
+ }
+ MenuSeparator {}
+ RowLayout {
+ TextField {
+ id: newTagName;
+ placeholderText: i18nc("@info:placeholder", "New Tag Name...");
+ Layout.fillWidth: true;
+ }
+ ToolButton {
+ icon.source: "qrc:///light_list-add.svg";
+ icon.color: palette.text;
+ onClicked: {
+ modelWrapper.addNewTag(newTagName.text, tagActionsContextMenu.resourceIndex);
+ newTagName.text = "";
+ tagActionsContextMenu.updateAndDismiss();
+ }
+ }
+ }
+ }
+ MenuSeparator {}
+ Action {
+ enabled: modelWrapper.showResourceTagged(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);
+ id: removeFromThisTag;
+ text: i18nc("@action:inmenu", "Remove from this tag");
+ icon.source: "qrc:///16_light_list-remove.svg";
+ icon.color: palette.text;
+ onTriggered: modelWrapper.untagResource(modelWrapper.currentTag, tagActionsContextMenu.resourceIndex);
+ }
+
+ Menu {
+ id: removeFromTag;
+ title: i18nc("@title:menu", "Remove from other tag");
+ ListView {
+ id: tagRemoveView;
+ model: tagActionsContextMenu.resourceTaggedModel;
+ height: contentHeight;
+ width: parent.width;
+ delegate: ItemDelegate {
+ width: tagRemoveView.width;
+ text: modelData.name;
+ visible: modelData.visible && modelData.enabled;
+ height: visible? implicitContentHeight: 0;
+ onClicked: {
+ modelWrapper.untagResource(modelData.value, tagActionsContextMenu.resourceIndex);
+ tagActionsContextMenu.updateAndDismiss()
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Frame {
+ Layout.minimumHeight: font.pixelSize*3;
+ Layout.fillWidth: true;
+ Layout.fillHeight: true;
+ Layout.preferredHeight: contentHeight;
+ palette: control.palette;
+ clip: true;
+ ListView {
+ anchors.fill: parent;
+ id: view;
+ implicitHeight: contentHeight;
+ currentIndex: modelWrapper.currentIndex;
+ ScrollBar.vertical: ScrollBar {
+ }
+ }
+ }
+ RowLayout {
+ Layout.preferredHeight: childrenRect.height;
+ TextField {
+ id: search;
+ placeholderText: i18nc("@info:placeholder", "Search...");
+ Layout.fillWidth: true;
+ text: modelWrapper.searchText;
+ onTextEdited: modelWrapper.searchText = text;
+ palette: control.palette;
+ }
+ CheckBox {
+ id: opticalSizeCbx
+ text: i18nc("@option:check", "Search in tag")
+ onCheckedChanged: modelWrapper.searchInTag = checked;
+ checked: modelWrapper.searchInTag;
+ palette: control.palette;
+ }
+ }
+ }
+}
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index 0763f1b000..ad6b931def 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -49,6 +49,9 @@ Rectangle {
TabButton {
text: i18nc("@title:tab", "Paragraph")
}
+ TabButton {
+ text: i18nc("@title:tab", "Preset")
+ }
}
StackLayout {
@@ -69,5 +72,25 @@ Rectangle {
propertyType: TextPropertyConfigModel.Paragraph;
configModel: root.configModel;
}
+
+ ResourceView {
+ id: presetView;
+ resourceType: "css_styles";
+ Layout.fillHeight: true;
+ Layout.fillWidth: true;
+ palette: paletteControl.palette;
+
+ onCurrentResourceChanged: {
+ mainWindow.applyPreset(currentResource);
+ }
+
+ resourceDelegate: ItemDelegate {
+ required property var model;
+ width: ListView.view.width;
+ text: model.name;
+
+ onClicked: presetView.currentIndex = model.index;
+ }
+ }
}
}
diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrc
index a1c36a2f28..86b316e6b6 100644
--- a/plugins/dockers/textproperties/textproperties.qrc
+++ b/plugins/dockers/textproperties/textproperties.qrc
@@ -60,5 +60,6 @@
<file alias="FontSizeAdjust.qml">qml/FontSizeAdjust.qml</file>
<file alias="TextRendering.qml">qml/TextRendering.qml</file>
<file alias="TextPropertyConfigDialog.qml">qml/TextPropertyConfigDialog.qml</file>
+ <file alias="ResourceView.qml">qml/ResourceView.qml</file>
</qresource>
</RCC>