Commit 959a473d authored by Clément Stenac's avatar Clément Stenac

Implement dock/undock for the playlist

parent e45f26dd
...@@ -182,6 +182,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL), ...@@ -182,6 +182,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
QPushButton *undockButton = new QPushButton( "UN", this ); QPushButton *undockButton = new QPushButton( "UN", this );
undockButton->setMaximumWidth( 25 ); undockButton->setMaximumWidth( 25 );
BUTTONACT( undockButton, undock() );
undockButton->setToolTip( qtr( "Undock playlist for main interface" ) ); undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
QPushButton *sourcesButton = new QPushButton( "Sources", this ); QPushButton *sourcesButton = new QPushButton( "Sources", this );
sourcesButton->setToolTip( qtr( "Select additional stream sources" ) ); sourcesButton->setToolTip( qtr( "Select additional stream sources" ) );
...@@ -214,6 +216,16 @@ PlaylistWidget::~PlaylistWidget() ...@@ -214,6 +216,16 @@ PlaylistWidget::~PlaylistWidget()
{ {
} }
void PlaylistWidget::undock()
{
hide();
THEDP->playlistDialog();
deleteLater();
QEvent *event = new QEvent( (QEvent::Type)(PLUndockEvent_Type) );
QApplication::postEvent( p_intf->p_sys->p_mi, event );
}
QSize PlaylistWidget::sizeHint() const QSize PlaylistWidget::sizeHint() const
{ {
fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() ); fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );
......
...@@ -106,6 +106,8 @@ private: ...@@ -106,6 +106,8 @@ private:
PLSelector *selector; PLSelector *selector;
PLPanel *rightPanel; PLPanel *rightPanel;
intf_thread_t *p_intf; intf_thread_t *p_intf;
private slots:
void undock();
}; };
#endif #endif
...@@ -22,16 +22,19 @@ ...@@ -22,16 +22,19 @@
******************************************************************************/ ******************************************************************************/
#include "dialogs/playlist.hpp" #include "dialogs/playlist.hpp"
#include "util/qvlcframe.hpp"
#include "qt4.hpp" #include "qt4.hpp"
#include "main_interface.hpp"
#include "util/qvlcframe.hpp"
#include "components/playlist/panels.hpp" #include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp" #include "components/playlist/selector.hpp"
#include "dialogs_provider.hpp"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QSignalMapper> #include <QSignalMapper>
#include <QMenu> #include <QMenu>
#include <QAction> #include <QAction>
#include <QMenuBar> #include <QMenuBar>
#include "dialogs_provider.hpp"
PlaylistDialog *PlaylistDialog::instance = NULL; PlaylistDialog *PlaylistDialog::instance = NULL;
...@@ -91,6 +94,7 @@ void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf ) ...@@ -91,6 +94,7 @@ void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
manageMenu->addMenu( subML ); manageMenu->addMenu( subML );
manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() )); manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() ));
manageMenu->addAction( "Dock playlist", this, SLOT( dock() ) );
bar->addMenu( manageMenu ); bar->addMenu( manageMenu );
bar->addMenu( SDMenu() ); bar->addMenu( SDMenu() );
} }
...@@ -134,6 +138,13 @@ QMenu *PlaylistDialog::SDMenu() ...@@ -134,6 +138,13 @@ QMenu *PlaylistDialog::SDMenu()
return menu; return menu;
} }
void PlaylistDialog::dock()
{
hide();
QEvent *event = new QEvent( (QEvent::Type)(PLDockEvent_Type) );
QApplication::postEvent( p_intf->p_sys->p_mi, event );
}
void PlaylistDialog::SDMenuAction( QString data ) void PlaylistDialog::SDMenuAction( QString data )
{ {
char *psz_sd = data.toUtf8().data(); char *psz_sd = data.toUtf8().data();
......
...@@ -39,7 +39,11 @@ public: ...@@ -39,7 +39,11 @@ public:
if( !instance) instance = new PlaylistDialog( p_intf ); if( !instance) instance = new PlaylistDialog( p_intf );
return instance; return instance;
} }
static void killInstance() { if( instance ) delete instance; } static void killInstance()
{
if( instance ) delete instance;
instance = NULL;
}
virtual ~PlaylistDialog(); virtual ~PlaylistDialog();
private: private:
...@@ -52,6 +56,7 @@ private: ...@@ -52,6 +56,7 @@ private:
PLSelector *selector; PLSelector *selector;
PLPanel *rightPanel; PLPanel *rightPanel;
private slots: private slots:
void dock();
void SDMenuAction( QString ); void SDMenuAction( QString );
}; };
......
...@@ -375,8 +375,7 @@ void MainInterface::visual() ...@@ -375,8 +375,7 @@ void MainInterface::visual()
/* Stop any currently running visualization */ /* Stop any currently running visualization */
visualSelector->hide(); visualSelector->hide();
} }
calculateInterfaceSize(); doComponentsUpdate();
resize( mainSize );
} }
void MainInterface::playlist() void MainInterface::playlist()
...@@ -426,9 +425,7 @@ void MainInterface::playlist() ...@@ -426,9 +425,7 @@ void MainInterface::playlist()
} }
if( VISIBLE( bgWidget ) ) bgWidget->hide(); if( VISIBLE( bgWidget ) ) bgWidget->hide();
} }
doComponentsUpdate();
calculateInterfaceSize();
resize( mainSize );
} }
/* Video widget cannot do this synchronously as it runs in another thread */ /* Video widget cannot do this synchronously as it runs in another thread */
...@@ -439,6 +436,23 @@ void MainInterface::doComponentsUpdate() ...@@ -439,6 +436,23 @@ void MainInterface::doComponentsUpdate()
resize( mainSize ); resize( mainSize );
} }
void MainInterface::customEvent( QEvent *event )
{
if( event->type() == PLUndockEvent_Type )
{
ui.vboxLayout->removeWidget( playlistWidget );
playlistWidget = NULL;
playlistEmbeddedFlag = false;
doComponentsUpdate();
}
else if( event->type() == PLDockEvent_Type )
{
PlaylistDialog::killInstance();
playlistEmbeddedFlag = true;
playlist();
}
}
/************************************************************************ /************************************************************************
* Other stuff * Other stuff
************************************************************************/ ************************************************************************/
......
...@@ -34,7 +34,7 @@ class QSettings; ...@@ -34,7 +34,7 @@ class QSettings;
class QCloseEvent; class QCloseEvent;
class QKeyEvent; class QKeyEvent;
class QLabel; class QLabel;
class QEvent;
class InputManager; class InputManager;
class InputSlider; class InputSlider;
class VideoWidget; class VideoWidget;
...@@ -86,6 +86,8 @@ private: ...@@ -86,6 +86,8 @@ private:
QLabel *timeLabel; QLabel *timeLabel;
QLabel *nameLabel; QLabel *nameLabel;
void customEvent( QEvent *);
private slots: private slots:
void setStatus( int ); void setStatus( int );
void setName( QString ); void setName( QString );
......
...@@ -63,6 +63,8 @@ struct intf_sys_t ...@@ -63,6 +63,8 @@ struct intf_sys_t
#define ON_TIMEOUT( act ) CONNECT( THEDP->fixed_timer, timeout(), this, act ) #define ON_TIMEOUT( act ) CONNECT( THEDP->fixed_timer, timeout(), this, act )
static int DialogEvent_Type = QEvent::User + 1; static int DialogEvent_Type = QEvent::User + 1;
static int PLUndockEvent_Type = QEvent::User + 2;
static int PLDockEvent_Type = QEvent::User + 3;
class DialogEvent : public QEvent class DialogEvent : public QEvent
{ {
......
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