Files

223 lines
10 KiB
QML
Raw Permalink Normal View History

2023-06-12 23:43:22 +02:00
/*
* This file is part of the Flowee project
2025-02-25 19:38:39 +01:00
* Copyright (C) 2023-2025 Tom Zander <tom@flowee.org>
2023-06-12 23:43:22 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Layouts
import "../Flowee" as Flowee
Page {
id: root
headerText: qsTr("Explore")
background: Rectangle {
2025-03-03 19:38:28 +01:00
color: palette.base
}
2023-06-13 15:48:16 +02:00
Item {
2023-06-12 23:43:22 +02:00
anchors.fill: parent
2023-06-13 15:48:16 +02:00
// clip: true
2023-06-12 23:43:22 +02:00
2023-06-13 15:48:16 +02:00
Flickable {
anchors.fill: parent
anchors.topMargin: 10
anchors.bottomMargin: 10
contentWidth: width
contentHeight: content.height
2023-06-12 23:43:22 +02:00
2023-06-13 15:48:16 +02:00
Column {
id: content
width: parent.width
spacing: 15
2023-06-12 23:43:22 +02:00
2023-06-13 15:48:16 +02:00
Repeater {
model: ModuleManager.registeredModules
Rectangle {
width: root.width - 30
height: 35 + titleLabel.height + statusField.height + Math.min(120, descriptionLabel.implicitHeight)
radius: 20
2025-03-03 19:38:28 +01:00
color: palette.light
2023-06-13 15:48:16 +02:00
border.width: 1
border.color: palette.midlight
2024-06-23 19:55:11 +02:00
visible: modelData.hasUISections // has user-visible parts.
2023-06-12 23:43:22 +02:00
Flowee.Label {
2023-06-13 15:48:16 +02:00
id: titleLabel
y: 15
text: modelData.title
font.bold: true
anchors.horizontalCenter: parent.horizontalCenter
2023-06-12 23:43:22 +02:00
}
2025-02-25 19:38:39 +01:00
NewIndicator {
id: newIndicator
buddy: titleLabel
buttonId: modelData.buttonId
}
2023-06-13 15:48:16 +02:00
Image {
2023-06-12 23:43:22 +02:00
x: 10
width: 64
2023-06-13 15:48:16 +02:00
anchors.top: descriptionFrame.top
source: modelData.iconSource
visible: modelData.iconSource !== ""
smooth: true
fillMode: Image.PreserveAspectFit
2023-06-12 23:43:22 +02:00
}
2023-06-13 15:48:16 +02:00
Item {
id: descriptionFrame
anchors.top: titleLabel.bottom
anchors.topMargin: 10
width: parent.width - (modelData.iconSource === "" ? 0 : 76)
2023-06-13 15:48:16 +02:00
clip: true
anchors.bottom: statusField.top
anchors.bottomMargin: 10
2023-06-12 23:43:22 +02:00
anchors.right: parent.right
2023-07-05 12:24:31 +02:00
z: 10
2023-06-13 15:48:16 +02:00
Flowee.Label {
id: descriptionLabel
width: parent.width - 20
x: 10
text: modelData.description
horizontalAlignment: Text.AlignJustify
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
MouseArea {
anchors.fill: parent
onClicked: descriptionFrame.clip = !descriptionFrame.clip
}
}
}
2023-06-12 23:43:22 +02:00
2023-06-13 15:48:16 +02:00
Item {
id: statusField
width: parent.width
height: 40
anchors.bottom: parent.bottom
2023-07-05 12:24:31 +02:00
z: 1
2023-06-13 15:48:16 +02:00
2024-12-31 16:44:11 +01:00
Image {
id: openIcon
rotation: 270; width: 12; height: 8
anchors.right: parent.right
anchors.rightMargin: 10
2026-03-14 21:14:42 +01:00
source: Pay.useDarkSkin ? "qrc:/smallArrow-light.svg" : "qrc:/smallArrow.svg"
2024-12-31 16:44:11 +01:00
anchors.verticalCenter: openLabel.verticalCenter
}
Flowee.Label {
id: openLabel
text: qsTr("Open")
anchors.right: openIcon.left
anchors.rightMargin: 6
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
}
MouseArea {
anchors.left: openLabel.left
anchors.right: parent.right
2025-02-25 19:38:39 +01:00
height: parent.height + 20
y: -10
2024-12-31 16:44:11 +01:00
onClicked: {
2026-03-14 21:14:42 +01:00
newIndicator.markSeen()
2024-12-31 16:44:11 +01:00
for (let s of modelData.sections) {
if (s.isMainMenuMethod || s.isSendMethod || s.isForExploreTab) {
2026-03-14 21:14:42 +01:00
thePile.replace(s.qml)
return
2024-12-31 16:44:11 +01:00
}
}
}
}
2023-06-13 15:48:16 +02:00
Row {
2025-02-25 19:38:39 +01:00
id: enabledRow
2023-06-13 15:48:16 +02:00
spacing: 10
2025-02-25 19:38:39 +01:00
height: parent.height
x: 10
2023-06-13 15:48:16 +02:00
Flowee.CheckBox {
2025-02-25 19:38:39 +01:00
id: moduleEnabled
2023-06-13 15:48:16 +02:00
anchors.verticalCenter: parent.verticalCenter
checked: modelData.enabled
2026-03-14 21:14:42 +01:00
onClicked: modelData.enabled = checked
2024-12-30 15:59:01 +01:00
visible: modelData.canBeEnabled
2023-06-13 15:48:16 +02:00
}
// one icon per section-type
Image {
2026-03-14 21:14:42 +01:00
source: "qrc:/sending" + (Pay.useDarkSkin ? "-light.svg" : ".svg")
2023-07-04 23:16:35 +02:00
width: 16
height: width
anchors.verticalCenter: parent.verticalCenter
visible: section != null
opacity: (visible && section.enabled) ? 0.8 : 0.3
property QtObject section: {
// find the section our icon represents.
for (let s of modelData.sections) {
if (s.isSendMethod)
2026-03-14 21:14:42 +01:00
return s
2023-07-04 23:16:35 +02:00
}
2026-03-14 21:14:42 +01:00
return null // module doesn't have such a section.
2023-07-04 23:16:35 +02:00
}
}
Image {
2026-03-14 21:14:42 +01:00
source: "qrc:/module-mainmenu" + (Pay.useDarkSkin ? "-light.svg" : ".svg")
2023-06-13 15:48:16 +02:00
width: 16
height: width
anchors.verticalCenter: parent.verticalCenter
visible: section != null
opacity: (visible && section.enabled) ? 0.8 : 0.3
property QtObject section: {
// find the section our icon represents.
for (let s of modelData.sections) {
2023-07-05 12:24:31 +02:00
if (s.isMainMenuMethod)
2026-03-14 21:14:42 +01:00
return s
2023-06-13 15:48:16 +02:00
}
2026-03-14 21:14:42 +01:00
return null
2024-12-22 17:23:27 +01:00
}
}
Image {
2026-03-14 21:14:42 +01:00
source: "qrc:/exploretab" + (Pay.useDarkSkin ? "-light.svg" : ".svg")
2024-12-22 17:23:27 +01:00
width: 16
height: width
anchors.verticalCenter: parent.verticalCenter
visible: section != null
opacity: (visible && section.enabled
|| !modelData.canBeEnabled) ? 0.8 : 0.3
2024-12-22 17:23:27 +01:00
property QtObject section: {
// find the section our icon represents.
for (let s of modelData.sections) {
if (s.isForExploreTab)
2026-03-14 21:14:42 +01:00
return s
2024-12-22 17:23:27 +01:00
}
2026-03-14 21:14:42 +01:00
return null
2023-06-13 15:48:16 +02:00
}
}
}
2025-02-25 19:38:39 +01:00
MouseArea {
anchors.fill: enabledRow
anchors.margins: -10
onClicked: {
2026-03-14 21:14:42 +01:00
newIndicator.markSeen()
modelData.enabled = !moduleEnabled.checked
2025-02-25 19:38:39 +01:00
}
}
2023-06-12 23:43:22 +02:00
}
}
}
}
}
}
}