Commit 5a1d728e authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - MainInterface, correct the resizing when docking the playlist for the...

Qt4 - MainInterface, correct the resizing when docking the playlist for the first time. Remove some dead code... Not finished yet... Feel free to fix, but not to break :D
parent 76edc14f
...@@ -141,7 +141,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -141,7 +141,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
label->setMinimumWidth( MIN_BG_SIZE ); label->setMinimumWidth( MIN_BG_SIZE );
label->setPixmap( QPixmap( ":/vlc128.png" ) ); label->setPixmap( QPixmap( ":/vlc128.png" ) );
QVBoxLayout *backgroundLayout = new QVBoxLayout( this ); QHBoxLayout *backgroundLayout = new QHBoxLayout( this );
backgroundLayout->addWidget( label ); backgroundLayout->addWidget( label );
resize( 300, 150 ); resize( 300, 150 );
...@@ -434,7 +434,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, ...@@ -434,7 +434,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
playButton->setMinimumSize( QSize( 45, 45 ) ); playButton->setMinimumSize( QSize( 45, 45 ) );
playButton->setIconSize( QSize( 30, 30 ) ); playButton->setIconSize( QSize( 30, 30 ) );
controlLayout->addWidget( playButton, 2, 0, 2, 2, Qt::AlignBottom ); controlLayout->addWidget( playButton, 2, 0, 2, 2 );
controlLayout->setColumnMinimumWidth( 2, 20 ); controlLayout->setColumnMinimumWidth( 2, 20 );
controlLayout->setColumnStretch( 2, 0 ); controlLayout->setColumnStretch( 2, 0 );
...@@ -775,9 +775,9 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) : ...@@ -775,9 +775,9 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) :
QList<int> sizeList; QList<int> sizeList;
sizeList << 180 << 420 ; sizeList << 180 << 420 ;
setSizes( sizeList ); setSizes( sizeList );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
resize( 600, 300 ); resize( 600, 300 );
updateGeometry(); //updateGeometry();
} }
void PlaylistWidget::setArt( QString url ) void PlaylistWidget::setArt( QString url )
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "dialogs/playlist.hpp" #include "dialogs/playlist.hpp"
#include "menus.hpp" #include "menus.hpp"
#include <QMenuBar> #include <QMenuBar>
#include <QCloseEvent> #include <QCloseEvent>
#include <QPushButton> #include <QPushButton>
...@@ -53,14 +52,6 @@ ...@@ -53,14 +52,6 @@
#include <vlc_keys.h> #include <vlc_keys.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#ifdef WIN32
#define PREF_W 410
#define PREF_H 151
#else
#define PREF_W 400
#define PREF_H 140
#endif
#define SET_WIDTH(i,j) i->widgetSize.setWidth(j) #define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
#define SET_HEIGHT(i,j) i->widgetSize.setHeight(j) #define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
#define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k); #define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
...@@ -99,7 +90,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -99,7 +90,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _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") )
{ {
QList<ConfigControl *> controls; QList<ConfigControl *> controls;
...@@ -150,13 +141,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -150,13 +141,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* Create a Dock to get the playlist */ /* Create a Dock to get the playlist */
dockPL = new QDockWidget( qtr("Playlist"), this ); dockPL = new QDockWidget( qtr("Playlist"), this );
dockPL->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
dockPL->setAllowedAreas( Qt::LeftDockWidgetArea dockPL->setAllowedAreas( Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea | Qt::RightDockWidgetArea
| Qt::BottomDockWidgetArea ); | Qt::BottomDockWidgetArea );
dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
dockPL->setWidget( playlistWidget );
/* Menu Bar */ /************
* Menu Bar
************/
QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled ); QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled );
/**************** /****************
...@@ -286,7 +279,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -286,7 +279,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( dockPL, topLevelChanged( bool ), this, doComponentsUpdate() ); CONNECT( dockPL, topLevelChanged( bool ), this, doComponentsUpdate() );
// DEBUG FIXME // DEBUG FIXME
hide(); hide();
updateGeometry(); updateGeometry();
settings->endGroup();
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
...@@ -300,11 +296,10 @@ MainInterface::~MainInterface() ...@@ -300,11 +296,10 @@ MainInterface::~MainInterface()
var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf ); var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
settings->beginGroup( "MainWindow" );
settings->setValue( "playlist-floats", dockPL->isFloating() ); settings->setValue( "playlist-floats", dockPL->isFloating() );
settings->setValue( "adv-controls", getControlsVisibilityStatus() & CONTROLS_ADVANCED ); settings->setValue( "adv-controls", getControlsVisibilityStatus() & CONTROLS_ADVANCED );
settings->setValue( "pos", pos() ); settings->setValue( "pos", pos() );
if( playlistWidget )
playlistWidget->saveSettings( settings ); playlistWidget->saveSettings( settings );
settings->endGroup(); settings->endGroup();
delete settings; delete settings;
...@@ -336,7 +331,6 @@ void MainInterface::setVLCWindowsTitle( QString aTitle ) ...@@ -336,7 +331,6 @@ void MainInterface::setVLCWindowsTitle( QString aTitle )
} }
} }
void MainInterface::handleMainUi( QSettings *settings ) void MainInterface::handleMainUi( QSettings *settings )
{ {
/* Create the main Widget and the mainLayout */ /* Create the main Widget and the mainLayout */
...@@ -368,12 +362,13 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -368,12 +362,13 @@ void MainInterface::handleMainUi( QSettings *settings )
widgetAction->setDefaultWidget( speedControl ); widgetAction->setDefaultWidget( speedControl );
speedControlMenu->addAction( widgetAction ); speedControlMenu->addAction( widgetAction );
/* Set initial size */
/* Visualisation */ /* Visualisation */
/* Disabled for now, they SUCK */
#if 0
visualSelector = new VisualSelector( p_intf ); visualSelector = new VisualSelector( p_intf );
mainLayout->insertWidget( 0, visualSelector ); mainLayout->insertWidget( 0, visualSelector );
visualSelector->hide(); visualSelector->hide();
#endif
/* And video Outputs */ /* And video Outputs */
if( alwaysVideoFlag ) if( alwaysVideoFlag )
...@@ -400,11 +395,9 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -400,11 +395,9 @@ void MainInterface::handleMainUi( QSettings *settings )
} }
/* Finish the sizing */ /* Finish the sizing */
setMinimumSize( PREF_W, PREF_H );
updateGeometry(); updateGeometry();
} }
void MainInterface::privacyDialog( QList<ConfigControl *> controls ) void MainInterface::privacyDialog( QList<ConfigControl *> controls )
{ {
QDialog *privacy = new QDialog( this ); QDialog *privacy = new QDialog( this );
...@@ -470,19 +463,27 @@ void MainInterface::privacyDialog( QList<ConfigControl *> controls ) ...@@ -470,19 +463,27 @@ void MainInterface::privacyDialog( QList<ConfigControl *> controls )
privacy->exec(); privacy->exec();
} }
//FIXME remove me at the end...
void MainInterface::debug() void MainInterface::debug()
{ {
msg_Dbg( p_intf, "size: %i - %i", controls->size().height(), controls->size().width() ); msg_Dbg( p_intf, "size: %i - %i", controls->size().height(), controls->size().width() );
msg_Dbg( p_intf, "sizeHint: %i - %i", controls->sizeHint().height(), controls->sizeHint().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", controls->sizeHint().height(), controls->sizeHint().width() );
} }
/********************************************************************** /**********************************************************************
* Handling of sizing of the components * Handling of sizing of the components
**********************************************************************/ **********************************************************************/
/* This function is probably wrong, but we don't have many many choices...
Since we can't know from the playlist Widget if we are inside a dock or not,
because the playlist Widget can be called by THEDP, as a separate windows for
the skins.
Maybe the other solution is to redefine the sizeHint() of the playlist and
ask _parent->isFloating()...
If you think this would be better, please FIX it...
*/
QSize MainInterface::sizeHint() const QSize MainInterface::sizeHint() const
{ {
msg_Dbg( p_intf, "Annoying debug to remove, main sizeHint was called %i %i ",
menuBar()->size().height(), menuBar()->size().width() );
QSize tempSize = controls->sizeHint() + QSize tempSize = controls->sizeHint() +
QSize( 100, menuBar()->size().height() + statusBar()->size().height() ); QSize( 100, menuBar()->size().height() + statusBar()->size().height() );
...@@ -498,34 +499,7 @@ QSize MainInterface::sizeHint() const ...@@ -498,34 +499,7 @@ QSize MainInterface::sizeHint() const
} }
#if 0 #if 0
void MainInterface::calculateInterfaceSize() /* This is dead code and need to be removed AT THE END */
{
int width = 0, height = 0;
if( VISIBLE( bgWidget ) )
{
width = bgWidget->widgetSize.width();
height = bgWidget->widgetSize.height();
}
else if( videoIsActive )
{
width = videoWidget->widgetSize.width() ;
height = videoWidget->widgetSize.height();
}
else
{
width = PREF_W - addSize.width();
height = PREF_H - addSize.height();
}
if( !dockPL->isFloating() && dockPL->widget() )
{
width += dockPL->widget()->width();
height += dockPL->widget()->height();
}
if( VISIBLE( visualSelector ) )
height += visualSelector->height();
mainSize = QSize( width + addSize.width(), height + addSize.height() );
}
void MainInterface::resizeEvent( QResizeEvent *e ) void MainInterface::resizeEvent( QResizeEvent *e )
{ {
if( videoWidget ) if( videoWidget )
...@@ -563,8 +537,7 @@ class SetVideoOnTopQtEvent : public QEvent ...@@ -563,8 +537,7 @@ class SetVideoOnTopQtEvent : public QEvent
public: public:
SetVideoOnTopQtEvent( bool _onTop ) : SetVideoOnTopQtEvent( bool _onTop ) :
QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop) QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
{ {}
}
bool OnTop() const bool OnTop() const
{ {
...@@ -575,7 +548,6 @@ private: ...@@ -575,7 +548,6 @@ private:
bool onTop; bool onTop;
}; };
void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
int *pi_y, unsigned int *pi_width, int *pi_y, unsigned int *pi_width,
unsigned int *pi_height ) unsigned int *pi_height )
...@@ -586,7 +558,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, ...@@ -586,7 +558,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
videoIsActive = true; videoIsActive = true;
bool bgWasVisible = false; bool bgWasVisible = false;
/* Did we have a bg */ /* Did we have a bg ? */
if( VISIBLE( bgWidget) ) if( VISIBLE( bgWidget) )
{ {
bgWasVisible = true; bgWasVisible = true;
...@@ -673,7 +645,8 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) ...@@ -673,7 +645,8 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
**/ **/
void MainInterface::togglePlaylist() void MainInterface::togglePlaylist()
{ {
/* If no playlist exist, then create one and attach it to the DockPL*/ /* CREATION
If no playlist exist, then create one and attach it to the DockPL*/
if( !playlistWidget ) if( !playlistWidget )
{ {
msg_Dbg( p_intf, "Creating a new playlist" ); msg_Dbg( p_intf, "Creating a new playlist" );
...@@ -682,17 +655,12 @@ void MainInterface::togglePlaylist() ...@@ -682,17 +655,12 @@ void MainInterface::togglePlaylist()
CONNECT( playlistWidget, artSet( QString ), CONNECT( playlistWidget, artSet( QString ),
bgWidget, setArt(QString) ); bgWidget, setArt(QString) );
//FIXME
/* playlistWidget->widgetSize = settings->value( "playlistSize",
QSize( 650, 310 ) ).toSize();*/
/* Add it to the parent DockWidget */ /* Add it to the parent DockWidget */
dockPL->setWidget( playlistWidget ); dockPL->setWidget( playlistWidget );
/* Add the dock to the main Interface */ /* Add the dock to the main Interface */
addDockWidget( Qt::BottomDockWidgetArea, dockPL ); addDockWidget( Qt::BottomDockWidgetArea, dockPL );
msg_Dbg( p_intf, "Creating a new playlist" );
/* Make the playlist floating is requested. Default is not. */ /* Make the playlist floating is requested. Default is not. */
if( settings->value( "playlist-floats", false ).toBool() ); if( settings->value( "playlist-floats", false ).toBool() );
{ {
...@@ -702,9 +670,9 @@ void MainInterface::togglePlaylist() ...@@ -702,9 +670,9 @@ void MainInterface::togglePlaylist()
} }
else else
{ {
/* toggle the display */ /* toggle the visibility of the playlist */
TOGGLEV( dockPL ); TOGGLEV( dockPL );
resize(sizeHint()); //resize(sizeHint());
} }
#if 0 #if 0
doComponentsUpdate(); doComponentsUpdate();
...@@ -712,36 +680,12 @@ void MainInterface::togglePlaylist() ...@@ -712,36 +680,12 @@ void MainInterface::togglePlaylist()
updateGeometry(); updateGeometry();
} }
/* Function called from the menu to undock the playlist */
void MainInterface::undockPlaylist() void MainInterface::undockPlaylist()
{ {
dockPL->setFloating( true ); dockPL->setFloating( true );
updateGeometry(); updateGeometry();
#if 0
doComponentsUpdate();
#endif
}
#if 0
void MainInterface::visual()
{
if( !VISIBLE( visualSelector) )
{
visualSelector->show();
if( !THEMIM->getIM()->hasVideo() )
{
/* Show the background widget */
}
visualSelectorEnabled = true;
}
else
{
/* Stop any currently running visualization */
visualSelector->hide();
visualSelectorEnabled = false;
}
doComponentsUpdate();
} }
#endif
void MainInterface::toggleMinimalView() void MainInterface::toggleMinimalView()
{ {
...@@ -755,23 +699,44 @@ void MainInterface::toggleMinimalView() ...@@ -755,23 +699,44 @@ void MainInterface::toggleMinimalView()
/* Well, could it, actually ? Probably dangerous ... */ /* Well, could it, actually ? Probably dangerous ... */
void MainInterface::doComponentsUpdate() void MainInterface::doComponentsUpdate()
{ {
msg_Dbg( p_intf, "trying" ); updateGeometry();
resize( sizeHint() );
} }
/* toggling advanced controls buttons */
void MainInterface::toggleAdvanced() void MainInterface::toggleAdvanced()
{ {
controls->toggleAdvanced(); controls->toggleAdvanced();
} }
/* Get the visibility status of the controls (hidden or not, advanced or not) */
int MainInterface::getControlsVisibilityStatus() int MainInterface::getControlsVisibilityStatus()
{ {
return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN ) return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )
+ CONTROLS_ADVANCED * controls->b_advancedVisible ); + CONTROLS_ADVANCED * controls->b_advancedVisible );
} }
#if 0
void MainInterface::visual()
{
if( !VISIBLE( visualSelector) )
{
visualSelector->show();
if( !THEMIM->getIM()->hasVideo() )
{
/* Show the background widget */
}
visualSelectorEnabled = true;
}
else
{
/* Stop any currently running visualization */
visualSelector->hide();
visualSelectorEnabled = false;
}
doComponentsUpdate();
}
#endif
/************************************************************************ /************************************************************************
* Other stuff * Other stuff
************************************************************************/ ************************************************************************/
......
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