[vlc-devel] [PATCH 17/21] qt: provide function to toggle random visualization in player_controller
Prince Gupta
guptaprince8832 at gmail.com
Fri Oct 23 15:21:11 CEST 2020
---
modules/gui/qt/player/player_controller.cpp | 23 +++++++++++++++++++++
modules/gui/qt/player/player_controller.hpp | 1 +
modules/gui/qt/util/varchoicemodel.cpp | 5 +++++
modules/gui/qt/util/varchoicemodel.hpp | 1 +
4 files changed, 30 insertions(+)
diff --git a/modules/gui/qt/player/player_controller.cpp b/modules/gui/qt/player/player_controller.cpp
index 25dc94e37e..3a23c71a24 100644
--- a/modules/gui/qt/player/player_controller.cpp
+++ b/modules/gui/qt/player/player_controller.cpp
@@ -1659,6 +1659,29 @@ void PlayerController::toggleRecord()
setRecording(!d->m_recording);
}
+void PlayerController::toggleVisualization()
+{
+ Q_D(PlayerController);
+
+ if ( d->m_audioVisualization.rowCount() < 1 )
+ return;
+
+ if ( !d->m_audioVisualization.hasCurrent()
+ || d->m_audioVisualization.currentRow() == 0 /*0th row is "Disable"*/)
+ {
+ const int r = rand() % d->m_audioVisualization.rowCount();
+ d->m_audioVisualization.setData( d->m_audioVisualization.index( r )
+ , QVariant::fromValue<bool>( true )
+ , Qt::CheckStateRole );
+ }
+ else
+ {
+ d->m_audioVisualization.setData( d->m_audioVisualization.index(0)
+ , QVariant::fromValue<bool>( true )
+ , Qt::CheckStateRole);
+ }
+}
+
void PlayerController::setRecording( bool recording )
{
Q_D(PlayerController);
diff --git a/modules/gui/qt/player/player_controller.hpp b/modules/gui/qt/player/player_controller.hpp
index 8dc4ed43dd..f45aedacf5 100644
--- a/modules/gui/qt/player/player_controller.hpp
+++ b/modules/gui/qt/player/player_controller.hpp
@@ -225,6 +225,7 @@ public slots:
Q_INVOKABLE void toggleABloopState();
Q_INVOKABLE void snapshot();
Q_INVOKABLE void toggleRecord();
+ Q_INVOKABLE void toggleVisualization();
public:
PlayerController( intf_thread_t * );
diff --git a/modules/gui/qt/util/varchoicemodel.cpp b/modules/gui/qt/util/varchoicemodel.cpp
index 88b719c8d1..49f8d1ccac 100644
--- a/modules/gui/qt/util/varchoicemodel.cpp
+++ b/modules/gui/qt/util/varchoicemodel.cpp
@@ -229,6 +229,11 @@ bool VLCVarChoiceModel::hasCurrent() const
return m_current != -1;
}
+int VLCVarChoiceModel::currentRow() const
+{
+ return m_current;
+}
+
void VLCVarChoiceModel::toggleIndex(int index)
{
setData(QAbstractItemModel::createIndex(index,0),true,Qt::CheckStateRole);
diff --git a/modules/gui/qt/util/varchoicemodel.hpp b/modules/gui/qt/util/varchoicemodel.hpp
index 9f5b20729a..ffe3a15af6 100644
--- a/modules/gui/qt/util/varchoicemodel.hpp
+++ b/modules/gui/qt/util/varchoicemodel.hpp
@@ -67,6 +67,7 @@ public:
bool resetObject(T *object);
bool hasCurrent() const;
+ int currentRow() const;
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);
--
2.25.1
More information about the vlc-devel
mailing list