From 283349239015568fbf1a324532d032858ae41d9a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Mon, 24 Dec 2007 01:00:03 +0000 Subject: [PATCH] Qt4 - Background Widget change. Resetting the maximum size at each resize is wrong. Scaling content can be really really ugly. To be finished. --- .../gui/qt4/components/interface_widgets.cpp | 39 +++++-------------- .../gui/qt4/components/interface_widgets.hpp | 9 ++--- modules/gui/qt4/main_interface.cpp | 10 +++-- 3 files changed, 19 insertions(+), 39 deletions(-) diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index cad4a6b041..25b80d2066 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -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 ); diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp index a03547925b..0a7e78173a 100644 --- a/modules/gui/qt4/components/interface_widgets.hpp +++ b/modules/gui/qt4/components/interface_widgets.hpp @@ -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 * ); diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 21b0703af0..c395c2844f 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -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; -- 2.20.1