[vlc-devel] [PATCH 02/18] qml: introduce BannerTabButton widget

Prince Gupta guptaprince8832 at gmail.com
Thu Aug 20 14:15:25 CEST 2020


supposed to be used for tabs in BannerSources
---
 modules/gui/qt/Makefile.am                    |  1 +
 modules/gui/qt/vlc.qrc                        |  1 +
 .../gui/qt/widgets/qml/BannerTabButton.qml    | 83 +++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 modules/gui/qt/widgets/qml/BannerTabButton.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 53fd5ded18..2b0e180b83 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -662,6 +662,7 @@ libqt_plugin_la_QML = \
 	gui/qt/style/qmldir \
 	gui/qt/util/qml/KeyHelper.js \
 	gui/qt/util/qml/SelectableDelegateModel.qml \
+	gui/qt/widgets/qml/BannerTabButton.qml \
 	gui/qt/widgets/qml/BusyIndicatorExt.qml \
 	gui/qt/widgets/qml/CaptionLabel.qml \
 	gui/qt/widgets/qml/ComboBoxExt.qml \
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index b545e1b8dd..4c329dbb2a 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -178,6 +178,7 @@
         <file alias="MainInterface.qml">maininterface/qml/MainInterface.qml</file>
     </qresource>
     <qresource prefix="/widgets">
+        <file alias="BannerTabButton.qml">widgets/qml/BannerTabButton.qml</file>
         <file alias="BusyIndicatorExt.qml">widgets/qml/BusyIndicatorExt.qml</file>
         <file alias="GridItem.qml">widgets/qml/GridItem.qml</file>
         <file alias="ListItem.qml">widgets/qml/ListItem.qml</file>
diff --git a/modules/gui/qt/widgets/qml/BannerTabButton.qml b/modules/gui/qt/widgets/qml/BannerTabButton.qml
new file mode 100644
index 0000000000..66e288ffaf
--- /dev/null
+++ b/modules/gui/qt/widgets/qml/BannerTabButton.qml
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * Copyright (C) 2020 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.11
+import QtQuick.Controls 2.4
+import QtQuick.Templates 2.4 as T
+import QtQuick.Layouts 1.11
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+T.TabButton {
+    id: control
+
+    property color color: VLCStyle.colors.banner
+    property color colorSelected: VLCStyle.colors.bg
+
+    text: model.displayText
+    padding: 0
+    width: VLCStyle.colWidth(1)
+    height: implicitHeight
+    implicitWidth: contentItem.implicitWidth
+    implicitHeight: contentItem.implicitHeight
+
+    property string iconTxt: ""
+    property bool selected: false
+
+    background: Rectangle {
+        height: control.height
+        width: control.width
+        color: (control.activeFocus || control.hovered) ? VLCStyle.colors.accent
+                                                        :  (control.selected ? control.colorSelected : control.color)
+        Behavior on color {
+            ColorAnimation {
+                duration: 128
+            }
+        }
+    }
+
+    contentItem: Item {
+        implicitWidth: tabRow.implicitWidth
+        implicitHeight: tabRow.implicitHeight
+
+        RowLayout {
+            id: tabRow
+
+            anchors.centerIn: parent
+            spacing: VLCStyle.margin_xsmall
+
+            Widgets.IconLabel {
+                id: icon
+
+                text: control.iconTxt
+                font.pixelSize: VLCIcons.pixelSize(VLCStyle.banner_icon_size)
+                color: control.selected && !(control.activeFocus || control.hovered) ? VLCStyle.colors.accent
+                                                                                     : VLCStyle.colors.text
+            }
+
+            Widgets.MenuLabel {
+                id: txt
+
+                font.weight: (control.activeFocus || control.hovered || control.selected) ? Font.DemiBold : Font.Normal
+                color: (control.activeFocus || control.hovered || control.selected) ? VLCStyle.colors.text : VLCStyle.colors.menuCaption
+                text: control.text
+            }
+        }
+    }
+}
-- 
2.25.1



More information about the vlc-devel mailing list