[vlc-devel] [PATCH 2/5] qml: Add aspect ratio widget
Rohan Rajpal
rohan17089 at iiitd.ac.in
Fri Jun 28 11:46:04 CEST 2019
Add the aspect ratio combobox for
the player controller
---
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 ed3e9bf2b6..a58f67961a 100644
--- a/modules/gui/qt/adapters/var_choice_model.cpp
+++ b/modules/gui/qt/adapters/var_choice_model.cpp
@@ -225,3 +225,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 76399d488d..e561d1bba8 100644
--- a/modules/gui/qt/qml/player/ControlBar.qml
+++ b/modules/gui/qt/qml/player/ControlBar.qml
@@ -91,7 +91,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 a293d8d386..b7874775a8 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
+ property bool acceptFocus: true
+ Layout.alignment: Qt.AlignVCenter
+ height: VLCStyle.heightInput
+ width: VLCStyle.widthSortBox
+ textRole: "display"
+ model: player.aspectRatio
+ onCurrentIndexChanged: model.toggleIndex(currentIndex)
+ }
+ }
+
Component{
id: volumeBtnDelegate
VolumeWidget{}
--
2.17.1
More information about the vlc-devel
mailing list