[vlc-commits] qml: factorize the item used to focus background

Pierre Lamot git at videolan.org
Fri Jan 10 15:06:58 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Jan  7 16:09:57 2020 +0100| [c42d60ed104b02549914d977d5d00aeb9e54aa3d] | committer: Jean-Baptiste Kempf

qml: factorize the item used to focus background

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt/Makefile.am                     |  1 +
 modules/gui/qt/vlc.qrc                         |  1 +
 modules/gui/qt/widgets/qml/FocusBackground.qml | 67 ++++++++++++++++++++++++++
 3 files changed, 69 insertions(+)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 47ddf08afb..7691353032 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -615,6 +615,7 @@ libqt_plugin_la_QML = \
 	gui/qt/widgets/qml/DNDLabel.qml \
 	gui/qt/widgets/qml/DrawerExt.qml \
 	gui/qt/widgets/qml/ExpandGridView.qml \
+	gui/qt/widgets/qml/FocusBackground.qml \
 	gui/qt/widgets/qml/GridItem.qml \
 	gui/qt/widgets/qml/IconToolButton.qml \
 	gui/qt/widgets/qml/ImageToolButton.qml \
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 63ca6e19ac..cf1dbc4430 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -186,6 +186,7 @@
         <file alias="DNDLabel.qml">widgets/qml/DNDLabel.qml</file>
         <file alias="KeyNavigableTableView.qml">widgets/qml/KeyNavigableTableView.qml</file>
         <file alias="NavigableFocusScope.qml">widgets/qml/NavigableFocusScope.qml</file>
+        <file alias="FocusBackground.qml">widgets/qml/FocusBackground.qml</file>
         <file alias="ImageToolButton.qml">widgets/qml/ImageToolButton.qml</file>
         <file alias="TextToolButton.qml">widgets/qml/TextToolButton.qml</file>
         <file alias="IconToolButton.qml">widgets/qml/IconToolButton.qml</file>
diff --git a/modules/gui/qt/widgets/qml/FocusBackground.qml b/modules/gui/qt/widgets/qml/FocusBackground.qml
new file mode 100644
index 0000000000..254ade910b
--- /dev/null
+++ b/modules/gui/qt/widgets/qml/FocusBackground.qml
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+import QtQuick 2.0
+
+import "qrc:///style/"
+
+Rectangle {
+    property bool active: activeFocus
+    property bool selected: false
+
+    onActiveChanged: {
+        animateSelected.running = false
+        if (active) {
+            animateActive.restart()
+        } else {
+            if (selected)
+                color = VLCStyle.colors.bgHoverInactive
+            else
+                color = "transparent"
+            animateActive.running = false
+        }
+    }
+
+    onSelectedChanged: {
+        if (active)
+            return
+        color = "transparent"
+        if (selected) {
+            animateSelected.restart()
+        } else {
+            animateSelected.running = false
+        }
+
+    }
+
+    color: "transparent"
+    ColorAnimation on color {
+        id: animateActive
+        running: false
+        to: VLCStyle.colors.accent
+        duration: 200
+        easing.type: Easing.OutCubic
+    }
+    ColorAnimation on color {
+        id: animateSelected
+        running: false
+        to: VLCStyle.colors.bgHoverInactive
+        duration: 200
+        easing.type: Easing.OutCubic
+    }
+}



More information about the vlc-commits mailing list