Add tags settings in UI

This commit is contained in:
Vyn 2024-04-22 14:34:24 +02:00
parent 01037b1717
commit e5328c15d4
10 changed files with 233 additions and 22 deletions

View file

@ -7,6 +7,7 @@
import QtQuick
import QtQuick.Window
import QtQuick.Layouts
import QtQuick.Controls
import Mirai
ColumnLayout {
@ -50,9 +51,20 @@ ColumnLayout {
Item { Layout.preferredHeight: 16 }
AppText {
text: "Tags"
font.pixelSize: 32
RowLayout {
AppText {
text: "Tags"
font.pixelSize: 32
}
Item { Layout.fillWidth: true }
AppIcon {
icon.source: "qrc:/qt/qml/Mirai/src/images/settings.png"
icon.color: colorPalette.selected.textPlaceholder
onClicked: {
tagsForm.reset();
tagsFormPopup.open();
}
}
}
Item { Layout.preferredHeight: 16 }
@ -62,25 +74,26 @@ ColumnLayout {
Rectangle {
Layout.preferredHeight: childrenRect.height
Layout.fillWidth: true
color: backend.activeTagsFilter.includes(modelData) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
color: backend.activeTagsFilter.includes(modelData.name) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
radius: 4
QtObject {
id: internal
property string configTagColor: backend.getTagColor(modelData)
}
AppText {
text: modelData
color: internal.configTagColor != "" ? internal.configTagColor : MiraiColorPalette.text
text: modelData.name
color: {
console.log("ttagg", modelData.name, modelData.color)
return modelData.color
}
padding: 4
}
MouseArea {
anchors.fill: parent
onClicked: {
if (backend.activeTagsFilter.includes(modelData)) {
backend.removeTagFilter(modelData)
if (backend.activeTagsFilter.includes(modelData.name)) {
backend.removeTagFilter(modelData.name)
} else {
backend.addTagFilter(modelData)
backend.addTagFilter(modelData.name)
}
}
HoverHandler {
@ -104,10 +117,27 @@ ColumnLayout {
}
}
/*AppButton {
text: `Settings`
onClicked: {
root.openSettings()
Popup {
parent: Overlay.overlay
id: tagsFormPopup
width: parent.width * 0.75
implicitHeight: tagsForm.height + padding * 2
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height * 0.4) / 2)
padding: 8
background: Rectangle {
border.color: colorPalette.selected.modalBorder
border.width: 2
color: colorPalette.selected.pane
radius: 4
}
}*/
TagsConfigForm {
id: tagsForm
width: parent.width
onConfirmed: (tags) => {
tagsFormPopup.close()
backend.saveTagsColor(tags)
}
}
}
}