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

Qt: Fixing main Interface, phase 1.

Removes a lot of hacks, especially around manipulating size (no more sizeHint(), very limited use of doComponentsUpdate and updateGeometry() ),
Simplify the number of starting options of the interface
Fixes crashes due to QStackWidget limitations
Still a lot of debug around, but mostly commented out, that will go in future commits
Close #3401
Close #3210
Close #3332
Close #1717
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b20a3618
...@@ -314,6 +314,9 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) ...@@ -314,6 +314,9 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
CONNECT( THEMIM->getIM(), artChanged( QString ), CONNECT( THEMIM->getIM(), artChanged( QString ),
this, updateArt( const QString& ) ); this, updateArt( const QString& ) );
/* Start Hidden */
label->hide();
} }
void BackgroundWidget::resizeEvent( QResizeEvent * event ) void BackgroundWidget::resizeEvent( QResizeEvent * event )
......
/***************************************************************************** /*****************************************************************************
* playlist.cpp : Custom widgets for the playlist * playlist.cpp : Custom widgets for the playlist
**************************************************************************** ****************************************************************************
* Copyright © 2007-2008 the VideoLAN team * Copyright © 2007-2010 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
...@@ -117,7 +117,6 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) ...@@ -117,7 +117,6 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
/* In case we want to keep the splitter informations */ /* In case we want to keep the splitter informations */
// components shall never write there setting to a fixed location, may infer // components shall never write there setting to a fixed location, may infer
// with other uses of the same component... // with other uses of the same component...
// getSettings()->beginGroup( "playlist" );
getSettings()->beginGroup("Playlist"); getSettings()->beginGroup("Playlist");
restoreState( getSettings()->value("splitterSizes").toByteArray()); restoreState( getSettings()->value("splitterSizes").toByteArray());
leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() ); leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() );
...@@ -161,3 +160,17 @@ void PlaylistWidget::closeEvent( QCloseEvent *event ) ...@@ -161,3 +160,17 @@ void PlaylistWidget::closeEvent( QCloseEvent *event )
event->ignore(); event->ignore();
} }
} }
void PlaylistWidget::forceHide()
{
leftSplitter->hide();
rightPanel->hide();
updateGeometry();
}
void PlaylistWidget::forceShow()
{
leftSplitter->show();
rightPanel->show();
updateGeometry();
}
...@@ -46,7 +46,7 @@ class ArtLabel : public CoverArtLabel ...@@ -46,7 +46,7 @@ class ArtLabel : public CoverArtLabel
{ {
public: public:
ArtLabel( QWidget *parent, intf_thread_t *intf ) ArtLabel( QWidget *parent, intf_thread_t *intf )
: CoverArtLabel( parent, intf ) {}; : CoverArtLabel( parent, intf ) {}
virtual void mouseDoubleClickEvent( QMouseEvent *event ) virtual void mouseDoubleClickEvent( QMouseEvent *event )
{ {
...@@ -61,6 +61,8 @@ class PlaylistWidget : public QSplitter ...@@ -61,6 +61,8 @@ class PlaylistWidget : public QSplitter
public: public:
PlaylistWidget( intf_thread_t *_p_i, QWidget * ); PlaylistWidget( intf_thread_t *_p_i, QWidget * );
virtual ~PlaylistWidget(); virtual ~PlaylistWidget();
void forceHide();
void forceShow();
private: private:
PLSelector *selector; PLSelector *selector;
ArtLabel *art; ArtLabel *art;
...@@ -72,6 +74,7 @@ protected: ...@@ -72,6 +74,7 @@ protected:
virtual void dropEvent( QDropEvent *); virtual void dropEvent( QDropEvent *);
virtual void dragEnterEvent( QDragEnterEvent * ); virtual void dragEnterEvent( QDragEnterEvent * );
virtual void closeEvent( QCloseEvent * ); virtual void closeEvent( QCloseEvent * );
}; };
#endif #endif
...@@ -19,10 +19,13 @@ ...@@ -19,10 +19,13 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software Foundation, Inc.,
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/* TODO:
- playlist minimumSize applies to all stackWidgets
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
...@@ -30,21 +33,20 @@ ...@@ -30,21 +33,20 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include "input_manager.hpp" #include "input_manager.hpp" // Creation
#include "actions_manager.hpp" #include "actions_manager.hpp" // killInstance
#include "extensions_manager.hpp" // killInstance #include "extensions_manager.hpp" // killInstance
#include "util/customwidgets.hpp" #include "util/customwidgets.hpp" // qtEventToVLCKey
#include "util/qt_dirs.hpp" #include "util/qt_dirs.hpp" // toNativeSeparators
#include "components/interface_widgets.hpp" #include "components/interface_widgets.hpp" // bgWidget, videoWidget
#include "components/controller.hpp" #include "components/controller.hpp" // controllers
#include "components/playlist/playlist.hpp" #include "components/playlist/playlist.hpp" // plWidget
#include "dialogs/external.hpp" #include "dialogs/firstrun.hpp" // First Run
#include "dialogs/firstrun.hpp"
#include "menus.hpp" #include "menus.hpp" // Menu creation
#include "recents.hpp" #include "recents.hpp" // RecentItems when DnD
#include <QCloseEvent> #include <QCloseEvent>
#include <QKeyEvent> #include <QKeyEvent>
...@@ -57,22 +59,17 @@ ...@@ -57,22 +59,17 @@
#include <QMenuBar> #include <QMenuBar>
#include <QStatusBar> #include <QStatusBar>
#include <QLabel> #include <QLabel>
#include <QGroupBox>
#include <QPushButton>
#include <QStackedWidget> #include <QStackedWidget>
#ifdef WIN32 #include <vlc_keys.h> /* Wheel event */
#include <vlc_vout_display.h> /* vout_thread_t and VOUT_ events */
#ifdef WIN32 /* Win7 taskbar */
#include <vlc_windows_interfaces.h> #include <vlc_windows_interfaces.h>
#include <QBitmap> #include <QBitmap>
#endif #endif
#include <assert.h> // #define DEBUG_INTF
#include <vlc_keys.h> /* Wheel event */
#include <vlc_vout_window.h>
#include <vlc_vout_display.h>
//#define DEBUG_INTF
/* Callback prototypes */ /* Callback prototypes */
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
...@@ -121,7 +118,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -121,7 +118,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
b_keep_size = !var_InheritBool( p_intf, "qt-video-autoresize" ); b_keep_size = !var_InheritBool( p_intf, "qt-video-autoresize" );
/* Are we in the enhanced always-video mode or not ? */ /* Are we in the enhanced always-video mode or not ? */
i_visualmode = var_InheritInteger( p_intf, "qt-display-mode" ); i_visualmode = var_InheritInteger( p_intf, "qt-minimal-view" );
/* Do we want anoying popups or not */ /* Do we want anoying popups or not */
b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" ); b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" );
...@@ -238,7 +235,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -238,7 +235,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( this, askUpdate(), this, doComponentsUpdate() ); CONNECT( this, askUpdate(), this, doComponentsUpdate() );
CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() ); CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
/* Enable the popup menu in the MI */ /* Enable the popup menu in the MI */
setContextMenuPolicy( Qt::CustomContextMenu ); setContextMenuPolicy( Qt::CustomContextMenu );
CONNECT( this, customContextMenuRequested( const QPoint& ), CONNECT( this, customContextMenuRequested( const QPoint& ),
this, popupMenu( const QPoint& ) ); this, popupMenu( const QPoint& ) );
...@@ -257,24 +254,18 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -257,24 +254,18 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/**** FINAL SIZING and placement of interface */ /**** FINAL SIZING and placement of interface */
settings->beginGroup( "MainWindow" ); settings->beginGroup( "MainWindow" );
QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) ); QVLCTools::restoreWidgetPosition( settings, this, QSize(400, 100) );
/* resize to previously saved main window size if appicable */ /* resize to previously saved main window size if appicable */
//FIXME remove.
if( b_keep_size ) if( b_keep_size )
{ {
if( i_visualmode == QT_ALWAYS_VIDEO_MODE || if( i_visualmode )
i_visualmode == QT_MINIMAL_MODE )
{
resize( mainVideoSize ); resize( mainVideoSize );
}
else else
{
resize( mainBasedSize ); resize( mainBasedSize );
}
} }
msg_Dbg( p_intf, "%i", stackCentralOldState );
/* Playlist */ /* Playlist */
int i_plVis = settings->value( "playlist-visible", 0 ).toInt(); int i_plVis = settings->value( "playlist-visible", 0 ).toInt();
...@@ -284,26 +275,19 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -284,26 +275,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 );
//setMinimumSize( QSize( 0, 0 ) );
// setMinimumWidth( __MAX( controls->sizeHint().width(),
// menuBar()->sizeHint().width() ) );
debug(); setMinimumWidth( __MAX( controls->sizeHint().width(),
/* And switch to minimal view if needed menuBar()->sizeHint().width() ) + 30 );
Must be called after the show() */
if( i_visualmode == QT_MINIMAL_MODE )
toggleMinimalView( true );
/* Update the geometry : It is useful if you switch between /* Switch to minimal view if needed, must be called after the show() */
qt-display-modes */ if( i_visualmode )
updateGeometry(); toggleMinimalView( true );
resize( sizeHint() );
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
{ {
/* Unsure we hide the videoWidget before destroying it */ /* Unsure we hide the videoWidget before destroying it */
if( stackCentralOldState == VIDEO_TAB ) if( stackCentralOldWidget == playlistWidget )
showBg(); showBg();
/* Save playlist state */ /* Save playlist state */
...@@ -388,8 +372,6 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -388,8 +372,6 @@ void MainInterface::createMainWidget( QSettings *settings )
QWidget *main = new QWidget; QWidget *main = new QWidget;
setCentralWidget( main ); setCentralWidget( main );
mainLayout = new QVBoxLayout( main ); mainLayout = new QVBoxLayout( main );
/* Margins, spacing */
main->setContentsMargins( 0, 0, 0, 0 ); main->setContentsMargins( 0, 0, 0, 0 );
mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 ); mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 );
...@@ -398,20 +380,15 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -398,20 +380,15 @@ void MainInterface::createMainWidget( QSettings *settings )
/* Bg Cone */ /* Bg Cone */
bgWidget = new BackgroundWidget( p_intf ); bgWidget = new BackgroundWidget( p_intf );
bgWidget->resize( stackCentralW->addWidget( bgWidget );
settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() );
bgWidget->updateGeometry();
stackCentralW->insertWidget( BACKG_TAB, bgWidget );
/* And video Outputs */ /* And video Outputs */
if( b_videoEmbedded ) if( b_videoEmbedded )
{ {
videoWidget = new VideoWidget( p_intf ); videoWidget = new VideoWidget( p_intf );
stackCentralW->insertWidget( VIDEO_TAB, videoWidget ); stackCentralW->addWidget( videoWidget );
} }
mainLayout->insertWidget( 1, stackCentralW, 100 ); mainLayout->insertWidget( 1, stackCentralW );
/* Create the CONTROLS Widget */ /* Create the CONTROLS Widget */
controls = new ControlsWidget( p_intf, controls = new ControlsWidget( p_intf,
...@@ -422,46 +399,27 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -422,46 +399,27 @@ void MainInterface::createMainWidget( QSettings *settings )
this, doComponentsUpdate() ); this, doComponentsUpdate() );
inputC = new InputControlsWidget( p_intf, this ); inputC = new InputControlsWidget( p_intf, this );
if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
i_visualmode != QT_MINIMAL_MODE )
{
hideStackWidget();
stackCentralOldState = HIDDEN_TAB;
}
else
{
showTab( BACKG_TAB );
stackCentralOldState = BACKG_TAB;
}
//mainLayout->setRowStretch( 1, 10 );
mainLayout->insertWidget( 2, inputC ); mainLayout->insertWidget( 2, inputC );
mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3, mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
controls ); controls );
/* Visualisation */ /* Visualisation, disabled for now, they SUCK */
/* Disabled for now, they SUCK */
#if 0 #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 #endif
/* Finish the sizing */
main->updateGeometry();
getSettings()->endGroup(); getSettings()->endGroup();
#ifdef WIN32
if ( depth() > 8 ) if ( depth() > 8 ) /* 8bit depth has too many issues with opacity */
#endif /* Create the FULLSCREEN CONTROLS Widget */
/* Create the FULLSCREEN CONTROLS Widget */ if( var_InheritBool( p_intf, "qt-fs-controller" ) )
if( var_InheritBool( p_intf, "qt-fs-controller" ) ) {
{ fullscreenControls = new FullscreenControllerWidget( p_intf, this );
fullscreenControls = new FullscreenControllerWidget( p_intf, this ); CONNECT( fullscreenControls, keyPressed( QKeyEvent * ),
CONNECT( fullscreenControls, keyPressed( QKeyEvent * ), this, handleKeyPress( QKeyEvent * ) );
this, handleKeyPress( QKeyEvent * ) ); }
}
} }
inline void MainInterface::initSystray() inline void MainInterface::initSystray()
...@@ -519,8 +477,8 @@ inline void MainInterface::createStatusBar() ...@@ -519,8 +477,8 @@ inline void MainInterface::createStatusBar()
CONNECT( THEMIM->getIM(), encryptionChanged( bool ), CONNECT( THEMIM->getIM(), encryptionChanged( bool ),
this, showCryptedLabel( bool ) ); this, showCryptedLabel( bool ) );
connect( THEMIM->getIM(), SIGNAL(seekRequested(float)), CONNECT( THEMIM->getIM(), seekRequested( float ),
timeLabel, SLOT(setDisplayPosition(float)) ); timeLabel, setDisplayPosition( float ) );
} }
#ifdef WIN32 #ifdef WIN32
...@@ -687,14 +645,14 @@ bool MainInterface::winEvent ( MSG * msg, long * result ) ...@@ -687,14 +645,14 @@ bool MainInterface::winEvent ( MSG * msg, long * result )
ask _parent->isFloating()... ask _parent->isFloating()...
If you think this would be better, please FIXME it... If you think this would be better, please FIXME it...
*/ */
#if 0
QSize MainInterface::sizeHint() const QSize MainInterface::sizeHint() const
{ {
#if 0 #if 0
if( b_keep_size ) if( b_keep_size )
{ {
if( i_visualmode == QT_ALWAYS_VIDEO_MODE || if( i_visualmode )
i_visualmode == QT_MINIMAL_MODE )
{ {
return mainVideoSize; return mainVideoSize;
} }
...@@ -720,11 +678,11 @@ QSize MainInterface::sizeHint() const ...@@ -720,11 +678,11 @@ QSize MainInterface::sizeHint() const
+ statusBar()->size().height() + statusBar()->size().height()
: 0 ; : 0 ;
if( stackCentralW->isVisible() ) /* if( stackCentralW->isVisible() )
{ {
nheight += stackCentralW->height(); nheight += stackCentralW->height();
nwidth = __MAX( nwidth, stackCentralW->width() ); nwidth = __MAX( nwidth, stackCentralW->width() );
} }*/
/* if( VISIBLE( bgWidget ) ) /* if( VISIBLE( bgWidget ) )
{ {
...@@ -751,7 +709,7 @@ QSize MainInterface::sizeHint() const ...@@ -751,7 +709,7 @@ QSize MainInterface::sizeHint() const
#endif #endif
return QSize( nwidth, nheight ); return QSize( nwidth, nheight );
} }
#endif
/* 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 ... */
...@@ -774,7 +732,7 @@ void MainInterface::doComponentsUpdate() ...@@ -774,7 +732,7 @@ void MainInterface::doComponentsUpdate()
#endif #endif
/* This is WRONG, but I believe there is a Qt bug here */ /* This is WRONG, but I believe there is a Qt bug here */
setMinimumSize( 0, 0 ); setMinimumSize( 0, 0 );
resize( sizeHint() ); //resize( sizeHint() );
//adjustSize() ; /* This is not needed, but might help in the future */ //adjustSize() ; /* This is not needed, but might help in the future */
} }
...@@ -783,10 +741,10 @@ void MainInterface::debug() ...@@ -783,10 +741,10 @@ void MainInterface::debug()
{ {
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->size().height(), size().width() ); msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->size().height(), size().width() );
if( b_videoEmbedded ) if( videoWidget )
msg_Dbg( p_intf, "Stack Size: %i - %i", msg_Dbg( p_intf, "Stack Size: %i - %i",
stackCentralW->widget( VIDEO_TAB )->size().height(), videoWidget->size().height(),
stackCentralW->widget( VIDEO_TAB )->size().width() ); videoWidget->size().width() );
else else
msg_Dbg( p_intf, "no embedded video" ); msg_Dbg( p_intf, "no embedded video" );
...@@ -794,13 +752,15 @@ void MainInterface::debug() ...@@ -794,13 +752,15 @@ void MainInterface::debug()
msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
//msg_Dbg( p_intf, "maximumsize: %i - %i", maximumSize().height(), maximumSize().width() ); //msg_Dbg( p_intf, "maximumsize: %i - %i", maximumSize().height(), maximumSize().width() );
msg_Dbg( p_intf, "Stack minimumsize: %i - %i", stackCentralW->minimumSize().height(), stackCentralW->minimumSize().width() ); msg_Dbg( p_intf, "Stack size: %i - %i", stackCentralW->size().height(), stackCentralW->size().width() );
msg_Dbg( p_intf, "Controls minimumsize: %i - %i", controls->minimumSize().height(), controls->minimumSize().width() ); msg_Dbg( p_intf, "Stack minimumSize(): %i - %i", stackCentralW->minimumHeight(), stackCentralW->minimumWidth() );
msg_Dbg( p_intf, "Central minimumsize: %i - %i", centralWidget()->minimumSize().height(), centralWidget()->minimumSize().width() ); msg_Dbg( p_intf, "Central minimumsize: %i - %i", centralWidget()->minimumSize().height(), centralWidget()->minimumSize().width() );
msg_Dbg( p_intf, "Central size: %i - %i", centralWidget()->size().height(), centralWidget()->size().width() );
msg_Dbg( p_intf, "Menu minimumsize: %i - %i", menuBar()->minimumSize().height(), menuBar()->minimumSize().width() ); msg_Dbg( p_intf, "Menu minimumsize: %i - %i", menuBar()->minimumSize().height(), menuBar()->minimumSize().width() );
msg_Dbg( p_intf, "Input minimuSize: %i - %i", inputC->minimumSize().height(), inputC->minimumSize().width() ); msg_Dbg( p_intf, "Input size: %i - %i", inputC->size().height(), inputC->size().width() );
msg_Dbg( p_intf, "Status minimumsize: %i - %i", statusBar()->minimumSize().height(), statusBar()->minimumSize().width() ); msg_Dbg( p_intf, "Status minimumsize: %i - %i", statusBar()->minimumSize().height(), statusBar()->minimumSize().width() );
msg_Dbg( p_intf, "minimumsize: %i - %i", minimumSize().height(), minimumSize().width() ); msg_Dbg( p_intf, "minimumsize: %i - %i", minimumSize().height(), minimumSize().width() );
msg_Dbg( p_intf, "bg Size: %i - %i", bgWidget->size().height(), bgWidget->size().width() );
/*if( videoWidget && videoWidget->isVisible() ) /*if( videoWidget && videoWidget->isVisible() )
{ {
...@@ -810,50 +770,35 @@ void MainInterface::debug() ...@@ -810,50 +770,35 @@ void MainInterface::debug()
#endif #endif
} }
inline void MainInterface::showTab( int i_tab ) inline void MainInterface::showVideo() { showTab( videoWidget ); }
inline void MainInterface::showBg() { showTab( bgWidget ); }
inline void MainInterface::showTab( QWidget *widget )
{ {
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Err( p_intf, "showTab %i", i_tab ); msg_Warn( p_intf, "Old stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
msg_Warn( p_intf, "Old stackCentralOldState %i", stackCentralOldState );
#endif
stackCentralOldState = stackCentralW->isVisible() ? stackCentralW->currentIndex()
: HIDDEN_TAB;
#ifdef DEBUG_INTF
msg_Warn( p_intf, "State change %i %i", stackCentralW->currentIndex(), i_tab );
#endif #endif
stackCentralOldWidget = stackCentralW->currentWidget();
if( i_visualmode == QT_NORMAL_MODE ) stackCentralW->setCurrentWidget( widget );
{
stackCentralW->setVisible( i_tab != HIDDEN_TAB );
doComponentsUpdate(); // resize the player
}
else
if( i_tab == HIDDEN_TAB ) i_tab = BACKG_TAB;
stackCentralW->setCurrentIndex( i_tab );
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "New stackCentralOldState %i", stackCentralOldState ); msg_Warn( p_intf, "State change %i", stackCentralW->currentIndex() );
msg_Warn( p_intf, "New stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
#endif #endif
} }
inline void MainInterface::restoreStackOldWidget() inline void MainInterface::restoreStackOldWidget()
{ {
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Old stackCentralOldState %i", stackCentralOldState ); msg_Warn( p_intf, "New stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
#endif #endif
int temp = stackCentralW->isVisible() ? stackCentralW->currentIndex() QWidget *wTemp = stackCentralW->currentWidget();
: HIDDEN_TAB;
stackCentralW->setCurrentIndex( stackCentralOldState );
if( i_visualmode == QT_NORMAL_MODE )
{
stackCentralW->setVisible( stackCentralOldState != HIDDEN_TAB );
doComponentsUpdate(); // resize the player
}
stackCentralOldState = temp; stackCentralW->setCurrentWidget( stackCentralOldWidget );
stackCentralOldWidget = wTemp;
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Debug %i %i", temp, stackCentralW->currentIndex() ); msg_Warn( p_intf, "Debug %i %i",stackCentralW->indexOf( wTemp ), stackCentralW->indexOf( stackCentralW->currentWidget() ) );
#endif #endif
} }
...@@ -955,6 +900,9 @@ void MainInterface::releaseVideoSlot( void ) ...@@ -955,6 +900,9 @@ void MainInterface::releaseVideoSlot( void )
restoreStackOldWidget(); restoreStackOldWidget();
/* We don't want to have a blank video to popup */
stackCentralOldWidget = bgWidget;
/* Try to resize, except when you are in Fullscreen mode */ /* Try to resize, except when you are in Fullscreen mode */
// doComponentsUpdate(); // doComponentsUpdate();
} }
...@@ -1017,7 +965,7 @@ void MainInterface::createPlaylist() ...@@ -1017,7 +965,7 @@ void MainInterface::createPlaylist()
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Here 1 %i", stackCentralW->currentIndex() ); msg_Warn( p_intf, "Here 1 %i", stackCentralW->currentIndex() );
#endif #endif
stackCentralW->insertWidget( PLAYL_TAB, playlistWidget ); stackCentralW->addWidget( playlistWidget );
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Here 2 %i", stackCentralW->currentIndex() ); msg_Warn( p_intf, "Here 2 %i", stackCentralW->currentIndex() );
#endif #endif
...@@ -1026,30 +974,25 @@ void MainInterface::createPlaylist() ...@@ -1026,30 +974,25 @@ void MainInterface::createPlaylist()
void MainInterface::togglePlaylist() void MainInterface::togglePlaylist()
{ {
#ifdef DEBUG_INTF
msg_Warn( p_intf, "Here toggling 1 %i %i", stackCentralW->currentIndex(), stackCentralOldState );
#endif
if( !playlistWidget ) if( !playlistWidget )
createPlaylist(); createPlaylist();
#ifdef DEBUG_INTF
msg_Warn( p_intf, "Here toggling 2 %i %i", stackCentralW->currentIndex(), stackCentralOldState );
#endif
if( b_plDocked ) if( b_plDocked )
{ {
/* Playlist not visible */ /* Playlist is not visible, show it */
if( stackCentralW->currentIndex() != PLAYL_TAB ) if( stackCentralW->currentWidget() != playlistWidget )
{ {
showTab( PLAYL_TAB ); playlistWidget->forceShow();
stackCentralW->show(); showTab( playlistWidget );
} }
else else /* Hide it! */
{ {
restoreStackOldWidget(); restoreStackOldWidget();
stackCentralW->updateGeometry();
// HACK: So it doesn't limit the stackWidget minimumSize
playlistWidget->forceHide();
} }
playlistVisible = ( stackCentralW->currentIndex() == PLAYL_TAB ); playlistVisible = ( stackCentralW->currentWidget() == playlistWidget );
//doComponentsUpdate(); //resize( sizeHint() );
} }
else else
{ {
...@@ -1057,11 +1000,14 @@ void MainInterface::togglePlaylist() ...@@ -1057,11 +1000,14 @@ void MainInterface::togglePlaylist()
playlistVisible = !playlistVisible; playlistVisible = !playlistVisible;
playlistWidget->setVisible( playlistVisible ); playlistWidget->setVisible( playlistVisible );
} }
debug();
} }
void MainInterface::dockPlaylist( bool p_docked ) void MainInterface::dockPlaylist( bool p_docked )
{ {
if( b_plDocked == p_docked ) return;
b_plDocked = p_docked; b_plDocked = p_docked;
if( !playlistWidget ) return; /* Playlist wasn't created yet */ if( !playlistWidget ) return; /* Playlist wasn't created yet */
if( !p_docked ) if( !p_docked )
{ {
...@@ -1070,41 +1016,36 @@ void MainInterface::dockPlaylist( bool p_docked ) ...@@ -1070,41 +1016,36 @@ void MainInterface::dockPlaylist( bool p_docked )
QVLCTools::restoreWidgetPosition( p_intf, "Playlist", QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
playlistWidget, QSize( 600, 300 ) ); playlistWidget, QSize( 600, 300 ) );
playlistWidget->show(); playlistWidget->show();
stackCentralW->hide(); restoreStackOldWidget();
doComponentsUpdate();
} }
else else
{ {
stackCentralW->insertWidget( PLAYL_TAB, playlistWidget ); playlistWidget->setWindowFlags( Qt::Widget ); // Probably a Qt bug here
// It would be logical that QStackWidget::addWidget reset the flags...
stackCentralW->addWidget( playlistWidget );
stackCentralW->setCurrentWidget( playlistWidget ); stackCentralW->setCurrentWidget( playlistWidget );
stackCentralW->show();
} }
} }
/* Function called from the menu to undock the playlist */
void MainInterface::undockPlaylist()
{
dockPlaylist( false );
}
void MainInterface::toggleMinimalView( bool b_switch ) void MainInterface::toggleMinimalView( bool b_switch )
{ {
if( i_visualmode != QT_ALWAYS_VIDEO_MODE && if( i_visualmode == 0 )
i_visualmode != QT_MINIMAL_MODE )
{ /* NORMAL MODE then */ { /* NORMAL MODE then */
stackCentralW->show(); if( !videoWidget || stackCentralW->currentWidget() != videoWidget )
if( !videoWidget || stackCentralW->currentIndex() != VIDEO_TAB )
{ {
showBg(); showBg();
} }
else else
{ {
/* If video is visible, then toggle the status of bgWidget */ /* If video is visible, then toggle the status of bgWidget */
//FIXME
//bgWasVisible = !bgWasVisible; //bgWasVisible = !bgWasVisible;
if( stackCentralOldState == BACKG_TAB ) /* if( stackCentralOldState == BACK G_TAB )
stackCentralOldState = HIDDEN_TAB; stackCentralOldState = HID DEN_TAB;
else else
stackCentralOldState = BACKG_TAB; stackCentralOldState = BACK G_TAB;
*/
} }
} }
...@@ -1466,8 +1407,7 @@ void MainInterface::resizeEvent( QResizeEvent * event ) ...@@ -1466,8 +1407,7 @@ void MainInterface::resizeEvent( QResizeEvent * event )
#if 0 #if 0
if( b_keep_size ) if( b_keep_size )
{ {
if( i_visualmode == QT_ALWAYS_VIDEO_MODE || if( i_visualmode )
i_visualmode == QT_MINIMAL_MODE )
{ {
mainVideoSize = size(); mainVideoSize = size();
} }
...@@ -1484,6 +1424,7 @@ void MainInterface::resizeEvent( QResizeEvent * event ) ...@@ -1484,6 +1424,7 @@ void MainInterface::resizeEvent( QResizeEvent * event )
#endif #endif
QVLCMW::resizeEvent( event ); QVLCMW::resizeEvent( event );
msg_Dbg( p_intf, "Resize Event, height: %i", size().height() ); msg_Dbg( p_intf, "Resize Event, height: %i", size().height() );
debug();
} }
void MainInterface::wheelEvent( QWheelEvent *e ) void MainInterface::wheelEvent( QWheelEvent *e )
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "components/preferences_widgets.hpp" /* First Start */ #include "components/preferences_widgets.hpp" /* First Start */
#ifdef WIN32 #ifdef WIN32
#include <vlc_windows_interfaces.h> #include <vlc_windows_interfaces.h>
#endif #endif
...@@ -87,7 +88,7 @@ public: ...@@ -87,7 +88,7 @@ public:
bool isPlDocked() { return ( b_plDocked != false ); } bool isPlDocked() { return ( b_plDocked != false ); }
/* Sizehint() */ /* Sizehint() */
virtual QSize sizeHint() const; // virtual QSize sizeHint() const;
protected: protected:
void dropEventPlay( QDropEvent *, bool); void dropEventPlay( QDropEvent *, bool);
...@@ -116,11 +117,10 @@ private: ...@@ -116,11 +117,10 @@ private:
void initSystray(); void initSystray();
/* Mess about stackWidget */ /* Mess about stackWidget */
void showTab( int i_tab ); void showTab( QWidget *);
void showVideo();
void showBg();
void restoreStackOldWidget(); void restoreStackOldWidget();
void showVideo() { showTab( VIDEO_TAB ); }
void showBg() { showTab( BACKG_TAB ); }
void hideStackWidget() { showTab( HIDDEN_TAB ); }
/* */ /* */
QSettings *settings; QSettings *settings;
...@@ -133,27 +133,21 @@ private: ...@@ -133,27 +133,21 @@ private:
ControlsWidget *controls; ControlsWidget *controls;
InputControlsWidget *inputC; InputControlsWidget *inputC;
FullscreenControllerWidget *fullscreenControls; FullscreenControllerWidget *fullscreenControls;
/* Widgets */
QStackedWidget *stackCentralW; QStackedWidget *stackCentralW;
/* Video */
VideoWidget *videoWidget; VideoWidget *videoWidget;
BackgroundWidget *bgWidget; BackgroundWidget *bgWidget;
VisualSelector *visualSelector;
PlaylistWidget *playlistWidget; PlaylistWidget *playlistWidget;
//VisualSelector *visualSelector;
/* Status Bar */ /* Status Bar */
QLabel *nameLabel; QLabel *nameLabel;
QLabel *cryptedLabel; QLabel *cryptedLabel;
/* Status and flags */ /* Status and flags */
enum { QWidget *stackCentralOldWidget;
HIDDEN_TAB = -1,
BACKG_TAB = 0,
VIDEO_TAB = 1,
PLAYL_TAB = 2,
};
int stackCentralOldState;
/* Flags */ /* Flags */
bool b_notificationEnabled; /// Systray Notifications bool b_notificationEnabled; /// Systray Notifications
...@@ -180,7 +174,6 @@ private: ...@@ -180,7 +174,6 @@ private:
#endif #endif
public slots: public slots:
void undockPlaylist();
void dockPlaylist( bool b_docked = true ); void dockPlaylist( bool b_docked = true );
void toggleMinimalView( bool ); void toggleMinimalView( bool );
void togglePlaylist(); void togglePlaylist();
......
...@@ -437,10 +437,6 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, ...@@ -437,10 +437,6 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
qtr( "Play&list" ), mi, qtr( "Play&list" ), mi,
SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) ); SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );
/*menu->addSeparator();
menu->addAction( qtr( "Undock from Interface" ), mi,
SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/
menu->addSeparator(); menu->addSeparator();
if( with_intf ) if( with_intf )
......
...@@ -150,10 +150,6 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * ); ...@@ -150,10 +150,6 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
"as lyrics, album arts...\n" \ "as lyrics, album arts...\n" \
" - minimal mode with limited controls" ) " - minimal mode with limited controls" )
#define QT_NORMAL_MODE_TEXT N_( "Classic" )
#define QT_ALWAYS_VIDEO_MODE_TEXT N_( "Complete (with information area)" )
#define QT_MINIMAL_MODE_TEXT N_( "Minimal (without menu)" )
#define QT_FULLSCREEN_TEXT N_( "Show a controller in fullscreen mode" ) #define QT_FULLSCREEN_TEXT N_( "Show a controller in fullscreen mode" )
#define QT_NATIVEOPEN_TEXT N_( "Embed the file browser in open dialog" ) #define QT_NATIVEOPEN_TEXT N_( "Embed the file browser in open dialog" )
...@@ -165,12 +161,7 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * ); ...@@ -165,12 +161,7 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define QT_AUTOLOAD_EXTENSIONS_LONGTEXT N_( "Automatically load the "\ #define QT_AUTOLOAD_EXTENSIONS_LONGTEXT N_( "Automatically load the "\
"extensions module on startup" ) "extensions module on startup" )
/* Various modes definition */ #define QT_MINIMAL_MODE_TEXT N_("Start in minimal view (without menus)" )
static const int i_mode_list[] =
{ QT_NORMAL_MODE, QT_ALWAYS_VIDEO_MODE, QT_MINIMAL_MODE };
static const char *const psz_mode_list_text[] =
{ QT_NORMAL_MODE_TEXT, QT_ALWAYS_VIDEO_MODE_TEXT, QT_MINIMAL_MODE_TEXT };
/**********************************************************************/ /**********************************************************************/
vlc_module_begin () vlc_module_begin ()
...@@ -182,9 +173,9 @@ vlc_module_begin () ...@@ -182,9 +173,9 @@ vlc_module_begin ()
set_callbacks( OpenIntf, Close ) set_callbacks( OpenIntf, Close )
add_shortcut("qt") add_shortcut("qt")
add_integer( "qt-display-mode", QT_NORMAL_MODE, NULL,
QT_MODE_TEXT, QT_MODE_LONGTEXT, false ) add_bool( "qt-minimal-view", false, NULL, QT_MINIMAL_MODE_TEXT,
change_integer_list( i_mode_list, psz_mode_list_text, NULL ) QT_MINIMAL_MODE_TEXT, false );
add_bool( "qt-notification", true, NULL, NOTIFICATION_TEXT, add_bool( "qt-notification", true, NULL, NOTIFICATION_TEXT,
NOTIFICATION_LONGTEXT, false ) NOTIFICATION_LONGTEXT, false )
...@@ -245,6 +236,7 @@ vlc_module_begin () ...@@ -245,6 +236,7 @@ vlc_module_begin ()
false ) false )
add_obsolete_bool( "qt-blingbling" ) /* Suppressed since 1.0.0 */ add_obsolete_bool( "qt-blingbling" ) /* Suppressed since 1.0.0 */
add_obsolete_integer( "qt-display-mode" ) /* Suppressed since 1.1.0 */
#ifdef WIN32 #ifdef WIN32
linked_with_a_crap_library_which_uses_atexit() linked_with_a_crap_library_which_uses_atexit()
......
...@@ -45,12 +45,6 @@ ...@@ -45,12 +45,6 @@
#define HAS_QT45 ( QT_VERSION >= 0x040500 ) #define HAS_QT45 ( QT_VERSION >= 0x040500 )
enum {
QT_NORMAL_MODE = 0,
QT_ALWAYS_VIDEO_MODE,
QT_MINIMAL_MODE
};
enum { enum {
DialogEventType = 0, DialogEventType = 0,
IMEventType = 100, IMEventType = 100,
......
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