mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:03:53 +02:00
FontAwseome button polish
This commit is contained in:
parent
4b9e5746cd
commit
093ccb483d
1 changed files with 41 additions and 8 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue