This repository has been archived on 2021-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
ui/qml/widgets/SimpleButton.qml

69 lines
1.5 KiB
QML
Raw Permalink Normal View History

2018-10-30 19:48:37 +00:00
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
import "controls" as Awesome
import "../fonts/Twemoji.js" as T
2018-10-23 18:52:13 +00:00
Rectangle {
id: button
2018-11-22 00:01:17 +00:00
width: (text == undefined || text == "" ? 0 : buttonText.width) + (icon == undefined || icon == "" ? 0 : ico.width) + 24 * gcd.themeScale
2018-10-30 19:48:37 +00:00
Layout.minimumWidth: width
Layout.maximumWidth: width
2018-11-22 00:01:17 +00:00
height: 20 * gcd.themeScale
2018-10-30 19:48:37 +00:00
Layout.minimumHeight: height
Layout.maximumHeight: height
color: mousedown ? "#B09CBC" : "#4B3557"
border.color: "#4B3557"
border.width: 1
2018-10-23 18:52:13 +00:00
radius: 2
antialiasing: true
property bool checked: false
property alias text: buttonText.text
2018-10-28 02:49:14 +00:00
property alias font: buttonText.font.family
2018-10-30 19:48:37 +00:00
property string icon
property bool mousedown
2018-10-23 18:52:13 +00:00
signal clicked
2018-10-30 19:48:37 +00:00
RowLayout {
anchors.centerIn: parent
Image {
anchors.left: parent.left
id: ico
2019-02-13 04:10:46 +00:00
source: "qrc:/qml/images/fontawesome/"+(icon!=""?icon:"regular/window-maximize")+".svg"
2018-10-30 19:48:37 +00:00
height: button.height / 2
sourceSize.height: button.height / 2
}
Label {
id: buttonText
font.pixelSize: button.height / 2
color: "#FFFFFF"
anchors.left: ico.right
anchors.leftMargin: 6
visible: button.text != "" && button.text != undefined
}
}
2018-10-23 18:52:13 +00:00
MouseArea {
id: mouseArea
anchors.fill: parent
2018-10-30 19:48:37 +00:00
2018-10-23 18:52:13 +00:00
onClicked: {
parent.focus = true
parent.clicked()
}
2018-10-30 19:48:37 +00:00
onPressed: mousedown = true
onReleased: mousedown = false
2018-10-23 18:52:13 +00:00
}
Keys.onSpacePressed: clicked()
}