Files
pay/guis/mobile/Page.qml
T

142 lines
4.2 KiB
QML
Raw Permalink Normal View History

2022-11-15 11:38:28 +01:00
/*
* This file is part of the Flowee project
2024-04-29 11:20:41 +02:00
* Copyright (C) 2022-2024 Tom Zander <tom@flowee.org>
2022-11-15 11:38:28 +01: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/>.
*/
2022-11-26 10:44:52 +01:00
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import "../Flowee" as Flowee
2022-11-15 11:38:28 +01:00
QQC2.Control {
id: root
2023-02-14 14:56:18 +01:00
width: parent == null ? 10 : parent.width
height: parent == null ? 10 : parent.height
2022-11-15 11:38:28 +01:00
2023-02-14 14:56:18 +01:00
background: Rectangle {
color: palette.base
2023-02-14 14:56:18 +01:00
}
leftPadding: 10
rightPadding: 10
2024-10-06 22:36:10 +02:00
topPadding: header.height
wheelEnabled: true // eat wheel events
2023-02-14 14:56:18 +01:00
default property alias content: focusScope.children
2022-11-15 11:38:28 +01:00
property alias headerText: headerLabel.text
2022-11-21 19:29:46 +01:00
property alias headerButtonVisible: headerButton.visible
property alias headerButtonText: headerButton.text
property alias headerButtonEnabled: headerButton.enabled
2024-10-06 00:17:04 +02:00
property bool hideHeader: false
2023-02-08 14:11:26 +01:00
/**
* A list of action objects to populate the menu with
* Setting this will make a hamburger button show up in the header
*/
property var menuItems: [ ]
2022-11-21 19:29:46 +01:00
signal headerButtonClicked
2022-11-15 11:38:28 +01:00
2024-04-29 11:20:41 +02:00
/**
* Handler called when the 'back' button in the page header is called.
* Replace this with your own function if the inheriting page needs to
* do something diffrent.
* Notice that you likely to call `thePile.pop()` from your handler.
*/
property var backHandler: function handler() { thePile.pop(); }
function takeFocus() {
focusScope.forceActiveFocus();
}
2023-05-31 15:20:11 +02:00
function closeHeaderMenu() {
headerMenu.close();
}
2023-02-08 14:11:26 +01:00
onMenuItemsChanged: {
// remove old ones first
while (headerMenu.count > 0) {
headerMenu.takeItem(0);
}
// set new ones
for (let i = 0; i < menuItems.length; ++i) {
headerMenu.addAction(menuItems[i]);
}
}
2022-11-15 11:38:28 +01:00
Rectangle {
id: header
2024-10-06 22:36:10 +02:00
width: parent.width
height: root.hideHeader ? 0 : 50
2023-02-21 16:40:46 +01:00
color: Pay.useDarkSkin ? palette.window : mainWindow.floweeBlue
2024-10-06 00:17:04 +02:00
visible: !root.hideHeader
2022-11-15 11:38:28 +01:00
2025-03-09 22:03:32 +01:00
gradient: Gradient {
GradientStop { position: 0.9; color: header.color }
GradientStop { position: 1; color: {
let c = header.color;
return Qt.rgba(c.r, c.g, c.b, 0);
}
}
}
2022-11-15 11:38:28 +01:00
Image {
id: backButton
2022-11-17 23:07:15 +01:00
x: 13
source: "qrc:/back-arrow.svg"
width: 20 * 1.1
height: 15 * 1.1
anchors.verticalCenter: parent.verticalCenter
2022-11-15 11:38:28 +01:00
MouseArea {
anchors.fill: parent
2022-11-17 23:07:15 +01:00
anchors.margins: -15
2024-04-29 11:20:41 +02:00
onClicked: root.backHandler();
2022-11-15 11:38:28 +01:00
}
}
2022-11-18 13:43:04 +01:00
QQC2.Label {
2022-11-15 11:38:28 +01:00
id: headerLabel
2022-11-17 23:07:15 +01:00
color: "white"
2025-03-09 22:03:32 +01:00
anchors.centerIn: parent
2022-11-21 19:29:46 +01:00
}
Flowee.Button {
id: headerButton
visible: false
anchors.right: parent.right
2022-11-22 23:09:31 +01:00
anchors.rightMargin: 10
2022-11-21 19:29:46 +01:00
anchors.verticalCenter: parent.verticalCenter
onClicked: root.headerButtonClicked()
2022-11-15 11:38:28 +01:00
}
2023-02-08 14:11:26 +01:00
Flowee.HamburgerMenu {
id: hamburgerMenu
2023-02-08 14:11:26 +01:00
visible: root.menuItems.length > 0
anchors.right: parent.right
anchors.rightMargin: 15
anchors.verticalCenter: parent.verticalCenter
2023-10-16 20:27:48 +02:00
color: "white"
2023-02-08 14:11:26 +01:00
MouseArea {
anchors.fill: parent
anchors.margins: -15
onClicked: headerMenu.open();
}
QQC2.Menu {
id: headerMenu
}
}
2022-11-15 11:38:28 +01:00
}
2023-02-14 14:56:18 +01:00
contentItem: FocusScope {
2022-12-05 20:31:00 +01:00
id: focusScope
2022-11-15 11:38:28 +01:00
}
}