Dekko
TitledHeaderButton.qml
1 /* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2 
3  This file is part of Dekko email client for Ubuntu devices
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License or (at your option) version 3
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 import QtQuick 2.4
19 import QtQuick.Controls.Suru 2.2
20 import Lomiri.Components 1.3
21 import Dekko.Components 1.0
22 
23 AbstractButton {
24  id: button
25 
26  property alias iconColor: icon.color
27  property bool showLabel: true
28 
29  readonly property int fullWidth: icon.width + label.width + units.gu(3)
30  readonly property int minWidth: icon.width + units.gu(2)
31 
32  implicitWidth: width
33  implicitHeight: height
34  width: showLabel ? fullWidth : minWidth
35 
36  LomiriShape {
37  anchors {
38  topMargin: 0
39  bottomMargin: 0
40  fill: parent
41  }
42  aspect: showLabel ? LomiriShape.DropShadow : LomiriShape.Flat
43  color: button.pressed ? Suru.neutralColor : Suru.secondaryBackgroundColor
44  }
45 
46  CachedImage {
47  id: icon
48  anchors {
49  left: parent.left
50  top: parent.top
51  bottom: parent.bottom
52  margins: units.gu(1)
53  }
54  height: units.gu(2)
55  width: height
56  name: action.iconName
57  }
58 
59  Label {
60  id: label
61  anchors {
62  left: icon.right
63  leftMargin: units.gu(1)
64  verticalCenter: parent.verticalCenter
65  }
66  text: action.text
67  visible: showLabel
68  }
69 }
70 
Dekko
Definition: Dekko.qml:30
Dekko::Lomiri::Components::CachedImage
Definition: CachedImage.qml:22