Commit 5f8020da authored by Ilkka Ollakka's avatar Ilkka Ollakka

qt4: no more calculateInterfaceSize, but sizeHint() stuff for

widget-size, 1. try from me
parent e1fcdb24
...@@ -123,15 +123,17 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -123,15 +123,17 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
plt.setColor( QPalette::Active, QPalette::Window , Qt::black ); plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black ); plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
setPalette( plt ); setPalette( plt );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred);
label = new QLabel; label = new QLabel;
label->setMaximumHeight( ICON_SIZE ); label->setMaximumHeight( MAX_BG_SIZE );
label->setMaximumWidth( ICON_SIZE ); label->setMaximumWidth( MAX_BG_SIZE );
label->setScaledContents( true ); label->setScaledContents( true );
label->setPixmap( QPixmap( ":/vlc128.png" ) ); label->setPixmap( QPixmap( ":/vlc128.png" ) );
backgroundLayout = new QHBoxLayout; backgroundLayout = new QHBoxLayout;
backgroundLayout->addWidget( label ); backgroundLayout->addWidget( label );
setLayout( backgroundLayout ); setLayout( backgroundLayout );
updateGeometry();
} }
BackgroundWidget::~BackgroundWidget() BackgroundWidget::~BackgroundWidget()
...@@ -146,19 +148,26 @@ void BackgroundWidget::setArt( QString url ) ...@@ -146,19 +148,26 @@ void BackgroundWidget::setArt( QString url )
label->setPixmap( QPixmap( ":/vlc128.png" ) ); label->setPixmap( QPixmap( ":/vlc128.png" ) );
else else
label->setPixmap( QPixmap( url ) ); label->setPixmap( QPixmap( url ) );
updateGeometry();
} }
QSize BackgroundWidget::sizeHint() const QSize BackgroundWidget::sizeHint() const
{ {
return widgetSize; return label->maximumSize();
} }
void BackgroundWidget::resizeEvent( QResizeEvent *e ) 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->setMaximumWidth( e->size().height() );
label->setMaximumHeight( e->size().width() );
}
else else
label->setMaximumWidth( ICON_SIZE ); {
label->setMaximumHeight( MAX_BG_SIZE );
label->setMaximumWidth( MAX_BG_SIZE );
}
} }
void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event ) void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
...@@ -194,6 +203,7 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) : ...@@ -194,6 +203,7 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
VisualSelector::~VisualSelector() VisualSelector::~VisualSelector()
{ {
} }
void VisualSelector::prev() void VisualSelector::prev()
...@@ -332,7 +342,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, ...@@ -332,7 +342,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
{ {
controlLayout = new QGridLayout( this ); controlLayout = new QGridLayout( this );
controlLayout->setSpacing( 0 ); controlLayout->setSpacing( 0 );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Fixed );
/** The main Slider **/ /** The main Slider **/
slider = new InputSlider( Qt::Horizontal, NULL ); slider = new InputSlider( Qt::Horizontal, NULL );
...@@ -518,12 +528,20 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, ...@@ -518,12 +528,20 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
VOLUME_MAX / (AOUT_VOLUME_MAX/2) ); VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
/* Volume control connection */ /* Volume control connection */
resize( QSize( 400, 60 ) );
CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) ); 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() ControlsWidget::~ControlsWidget()
{ {
} }
QSize ControlsWidget::sizeHint() const
{
return QSize( 300, 50 );
}
void ControlsWidget::stop() void ControlsWidget::stop()
{ {
THEMIM->stop(); THEMIM->stop();
...@@ -596,7 +614,7 @@ void ControlsWidget::updateOnTimer() ...@@ -596,7 +614,7 @@ void ControlsWidget::updateOnTimer()
/* Audio part */ /* Audio part */
audio_volume_t i_volume; audio_volume_t i_volume;
aout_VolumeGet( p_intf, &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(); int i_gauge = volumeSlider->value();
b_my_volume = false; b_my_volume = false;
if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 ) if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
...@@ -744,12 +762,18 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : ...@@ -744,12 +762,18 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) :
QList<int> sizeList; QList<int> sizeList;
sizeList << 180 << 520 ; sizeList << 180 << 520 ;
setSizes( sizeList ); setSizes( sizeList );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
resize(700,200);
updateGeometry();
} }
void PlaylistWidget::setArt( QString url ) void PlaylistWidget::setArt( QString url )
{ {
if( url.isNull() ) if( url.isNull() )
{
art->setPixmap( QPixmap( ":/noart.png" ) ); art->setPixmap( QPixmap( ":/noart.png" ) );
emit artSet( url );
}
else if( prevArt != url ) else if( prevArt != url )
{ {
art->setPixmap( QPixmap( url ) ); art->setPixmap( QPixmap( url ) );
...@@ -758,6 +782,11 @@ void PlaylistWidget::setArt( QString url ) ...@@ -758,6 +782,11 @@ void PlaylistWidget::setArt( QString url )
} }
} }
QSize PlaylistWidget::sizeHint() const
{
return QSize( 700, 200 );
}
PlaylistWidget::~PlaylistWidget() PlaylistWidget::~PlaylistWidget()
{ {
} }
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
vout_thread_t *p_vout; vout_thread_t *p_vout;
QSize widgetSize; QSize widgetSize;
virtual QSize sizeHint() const; QSize sizeHint() const;
private: private:
QWidget *frame; QWidget *frame;
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
BackgroundWidget( intf_thread_t * ); BackgroundWidget( intf_thread_t * );
virtual ~BackgroundWidget(); virtual ~BackgroundWidget();
QSize widgetSize; QSize widgetSize;
virtual QSize sizeHint() const; QSize sizeHint() const;
private: private:
QPalette plt; QPalette plt;
QLabel *label; QLabel *label;
...@@ -149,6 +149,7 @@ class ControlsWidget : public QFrame ...@@ -149,6 +149,7 @@ class ControlsWidget : public QFrame
public: public:
/* p_intf, advanced control visible or not, blingbling or not */ /* p_intf, advanced control visible or not, blingbling or not */
ControlsWidget( intf_thread_t *, bool, bool ); ControlsWidget( intf_thread_t *, bool, bool );
QSize sizeHint() const;
virtual ~ControlsWidget(); virtual ~ControlsWidget();
QPushButton *playlistButton; QPushButton *playlistButton;
...@@ -245,6 +246,7 @@ class PlaylistWidget : public QSplitter ...@@ -245,6 +246,7 @@ class PlaylistWidget : public QSplitter
public: public:
PlaylistWidget( intf_thread_t *_p_i ) ; PlaylistWidget( intf_thread_t *_p_i ) ;
virtual ~PlaylistWidget(); virtual ~PlaylistWidget();
QSize sizeHint() const;
private: private:
PLSelector *selector; PLSelector *selector;
PLPanel *rightPanel; PLPanel *rightPanel;
......
...@@ -96,6 +96,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -96,6 +96,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL; bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
embeddedPlaylistWasActive = videoIsActive = false; embeddedPlaylistWasActive = videoIsActive = false;
input_name = ""; input_name = "";
playlistWidget = new PlaylistWidget( p_intf );
/* Ask for the network policy on first startup */ /* Ask for the network policy on first startup */
if( config_GetInt( p_intf, "privacy-ask") ) if( config_GetInt( p_intf, "privacy-ask") )
...@@ -144,14 +145,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -144,14 +145,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
* UI and Widgets design * UI and Widgets design
**************************/ **************************/
setVLCWindowsTitle(); setVLCWindowsTitle();
handleMainUi( settings ); dockPL = new QDockWidget( qtr("Playlist"), this );
/* Create a Dock to get the playlist */ /* Create a Dock to get the playlist */
dockPL = new QDockWidget( qtr("Playlist"), this ); handleMainUi( settings );
dockPL->setAllowedAreas( Qt::LeftDockWidgetArea dockPL->setAllowedAreas( Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea | Qt::RightDockWidgetArea
| Qt::BottomDockWidgetArea ); | Qt::BottomDockWidgetArea );
dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures ); dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
dockPL->setWidget( playlistWidget );
addDockWidget( Qt::BottomDockWidgetArea, dockPL );
/* Menu Bar */ /* Menu Bar */
QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled ); QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled );
...@@ -283,6 +286,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -283,6 +286,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
// DEBUG FIXME // DEBUG FIXME
hide(); hide();
updateGeometry();
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
...@@ -363,8 +367,6 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -363,8 +367,6 @@ void MainInterface::handleMainUi( QSettings *settings )
speedControlMenu->addAction( widgetAction ); speedControlMenu->addAction( widgetAction );
/* Set initial size */ /* Set initial size */
resize( PREF_W, PREF_H );
addSize = QSize( mainLayout->margin() * 2, PREF_H );
/* Visualisation */ /* Visualisation */
visualSelector = new VisualSelector( p_intf ); visualSelector = new VisualSelector( p_intf );
...@@ -381,6 +383,7 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -381,6 +383,7 @@ void MainInterface::handleMainUi( QSettings *settings )
bgWidget->updateGeometry(); bgWidget->updateGeometry();
mainLayout->insertWidget( 0, bgWidget ); mainLayout->insertWidget( 0, bgWidget );
CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() ); CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) );
} }
if( videoEmbeddedFlag ) if( videoEmbeddedFlag )
...@@ -396,7 +399,8 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -396,7 +399,8 @@ void MainInterface::handleMainUi( QSettings *settings )
} }
/* Finish the sizing */ /* Finish the sizing */
setMinimumSize( PREF_W, addSize.height() ); setMinimumSize( PREF_W, PREF_H );
updateGeometry();
} }
...@@ -472,6 +476,7 @@ void MainInterface::debug() ...@@ -472,6 +476,7 @@ void MainInterface::debug()
/********************************************************************** /**********************************************************************
* Handling of sizing of the components * Handling of sizing of the components
**********************************************************************/ **********************************************************************/
#if 0
void MainInterface::calculateInterfaceSize() void MainInterface::calculateInterfaceSize()
{ {
int width = 0, height = 0; int width = 0, height = 0;
...@@ -518,6 +523,7 @@ void MainInterface::resizeEvent( QResizeEvent *e ) ...@@ -518,6 +523,7 @@ void MainInterface::resizeEvent( QResizeEvent *e )
playlistWidget->updateGeometry(); playlistWidget->updateGeometry();
} }
} }
#endif
/**************************************************************************** /****************************************************************************
* Small right-click menu for rate control * Small right-click menu for rate control
...@@ -577,7 +583,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, ...@@ -577,7 +583,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
videoWidget->widgetSize = QSize( *pi_width, *pi_height ); videoWidget->widgetSize = QSize( *pi_width, *pi_height );
} }
videoWidget->updateGeometry(); // Needed for deinterlace videoWidget->updateGeometry(); // Needed for deinterlace
need_components_update = true; updateGeometry();
} }
return ret; return ret;
} }
...@@ -596,7 +602,7 @@ void MainInterface::releaseVideoSlot( void *p_win ) ...@@ -596,7 +602,7 @@ void MainInterface::releaseVideoSlot( void *p_win )
bgWidget->show(); bgWidget->show();
videoIsActive = false; videoIsActive = false;
need_components_update = true; updateGeometry();
} }
int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) 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 ) ...@@ -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 ); unsigned int i_height = va_arg( args, unsigned int );
videoWidget->widgetSize = QSize( i_width, i_height ); videoWidget->widgetSize = QSize( i_width, i_height );
videoWidget->updateGeometry(); videoWidget->updateGeometry();
need_components_update = true; updateGeometry();
i_ret = VLC_SUCCESS; i_ret = VLC_SUCCESS;
break; break;
} }
...@@ -676,14 +682,21 @@ void MainInterface::togglePlaylist() ...@@ -676,14 +682,21 @@ void MainInterface::togglePlaylist()
{ {
/* toggle the display */ /* toggle the display */
TOGGLEV( dockPL ); TOGGLEV( dockPL );
resize(sizeHint());
} }
#if 0
doComponentsUpdate(); doComponentsUpdate();
#endif
updateGeometry();
} }
void MainInterface::undockPlaylist() void MainInterface::undockPlaylist()
{ {
dockPL->setFloating( true ); dockPL->setFloating( true );
updateGeometry();
#if 0
doComponentsUpdate(); doComponentsUpdate();
#endif
} }
#if 0 #if 0
...@@ -718,11 +731,13 @@ void MainInterface::toggleMinimalView() ...@@ -718,11 +731,13 @@ void MainInterface::toggleMinimalView()
/* Video widget cannot do this synchronously as it runs in another thread */ /* Video widget cannot do this synchronously as it runs in another thread */
/* Well, could it, actually ? Probably dangerous ... */ /* Well, could it, actually ? Probably dangerous ... */
#if 0
void MainInterface::doComponentsUpdate() void MainInterface::doComponentsUpdate()
{ {
calculateInterfaceSize(); calculateInterfaceSize();
resize( mainSize ); resize( mainSize );
} }
#endif
void MainInterface::toggleAdvanced() void MainInterface::toggleAdvanced()
{ {
...@@ -794,11 +809,13 @@ void MainInterface::updateOnTimer() ...@@ -794,11 +809,13 @@ void MainInterface::updateOnTimer()
QApplication::closeAllWindows(); QApplication::closeAllWindows();
QApplication::quit(); QApplication::quit();
} }
#if 0
if( need_components_update ) if( need_components_update )
{ {
doComponentsUpdate(); doComponentsUpdate();
need_components_update = false; need_components_update = false;
} }
#endif
controls->updateOnTimer(); controls->updateOnTimer();
} }
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
QMenu *getSysTrayMenu() { return systrayMenu; }; QMenu *getSysTrayMenu() { return systrayMenu; };
int getControlsVisibilityStatus(); int getControlsVisibilityStatus();
protected: protected:
void resizeEvent( QResizeEvent * ); // void resizeEvent( QResizeEvent * );
void dropEvent( QDropEvent *); void dropEvent( QDropEvent *);
void dragEnterEvent( QDragEnterEvent * ); void dragEnterEvent( QDragEnterEvent * );
void dragMoveEvent( QDragMoveEvent * ); void dragMoveEvent( QDragMoveEvent * );
...@@ -94,7 +94,6 @@ private: ...@@ -94,7 +94,6 @@ private:
bool need_components_update; bool need_components_update;
void calculateInterfaceSize();
void handleMainUi( QSettings* ); void handleMainUi( QSettings* );
void handleSystray(); void handleSystray();
void doComponentsUpdate(); void doComponentsUpdate();
......
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