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 )
#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 );
......
......@@ -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 * );
......
......@@ -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;
......
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