Files
pay/guis/mobile/TextButton.qml
T

87 lines
2.5 KiB
QML
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
2023-02-14 15:03:27 +01:00
* Copyright (C) 2022-2023 Tom Zander <tom@flowee.org>
*
* 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 "../Flowee" as Flowee
Item {
id: root
width: parent.width
2022-11-23 16:06:37 +01:00
height: label.height + (smallLabel.text === "" ? 0 : smallLabel.height + 6) + 20
2022-12-15 12:00:01 +01:00
baselineOffset: label.baselineOffset + 10
signal clicked
property alias text: label.text
2022-11-23 16:06:37 +01:00
property alias subtext: smallLabel.text
2022-12-05 18:35:02 +01:00
/// When true, show an arrow indicating we open a new page on click
2022-11-23 16:06:37 +01:00
property bool showPageIcon: false
property string imageSource: ""
property int imageWidth: 16
property int imageHeight: 16
Flowee.Label {
id: label
2022-11-23 16:06:37 +01:00
y: 10
width: parent.width
wrapMode: Text.WordWrap
2023-05-16 18:57:23 +02:00
color: enabled ? palette.windowText : palette.brightText
}
2022-11-23 16:06:37 +01:00
Flowee.Label {
id: smallLabel
anchors.top: label.bottom
anchors.topMargin: 6
2023-02-14 15:03:27 +01:00
font.pixelSize: label.font.pixelSize * 0.8
2022-11-23 16:06:37 +01:00
font.bold: false
2023-02-14 15:03:27 +01:00
color: palette.brightText
width: parent.width
wrapMode: Text.WordWrap
2022-11-23 16:06:37 +01:00
}
MouseArea {
anchors.fill: parent
onClicked: root.clicked()
}
2022-11-23 16:06:37 +01:00
Loader {
sourceComponent: {
if (root.showPageIcon)
return pageIcon;
if (root.imageSource !== "")
return genericImage;
return undefined;
}
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
Component {
id: pageIcon
Image {
width: 12
height: 8
source: Pay.useDarkSkin ? "qrc:/smallArrow-light.svg" : "qrc:/smallArrow.svg";
rotation: 270
}
}
Component {
id: genericImage
Image {
source: root.imageSource
width: root.imageWidth
height: root.imageHeight
}
}
}