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