Commit 28334923 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Background Widget change. Resetting the maximum size at each resize is...

Qt4 - Background Widget change. Resetting the maximum size at each resize is wrong. Scaling content can be really really ugly.
To be finished.

parent 77787198
...@@ -124,10 +124,10 @@ void VideoWidget::release( void *p_win ) ...@@ -124,10 +124,10 @@ void VideoWidget::release( void *p_win )
#define MIN_BG_SIZE 64 #define MIN_BG_SIZE 64
BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : 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 */ /* 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 */ /* A dark background */
setAutoFillBackground( true ); setAutoFillBackground( true );
...@@ -138,7 +138,6 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -138,7 +138,6 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
/* A cone in the middle */ /* A cone in the middle */
label = new QLabel; label = new QLabel;
label->setScaledContents( true );
label->setMargin( 5 ); label->setMargin( 5 );
label->setMaximumHeight( MAX_BG_SIZE ); label->setMaximumHeight( MAX_BG_SIZE );
label->setMaximumWidth( MAX_BG_SIZE ); label->setMaximumWidth( MAX_BG_SIZE );
...@@ -149,20 +148,20 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -149,20 +148,20 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
else else
label->setPixmap( QPixmap( ":/vlc128.png" ) ); label->setPixmap( QPixmap( ":/vlc128.png" ) );
QHBoxLayout *backgroundLayout = new QHBoxLayout( this ); QGridLayout *backgroundLayout = new QGridLayout( this );
backgroundLayout->addWidget( label ); backgroundLayout->addWidget( label, 0, 1 );
backgroundLayout->setColumnStretch( 0, 1 );
backgroundLayout->setColumnStretch( 2, 1 );
resize( 300, 150 );
updateGeometry();
CONNECT( THEMIM, inputChanged( input_thread_t *), CONNECT( THEMIM, inputChanged( input_thread_t *),
this, update( input_thread_t * ) ); this, update( input_thread_t * ) );
resize( 300, 150 );
} }
BackgroundWidget::~BackgroundWidget() BackgroundWidget::~BackgroundWidget()
{ {
} }
void BackgroundWidget::update( input_thread_t *p_input ) void BackgroundWidget::update( input_thread_t *p_input )
{ {
if( !p_input || p_input->b_dead ) if( !p_input || p_input->b_dead )
...@@ -174,12 +173,11 @@ void BackgroundWidget::update( input_thread_t *p_input ) ...@@ -174,12 +173,11 @@ void BackgroundWidget::update( input_thread_t *p_input )
return; return;
} }
vlc_object_yield( p_input ); vlc_object_yield( p_input );
char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) ); char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
vlc_object_release( 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( arturl.isNull() )
{ {
if( QDate::currentDate().dayOfYear() >= 354 ) if( QDate::currentDate().dayOfYear() >= 354 )
...@@ -195,25 +193,6 @@ void BackgroundWidget::update( input_thread_t *p_input ) ...@@ -195,25 +193,6 @@ void BackgroundWidget::update( input_thread_t *p_input )
free( psz_arturl ); 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 ) void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
{ {
QVLCMenu::PopupMenu( p_intf, true ); QVLCMenu::PopupMenu( p_intf, true );
......
...@@ -70,22 +70,19 @@ public slots: ...@@ -70,22 +70,19 @@ public slots:
}; };
/******************** Background Widget ****************/ /******************** Background Widget ****************/
class BackgroundWidget : public QFrame class BackgroundWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
BackgroundWidget( intf_thread_t * ); BackgroundWidget( intf_thread_t * );
virtual ~BackgroundWidget(); virtual ~BackgroundWidget();
QSize widgetSize;
QSize sizeHint() const;
bool b_need_update;
private: private:
QPalette plt; QPalette plt;
QLabel *label; QLabel *label;
virtual void resizeEvent( QResizeEvent *e );
virtual void contextMenuEvent( QContextMenuEvent *event ); virtual void contextMenuEvent( QContextMenuEvent *event );
intf_thread_t *p_intf; intf_thread_t *p_intf;
int i_runs;
public slots: public slots:
void toggle(){ TOGGLEV( this ); } void toggle(){ TOGGLEV( this ); }
void update( input_thread_t * ); void update( input_thread_t * );
......
...@@ -315,6 +315,8 @@ MainInterface::~MainInterface() ...@@ -315,6 +315,8 @@ MainInterface::~MainInterface()
getControlsVisibilityStatus() & CONTROLS_ADVANCED ); getControlsVisibilityStatus() & CONTROLS_ADVANCED );
settings->setValue( "pos", pos() ); settings->setValue( "pos", pos() );
settings->setValue( "size", size() ); settings->setValue( "size", size() );
if( bgWidget )
settings->setValue( "backgroundSize", bgWidget->size() );
settings->endGroup(); settings->endGroup();
delete settings; delete settings;
...@@ -398,9 +400,8 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -398,9 +400,8 @@ void MainInterface::handleMainUi( QSettings *settings )
if( alwaysVideoFlag ) if( alwaysVideoFlag )
{ {
bgWidget = new BackgroundWidget( p_intf ); bgWidget = new BackgroundWidget( p_intf );
bgWidget->widgetSize = settings->value( "backgroundSize", bgWidget->resize(
QSize( 300, 200 ) ).toSize(); settings->value( "backgroundSize", QSize( 300, 150 ) ).toSize() );
bgWidget->resize( bgWidget->widgetSize );
bgWidget->updateGeometry(); bgWidget->updateGeometry();
mainLayout->insertWidget( 0, bgWidget ); mainLayout->insertWidget( 0, bgWidget );
CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() ); CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
...@@ -539,6 +540,7 @@ QSize MainInterface::sizeHint() const ...@@ -539,6 +540,7 @@ QSize MainInterface::sizeHint() const
{ {
nheight += bgWidget->size().height(); nheight += bgWidget->size().height();
nwidth = bgWidget->size().width(); nwidth = bgWidget->size().width();
msg_Dbg( p_intf, "1b %i %i", nheight, nwidth );
} }
else if( videoIsActive ) else if( videoIsActive )
{ {
...@@ -1139,6 +1141,7 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, ...@@ -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 ) vlc_value_t old_val, vlc_value_t new_val, void *param )
{ {
intf_thread_t *p_intf = (intf_thread_t *)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 ) if( p_intf->pf_show_dialog )
{ {
...@@ -1156,6 +1159,7 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable, ...@@ -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 ) vlc_value_t old_val, vlc_value_t new_val, void *param )
{ {
intf_thread_t *p_intf = (intf_thread_t *)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; //p_intf->p_sys->b_intf_show = VLC_TRUE;
return VLC_SUCCESS; return VLC_SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment