Commit 84a974e6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: undock the playlist

Ref #3332
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 9ab96188
/***************************************************************************** /*****************************************************************************
* main_interface.cpp : Main interface * main_interface.cpp : Main interface
**************************************************************************** ****************************************************************************
* Copyright (C) 2006-2009 the VideoLAN team * Copyright (C) 2006-2010 VideoLAN and AUTHORS
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
...@@ -72,7 +72,8 @@ ...@@ -72,7 +72,8 @@
#include <vlc_vout_window.h> #include <vlc_vout_window.h>
#include <vlc_vout_display.h> #include <vlc_vout_display.h>
// #define DEBUG_INTF //#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,
vlc_value_t old_val, vlc_value_t new_val, void *param ); vlc_value_t old_val, vlc_value_t new_val, void *param );
...@@ -130,6 +131,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -130,6 +131,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
settings = getSettings(); settings = getSettings();
settings->beginGroup( "MainWindow" ); settings->beginGroup( "MainWindow" );
/* */
b_plDocked = getSettings()->value( "pl-dock-status", true ).toBool();
/** /**
* Retrieve saved sizes for main window * Retrieve saved sizes for main window
* mainBasedSize = based window size for normal mode * mainBasedSize = based window size for normal mode
...@@ -305,7 +310,7 @@ MainInterface::~MainInterface() ...@@ -305,7 +310,7 @@ MainInterface::~MainInterface()
/* Save playlist state */ /* Save playlist state */
if( playlistWidget ) if( playlistWidget )
{ {
if( !isDocked() ) if( !isPlDocked() )
QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget ); QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
delete playlistWidget; delete playlistWidget;
...@@ -330,7 +335,7 @@ MainInterface::~MainInterface() ...@@ -330,7 +335,7 @@ MainInterface::~MainInterface()
/* Save states */ /* Save states */
settings->beginGroup( "MainWindow" ); settings->beginGroup( "MainWindow" );
settings->setValue( "pl-dock-status", (int)i_pl_dock ); settings->setValue( "pl-dock-status", b_plDocked );
settings->setValue( "playlist-visible", (int)playlistVisible ); settings->setValue( "playlist-visible", (int)playlistVisible );
settings->setValue( "adv-controls", settings->setValue( "adv-controls",
getControlsVisibilityStatus() & CONTROLS_ADVANCED ); getControlsVisibilityStatus() & CONTROLS_ADVANCED );
...@@ -765,7 +770,7 @@ void MainInterface::doComponentsUpdate() ...@@ -765,7 +770,7 @@ void MainInterface::doComponentsUpdate()
/* Here we resize to sizeHint() and not adjustsize because we want /* Here we resize to sizeHint() and not adjustsize because we want
the videoWidget to be exactly the correctSize */ the videoWidget to be exactly the correctSize */
#ifndef NDEBUG #ifdef DEBUG_INTF
debug(); debug();
#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 */
...@@ -777,7 +782,7 @@ void MainInterface::doComponentsUpdate() ...@@ -777,7 +782,7 @@ void MainInterface::doComponentsUpdate()
void MainInterface::debug() void MainInterface::debug()
{ {
#ifndef NDEBUG #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( videoEmbeddedFlag ) if( videoEmbeddedFlag )
msg_Dbg( p_intf, "Stack Size: %i - %i", msg_Dbg( p_intf, "Stack Size: %i - %i",
...@@ -994,15 +999,11 @@ int MainInterface::controlVideo( int i_query, va_list args ) ...@@ -994,15 +999,11 @@ int MainInterface::controlVideo( int i_query, va_list args )
/** /**
* Toggle the playlist widget or dialog * Toggle the playlist widget or dialog
**/ **/
void MainInterface::createPlaylist( bool b_show ) void MainInterface::createPlaylist()
{ {
playlistWidget = new PlaylistWidget( p_intf, this ); playlistWidget = new PlaylistWidget( p_intf, this );
i_pl_dock = PL_BOTTOM; if( !b_plDocked )
/* i_pl_dock = (pl_dock_e)getSettings()
->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
if( i_pl_dock == PL_UNDOCKED )
{ {
playlistWidget->setWindowFlags( Qt::Window ); playlistWidget->setWindowFlags( Qt::Window );
...@@ -1014,35 +1015,28 @@ void MainInterface::createPlaylist( bool b_show ) ...@@ -1014,35 +1015,28 @@ void MainInterface::createPlaylist( bool b_show )
else else
{ {
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Here %i", stackCentralW->currentIndex() ); msg_Warn( p_intf, "Here 1 %i", stackCentralW->currentIndex() );
#endif #endif
stackCentralW->insertWidget( PLAYL_TAB, playlistWidget ); stackCentralW->insertWidget( PLAYL_TAB, playlistWidget );
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Here %i", stackCentralW->currentIndex() ); msg_Warn( p_intf, "Here 2 %i", stackCentralW->currentIndex() );
#endif #endif
} }
if( b_show )
{
playlistVisible = true;
stackCentralW->show();
}
} }
void MainInterface::togglePlaylist() void MainInterface::togglePlaylist()
{ {
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState ); msg_Warn( p_intf, "Here toggling 1 %i %i", stackCentralW->currentIndex(), stackCentralOldState );
#endif #endif
if( !playlistWidget ) if( !playlistWidget )
{ createPlaylist();
createPlaylist( true );
}
#ifdef DEBUG_INTF #ifdef DEBUG_INTF
msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState ); msg_Warn( p_intf, "Here toggling 2 %i %i", stackCentralW->currentIndex(), stackCentralOldState );
#endif #endif
if( i_pl_dock != PL_UNDOCKED ) if( b_plDocked )
{ {
/* Playlist not visible */ /* Playlist not visible */
if( stackCentralW->currentIndex() != PLAYL_TAB ) if( stackCentralW->currentIndex() != PLAYL_TAB )
...@@ -1057,17 +1051,40 @@ void MainInterface::togglePlaylist() ...@@ -1057,17 +1051,40 @@ void MainInterface::togglePlaylist()
playlistVisible = ( stackCentralW->currentIndex() == PLAYL_TAB ); playlistVisible = ( stackCentralW->currentIndex() == PLAYL_TAB );
//doComponentsUpdate(); //resize( sizeHint() ); //doComponentsUpdate(); //resize( sizeHint() );
} }
else
{
playlistWidget->setWindowFlags( Qt::Window );
playlistVisible = !playlistVisible;
playlistWidget->setVisible( playlistVisible );
}
} }
/* Function called from the menu to undock the playlist */ void MainInterface::dockPlaylist( bool p_docked )
void MainInterface::undockPlaylist()
{ {
// dockPL->setFloating( true ); b_plDocked = p_docked;
// adjustSize(); if( !playlistWidget ) return; /* Playlist wasn't created yet */
if( !p_docked )
{
stackCentralW->removeWidget( playlistWidget );
playlistWidget->setWindowFlags( Qt::Window );
QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
playlistWidget, QSize( 600, 300 ) );
playlistWidget->show();
stackCentralW->hide();
doComponentsUpdate();
}
else
{
stackCentralW->insertWidget( PLAYL_TAB, playlistWidget );
stackCentralW->setCurrentWidget( playlistWidget );
stackCentralW->show();
}
} }
void MainInterface::dockPlaylist( pl_dock_e i_pos ) /* 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 )
......
...@@ -62,13 +62,6 @@ enum { ...@@ -62,13 +62,6 @@ enum {
}; };
typedef enum pl_dock_e {
PL_UNDOCKED,
PL_BOTTOM,
PL_RIGHT,
PL_LEFT
} pl_dock_e;
class MainInterface : public QVLCMW class MainInterface : public QVLCMW
{ {
Q_OBJECT; Q_OBJECT;
...@@ -91,6 +84,7 @@ public: ...@@ -91,6 +84,7 @@ public:
QMenu *getSysTrayMenu() { return systrayMenu; } QMenu *getSysTrayMenu() { return systrayMenu; }
#endif #endif
int getControlsVisibilityStatus(); int getControlsVisibilityStatus();
bool isPlDocked() { return ( b_plDocked != false ); }
/* Sizehint() */ /* Sizehint() */
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
...@@ -113,12 +107,12 @@ protected: ...@@ -113,12 +107,12 @@ protected:
private: private:
void createMainWidget( QSettings* ); void createMainWidget( QSettings* );
void createStatusBar(); void createStatusBar();
void createPlaylist();
/* Systray */ /* Systray */
void handleSystray(); void handleSystray();
void createSystray(); void createSystray();
void initSystray(); void initSystray();
bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
void showTab( int i_tab ); void showTab( int i_tab );
void restoreStackOldWidget(); void restoreStackOldWidget();
...@@ -167,7 +161,7 @@ private: ...@@ -167,7 +161,7 @@ private:
QSize mainBasedSize; ///< based Wnd (normal mode only) QSize mainBasedSize; ///< based Wnd (normal mode only)
QSize mainVideoSize; ///< Wnd with video (all modes) QSize mainVideoSize; ///< Wnd with video (all modes)
int i_visualmode; ///< Visual Mode int i_visualmode; ///< Visual Mode
pl_dock_e i_pl_dock; bool b_plDocked;
int i_bg_height; ///< Save height of bgWidget int i_bg_height; ///< Save height of bgWidget
bool b_hideAfterCreation; bool b_hideAfterCreation;
...@@ -177,11 +171,10 @@ private: ...@@ -177,11 +171,10 @@ private:
UINT taskbar_wmsg; UINT taskbar_wmsg;
void createTaskBarButtons(); void createTaskBarButtons();
#endif #endif
void createPlaylist( bool );
public slots: public slots:
void undockPlaylist(); void undockPlaylist();
void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM ); void dockPlaylist( bool b_docked = true );
void toggleMinimalView( bool ); void toggleMinimalView( bool );
void togglePlaylist(); void togglePlaylist();
#ifndef HAVE_MAEMO #ifndef HAVE_MAEMO
......
...@@ -474,6 +474,12 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, ...@@ -474,6 +474,12 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED ) if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
action->setChecked( true ); action->setChecked( true );
/* Docked Playlist */
action = menu->addAction( qtr( "Docked Playlist" ) );
action->setCheckable( true );
action->setChecked( mi->isPlDocked() );
CONNECT( action, triggered( bool ), mi, dockPlaylist( bool ) );
if( with_intf ) if( with_intf )
// I don't want to manage consistency between menus, so no popup-menu // I don't want to manage consistency between menus, so no popup-menu
{ {
......
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