[vlc-commits] qt: provide function to toggle random visualization in player_controller
Prince Gupta
git at videolan.org
Fri Nov 6 16:00:58 CET 2020
vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Wed Oct 21 13:51:20 2020 +0530| [64ea5451b312b3846ca86881fd5c3bbc9bb40cb5] | committer: Pierre Lamot
qt: provide function to toggle random visualization in player_controller
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64ea5451b312b3846ca86881fd5c3bbc9bb40cb5
---
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 e219cd87aa..d224843a18 100644
--- a/modules/gui/qt/player/player_controller.cpp
+++ b/modules/gui/qt/player/player_controller.cpp
@@ -1656,6 +1656,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);
More information about the vlc-commits
mailing list