[vlc-commits] qml: Add aspect ratio widget

Rohan Rajpal git at videolan.org
Tue Jul 16 10:43:06 CEST 2019


vlc | branch: master | Rohan Rajpal <rohan17089 at iiitd.ac.in> | Fri Jun 28 17:01:47 2019 +0530| [59fc3c79b3a1d6a714118bfd814eb57bb007ed68] | committer: Jean-Baptiste Kempf

qml: Add aspect ratio widget

Add the aspect ratio combobox for
the player controller

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

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

 modules/gui/qt/adapters/var_choice_model.cpp |  5 +++++
 modules/gui/qt/adapters/var_choice_model.hpp |  3 +++
 modules/gui/qt/qml/player/ControlBar.qml     |  1 -
 modules/gui/qt/qml/player/ControlButtons.qml | 15 +++++++++++++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/adapters/var_choice_model.cpp b/modules/gui/qt/adapters/var_choice_model.cpp
index e283424b68..d5da2f0b58 100644
--- a/modules/gui/qt/adapters/var_choice_model.cpp
+++ b/modules/gui/qt/adapters/var_choice_model.cpp
@@ -228,3 +228,8 @@ bool VLCVarChoiceModel::hasCurrent() const
 {
     return m_current != -1;
 }
+
+void VLCVarChoiceModel::toggleIndex(int index)
+{
+    setData(QAbstractItemModel::createIndex(index,0),true,Qt::CheckStateRole);
+}
diff --git a/modules/gui/qt/adapters/var_choice_model.hpp b/modules/gui/qt/adapters/var_choice_model.hpp
index 837a8f06b8..3eb2b91e5b 100644
--- a/modules/gui/qt/adapters/var_choice_model.hpp
+++ b/modules/gui/qt/adapters/var_choice_model.hpp
@@ -71,6 +71,9 @@ public:
     static int on_variable_callback( vlc_object_t * object, char const * , vlc_value_t oldvalue, vlc_value_t newvalue, void * data);
     static int on_variable_list_callback( vlc_object_t * object, char const * , int action, vlc_value_t* value, void * data);
 
+public slots:
+    Q_INVOKABLE void toggleIndex(int index);
+
 private slots:
     void onDataUpdated(const vlc_object_t* object, QVariant oldvalue, QVariant newvalue);
     void onListUpdated(const vlc_object_t* object, int action, QVariant newvalue);
diff --git a/modules/gui/qt/qml/player/ControlBar.qml b/modules/gui/qt/qml/player/ControlBar.qml
index 7889717410..cfa5d79c9a 100644
--- a/modules/gui/qt/qml/player/ControlBar.qml
+++ b/modules/gui/qt/qml/player/ControlBar.qml
@@ -90,7 +90,6 @@ Utils.NavigableFocusScope {
                     property bool _focusGiven: false
                     focus: true
                     anchors.fill: parent
-                    spacing: 0
 
                     Repeater{
                         model: PlayerControlBarModel{
diff --git a/modules/gui/qt/qml/player/ControlButtons.qml b/modules/gui/qt/qml/player/ControlButtons.qml
index d746dd6da4..5b7ce4b628 100644
--- a/modules/gui/qt/qml/player/ControlButtons.qml
+++ b/modules/gui/qt/qml/player/ControlButtons.qml
@@ -56,6 +56,7 @@ Item{
         case PlayerControlBarModel.SKIP_BACK_BUTTON: return stepBackBtnDelegate
         case PlayerControlBarModel.QUIT_BUTTON: return quitBtnDelegate
         case PlayerControlBarModel.VOLUME: return volumeBtnDelegate
+        case PlayerControlBarModel.ASPECT_RATIO_COMBOBOX: return aspectRatioDelegate
         }
         console.log("button delegate id " + inpID +  " doesn't exists")
         return spacerDelegate
@@ -390,6 +391,20 @@ Item{
     }
 
     Component{
+        id: aspectRatioDelegate
+        Utils.ComboBoxExt {
+            id: combo
+            Layout.alignment: Qt.AlignVCenter
+            height: 28 * scale
+            width: 100 * scale
+            textRole: "display"
+            model: player.aspectRatio
+            onCurrentIndexChanged: model.toggleIndex(currentIndex)
+            property bool acceptFocus: true
+        }
+    }
+
+    Component{
         id: volumeBtnDelegate
         VolumeWidget{}
     }



More information about the vlc-commits mailing list