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

Pierre Lamot pierre at videolabs.io
Mon Jul 1 10:48:05 CEST 2019


On 2019-06-28 13:14, Rohan Rajpal wrote:
> Add the teletxt widget to the player
> controller
> ---
>  modules/gui/qt/Makefile.am                    |   1 +
>  .../gui/qt/components/player_controller.hpp   |   9 ++
>  .../qt/components/playercontrolbarmodel.cpp   |   4 +-
>  modules/gui/qt/qml/player/ControlButtons.qml  |   6 +
>  modules/gui/qt/qml/player/TeletextWidget.qml  | 121 ++++++++++++++++++
>  modules/gui/qt/vlc.qrc                        |   1 +
>  6 files changed, 140 insertions(+), 2 deletions(-)
>  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 966dd37924..2624f3bea1 100644
> --- a/modules/gui/qt/Makefile.am
> +++ b/modules/gui/qt/Makefile.am
> @@ -539,6 +539,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 885eba2cd4..bd199aece7 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/components/playercontrolbarmodel.cpp
> b/modules/gui/qt/components/playercontrolbarmodel.cpp
> index 2fd1df9682..9798abace5 100644
> --- a/modules/gui/qt/components/playercontrolbarmodel.cpp
> +++ b/modules/gui/qt/components/playercontrolbarmodel.cpp
> @@ -20,7 +20,7 @@
>  #include "qt.hpp"
>  #include "playercontrolbarmodel.hpp"
> 
> -#define MAIN_TB1_DEFAULT "67;68;37;65;19;22;0-2;23;20;65;35;7"
> +#define MAIN_TB1_DEFAULT "67;68;37;65;19;22;0-2;23;20;65;35;41;38;7"

I'm not sure we want the aspect ratio box present by default in the main 
player bar (and maybe not the teletetex)
And the playlist button is missing.


>  PlayerControlBarModel::PlayerControlBarModel(QObject *_parent) :
> QAbstractListModel(_parent)
>  {
> @@ -29,7 +29,7 @@ PlayerControlBarModel::PlayerControlBarModel(QObject
> *_parent) : QAbstractListMo
>  void PlayerControlBarModel::loadConfig()
>  {
>      p_intf = m_mainCtx->getIntf();
> -    QString config = getSettings() ->value(
> "MainWindow/PlayerControlToolbar1", MAIN_TB1_DEFAULT )
> +    QString config = getSettings() ->value(
> "MainWindow/PlayerControlToolbar1Alt", MAIN_TB1_DEFAULT )
>                                              .toString();
>      parseAndAdd(config);
>  }
> diff --git a/modules/gui/qt/qml/player/ControlButtons.qml
> b/modules/gui/qt/qml/player/ControlButtons.qml
> index 2a32d401a5..8d547d28ac 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
> @@ -405,6 +406,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..1842873eb9
> --- /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 : 280 * 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/vlc.qrc b/modules/gui/qt/vlc.qrc
> index aa6988cd1e..cb5cbcc926 100644
> --- a/modules/gui/qt/vlc.qrc
> +++ b/modules/gui/qt/vlc.qrc
> @@ -253,6 +253,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>


More information about the vlc-devel mailing list