]> git.sesse.net Git - vlc/commitdiff
qt4: no more calculateInterfaceSize, but sizeHint() stuff for
authorIlkka Ollakka <ileoo@videolan.org>
Sat, 24 Nov 2007 21:30:50 +0000 (21:30 +0000)
committerIlkka Ollakka <ileoo@videolan.org>
Sat, 24 Nov 2007 21:30:50 +0000 (21:30 +0000)
widget-size, 1. try from me

modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index 239cc4e0e99560e6d29902c1615604a6555090df..8df64eccf547f5060187e27e020873efcfc80ad1 100644 (file)
@@ -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<int> 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()
 {
 }
index 1966717d2c68c61c0eff7bae67e63c6f1895398c..2bfc3d0ea0a6c9602ddc2ec49ff5dca34646ba54 100644 (file)
@@ -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;
index 0e7b503cedbf532f1214d28775644f7c57242564..68463930082c37c658c1a7773a68fca2a88a5395 100644 (file)
@@ -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();
 }
index 6b755405a3ab226f1ce033317bc2ad33bbc46a1d..972ba359c79dd5f50f7cba85d8f4058d3de88fbb 100644 (file)
@@ -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();