Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Sébastien blin <sebastien.blin@savoirfairelinux.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.14
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.14
import QtGraphicalEffects 1.15
Button {
id: root
property alias source: root.icon.source
property string toolTipText: ""
property var color: "transparent"
property var outlined: false
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: 400
Layout.preferredHeight: 36
font.kerning: true
icon.source: ""
icon.height: 18
icon.width: 18
contentItem: Item {
Rectangle {
anchors.fill: parent
color: "transparent"
Image {
source: root.icon.source
width: root.icon.width
height: root.icon.height
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 16
layer {
enabled: true
effect: ColorOverlay {
id: overlay
color: outlined ? root.color : "white"
}
}
}
Text {
text: root.text
color: outlined? root.color : "white"
font: root.font
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
}
}
}
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.visible: hovered && (toolTipText.length > 0)
ToolTip.text: toolTipText
background: Rectangle {
id: backgroundRect
anchors.fill: parent
color: !outlined ? root.color : "transparent"
border.color: outlined ? root.color : "transparent"
radius: 4
}
}