vlc | branch: master | Prince Gupta <guptaprince8...@gmail.com> | Mon Dec 28 
17:09:15 2020 +0530| [ce0ce6c2738e62ce90f1b4441af96c16b0fe658c] | committer: 
Pierre Lamot

qml: change background and foreground of AddressbarButton based on state

Signed-off-by: Pierre Lamot <pie...@videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce0ce6c2738e62ce90f1b4441af96c16b0fe658c
---

 modules/gui/qt/network/qml/AddressbarButton.qml | 39 +++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt/network/qml/AddressbarButton.qml 
b/modules/gui/qt/network/qml/AddressbarButton.qml
index fbc16afb51..4a8fd0ca7d 100644
--- a/modules/gui/qt/network/qml/AddressbarButton.qml
+++ b/modules/gui/qt/network/qml/AddressbarButton.qml
@@ -27,15 +27,48 @@ AbstractButton {
 
     property bool onlyIcon: true
     property bool highlighted: false
+    property color color
+    property color foregroundColor
 
     font.pixelSize: onlyIcon ? VLCIcons.pixelSize(VLCStyle.icon_normal) : 
VLCStyle.fontSize_large
     padding: VLCStyle.margin_xxsmall
     width: implicitWidth
     height: implicitHeight
 
+    state: (button.hovered || button.activeFocus) ? "active" : "normal"
+    states: [
+        State {
+            name: "active"
+            PropertyChanges {
+                target: button
+
+                color: VLCStyle.colors.accent
+                foregroundColor: VLCStyle.colors.accentText
+            }
+        },
+        State {
+            name: "normal"
+            PropertyChanges {
+                target: button
+
+                color: "transparent"
+                foregroundColor: VLCStyle.colors.text
+            }
+        }
+    ]
+
+    transitions: Transition {
+        to: "*"
+
+        ColorAnimation {
+            duration: 200
+            properties: "foregroundColor,color"
+        }
+    }
+
     contentItem: contentLoader.item
     background: Rectangle {
-        color: (button.hovered || button.activeFocus) ? VLCStyle.colors.accent 
: "transparent"
+        color: button.color
     }
 
     Loader {
@@ -51,7 +84,7 @@ AbstractButton {
             text: button.text
             elide: Text.ElideRight
             font.pixelSize: button.font.pixelSize
-            color: VLCStyle.colors.text
+            color: button.foregroundColor
             opacity: (button.highlighted  || button.hovered || 
button.activeFocus) ? 1 : .6
             verticalAlignment: Text.AlignVCenter
         }
@@ -65,7 +98,7 @@ AbstractButton {
             elide: Text.ElideRight
             font.pixelSize: button.font.pixelSize
             font.weight: button.highlighted ? Font.DemiBold : Font.Normal
-            color: VLCStyle.colors.text
+            color: button.foregroundColor
             opacity: (button.highlighted || button.hovered || 
button.activeFocus) ? 1 : .6
             verticalAlignment: Text.AlignVCenter
         }

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to