mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 18:23:19 +00:00
Add tags settings in UI
This commit is contained in:
parent
01037b1717
commit
e5328c15d4
10 changed files with 233 additions and 22 deletions
77
src/qml/forms/TagsConfigForm.qml
Normal file
77
src/qml/forms/TagsConfigForm.qml
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Mirai. Copyright (C) 2024 Vyn
|
||||
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Window
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Dialogs
|
||||
import Mirai
|
||||
|
||||
ColumnLayout {
|
||||
id: form
|
||||
spacing: 6
|
||||
signal confirmed(tags: var)
|
||||
|
||||
function reset() {
|
||||
internal.tags = Qt.binding(function () { return [] })
|
||||
internal.tags = Qt.binding(function () { return backend.tags.map(tag => {
|
||||
return {name: tag.name, color: tag.color}
|
||||
})})
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: internal
|
||||
property var tags: []
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: tagsList
|
||||
model: internal.tags
|
||||
RowLayout {
|
||||
Rectangle {
|
||||
id: newTagColor
|
||||
color: colorDialog.selectedColor
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: 32
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
colorDialog.open()
|
||||
}
|
||||
HoverHandler {
|
||||
id: mouse
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColorDialog {
|
||||
id: colorDialog
|
||||
selectedColor: modelData.color
|
||||
onAccepted: {
|
||||
colorDialog.selectedColor = selectedColor
|
||||
internal.tags[index].color = selectedColor
|
||||
}
|
||||
}
|
||||
|
||||
AppText {
|
||||
text: modelData.name
|
||||
color: colorDialog.selectedColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppButton {
|
||||
text: "Save"
|
||||
onClicked: {
|
||||
form.confirmed(internal.tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue