From 5f8020dad16c760801c8324119f5217db054427f Mon Sep 17 00:00:00 2001 From: Ilkka Ollakka Date: Sat, 24 Nov 2007 21:30:50 +0000 Subject: [PATCH] qt4: no more calculateInterfaceSize, but sizeHint() stuff for widget-size, 1. try from me --- .../gui/qt4/components/interface_widgets.cpp | 45 +++++++++++++++---- .../gui/qt4/components/interface_widgets.hpp | 6 ++- modules/gui/qt4/main_interface.cpp | 33 ++++++++++---- modules/gui/qt4/main_interface.hpp | 3 +- 4 files changed, 67 insertions(+), 20 deletions(-) diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index 239cc4e0e9..8df64eccf5 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -123,15 +123,17 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : plt.setColor( QPalette::Active, QPalette::Window , Qt::black ); plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black ); setPalette( plt ); + setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred); label = new QLabel; - label->setMaximumHeight( ICON_SIZE ); - label->setMaximumWidth( ICON_SIZE ); + label->setMaximumHeight( MAX_BG_SIZE ); + label->setMaximumWidth( MAX_BG_SIZE ); label->setScaledContents( true ); label->setPixmap( QPixmap( ":/vlc128.png" ) ); backgroundLayout = new QHBoxLayout; backgroundLayout->addWidget( label ); setLayout( backgroundLayout ); + updateGeometry(); } BackgroundWidget::~BackgroundWidget() @@ -146,19 +148,26 @@ void BackgroundWidget::setArt( QString url ) label->setPixmap( QPixmap( ":/vlc128.png" ) ); else label->setPixmap( QPixmap( url ) ); + updateGeometry(); } QSize BackgroundWidget::sizeHint() const { - return widgetSize; + return label->maximumSize(); } void BackgroundWidget::resizeEvent( QResizeEvent *e ) { - if( e->size().height() < ICON_SIZE -1 ) + if( e->size().height() < MAX_BG_SIZE -1 ) + { label->setMaximumWidth( e->size().height() ); + label->setMaximumHeight( e->size().width() ); + } else - label->setMaximumWidth( ICON_SIZE ); + { + label->setMaximumHeight( MAX_BG_SIZE ); + label->setMaximumWidth( MAX_BG_SIZE ); + } } void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event ) @@ -194,6 +203,7 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) : VisualSelector::~VisualSelector() { + } void VisualSelector::prev() @@ -332,7 +342,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, { controlLayout = new QGridLayout( this ); controlLayout->setSpacing( 0 ); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); + setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Fixed ); /** The main Slider **/ slider = new InputSlider( Qt::Horizontal, NULL ); @@ -518,12 +528,20 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, VOLUME_MAX / (AOUT_VOLUME_MAX/2) ); /* Volume control connection */ + resize( QSize( 400, 60 ) ); CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) ); - msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); + msg_Dbg( p_intf, "controls size: %i - %i", size().width(), size().height() ); } ControlsWidget::~ControlsWidget() { } + +QSize ControlsWidget::sizeHint() const +{ + return QSize( 300, 50 ); +} + + void ControlsWidget::stop() { THEMIM->stop(); @@ -596,7 +614,7 @@ void ControlsWidget::updateOnTimer() /* Audio part */ audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); - i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2) ; + i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2); int i_gauge = volumeSlider->value(); b_my_volume = false; if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 ) @@ -744,12 +762,18 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : QList sizeList; sizeList << 180 << 520 ; setSizes( sizeList ); + setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + resize(700,200); + updateGeometry(); } void PlaylistWidget::setArt( QString url ) { if( url.isNull() ) + { art->setPixmap( QPixmap( ":/noart.png" ) ); + emit artSet( url ); + } else if( prevArt != url ) { art->setPixmap( QPixmap( url ) ); @@ -758,6 +782,11 @@ void PlaylistWidget::setArt( QString url ) } } +QSize PlaylistWidget::sizeHint() const +{ + return QSize( 700, 200 ); +} + PlaylistWidget::~PlaylistWidget() { } diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp index 1966717d2c..2bfc3d0ea0 100644 --- a/modules/gui/qt4/components/interface_widgets.hpp +++ b/modules/gui/qt4/components/interface_widgets.hpp @@ -59,7 +59,7 @@ public: vout_thread_t *p_vout; QSize widgetSize; - virtual QSize sizeHint() const; + QSize sizeHint() const; private: QWidget *frame; intf_thread_t *p_intf; @@ -79,7 +79,7 @@ public: BackgroundWidget( intf_thread_t * ); virtual ~BackgroundWidget(); QSize widgetSize; - virtual QSize sizeHint() const; + QSize sizeHint() const; private: QPalette plt; QLabel *label; @@ -149,6 +149,7 @@ class ControlsWidget : public QFrame public: /* p_intf, advanced control visible or not, blingbling or not */ ControlsWidget( intf_thread_t *, bool, bool ); + QSize sizeHint() const; virtual ~ControlsWidget(); QPushButton *playlistButton; @@ -245,6 +246,7 @@ class PlaylistWidget : public QSplitter public: PlaylistWidget( intf_thread_t *_p_i ) ; virtual ~PlaylistWidget(); + QSize sizeHint() const; private: PLSelector *selector; PLPanel *rightPanel; diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 0e7b503ced..6846393008 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -96,6 +96,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL; embeddedPlaylistWasActive = videoIsActive = false; input_name = ""; + playlistWidget = new PlaylistWidget( p_intf ); /* Ask for the network policy on first startup */ if( config_GetInt( p_intf, "privacy-ask") ) @@ -144,14 +145,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) * UI and Widgets design **************************/ setVLCWindowsTitle(); - handleMainUi( settings ); + dockPL = new QDockWidget( qtr("Playlist"), this ); /* Create a Dock to get the playlist */ - dockPL = new QDockWidget( qtr("Playlist"), this ); + handleMainUi( settings ); dockPL->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea ); dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures ); + dockPL->setWidget( playlistWidget ); + addDockWidget( Qt::BottomDockWidgetArea, dockPL ); /* Menu Bar */ QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled ); @@ -283,6 +286,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) // DEBUG FIXME hide(); + updateGeometry(); } MainInterface::~MainInterface() @@ -363,8 +367,6 @@ void MainInterface::handleMainUi( QSettings *settings ) speedControlMenu->addAction( widgetAction ); /* Set initial size */ - resize( PREF_W, PREF_H ); - addSize = QSize( mainLayout->margin() * 2, PREF_H ); /* Visualisation */ visualSelector = new VisualSelector( p_intf ); @@ -381,6 +383,7 @@ void MainInterface::handleMainUi( QSettings *settings ) bgWidget->updateGeometry(); mainLayout->insertWidget( 0, bgWidget ); CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() ); + CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) ); } if( videoEmbeddedFlag ) @@ -396,7 +399,8 @@ void MainInterface::handleMainUi( QSettings *settings ) } /* Finish the sizing */ - setMinimumSize( PREF_W, addSize.height() ); + setMinimumSize( PREF_W, PREF_H ); + updateGeometry(); } @@ -472,6 +476,7 @@ void MainInterface::debug() /********************************************************************** * Handling of sizing of the components **********************************************************************/ +#if 0 void MainInterface::calculateInterfaceSize() { int width = 0, height = 0; @@ -518,6 +523,7 @@ void MainInterface::resizeEvent( QResizeEvent *e ) playlistWidget->updateGeometry(); } } +#endif /**************************************************************************** * Small right-click menu for rate control @@ -577,7 +583,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, videoWidget->widgetSize = QSize( *pi_width, *pi_height ); } videoWidget->updateGeometry(); // Needed for deinterlace - need_components_update = true; + updateGeometry(); } return ret; } @@ -596,7 +602,7 @@ void MainInterface::releaseVideoSlot( void *p_win ) bgWidget->show(); videoIsActive = false; - need_components_update = true; + updateGeometry(); } int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) @@ -619,7 +625,7 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) unsigned int i_height = va_arg( args, unsigned int ); videoWidget->widgetSize = QSize( i_width, i_height ); videoWidget->updateGeometry(); - need_components_update = true; + updateGeometry(); i_ret = VLC_SUCCESS; break; } @@ -676,14 +682,21 @@ void MainInterface::togglePlaylist() { /* toggle the display */ TOGGLEV( dockPL ); + resize(sizeHint()); } +#if 0 doComponentsUpdate(); +#endif + updateGeometry(); } void MainInterface::undockPlaylist() { dockPL->setFloating( true ); + updateGeometry(); +#if 0 doComponentsUpdate(); +#endif } #if 0 @@ -718,11 +731,13 @@ void MainInterface::toggleMinimalView() /* Video widget cannot do this synchronously as it runs in another thread */ /* Well, could it, actually ? Probably dangerous ... */ +#if 0 void MainInterface::doComponentsUpdate() { calculateInterfaceSize(); resize( mainSize ); } +#endif void MainInterface::toggleAdvanced() { @@ -794,11 +809,13 @@ void MainInterface::updateOnTimer() QApplication::closeAllWindows(); QApplication::quit(); } +#if 0 if( need_components_update ) { doComponentsUpdate(); need_components_update = false; } +#endif controls->updateOnTimer(); } diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp index 6b755405a3..972ba359c7 100644 --- a/modules/gui/qt4/main_interface.hpp +++ b/modules/gui/qt4/main_interface.hpp @@ -73,7 +73,7 @@ public: QMenu *getSysTrayMenu() { return systrayMenu; }; int getControlsVisibilityStatus(); protected: - void resizeEvent( QResizeEvent * ); +// void resizeEvent( QResizeEvent * ); void dropEvent( QDropEvent *); void dragEnterEvent( QDragEnterEvent * ); void dragMoveEvent( QDragMoveEvent * ); @@ -94,7 +94,6 @@ private: bool need_components_update; - void calculateInterfaceSize(); void handleMainUi( QSettings* ); void handleSystray(); void doComponentsUpdate(); -- 2.39.2