Commit 9078322b authored by Jakob Leben's avatar Jakob Leben

Revert "Qt: make ground for proper main interface size management"

This reverts commit 9d9ffe9f.
parent 0b4f577d
...@@ -75,7 +75,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -75,7 +75,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
bgWidget = NULL; bgWidget = NULL;
videoWidget = NULL; videoWidget = NULL;
playlistWidget = NULL; playlistWidget = NULL;
videoRoleWidget = NULL;
#ifndef HAVE_MAEMO #ifndef HAVE_MAEMO
sysTray = NULL; sysTray = NULL;
#endif #endif
...@@ -151,11 +150,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -151,11 +150,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
this, destroyPopupMenu() ); this, destroyPopupMenu() );
minWidthHolder = new QWidget;
minWidthHolder->setMinimumWidth(
__MAX( menuBar()->sizeHint().width() + 30, 400 ) );
mainLayout->addWidget( minWidthHolder );
/********************************* /*********************************
* Create the Systray Management * * Create the Systray Management *
*********************************/ *********************************/
...@@ -250,13 +244,13 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -250,13 +244,13 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* resize to previously saved main window size if appicable */ /* resize to previously saved main window size if appicable */
//FIXME remove. //FIXME remove.
/*if( b_keep_size ) if( b_keep_size )
{ {
if( i_visualmode ) if( i_visualmode )
resize( mainVideoSize ); resize( mainVideoSize );
else else
resize( mainBasedSize ); resize( mainBasedSize );
}*/ }
/* Playlist */ /* Playlist */
int i_plVis = settings->value( "playlist-visible", 0 ).toInt(); int i_plVis = settings->value( "playlist-visible", 0 ).toInt();
...@@ -268,17 +262,19 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -268,17 +262,19 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* Final sizing and showing */ /* Final sizing and showing */
setVisible( !b_hideAfterCreation ); setVisible( !b_hideAfterCreation );
setMinimumWidth( __MAX( controls->sizeHint().width(),
menuBar()->sizeHint().width() ) + 30 );
/* Switch to minimal view if needed, must be called after the show() */ /* Switch to minimal view if needed, must be called after the show() */
if( i_visualmode ) if( i_visualmode )
toggleMinimalView( true ); toggleMinimalView( true );
else
showTab();
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
{ {
/* Unsure we hide the videoWidget before destroying it */ /* Unsure we hide the videoWidget before destroying it */
//showTab( PLAYLIST_TAB ); if( stackCentralOldWidget == playlistWidget )
showBg();
/* Save playlist state */ /* Save playlist state */
if( playlistWidget ) if( playlistWidget )
...@@ -365,12 +361,11 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -365,12 +361,11 @@ void MainInterface::createMainWidget( QSettings *settings )
mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 ); mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 );
/* */ /* */
stackCentralW = new QVLCStackedWidget( main ); stackCentralW = new QStackedWidget( main );
/* Bg Cone */ /* Bg Cone */
bgWidget = new BackgroundWidget( p_intf ); bgWidget = new BackgroundWidget( p_intf );
stackCentralW->addWidget( bgWidget ); stackCentralW->addWidget( bgWidget );
videoRoleWidget = bgWidget;
/* And video Outputs */ /* And video Outputs */
if( b_videoEmbedded ) if( b_videoEmbedded )
...@@ -383,7 +378,6 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -383,7 +378,6 @@ void MainInterface::createMainWidget( QSettings *settings )
/* Create the CONTROLS Widget */ /* Create the CONTROLS Widget */
controls = new ControlsWidget( p_intf, controls = new ControlsWidget( p_intf,
settings->value( "adv-controls", false ).toBool(), this ); settings->value( "adv-controls", false ).toBool(), this );
CONNECT( controls, advancedControlsToggled( bool ), CONNECT( controls, advancedControlsToggled( bool ),
this, adaptGeometry() ); this, adaptGeometry() );
CONNECT( controls, sizeChanged(), CONNECT( controls, sizeChanged(),
...@@ -487,7 +481,7 @@ inline void MainInterface::createStatusBar() ...@@ -487,7 +481,7 @@ inline void MainInterface::createStatusBar()
*/ */
void MainInterface::adaptGeometry() void MainInterface::adaptGeometry()
{ {
//resize( sizeHint() ); resize( sizeHint() );
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
debug(); debug();
...@@ -507,40 +501,36 @@ void MainInterface::debug() ...@@ -507,40 +501,36 @@ void MainInterface::debug()
#endif #endif
} }
inline void MainInterface::showTab( StackTab tab ) inline void MainInterface::showVideo() { showTab( videoWidget ); }
inline void MainInterface::showBg() { showTab( bgWidget ); }
inline void MainInterface::showTab( QWidget *widget )
{ {
if( tab == PLAYLIST_TAB && !b_plDocked ) return; #ifdef DEBUG_INTF
msg_Warn( p_intf, "Old stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
#endif
stackCentralOldWidget = stackCentralW->currentWidget();
stackCentralW->setCurrentWidget( widget );
QWidget *widget; #ifdef DEBUG_INTF
switch ( tab ) msg_Warn( p_intf, "State change %i", stackCentralW->currentIndex() );
{ msg_Warn( p_intf, "New stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
case PLAYLIST_TAB: widget = playlistWidget; break; #endif
case VIDEO_TAB: widget = videoRoleWidget; break; }
case CURRENT_TAB: widget = stackCentralW->currentWidget(); break;
}
stackCentralW->setCurrentWidget( widget ); inline void MainInterface::restoreStackOldWidget()
{
#ifdef DEBUG_INTF
msg_Warn( p_intf, "New stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
#endif
QWidget *wTemp = stackCentralW->currentWidget();
// Go into compact mode if needed (stackCentralW hidden) stackCentralW->setCurrentWidget( stackCentralOldWidget );
if( widget == bgWidget && !b_keep_size && controls->isVisible() && !isFullScreen() )
{
resize( 0, 0 );
}
/* TODO Alternatively, for compact mode the best thing would be to setSizeConstraint stackCentralOldWidget = wTemp;
on layout, but sadly, we can only constrain the whole size, while we should #ifdef DEBUG_INTF
constrain height only */ msg_Warn( p_intf, "Debug %i %i",stackCentralW->indexOf( wTemp ), stackCentralW->indexOf( stackCentralW->currentWidget() ) );
/*if( widget == bgWidget && !b_keep_size && controls->isVisible() && !isFullScreen() ) #endif
{
stackCentralW->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
}
else
{
layout()->setSizeConstraint( QLayout::SetDefaultConstraint );
setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
stackCentralW->show();
}*/
} }
void MainInterface::destroyPopupMenu() void MainInterface::destroyPopupMenu()
...@@ -612,9 +602,8 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y, ...@@ -612,9 +602,8 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
/* ask videoWidget to show */ /* ask videoWidget to show */
videoWidget->SetSizing( *pi_width, *pi_height ); videoWidget->SetSizing( *pi_width, *pi_height );
videoRoleWidget = videoWidget;
/* Consider the video active now */ /* Consider the video active now */
showTab( VIDEO_TAB ); showVideo();
} }
} }
...@@ -627,11 +616,12 @@ void MainInterface::releaseVideo( void ) ...@@ -627,11 +616,12 @@ void MainInterface::releaseVideo( void )
/* Function that is CONNECTED to the previous emit */ /* Function that is CONNECTED to the previous emit */
void MainInterface::releaseVideoSlot( void ) void MainInterface::releaseVideoSlot( void )
{ {
videoRoleWidget = bgWidget; videoWidget->release();
showTab( b_plDocked && playlistVisible ? PLAYLIST_TAB : VIDEO_TAB ); restoreStackOldWidget();
videoWidget->release(); /* We don't want to have a blank video to popup */
stackCentralOldWidget = bgWidget;
} }
/* Asynchronous call from WindowControl function */ /* Asynchronous call from WindowControl function */
...@@ -697,8 +687,19 @@ void MainInterface::togglePlaylist() ...@@ -697,8 +687,19 @@ void MainInterface::togglePlaylist()
if( b_plDocked ) if( b_plDocked )
{ {
showTab( stackCentralW->currentWidget() != playlistWidget ? /* Playlist is not visible, show it */
PLAYLIST_TAB : VIDEO_TAB ); if( stackCentralW->currentWidget() != playlistWidget )
{
playlistWidget->forceShow();
showTab( playlistWidget );
}
else /* Hide it! */
{
restoreStackOldWidget();
stackCentralW->updateGeometry();
// HACK: So it doesn't limit the stackWidget minimumSize
playlistWidget->forceHide();
}
playlistVisible = ( stackCentralW->currentWidget() == playlistWidget ); playlistVisible = ( stackCentralW->currentWidget() == playlistWidget );
} }
else else
...@@ -718,21 +719,20 @@ void MainInterface::dockPlaylist( bool p_docked ) ...@@ -718,21 +719,20 @@ void MainInterface::dockPlaylist( bool p_docked )
if( !playlistWidget ) return; /* Playlist wasn't created yet */ if( !playlistWidget ) return; /* Playlist wasn't created yet */
if( !p_docked ) if( !p_docked )
{ {
showTab( VIDEO_TAB );
stackCentralW->removeWidget( playlistWidget ); stackCentralW->removeWidget( playlistWidget );
playlistWidget->setWindowFlags( Qt::Window ); playlistWidget->setWindowFlags( Qt::Window );
QVLCTools::restoreWidgetPosition( p_intf, "Playlist", QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
playlistWidget, QSize( 600, 300 ) ); playlistWidget, QSize( 600, 300 ) );
playlistWidget->show(); playlistWidget->show();
restoreStackOldWidget();
} }
else else
{ {
playlistWidget->setWindowFlags( Qt::Widget ); // Probably a Qt bug here playlistWidget->setWindowFlags( Qt::Widget ); // Probably a Qt bug here
// It would be logical that QStackWidget::addWidget reset the flags... // It would be logical that QStackWidget::addWidget reset the flags...
stackCentralW->addWidget( playlistWidget ); stackCentralW->addWidget( playlistWidget );
showTab( PLAYLIST_TAB ); stackCentralW->setCurrentWidget( playlistWidget );
} }
playlistVisible = true;
} }
/* /*
...@@ -740,14 +740,30 @@ void MainInterface::dockPlaylist( bool p_docked ) ...@@ -740,14 +740,30 @@ void MainInterface::dockPlaylist( bool p_docked )
*/ */
void MainInterface::toggleMinimalView( bool b_switch ) void MainInterface::toggleMinimalView( bool b_switch )
{ {
if( i_visualmode == 0 )
{ /* NORMAL MODE then */
if( !videoWidget || stackCentralW->currentWidget() != videoWidget )
{
showBg();
}
else
{
/* If video is visible, then toggle the status of bgWidget */
//FIXME
//bgWasVisible = !bgWasVisible;
/* if( stackCentralOldState == BACK G_TAB )
stackCentralOldState = HID DEN_TAB;
else
stackCentralOldState = BACK G_TAB;
*/
}
}
menuBar()->setVisible( !b_switch ); menuBar()->setVisible( !b_switch );
controls->setVisible( !b_switch ); controls->setVisible( !b_switch );
statusBar()->setVisible( !b_switch ); statusBar()->setVisible( !b_switch );
inputC->setVisible( !b_switch ); inputC->setVisible( !b_switch );
minWidthHolder->setVisible( !b_switch );
// Go to compact mode and back if needed
showTab();
emit minimalViewToggled( b_switch ); emit minimalViewToggled( b_switch );
} }
...@@ -1143,7 +1159,6 @@ void MainInterface::toggleFullScreen() ...@@ -1143,7 +1159,6 @@ void MainInterface::toggleFullScreen()
showFullScreen(); showFullScreen();
emit fullscreenInterfaceToggled( true ); emit fullscreenInterfaceToggled( true );
} }
showTab();
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -114,13 +114,10 @@ private: ...@@ -114,13 +114,10 @@ private:
void handleSystray(); void handleSystray();
/* Central StackWidget Management */ /* Central StackWidget Management */
enum StackTab void showTab( QWidget *);
{ void showVideo();
PLAYLIST_TAB, void showBg();
VIDEO_TAB, void restoreStackOldWidget();
CURRENT_TAB
};
void showTab( StackTab = CURRENT_TAB );
/* */ /* */
QSettings *settings; QSettings *settings;
...@@ -141,14 +138,15 @@ private: ...@@ -141,14 +138,15 @@ private:
VideoWidget *videoWidget; VideoWidget *videoWidget;
BackgroundWidget *bgWidget; BackgroundWidget *bgWidget;
PlaylistWidget *playlistWidget; PlaylistWidget *playlistWidget;
QWidget *videoRoleWidget;
//VisualSelector *visualSelector; //VisualSelector *visualSelector;
QWidget *minWidthHolder;
/* Status Bar */ /* Status Bar */
QLabel *nameLabel; QLabel *nameLabel;
QLabel *cryptedLabel; QLabel *cryptedLabel;
/* Status and flags */
QWidget *stackCentralOldWidget;
/* Flags */ /* Flags */
bool b_notificationEnabled; /// Systray Notifications bool b_notificationEnabled; /// Systray Notifications
bool b_keep_size; ///< persistent resizeable window bool b_keep_size; ///< persistent resizeable window
...@@ -228,14 +226,4 @@ signals: ...@@ -228,14 +226,4 @@ signals:
}; };
class QVLCStackedWidget : public QStackedWidget
{
public:
QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
virtual QSize minimumSizeHint () const
{
return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
}
};
#endif #endif
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