mirai/src/qml/SideMenu.qml

180 lines
3.9 KiB
QML
Raw Normal View History

2024-04-10 16:53:18 +02:00
/*
* 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.Layouts
2024-04-22 14:34:24 +02:00
import QtQuick.Controls
2024-04-10 16:53:18 +02:00
import Mirai
ColumnLayout {
2024-04-22 15:45:26 +02:00
RowLayout {
AppText {
text: "Files"
font.pixelSize: 32
}
Item { Layout.fillWidth: true }
AppIcon {
icon.source: "qrc:/qt/qml/Mirai/src/images/settings.png"
icon.color: colorPalette.selected.textPlaceholder
onClicked: {
filesForm.reset();
filesFormPopup.open();
}
}
2024-04-14 14:11:41 +02:00
}
Item { Layout.preferredHeight: 16 }
Repeater {
model: backend.files
Rectangle {
Layout.preferredHeight: childrenRect.height
Layout.fillWidth: true
color: backend.activeFilesFilter.includes(modelData.name) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
radius: 4
AppText {
text: modelData.name
padding: 4
}
MouseArea {
anchors.fill: parent
onClicked: {
if (backend.activeFilesFilter.includes(modelData.name)) {
backend.removeFileFilter(modelData.name)
} else {
backend.addFileFilter(modelData.name)
}
}
HoverHandler {
id: mouse
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
cursorShape: Qt.PointingHandCursor
}
}
}
}
Item { Layout.preferredHeight: 16 }
2024-04-22 14:34:24 +02:00
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();
}
}
2024-04-10 16:53:18 +02:00
}
Item { Layout.preferredHeight: 16 }
Repeater {
model: backend.tags
Rectangle {
Layout.preferredHeight: childrenRect.height
Layout.fillWidth: true
2024-04-22 14:34:24 +02:00
color: backend.activeTagsFilter.includes(modelData.name) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
2024-04-10 16:53:18 +02:00
radius: 4
2024-04-14 14:36:07 +02:00
QtObject {
id: internal
}
2024-04-10 16:53:18 +02:00
AppText {
2024-04-22 14:34:24 +02:00
text: modelData.name
color: {
return modelData.color
}
2024-04-10 16:53:18 +02:00
padding: 4
}
MouseArea {
anchors.fill: parent
onClicked: {
2024-04-22 14:34:24 +02:00
if (backend.activeTagsFilter.includes(modelData.name)) {
backend.removeTagFilter(modelData.name)
2024-04-10 16:53:18 +02:00
} else {
2024-04-22 14:34:24 +02:00
backend.addTagFilter(modelData.name)
2024-04-10 16:53:18 +02:00
}
}
HoverHandler {
id: mouse
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
cursorShape: Qt.PointingHandCursor
}
}
}
}
Item {
Layout.fillHeight: true
}
AppButton {
text: `Hide completed tasks: ${backend.shouldHideCompletedTasks ? "ON" : "OFF"}`
onClicked: {
backend.hideCompletedTasks(!backend.shouldHideCompletedTasks)
}
}
2024-04-14 14:11:41 +02:00
2024-04-22 15:45:26 +02:00
Popup {
parent: Overlay.overlay
id: filesFormPopup
width: parent.width * 0.75
implicitHeight: filesForm.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
}
FilesForm {
id: filesForm
width: parent.width
onConfirmed: (filesPath) => {
filesFormPopup.close()
console.log(filesPath)
backend.saveFilesPath(filesPath)
}
}
}
2024-04-22 14:34:24 +02:00
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
2024-04-14 14:11:41 +02:00
}
2024-04-22 14:34:24 +02:00
TagsConfigForm {
id: tagsForm
width: parent.width
onConfirmed: (tags) => {
tagsFormPopup.close()
backend.saveTagsColor(tags)
}
}
}
2024-04-10 16:53:18 +02:00
}