[vlc-devel] [PATCH] Qt: Add FullscreenControllerWidget::updateFSCtoolbar() and use it
Edward Wang
edward.c.wang at compdigitec.com
Thu Feb 23 03:47:56 CET 2012
Close #6116
---
modules/gui/qt4/components/controller.cpp | 46 ++++++++++++++++++++++-------
modules/gui/qt4/components/controller.hpp | 3 ++
modules/gui/qt4/main_interface.cpp | 7 ++--
3 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index ea55de3..2f2e458 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -744,17 +744,8 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
setFrameStyle( QFrame::Sunken );
setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
- QVBoxLayout *controlLayout2 = new QVBoxLayout( this );
- controlLayout2->setContentsMargins( 4, 6, 4, 2 );
-
- /* First line */
- InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
- controlLayout2->addWidget( inputC );
-
- controlLayout = new QHBoxLayout;
- QString line = getSettings()->value( "MainWindow/FSCtoolbar", FSC_TB_DEFAULT ).toString();
- parseAndCreate( line, controlLayout );
- controlLayout2->addLayout( controlLayout );
+ controlLayout2 = NULL;
+ updateFSCtoolbar();
/* hiding timer */
p_hideTimer = new QTimer( this );
@@ -790,6 +781,39 @@ FullscreenControllerWidget::~FullscreenControllerWidget()
vlc_mutex_destroy( &lock );
}
+void clearLayout( QLayout* layout )
+{
+ while( QLayoutItem* item = layout->takeAt(0) )
+ {
+ if( QWidget* widget = item->widget() )
+ delete widget;
+ else if( QLayout* childLayout = item->layout() )
+ clearLayout( childLayout );
+ delete item;
+ }
+}
+
+
+/* Update the layout - for example, on customize of toolbar */
+void FullscreenControllerWidget::updateFSCtoolbar()
+{
+ if( controlLayout2 == NULL )
+ controlLayout2 = new QVBoxLayout( this );
+ else
+ clearLayout( controlLayout2 );
+
+ controlLayout2->setContentsMargins( 4, 6, 4, 2 );
+
+ /* First line */
+ InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
+ controlLayout2->addWidget( inputC );
+
+ controlLayout = new QHBoxLayout;
+ QString line = getSettings()->value( "MainWindow/FSCtoolbar", FSC_TB_DEFAULT ).toString();
+ parseAndCreate( line, controlLayout );
+ controlLayout2->addLayout( controlLayout );
+}
+
void FullscreenControllerWidget::restoreFSC()
{
if( !isWideFSC )
diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp
index 90d9b9c..3132e2a 100644
--- a/modules/gui/qt4/components/controller.hpp
+++ b/modules/gui/qt4/components/controller.hpp
@@ -47,6 +47,7 @@ class QLabel;
class QGridLayout;
class QHBoxLayout;
+class QVBoxLayout;
class QBoxLayout;
class QAbstractSlider;
@@ -265,6 +266,7 @@ public:
void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
void toggleFullwidth();
void updateFullwidthGeometry( int number );
+ void updateFSCtoolbar();
int targetScreen();
signals:
@@ -294,6 +296,7 @@ private slots:
void centerFSC( int );
private:
+ QVBoxLayout *controlLayout2;
QTimer *p_hideTimer;
#if HAVE_TRANSPARENCY
QTimer *p_slowHideTimer;
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 091a99b..c1c00b2 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -344,10 +344,9 @@ void MainInterface::recreateToolbars()
if( fullscreenControls )
{
- delete fullscreenControls;
- fullscreenControls = new FullscreenControllerWidget( p_intf, this );
- CONNECT( fullscreenControls, keyPressed( QKeyEvent * ),
- this, handleKeyPress( QKeyEvent * ) );
+ /* Update the existing fullscreen controller, since creating a
+ * new one causes the new one to not appear */
+ fullscreenControls->updateFSCtoolbar();
}
}
--
1.7.5.4
More information about the vlc-devel
mailing list