]> git.sesse.net Git - vlc/commitdiff
Qt4 - Background Widget change. Resetting the maximum size at each resize is wrong...
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 24 Dec 2007 01:00:03 +0000 (01:00 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 24 Dec 2007 01:00:03 +0000 (01:00 +0000)
To be finished.

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

index cad4a6b041bcab4c8dd5fa471b6a9a7d935fd2ce..25b80d2066839199745aa88a6c007102439b1efc 100644 (file)
@@ -124,10 +124,10 @@ void VideoWidget::release( void *p_win )
 #define MIN_BG_SIZE 64
 
 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
-                                        QFrame( NULL ), p_intf( _p_i )
+                                        QWidget( NULL ), p_intf( _p_i )
 {
     /* We should use that one to take the more size it can */
-    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
+    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
 
     /* A dark background */
     setAutoFillBackground( true );
@@ -138,7 +138,6 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
 
     /* A cone in the middle */
     label = new QLabel;
-    label->setScaledContents( true );
     label->setMargin( 5 );
     label->setMaximumHeight( MAX_BG_SIZE );
     label->setMaximumWidth( MAX_BG_SIZE );
@@ -149,20 +148,20 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
     else
         label->setPixmap( QPixmap( ":/vlc128.png" ) );
 
-    QHBoxLayout *backgroundLayout = new QHBoxLayout( this );
-    backgroundLayout->addWidget( label );
+    QGridLayout *backgroundLayout = new QGridLayout( this );
+    backgroundLayout->addWidget( label, 0, 1 );
+    backgroundLayout->setColumnStretch( 0, 1 );
+    backgroundLayout->setColumnStretch( 2, 1 );
 
-    resize( 300, 150 );
-    updateGeometry();
     CONNECT( THEMIM, inputChanged( input_thread_t *),
              this, update( input_thread_t * ) );
+    resize( 300, 150 );
 }
 
 BackgroundWidget::~BackgroundWidget()
 {
 }
 
-
 void BackgroundWidget::update( input_thread_t *p_input )
 {
     if( !p_input || p_input->b_dead )
@@ -174,12 +173,11 @@ void BackgroundWidget::update( input_thread_t *p_input )
         return;
     }
 
-
     vlc_object_yield( p_input );
     char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
     vlc_object_release( p_input );
-    QString url = qfu( psz_arturl );
-    QString arturl = url.replace( "file://",QString("" ) );
+
+    QString arturl = qfu( psz_arturl ).replace( "file://",QString("" ) );
     if( arturl.isNull() )
     {
         if( QDate::currentDate().dayOfYear() >= 354 )
@@ -195,25 +193,6 @@ void BackgroundWidget::update( input_thread_t *p_input )
     free( psz_arturl );
 }
 
-QSize BackgroundWidget::sizeHint() const
-{
-    return label->size();
-}
-
-void BackgroundWidget::resizeEvent( QResizeEvent *e )
-{
-    if( e->size().height() < MAX_BG_SIZE -1 )
-    {
-        label->setMaximumWidth( e->size().height() );
-        label->setMaximumHeight( e->size().width() );
-    }
-    else
-    {
-        label->setMaximumHeight( MAX_BG_SIZE );
-        label->setMaximumWidth( MAX_BG_SIZE );
-    }
-}
-
 void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
 {
     QVLCMenu::PopupMenu( p_intf, true );
index a03547925b00b6928d6c2c8b44d7f26aef0d4592..0a7e78173a9c5ed494e64396b2ac5670ebc5f76c 100644 (file)
@@ -70,22 +70,19 @@ public slots:
 };
 
 /******************** Background Widget ****************/
-class BackgroundWidget : public QFrame
+class BackgroundWidget : public QWidget
 {
     Q_OBJECT
 public:
     BackgroundWidget( intf_thread_t * );
     virtual ~BackgroundWidget();
-    QSize widgetSize;
-    QSize sizeHint() const;
-    bool b_need_update;
+
 private:
     QPalette plt;
     QLabel *label;
-    virtual void resizeEvent( QResizeEvent *e );
     virtual void contextMenuEvent( QContextMenuEvent *event );
     intf_thread_t *p_intf;
-    int i_runs;
+
 public slots:
     void toggle(){ TOGGLEV( this ); }
     void update( input_thread_t * );
index 21b0703af0e2de523eae21caef31ed4f385063e2..c395c2844fcf68fe0b6f080b4f10c4516ad8d249 100644 (file)
@@ -315,6 +315,8 @@ MainInterface::~MainInterface()
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
     settings->setValue( "pos", pos() );
     settings->setValue( "size", size() );
+    if( bgWidget )
+        settings->setValue( "backgroundSize", bgWidget->size() );
 
     settings->endGroup();
     delete settings;
@@ -398,9 +400,8 @@ void MainInterface::handleMainUi( QSettings *settings )
     if( alwaysVideoFlag )
     {
         bgWidget = new BackgroundWidget( p_intf );
-        bgWidget->widgetSize = settings->value( "backgroundSize",
-                                           QSize( 300, 200 ) ).toSize();
-        bgWidget->resize( bgWidget->widgetSize );
+        bgWidget->resize(
+             settings->value( "backgroundSize", QSize( 300, 150 ) ).toSize() );
         bgWidget->updateGeometry();
         mainLayout->insertWidget( 0, bgWidget );
         CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
@@ -539,6 +540,7 @@ QSize MainInterface::sizeHint() const
     {
         nheight += bgWidget->size().height();
         nwidth  = bgWidget->size().width();
+        msg_Dbg( p_intf, "1b %i %i", nheight, nwidth );
     }
     else if( videoIsActive )
     {
@@ -1139,6 +1141,7 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                         vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t *p_intf = (intf_thread_t *)param;
+    msg_Dbg( p_this, "Menu Requested" ); // DEBUG to track the non disparition of the menu...
 
     if( p_intf->pf_show_dialog )
     {
@@ -1156,6 +1159,7 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t *p_intf = (intf_thread_t *)param;
+    msg_Dbg( p_this, "Intf Show Requested" ); // DEBUG to track the non disparition of the menu...
     //p_intf->p_sys->b_intf_show = VLC_TRUE;
 
     return VLC_SUCCESS;