[vlc-devel] [PATCH] qml: Add Teletext widget

Rohan Rajpal rohan17089 at iiitd.ac.in
Tue Jul 16 14:57:44 CEST 2019


Add the teletxt widget to the player
controller
---
 modules/gui/qt/Makefile.am                    |   1 +
 .../gui/qt/components/player_controller.hpp   |   9 ++
 modules/gui/qt/qml/player/ControlButtons.qml  |   6 +
 modules/gui/qt/qml/player/TeletextWidget.qml  | 121 ++++++++++++++++++
 modules/gui/qt/qml/style/VLCStyle.qml         |   1 +
 modules/gui/qt/vlc.qrc                        |   1 +
 6 files changed, 139 insertions(+)
 create mode 100644 modules/gui/qt/qml/player/TeletextWidget.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index d4e5193af0..e8673b327d 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -542,6 +542,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/player/VolumeWidget.qml \
 	gui/qt/qml/player/ModalControlBar.qml \
 	gui/qt/qml/player/SliderBar.qml \
+	gui/qt/qml/player/TeletextWidget.qml \
 	gui/qt/qml/dialogs/Dialogs.qml \
 	gui/qt/qml/dialogs/ModalDialog.qml \
 	gui/qt/qml/utils/DNDLabel.qml \
diff --git a/modules/gui/qt/components/player_controller.hpp b/modules/gui/qt/components/player_controller.hpp
index 24373e2d8f..1064a581b2 100644
--- a/modules/gui/qt/components/player_controller.hpp
+++ b/modules/gui/qt/components/player_controller.hpp
@@ -97,6 +97,15 @@ public:
     };
     Q_ENUM(MediaStopAction)
 
+    enum Telekeys{
+        TELE_RED = VLC_PLAYER_TELETEXT_KEY_RED,
+        TELE_GREEN = VLC_PLAYER_TELETEXT_KEY_GREEN,
+        TELE_YELLOW = VLC_PLAYER_TELETEXT_KEY_YELLOW,
+        TELE_BLUE = VLC_PLAYER_TELETEXT_KEY_BLUE,
+        TELE_INDEX = VLC_PLAYER_TELETEXT_KEY_INDEX
+    };
+    Q_ENUM(Telekeys)
+
     //playback
     Q_PROPERTY(PlayingState playingState READ getPlayingState NOTIFY playingStateChanged)
     Q_PROPERTY(bool isPlaying READ hasInput NOTIFY inputChanged)
diff --git a/modules/gui/qt/qml/player/ControlButtons.qml b/modules/gui/qt/qml/player/ControlButtons.qml
index 5b7ce4b628..41a2aab16f 100644
--- a/modules/gui/qt/qml/player/ControlButtons.qml
+++ b/modules/gui/qt/qml/player/ControlButtons.qml
@@ -57,6 +57,7 @@ Item{
         case PlayerControlBarModel.QUIT_BUTTON: return quitBtnDelegate
         case PlayerControlBarModel.VOLUME: return volumeBtnDelegate
         case PlayerControlBarModel.ASPECT_RATIO_COMBOBOX: return aspectRatioDelegate
+        case PlayerControlBarModel.TELETEXT_BUTTONS: return teletextdelegate
         }
         console.log("button delegate id " + inpID +  " doesn't exists")
         return spacerDelegate
@@ -404,6 +405,11 @@ Item{
         }
     }
 
+    Component{
+        id: teletextdelegate
+        TeletextWidget{}
+    }
+
     Component{
         id: volumeBtnDelegate
         VolumeWidget{}
diff --git a/modules/gui/qt/qml/player/TeletextWidget.qml b/modules/gui/qt/qml/player/TeletextWidget.qml
new file mode 100644
index 0000000000..e63ec52f1b
--- /dev/null
+++ b/modules/gui/qt/qml/player/TeletextWidget.qml
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * 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.11
+import QtQuick.Layouts 1.3
+import QtQuick.Controls 2.4
+
+import org.videolan.vlc 0.1
+
+import "qrc:///utils/" as Utils
+import "qrc:///style/"
+
+FocusScope{
+    id: widgetfscope
+    x: teleWidget.x
+    y: teleWidget.y
+    width: teleWidget.width
+    height: teleWidget.height
+
+    property bool autohide: !player.isTeletextAvailable
+    property bool acceptFocus: autohide
+    visible: !autohide
+
+    RowLayout{
+        id: teleWidget
+        width: autohide ? 0 : VLCStyle.widthTeletext * scale
+
+        spacing: 0
+
+        Utils.IconToolButton{
+            id: teleActivateBtn
+            text: VLCIcons.tv
+            size: VLCStyle.icon_normal
+            onClicked: player.teletextEnabled = !player.teletextEnabled
+            checked: player.teletextEnabled
+            focus: true
+            KeyNavigation.right: player.teletextEnabled ?
+                                     teleTransparencyBtn : blueKeyBtn.KeyNavigation.right
+        }
+
+        Utils.IconToolButton{
+            id: teleTransparencyBtn
+            text: VLCIcons.tvtelx
+            size: VLCStyle.icon_normal
+            opacity: 0.5
+            enabled: player.teletextEnabled
+            onClicked: player.teletextTransparency = !player.teletextTransparency
+            KeyNavigation.right: telePageNumber
+        }
+
+        Utils.SpinBoxExt{
+            id: telePageNumber
+            enabled: player.teletextEnabled
+            from: 100
+            to: 899
+            editable: true
+            onValueChanged: player.teletextPage = value
+            KeyNavigation.right: indexKeyBtn
+        }
+
+        Utils.IconToolButton{
+            id: indexKeyBtn
+            enabled: player.teletextEnabled
+            size: VLCStyle.icon_normal
+            text: VLCIcons.record
+            onClicked: player.teletextPage = PlayerController.TELE_INDEX
+            color: "grey"
+            KeyNavigation.right: redKeyBtn
+        }
+        Utils.IconToolButton{
+            id: redKeyBtn
+            enabled: player.teletextEnabled
+            size: VLCStyle.icon_normal
+            text: VLCIcons.record
+            onClicked: player.teletextPage = PlayerController.TELE_RED
+            color: enabled ? "red" : "grey"
+            KeyNavigation.right: greenKeyBtn
+        }
+        Utils.IconToolButton{
+            id: greenKeyBtn
+            enabled: player.teletextEnabled
+            size: VLCStyle.icon_normal
+            text: VLCIcons.record
+            onClicked: player.teletextPage = PlayerController.TELE_GREEN
+            color: enabled ? "green" : "grey"
+            KeyNavigation.right: yellowKeyBtn
+        }
+        Utils.IconToolButton{
+            id: yellowKeyBtn
+            enabled: player.teletextEnabled
+            size: VLCStyle.icon_normal
+            text: VLCIcons.record
+            onClicked: player.teletextPage = PlayerController.TELE_YELLOW
+            color: enabled ? "yellow" : "grey"
+            KeyNavigation.right: blueKeyBtn
+        }
+        Utils.IconToolButton{
+            id: blueKeyBtn
+            enabled: player.teletextEnabled
+            size: VLCStyle.icon_normal
+            text: VLCIcons.record
+            onClicked: player.teletextPage = PlayerController.TELE_BLUE
+            color: enabled ? "blue" : "grey"
+        }
+    }
+}
diff --git a/modules/gui/qt/qml/style/VLCStyle.qml b/modules/gui/qt/qml/style/VLCStyle.qml
index 0e0fcfcb63..888707ca53 100644
--- a/modules/gui/qt/qml/style/VLCStyle.qml
+++ b/modules/gui/qt/qml/style/VLCStyle.qml
@@ -96,6 +96,7 @@ Item {
 
     property int widthSearchInput: 200 * scale;
     property int widthSortBox: 150 * scale;
+    property int widthTeletext: 280 * scale;
     property int heightInput: 22 * scale;
 
     property int selectedBorder: 2
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 60b53c889f..e325b9ba61 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -251,6 +251,7 @@
         <file alias="ModalControlBar.qml">qml/player/ModalControlBar.qml</file>
         <file alias="ControlButtons.qml">qml/player/ControlButtons.qml</file>
         <file alias="VolumeWidget.qml">qml/player/VolumeWidget.qml</file>
+        <file alias="TeletextWidget.qml">qml/player/TeletextWidget.qml</file>
     </qresource>
     <qresource prefix="/about">
         <file alias="About.qml">qml/about/About.qml</file>
-- 
2.17.1



More information about the vlc-devel mailing list