#include "components/controller.hpp" // controllers
#include "components/playlist/playlist.hpp" // plWidget
#include "dialogs/firstrun.hpp" // First Run
+#include "dialogs/playlist.hpp" // PlaylistDialog
#include "menus.hpp" // Menu creation
#include "recents.hpp" // RecentItems when DnD
#include <QUrl>
#include <QSize>
#include <QDate>
+#include <QMimeData>
#include <QMenu>
#include <QMenuBar>
#include <QStatusBar>
#include <QLabel>
#include <QStackedWidget>
+#include <QFileInfo>
#include <vlc_keys.h> /* Wheel event */
#include <vlc_vout_display.h> /* vout_thread_t and VOUT_ events */
vlc_value_t old_val, vlc_value_t new_val,
void *param );
+const QEvent::Type MainInterface::ToolbarsNeedRebuild =
+ (QEvent::Type)QEvent::registerEventType();
+
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{
/* Variables initialisation */
input_name = "";
b_interfaceFullScreen= false;
b_hasPausedWhenMinimized = false;
-
+ i_kc_offset = false;
/* Ask for Privacy */
FirstRun::CheckAndRun( this, p_intf );
#ifdef WIN32
himl = NULL;
p_taskbl = NULL;
- taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated");
+ taskbar_wmsg = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
#endif
/*********************************
CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
this, setVideoSize( unsigned int, unsigned int ) );
CONNECT( videoWidget, sizeChanged( int, int ),
- this, resizeStack( int, int ) );
+ this, videoSizeChanged( int, int ) );
}
CONNECT( this, askVideoSetFullScreen( bool ),
this, setVideoFullScreen( bool ) );
}
- CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
+ CONNECT( THEDP, toolBarConfUpdated(), this, toolBarConfUpdated() );
+ installEventFilter( this );
CONNECT( this, askToQuit(), THEDP, quit() );
settings->beginGroup("MainWindow");
settings->setValue( "pl-dock-status", b_plDocked );
+
/* Save playlist state */
- if( playlistWidget )
- settings->setValue( "playlist-visible", playlistVisible );
+ settings->setValue( "playlist-visible", playlistVisible );
settings->setValue( "adv-controls",
getControlsVisibilityStatus() & CONTROLS_ADVANCED );
/* Save this size */
QVLCTools::saveWidgetPosition(settings, this);
- /* Save undocked playlist size */
- if( playlistWidget && !isPlDocked() )
- QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
-
- delete playlistWidget;
-
delete statusBar();
/* Unregister callbacks */
fullscreenControls = new FullscreenControllerWidget( p_intf, this );
CONNECT( fullscreenControls, keyPressed( QKeyEvent * ),
this, handleKeyPress( QKeyEvent * ) );
+ THEMIM->requestVoutUpdate();
}
+
+ setMinimalView( b_minimalView );
}
void MainInterface::reloadPrefs()
}
}
-void MainInterface::createMainWidget( QSettings *settings )
+void MainInterface::createMainWidget( QSettings *creationSettings )
{
/* Create the main Widget and the mainLayout */
QWidget *main = new QWidget;
stackCentralW = new QVLCStackedWidget( main );
/* Bg Cone */
- bgWidget = new BackgroundWidget( p_intf );
+ if ( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY
+ && var_InheritBool( p_intf, "qt-icon-change" ) )
+ {
+ bgWidget = new EasterEggBackgroundWidget( p_intf );
+ CONNECT( this, kc_pressed(), bgWidget, animate() );
+ }
+ else
+ bgWidget = new BackgroundWidget( p_intf );
+
stackCentralW->addWidget( bgWidget );
if ( !var_InheritBool( p_intf, "qt-bgcone" ) )
bgWidget->setWithArt( false );
}
mainLayout->insertWidget( 1, stackCentralW );
- stackWidgetsSizes[bgWidget] = settings->value( "MainWindow/bgSize", QSize( 600, 0 ) ).toSize();
+ stackWidgetsSizes[bgWidget] =
+ creationSettings->value( "MainWindow/bgSize", QSize( 600, 0 ) ).toSize();
/* Resize even if no-auto-resize, because we are at creation */
resizeStack( stackWidgetsSizes[bgWidget].width(), stackWidgetsSizes[bgWidget].height() );
/* Create the CONTROLS Widget */
controls = new ControlsWidget( p_intf,
- settings->value( "MainWindow/adv-controls", false ).toBool(), this );
+ creationSettings->value( "MainWindow/adv-controls", false ).toBool(), this );
inputC = new InputControlsWidget( p_intf, this );
mainLayout->insertWidget( 2, inputC );
- mainLayout->insertWidget( settings->value( "MainWindow/ToolbarPos", 0 ).toInt() ? 0: 3,
- controls );
+ mainLayout->insertWidget(
+ creationSettings->value( "MainWindow/ToolbarPos", 0 ).toInt() ? 0: 3,
+ controls );
/* Visualisation, disabled for now, they SUCK */
#if 0
inline void MainInterface::showTab( QWidget *widget )
{
+ if ( !widget ) widget = bgWidget; /* trying to restore a null oldwidget */
#ifdef DEBUG_INTF
- msg_Warn( p_intf, "Old stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
+ if ( stackCentralOldWidget )
+ msg_Dbg( p_intf, "Old stackCentralOldWidget %s at index %i",
+ stackCentralOldWidget->metaObject()->className(),
+ stackCentralW->indexOf( stackCentralOldWidget ) );
+ msg_Dbg( p_intf, "ShowTab request for %s", widget->metaObject()->className() );
#endif
+ /* fixing when the playlist has been undocked after being hidden.
+ restoreStackOldWidget() is called when video stops but
+ stackCentralOldWidget would still be pointing to playlist */
+ if ( widget == playlistWidget && !isPlDocked() )
+ widget = bgWidget;
stackCentralOldWidget = stackCentralW->currentWidget();
stackWidgetsSizes[stackCentralOldWidget] = stackCentralW->size();
/* Embedded playlist -> Non-embedded playlist */
if( bgWidget == stackCentralOldWidget && widget == videoWidget )
{
- playlistWidget->artContainer->removeWidget( videoWidget );
+ /* In rare case when video is started before the interface */
+ if( playlistWidget != NULL )
+ playlistWidget->artContainer->removeWidget( videoWidget );
videoWidget->show(); videoWidget->raise();
stackCentralW->addWidget( videoWidget );
stackCentralW->setCurrentWidget( videoWidget );
resizeStack( stackWidgetsSizes[widget].width(), stackWidgetsSizes[widget].height() );
#ifdef DEBUG_INTF
- msg_Warn( p_intf, "State change %i", stackCentralW->currentIndex() );
- msg_Warn( p_intf, "New stackCentralOldWidget %i", stackCentralW->indexOf( stackCentralOldWidget ) );
+ msg_Dbg( p_intf, "Stack state changed to %s, index %i",
+ stackCentralW->currentWidget()->metaObject()->className(),
+ stackCentralW->currentIndex() );
+ msg_Dbg( p_intf, "New stackCentralOldWidget %s at index %i",
+ stackCentralOldWidget->metaObject()->className(),
+ stackCentralW->indexOf( stackCentralOldWidget ) );
#endif
/* This part is done later, to account for the new pl size */
{
if( !fullscreenControls ) return;
- IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type );
+ IMEvent *eShow = new IMEvent( IMEvent::FullscreenControlToggle );
QApplication::postEvent( fullscreenControls, eShow );
}
videoWidget->SetSizing( w, h );
}
+void MainInterface::videoSizeChanged( int w, int h )
+{
+ if( !playlistWidget || playlistWidget->artContainer->currentWidget() != videoWidget )
+ resizeStack( w, h );
+}
+
void MainInterface::setVideoFullScreen( bool fs )
{
b_videoFullScreen = fs;
**/
void MainInterface::createPlaylist()
{
- playlistWidget = new PlaylistWidget( p_intf, this );
+ PlaylistDialog *dialog = PlaylistDialog::getInstance( p_intf );
if( b_plDocked )
{
+ playlistWidget = dialog->exportPlaylistWidget();
stackCentralW->addWidget( playlistWidget );
stackWidgetsSizes[playlistWidget] = settings->value( "playlistSize", QSize( 600, 300 ) ).toSize();
}
- else
- {
-#ifdef WIN32
- playlistWidget->setParent( NULL );
-#endif
- playlistWidget->setWindowFlags( Qt::Window );
-
- /* This will restore the geometry but will not work for position,
- because of parenting */
- QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
- playlistWidget, QSize( 600, 300 ) );
- }
+ CONNECT( dialog, visibilityChanged(bool), this, setPlaylistVisibility(bool) );
}
void MainInterface::togglePlaylist()
{
- if( !playlistWidget )
- {
- createPlaylist();
- }
+ if( !playlistWidget ) createPlaylist();
+ PlaylistDialog *dialog = PlaylistDialog::getInstance( p_intf );
if( b_plDocked )
{
+ if ( dialog->hasPlaylistWidget() )
+ playlistWidget = dialog->exportPlaylistWidget();
/* Playlist is not visible, show it */
if( stackCentralW->currentWidget() != playlistWidget )
{
}
else
{
-#ifdef WIN32
- playlistWidget->setParent( NULL );
-#endif
- playlistWidget->setWindowFlags( Qt::Window );
playlistVisible = !playlistVisible;
- playlistWidget->setVisible( playlistVisible );
+ if ( ! dialog->hasPlaylistWidget() )
+ dialog->importPlaylistWidget( playlistWidget );
+ if ( playlistVisible )
+ dialog->show();
+ else
+ dialog->hide();
}
debug();
}
+const Qt::Key MainInterface::kc[10] =
+{
+ Qt::Key_Up, Qt::Key_Up,
+ Qt::Key_Down, Qt::Key_Down,
+ Qt::Key_Left, Qt::Key_Right, Qt::Key_Left, Qt::Key_Right,
+ Qt::Key_B, Qt::Key_A
+};
+
void MainInterface::dockPlaylist( bool p_docked )
{
if( b_plDocked == p_docked ) return;
+ /* some extra check */
+ if ( b_plDocked && !playlistWidget ) createPlaylist();
+
b_plDocked = p_docked;
+ PlaylistDialog *dialog = PlaylistDialog::getInstance( p_intf );
- if( !playlistWidget ) return; /* Playlist wasn't created yet */
if( !p_docked ) /* Previously docked */
{
- /* If playlist is invisible don't show it */
- if( stackCentralW->currentWidget() != playlistWidget ) return;
+ playlistVisible = playlistWidget->isVisible();
stackCentralW->removeWidget( playlistWidget );
-#ifdef WIN32
- playlistWidget->setParent( NULL );
-#endif
- playlistWidget->setWindowFlags( Qt::Window );
- QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
- playlistWidget, QSize( 600, 300 ) );
- playlistWidget->show();
+ dialog->importPlaylistWidget( playlistWidget );
+ if ( playlistVisible ) dialog->show();
restoreStackOldWidget();
}
else /* Previously undocked */
{
- QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
- playlistWidget->setWindowFlags( Qt::Widget ); // Probably a Qt bug here
- // It would be logical that QStackWidget::addWidget reset the flags...
+ playlistVisible = dialog->isVisible();
+ dialog->hide();
+ playlistWidget = dialog->exportPlaylistWidget();
stackCentralW->addWidget( playlistWidget );
/* If playlist is invisible don't show it */
- if( !playlistWidget->isVisible() ) return;
- showTab( playlistWidget );
+ if( playlistVisible ) showTab( playlistWidget );
}
- playlistVisible = true;
}
/*
{
if( !controls ) return 0;
return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )
- + CONTROLS_ADVANCED * controls->b_advancedVisible );
+ + CONTROLS_ADVANCED * controls->b_advancedVisible );
+}
+
+StandardPLPanel *MainInterface::getPlaylistView()
+{
+ if( !playlistWidget ) return NULL;
+ else return playlistWidget->mainView;
}
void MainInterface::setStatusBarVisibility( bool b_visible )
if( controls ) controls->setGripVisible( !b_statusbarVisible );
}
+
+void MainInterface::setPlaylistVisibility( bool b_visible )
+{
+ if ( !isPlDocked() )
+ playlistVisible = b_visible;
+}
+
#if 0
void MainInterface::visual()
{
*/
void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playlist )
{
- if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction ) )
+ if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction | Qt::LinkAction ) )
event->setDropAction( Qt::CopyAction );
else
return;
if( url.isValid() )
{
QString mrl = toURI( url.toEncoded().constData() );
- playlist_Add( THEPL, qtu(mrl), NULL,
+ QFileInfo info( url.toLocalFile() );
+ if( info.exists() && info.isSymLink() )
+ {
+ QString target = info.symLinkTarget();
+ QUrl url;
+ if( QFile::exists( target ) )
+ {
+ url = QUrl::fromLocalFile( target );
+ }
+ else
+ {
+ url.setUrl( target );
+ }
+ mrl = toURI( url.toEncoded().constData() );
+ }
+ if( mrl.length() > 0 )
+ {
+ playlist_Add( THEPL, qtu(mrl), NULL,
PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
PLAYLIST_END, b_playlist, pl_Unlocked );
- first = false;
- RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+ first = false;
+ RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+ }
}
}
void MainInterface::keyPressEvent( QKeyEvent *e )
{
handleKeyPress( e );
+
+ /* easter eggs sequence handling */
+ if ( e->key() == kc[ i_kc_offset ] )
+ i_kc_offset++;
+ else
+ i_kc_offset = 0;
+
+ if ( i_kc_offset == (sizeof( kc ) / sizeof( Qt::Key )) )
+ {
+ i_kc_offset = 0;
+ emit kc_pressed();
+ }
}
void MainInterface::handleKeyPress( QKeyEvent *e )
e->accept();
}
+bool MainInterface::eventFilter( QObject *obj, QEvent *event )
+{
+ if ( event->type() == MainInterface::ToolbarsNeedRebuild ) {
+ event->accept();
+ recreateToolbars();
+ return true;
+ } else {
+ return QObject::eventFilter( obj, event );
+ }
+}
+
+void MainInterface::toolBarConfUpdated()
+{
+ QApplication::postEvent( this, new QEvent( MainInterface::ToolbarsNeedRebuild ) );
+}
+
void MainInterface::setInterfaceFullScreen( bool fs )
{
if( fs )