From 093ccb483dd1f4be41da8add6cb02d479fea6f1f Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Mon, 1 Feb 2016 14:14:47 -0800 Subject: [PATCH] FontAwseome button polish --- .../resources/qml/controls/ButtonAwesome.qml | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/controls/ButtonAwesome.qml b/interface/resources/qml/controls/ButtonAwesome.qml index 47c9fdc742..bb1df94471 100644 --- a/interface/resources/qml/controls/ButtonAwesome.qml +++ b/interface/resources/qml/controls/ButtonAwesome.qml @@ -1,21 +1,54 @@ import QtQuick 2.3 import QtQuick.Controls 1.3 as Original import QtQuick.Controls.Styles 1.3 as OriginalStyles + import "." import "../styles" Original.Button { + id: root property color iconColor: "black" - FontLoader { id: iconFont; source: "../../fonts/fontawesome-webfont.ttf"; } - style: OriginalStyles.ButtonStyle { - label: Text { - renderType: Text.NativeRendering + property real size: 32 + SystemPalette { id: palette; colorGroup: SystemPalette.Active } + SystemPalette { id: disabledPalette; colorGroup: SystemPalette.Disabled } + style: OriginalStyles.ButtonStyle { + label: FontAwesome { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter - font.family: iconFont.name - font.pointSize: 20 - color: control.enabled ? control.iconColor : "gray" + font.pixelSize: control.size - 4 + color: control.enabled ? palette.buttonText : disabledPalette.buttonText text: control.text - } + } + background: Rectangle { + id: background + implicitWidth: size + implicitHeight: size + border.width: 1 + border.color: "black" + radius: 4 + color: control.enabled ? palette.button : disabledPalette.button + + Connections { + target: control + onActiveFocusChanged: { + if (control.activeFocus) { + pulseAnimation.restart(); + } else { + pulseAnimation.stop(); + } + background.border.width = 1; + } + } + + SequentialAnimation { + id: pulseAnimation; + running: false + NumberAnimation { target: border; property: "width"; to: 3; duration: 500 } + NumberAnimation { target: border; property: "width"; to: 1; duration: 500 } + onStopped: if (control.activeFocus) { start(); } + } + } } + Keys.onEnterPressed: root.clicked(); + Keys.onReturnPressed: root.clicked(); }