diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-04-06 13:47:19 +0200 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-04-06 13:47:19 +0200 |
commit | 339b0a795d3cf1cb6999d685976f511ab2091e8a (patch) | |
tree | fb43ae1f7eebb324db5fbc49ead9ad3d18a3c19f | |
parent | b68a8d2360d10adf9d42c73a5255ac4c03f71155 (diff) | |
download | kube-339b0a795d3cf1cb6999d685976f511ab2091e8a.tar.gz kube-339b0a795d3cf1cb6999d685976f511ab2091e8a.zip |
kube.button based on controls templates
-rw-r--r-- | framework/qml/Button.qml | 57 | ||||
-rw-r--r-- | framework/qml/Colors.qml | 3 |
2 files changed, 28 insertions, 32 deletions
diff --git a/framework/qml/Button.qml b/framework/qml/Button.qml index a2be7136..44e36e34 100644 --- a/framework/qml/Button.qml +++ b/framework/qml/Button.qml | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | 2 | * Copyright (C) 2017 Michael Bohlender, <bohlender@kolabsys.com> |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
@@ -16,43 +16,40 @@ | |||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | import QtQuick 2.7 | 19 | import QtQuick 2.8 |
20 | import QtQuick.Templates 2.1 as T | ||
21 | import org.kube.framework 1.0 | ||
20 | 22 | ||
21 | import org.kube.framework 1.0 as Kube | 23 | T.Button { |
22 | |||
23 | Rectangle { | ||
24 | id: root | 24 | id: root |
25 | 25 | ||
26 | signal clicked() | 26 | width: Math.max(Units.gridUnit, contentItem.implicitWidth + leftPadding + rightPadding) |
27 | property alias text: text.text | 27 | height: contentItem.implicitHeight + Units.smallSpacing * 2 |
28 | property color textColor: Kube.Colors.highlightedTextColor | 28 | |
29 | property string iconName: "" | 29 | padding: Units.largeSpacing |
30 | property alias implicitHeight: content.implicitHeight | 30 | topPadding: Units.smallSpacing * 2 |
31 | property alias implicitWidth: content.implicitWidth | 31 | bottomPadding: Units.smallSpacing *2 |
32 | width: implicitWidth | ||
33 | height: implicitHeight | ||
34 | 32 | ||
35 | clip: true | 33 | clip: true |
34 | hoverEnabled: true | ||
36 | 35 | ||
37 | Row { | 36 | background: Rectangle { |
38 | id: content | 37 | color: root.pressed ? Colors.highlightColor : Colors.buttonColor |
39 | anchors.centerIn: parent | 38 | |
40 | spacing: Kube.Units.smallSpacing | 39 | Rectangle { |
41 | Text { | 40 | anchors.fill: parent |
42 | id: text | 41 | visible: root.hovered |
43 | anchors.verticalCenter: parent.verticalCenter | 42 | color: Colors.viewBackgroundColor |
44 | color: root.textColor | 43 | opacity: 0.1 |
45 | } | ||
46 | Icon { | ||
47 | id: icon | ||
48 | anchors.verticalCenter: parent.verticalCenter | ||
49 | iconName: root.iconName | ||
50 | visible: iconName != "" | ||
51 | } | 44 | } |
52 | } | 45 | } |
53 | 46 | ||
54 | MouseArea { | 47 | contentItem: Text { |
55 | anchors.fill: parent | 48 | text: root.text |
56 | onClicked: root.clicked() | 49 | //TODO font |
50 | elide: Text.ElideRight | ||
51 | horizontalAlignment: Text.AlignHCenter | ||
52 | verticalAlignment: Text.AlignVCenter | ||
53 | color: Colors.textColor | ||
57 | } | 54 | } |
58 | } | 55 | } |
diff --git a/framework/qml/Colors.qml b/framework/qml/Colors.qml index 5e1f1689..e3c53a1f 100644 --- a/framework/qml/Colors.qml +++ b/framework/qml/Colors.qml | |||
@@ -27,8 +27,7 @@ Item { | |||
27 | property string viewBackgroundColor: "#fcfcfc" | 27 | property string viewBackgroundColor: "#fcfcfc" |
28 | property string highlightColor: "#3daee9" | 28 | property string highlightColor: "#3daee9" |
29 | property string highlightedTextColor: "#fcfcfc" | 29 | property string highlightedTextColor: "#fcfcfc" |
30 | 30 | property string buttonColor: "#bdc3c7" | |
31 | |||
32 | property string positiveColor: "#27ae60" | 31 | property string positiveColor: "#27ae60" |
33 | property string warningColor: "#f67400" | 32 | property string warningColor: "#f67400" |
34 | property string negativeColor: "#ed1515" | 33 | property string negativeColor: "#ed1515" |