/*****************************************************************************
* main_interface.cpp : Main interface
****************************************************************************
- * Copyright (C) 2006-2008 the VideoLAN team
+ * Copyright (C) 2006-2009 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
#include "components/interface_widgets.hpp"
#include "components/controller.hpp"
#include "components/playlist/playlist.hpp"
+#include "dialogs/external.hpp"
#include "menus.hpp"
#include "recents.hpp"
#include <QLabel>
#include <QGroupBox>
#include <QPushButton>
+#include <QStackedWidget>
+
+#ifdef WIN32
+ #include <vlc_windows_interfaces.h>
+ #include <QBitmap>
+#endif
#include <assert.h>
#include <vlc_keys.h> /* Wheel event */
+#include <vlc_vout_window.h>
#include <vlc_vout.h>
/* Callback prototypes */
vlc_value_t old_val, vlc_value_t new_val, void *param );
static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param );
-static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
- vlc_value_t, void *);
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{
bgWidget = NULL;
videoWidget = NULL;
playlistWidget = NULL;
+#ifndef HAVE_MAEMO
sysTray = NULL;
- videoIsActive = false;
+#endif
playlistVisible = false;
input_name = "";
fullscreenControls = NULL;
-#if 0
cryptedLabel = NULL;
-#endif
+ controls = NULL;
+ inputC = NULL;
+ b_shouldHide = false;
+
+ stackCentralOldState = HIDDEN_TAB;
+ i_bg_height = 0;
/* Ask for privacy */
askForPrivacy();
/* Main settings */
setFocusPolicy( Qt::StrongFocus );
setAcceptDrops( true );
+ setWindowRole( "vlc-main" );
setWindowIcon( QApplication::windowIcon() );
setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
/* Are we in the enhanced always-video mode or not ? */
i_visualmode = config_GetInt( p_intf, "qt-display-mode" );
+ /* Do we want anoying popups or not */
+ notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
+
/* Set the other interface settings */
settings = getSettings();
settings->beginGroup( "MainWindow" );
mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize();
mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize();
- /* Do we want anoying popups or not */
- notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
-
/**************
* Status Bar *
**************/
* UI and Widgets design
**************************/
setVLCWindowsTitle();
- handleMainUi( settings );
+ createMainWidget( settings );
/************
* Menu Bar *
************/
QVLCMenu::createMenuBar( this, p_intf );
+ CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
+ this, destroyPopupMenu() );
#if 0
/* Create a Dock to get the playlist */
dockPL->hide();
#endif
+ /*********************************
+ * Create the Systray Management *
+ *********************************/
+ initSystray();
+
/********************
* Input Manager *
********************/
MainInputManager::getInstance( p_intf );
- /**************************
- * Various CONNECTs on IM *
- **************************/
- /* Connect the input manager to the GUI elements it manages */
-
+ /************************************************************
+ * Connect the input manager to the GUI elements it manages *
+ ************************************************************/
/**
* Connects on nameChanged()
- * Those connects are not merged because different options can trigger
- * them down.
- */
- /* Naming in the controller statusbar */
- CONNECT( THEMIM->getIM(), nameChanged( QString ),
- this, setName( QString ) );
- /* and in the systray */
+ * Those connects are different because options can impeach them to trigger.
+ **/
+ /* Main Interface statusbar */
+ CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
+ this, setName( const QString& ) );
+ /* and systray */
+#ifndef HAVE_MAEMO
if( sysTray )
{
- CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
- updateSystrayTooltipName( QString ) );
+ CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
+ this, updateSystrayTooltipName( const QString& ) );
}
- /* and in the title of the controller */
+#endif
+ /* and title of the Main Interface*/
if( config_GetInt( p_intf, "qt-name-in-title" ) )
{
- CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
- setVLCWindowsTitle( QString ) );
+ CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
+ this, setVLCWindowsTitle( const QString& ) );
}
/**
* CONNECTS on PLAY_STATUS
**/
/* Status on the systray */
+#ifndef HAVE_MAEMO
if( sysTray )
{
CONNECT( THEMIM->getIM(), statusChanged( int ),
this, updateSystrayTooltipStatus( int ) );
}
+#endif
/* END CONNECTS ON IM */
-
/************
* Callbacks
************/
- var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
- var_AddCallback( p_intf, "interaction", InteractCallback, this );
- interaction_Register( p_intf );
-
var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
/* Register callback for the intf-popupmenu variable */
var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
- /* VideoWidget connects to avoid different threads speaking to each other */
+ /* VideoWidget connects for asynchronous calls */
+ connect( this, SIGNAL(askGetVideo(WId*,int*,int*,unsigned*,unsigned *)),
+ this, SLOT(getVideoSlot(WId*,int*,int*,unsigned*,unsigned*)),
+ Qt::BlockingQueuedConnection );
connect( this, SIGNAL(askReleaseVideo( void )),
- this, SLOT(releaseVideoSlot( void )), Qt::BlockingQueuedConnection );
+ this, SLOT(releaseVideoSlot( void )),
+ Qt::BlockingQueuedConnection );
if( videoWidget )
{
CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
videoWidget, SetSizing( unsigned int, unsigned int ) );
-
- connect( this, SIGNAL(askVideoToShow( unsigned int, unsigned int)),
- videoWidget, SLOT(SetSizing(unsigned int, unsigned int )),
- Qt::BlockingQueuedConnection );
+ CONNECT( this, askVideoSetFullScreen( bool ),
+ videoWidget, SetFullScreen( bool ) );
+ CONNECT( videoWidget, keyPressed( QKeyEvent * ),
+ this, handleKeyPress( QKeyEvent * ) );
}
CONNECT( this, askUpdate(), this, doComponentsUpdate() );
+ CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
/* Size and placement of interface */
settings->beginGroup( "MainWindow" );
}
}
- bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
+ bool b_pl_visible = settings->value( "playlist-visible", 0 ).toInt();
settings->endGroup();
/* Playlist */
- if( b_visible ) togglePlaylist();
+ if( b_pl_visible ) togglePlaylist();
+
+ /* Enable the popup menu in the MI */
+ setContextMenuPolicy( Qt::CustomContextMenu );
+ CONNECT( this, customContextMenuRequested( const QPoint& ),
+ this, popupMenu( const QPoint& ) );
+
+ debug();
/* Final sizing and showing */
- setMinimumWidth( __MAX( controls->sizeHint().width(),
- menuBar()->sizeHint().width() ) );
- show();
+ setVisible( !b_shouldHide );
+ //setMinimumSize( QSize( 0, 0 ) );
+// setMinimumWidth( __MAX( controls->sizeHint().width(),
+ // menuBar()->sizeHint().width() ) );
+ debug();
/* And switch to minimal view if needed
Must be called after the show() */
if( i_visualmode == QT_MINIMAL_MODE )
toggleMinimalView( true );
/* Update the geometry : It is useful if you switch between
- qt-display-modes ?*/
+ qt-display-modes */
updateGeometry();
resize( sizeHint() );
- /*****************************************************
- * End everything by creating the Systray Management *
- *****************************************************/
- initSystray();
+#ifdef WIN32
+ createTaskBarButtons();
+#endif
}
MainInterface::~MainInterface()
msg_Dbg( p_intf, "Destroying the main interface" );
/* Unsure we hide the videoWidget before destroying it */
- if( videoIsActive ) videoWidget->hide();
+ if( stackCentralOldState == VIDEO_TAB )
+ {
+ showBg();
+ }
/* Save playlist state */
if( playlistWidget )
delete playlistWidget;
}
+#ifdef WIN32
+ if( himl )
+ ImageList_Destroy( himl );
+ if(p_taskbl)
+ p_taskbl->vt->Release(p_taskbl);
+ CoUninitialize();
+#endif
+
/* Be sure to kill the actionsManager... FIXME */
ActionsManager::killInstance();
/* Delete the FSC controller */
- if( fullscreenControls ) delete fullscreenControls;
+ delete fullscreenControls;
/* Save states */
settings->beginGroup( "MainWindow" );
var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
- interaction_Unregister( p_intf );
- var_DelCallback( p_intf, "interaction", InteractCallback, this );
-
p_intf->p_sys->p_mi = NULL;
}
/*****************************
* Main UI handling *
*****************************/
+void MainInterface::recreateToolbars()
+{
+ msg_Err( p_intf, "Recreating the toolbars" );
+ settings->beginGroup( "MainWindow" );
+ delete controls;
+ delete inputC;
+ controls = new ControlsWidget( p_intf, false, this ); /* FIXME */
+ CONNECT( controls, advancedControlsToggled( bool ),
+ this, doComponentsUpdate() );
+ CONNECT( controls, sizeChanged(),
+ this, doComponentsUpdate() );
+ inputC = new InputControlsWidget( p_intf, this );
+
+ mainLayout->insertWidget( 2, inputC );
+ mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
+ controls );
+ settings->endGroup();
+}
+
+void MainInterface::createMainWidget( QSettings *settings )
+{
+ /* Create the main Widget and the mainLayout */
+ QWidget *main = new QWidget;
+ setCentralWidget( main );
+ mainLayout = new QVBoxLayout( main );
+
+ /* Margins, spacing */
+ main->setContentsMargins( 0, 0, 0, 0 );
+ mainLayout->setSpacing( 0 );
+ mainLayout->setMargin( 0 );
+
+ /* */
+ stackCentralW = new QStackedWidget( main );
+
+ /* Bg Cone */
+ bgWidget = new BackgroundWidget( p_intf );
+ bgWidget->resize(
+ settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() );
+ bgWidget->updateGeometry();
+ stackCentralW->insertWidget( BACKG_TAB, bgWidget );
+
+ if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
+ i_visualmode != QT_MINIMAL_MODE )
+ {
+ stackCentralW->hide();
+ }
+
+ /* And video Outputs */
+ if( videoEmbeddedFlag )
+ {
+ videoWidget = new VideoWidget( p_intf );
+ stackCentralW->insertWidget( VIDEO_TAB, videoWidget );
+ }
+ mainLayout->insertWidget( 1, stackCentralW, 100 );
+ /* Create the CONTROLS Widget */
+ controls = new ControlsWidget( p_intf,
+ settings->value( "adv-controls", false ).toBool(), this );
+ CONNECT( controls, advancedControlsToggled( bool ),
+ this, doComponentsUpdate() );
+ CONNECT( controls, sizeChanged(),
+ this, doComponentsUpdate() );
+ inputC = new InputControlsWidget( p_intf, this );
+
+ //mainLayout->setRowStretch( 1, 10 );
+ mainLayout->insertWidget( 2, inputC );
+ mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
+ controls );
+
+ /* Visualisation */
+ /* Disabled for now, they SUCK */
+ #if 0
+ visualSelector = new VisualSelector( p_intf );
+ mainLayout->insertWidget( 0, visualSelector );
+ visualSelector->hide();
+ #endif
+
+ /* Finish the sizing */
+ main->updateGeometry();
+
+ getSettings()->endGroup();
+#ifdef WIN32
+ if ( depth() > 8 )
+#endif
+ /* Create the FULLSCREEN CONTROLS Widget */
+ if( config_GetInt( p_intf, "qt-fs-controller" ) )
+ {
+ fullscreenControls = new FullscreenControllerWidget( p_intf, this );
+ CONNECT( fullscreenControls, keyPressed( QKeyEvent * ),
+ this, handleKeyPress( QKeyEvent * ) );
+ }
+}
inline void MainInterface::createStatusBar()
{
- right-clicking and clicking just toggle between remaining and
elapsed time.*/
CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
-#if 0
- CONNECT( THEMIM->getIM(), encryptionChanged( bool ) , this, showCryptedLabel( bool ) );
-#endif
+
+ CONNECT( THEMIM->getIM(), encryptionChanged( bool ),
+ this, showCryptedLabel( bool ) );
}
-#if 0
-void MainInterface::showCryptedLabel( bool )
+#ifdef WIN32
+void MainInterface::createTaskBarButtons()
{
- if( cryptedLabel == NULL )
+ /*Here is the code for the taskbar thumb buttons
+ FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
+ FIXME:the play button's picture doesn't changed to pause when clicked
+ */
+ OSVERSIONINFO winVer;
+ winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
{
- cryptedLabel = new QLabel;
- cryptedLabel->setPixmap( QPixmap( ":/lock" ) );
- statusBar()->addWidget( cryptedLabel );
- }
+ if(himl = ImageList_Create( 15, //cx
+ 18, //cy
+ ILC_COLOR,//flags
+ 4,//initial nb of images
+ 0//nb of images that can be added
+ ))
+ {
+ QPixmap img = QPixmap(":/toolbar/previous_b");
+ QPixmap img2 = QPixmap(":/toolbar/pause_b");
+ QPixmap img3 = QPixmap(":/toolbar/play_b");
+ QPixmap img4 = QPixmap(":/toolbar/next_b");
+ QBitmap mask = img.createMaskFromColor(Qt::transparent);
+ QBitmap mask2 = img2.createMaskFromColor(Qt::transparent);
+ QBitmap mask3 = img3.createMaskFromColor(Qt::transparent);
+ QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
+
+ if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP()))
+ msg_Err( p_intf, "ImageList_Add failed" );
+ if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP()))
+ msg_Err( p_intf, "ImageList_Add failed" );
+ if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP()))
+ msg_Err( p_intf, "ImageList_Add failed" );
+ if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP()))
+ msg_Err( p_intf, "ImageList_Add failed" );
+ }
- cryptedLabel->show();
+ CoInitialize( 0 );
+
+ if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
+ NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskbarList3,
+ (void **)&p_taskbl) )
+ {
+ p_taskbl->vt->HrInit(p_taskbl);
+
+ int msg_value = RegisterWindowMessage("TaskbarButtonCreated");
+ //msg_Info( p_intf, "msg value: %04x", msg_value );
+
+ // Define an array of two buttons. These buttons provide images through an
+ // image list and also provide tooltips.
+ DWORD dwMask = THB_BITMAP | THB_FLAGS;
+
+ THUMBBUTTON thbButtons[2];
+ thbButtons[0].dwMask = dwMask;
+ thbButtons[0].iId = 0;
+ thbButtons[0].iBitmap = 0;
+ thbButtons[0].dwFlags = THBF_HIDDEN;
+
+ thbButtons[1].dwMask = dwMask;
+ thbButtons[1].iId = 1;
+ thbButtons[1].iBitmap = 2;
+ thbButtons[1].dwFlags = THBF_HIDDEN;
+
+ thbButtons[2].dwMask = dwMask;
+ thbButtons[2].iId = 2;
+ thbButtons[2].iBitmap = 3;
+ thbButtons[2].dwFlags = THBF_HIDDEN;
+
+ HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, GetForegroundWindow(), himl );
+ if(S_OK != hr)
+ msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
+ if(S_OK != p_taskbl->vt->ThumbBarAddButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons))
+ msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", GetLastError() );
+
+ CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
+ }
+ }
+ else
+ {
+ himl = NULL;
+ p_taskbl = NULL;
+ }
}
#endif
+
inline void MainInterface::initSystray()
{
+#ifndef HAVE_MAEMO
bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
bool b_systrayWanted = config_GetInt( p_intf, "qt-system-tray" );
if( b_systrayAvailable )
{
b_systrayWanted = true;
- hide();
+ b_shouldHide = true;
}
else
msg_Err( p_intf, "cannot start minimized without system tray bar" );
if( b_systrayAvailable && b_systrayWanted )
createSystray();
-}
-
-/**
- * Give the decorations of the Main Window a correct Name.
- * If nothing is given, set it to VLC...
- **/
-void MainInterface::setVLCWindowsTitle( QString aTitle )
-{
- if( aTitle.isEmpty() )
- {
- setWindowTitle( qtr( "VLC media player" ) );
- }
- else
- {
- setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
- }
-}
-
-void MainInterface::handleMainUi( QSettings *settings )
-{
- /* Create the main Widget and the mainLayout */
- QWidget *main = new QWidget;
- setCentralWidget( main );
- mainLayout = new QVBoxLayout( main );
-
- /* Margins, spacing */
- main->setContentsMargins( 0, 0, 0, 0 );
- main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
- mainLayout->setSpacing( 0 );
- mainLayout->setMargin( 0 );
-
- /* Create the CONTROLS Widget */
- controls = new ControlsWidget( p_intf,
- settings->value( "adv-controls", false ).toBool(), this );
- CONNECT( controls, advancedControlsToggled( bool ),
- this, doComponentsUpdate() );
- inputC = new InputControlsWidget( p_intf, this );
-
- /* Visualisation */
- /* Disabled for now, they SUCK */
- #if 0
- visualSelector = new VisualSelector( p_intf );
- mainLayout->insertWidget( 0, visualSelector );
- visualSelector->hide();
- #endif
-
- /* Bg Cone */
- bgWidget = new BackgroundWidget( p_intf );
- bgWidget->resize(
- settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() );
- bgWidget->updateGeometry();
- CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
-
- if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
- i_visualmode != QT_MINIMAL_MODE )
- {
- bgWidget->hide();
- }
-
- /* And video Outputs */
- if( videoEmbeddedFlag )
- videoWidget = new VideoWidget( p_intf );
-
- /* Add the controls Widget to the main Widget */
- mainLayout->insertWidget( 0, bgWidget );
- if( videoWidget ) mainLayout->insertWidget( 0, videoWidget, 10 );
- mainLayout->insertWidget( 2, inputC, 0, Qt::AlignBottom );
- mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
- controls, 0, Qt::AlignBottom );
-
- /* Finish the sizing */
- main->updateGeometry();
-
- getSettings()->endGroup();
-#ifdef WIN32
- if ( depth() > 8 )
#endif
- /* Create the FULLSCREEN CONTROLS Widget */
- if( config_GetInt( p_intf, "qt-fs-controller" ) )
- {
- fullscreenControls = new FullscreenControllerWidget( p_intf );
- }
}
inline void MainInterface::askForPrivacy()
{
+#ifndef HAVE_MAEMO
/**
* Ask for the network policy on FIRST STARTUP
**/
config_SaveConfigFile( p_intf, NULL );
}
}
+#endif
}
int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
QDialog *privacy = new QDialog( this );
privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) );
+ privacy->setWindowRole( "vlc-privacy" );
QGridLayout *gLayout = new QGridLayout( privacy );
{ \
control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
p_config, options, false, optionsLayout, line ); \
- controls->append( control ); \
+ controls->append( control ); \
}
#define CONFIG_GENERIC_NOBOOL( option, type ) \
if( p_config ) \
{ \
control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
- p_config, options, optionsLayout, line ); \
- controls->append( control ); \
+ p_config, options, optionsLayout, line ); \
+ controls->append( control ); \
}
CONFIG_GENERIC( "album-art", IntegerList ); line++;
#ifdef UPDATE_CHECK
CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
- CONFIG_GENERIC_NOBOOL( "qt-updates-days", Integer ); line++;
#endif
QPushButton *ok = new QPushButton( qtr( "OK" ) );
QSize MainInterface::sizeHint() const
{
+#if 0
if( b_keep_size )
{
if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
return mainBasedSize;
}
}
+#endif
+
+ int nwidth = __MAX( controls->sizeHint().width(),
+ menuBar()->sizeHint().width() );
- int nwidth = controls->sizeHint().width();
int nheight = controls->isVisible() ?
controls->size().height()
+ inputC->size().height()
+ statusBar()->size().height()
: 0 ;
- if( VISIBLE( bgWidget ) )
+ if( stackCentralW->isVisible() )
+ nheight += stackCentralW->height();
+ nwidth = __MAX( nwidth, stackCentralW->width() );
+
+/* if( VISIBLE( bgWidget ) )
{
- nheight += bgWidget->size().height();
- nwidth = bgWidget->size().width();
+ msg_Warn( p_intf, "Hello here" );
+ if( i_bg_height )
+ nheight += i_bg_height;
+ else
+ nheight += bgWidget->size().height();
+ nwidth = __MAX( nwidth, bgWidget->size().width() );
}
else if( videoIsActive && videoWidget->isVisible() )
{
+ msg_Warn( p_intf, "Hello there" );
nheight += videoWidget->sizeHint().height();
- nwidth = videoWidget->sizeHint().width();
- }
+ nwidth = __MAX( nwidth, videoWidget->sizeHint().width() );
+ }*/
#if 0
if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget() )
{
return QSize( nwidth, nheight );
}
-void MainInterface::toggleFSC()
+
+/* Video widget cannot do this synchronously as it runs in another thread */
+/* Well, could it, actually ? Probably dangerous ... */
+
+/* This function is called:
+ - toggling of minimal View
+ - through askUpdate() by Vout thread request video and resize video (zoom)
+ - Advanced buttons toggled
+ */
+void MainInterface::doComponentsUpdate()
{
- if( !fullscreenControls ) return;
+ if( isFullScreen() || isMaximized() ) return;
- IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 );
- QApplication::postEvent( fullscreenControls, eShow );
+ msg_Err( p_intf, "Updating the geometry" );
+ /* Here we resize to sizeHint() and not adjustsize because we want
+ the videoWidget to be exactly the correctSize */
+
+#if 1
+ debug();
+#endif
+ /* This is WRONG */
+ setMinimumSize( 0, 0 );
+ resize( sizeHint() );
+
+ //adjustSize() ;
}
void MainInterface::debug()
{
-#ifndef NDEBUG
+#if 1
+ if( stackCentralW->isVisible() )
+ msg_Dbg( p_intf, "CentralStack visible" );
+ else
+ msg_Dbg( p_intf, "CentralStack inVisible" );
+ //msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->sizeHint().height(), stackCentralW->sizeHint().width() );
+ msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->size().height(), size().width() );
+ msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->widget( VIDEO_TAB )->size().height(), stackCentralW->widget( VIDEO_TAB )->size().width() );
+
msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
- if( videoWidget && videoWidget->isVisible() )
+ //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, "Controls minimumsize: %i - %i", controls->minimumSize().height(), controls->minimumSize().width() );
+ msg_Dbg( p_intf, "Central minimumsize: %i - %i", centralWidget()->minimumSize().height(), centralWidget()->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, "Status minimumsize: %i - %i", statusBar()->minimumSize().height(), statusBar()->minimumSize().width() );
+ msg_Dbg( p_intf, "minimumsize: %i - %i", minimumSize().height(), minimumSize().width() );
+
+
+ /*if( videoWidget && videoWidget->isVisible() )
{
msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
- }
+ }*/
#endif
}
+void MainInterface::destroyPopupMenu()
+{
+ QVLCMenu::PopupMenu(p_intf, false );
+}
+
+
+void MainInterface::toggleFSC()
+{
+ if( !fullscreenControls ) return;
+
+ IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 );
+ QApplication::postEvent( fullscreenControls, eShow );
+}
+
+void MainInterface::popupMenu( const QPoint &p )
+{
+ /* Ow, that's ugly: don't show the popup menu if cursor over
+ * the main menu bar or the status bar */
+ if( !childAt( p ) || ( ( childAt( p ) != menuBar() )
+ && ( childAt( p )->parentWidget() != statusBar() ) ) )
+ QVLCMenu::PopupMenu( p_intf, true );
+}
+
/****************************************************************************
* Video Handling
****************************************************************************/
};
/**
- * README
- * Thou shall not call/resize/hide widgets from on another thread.
- * This is wrong, and this is THE reason to emit signals on those Video Functions
- **/
-WId MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
- int *pi_y, unsigned int *pi_width,
- unsigned int *pi_height )
+ * NOTE:
+ * You must note change the state of this object or other Qt4 UI objects,
+ * from the video output thread - only from the Qt4 UI main loop thread.
+ * All window provider queries must be handled through signals or events.
+ * That's why we have all those emit statements...
+ */
+WId MainInterface::getVideo( int *pi_x, int *pi_y,
+ unsigned int *pi_width, unsigned int *pi_height )
+{
+ if( !videoWidget )
+ return 0;
+
+ /* This is a blocking call signal. Results are returned through pointers.
+ * Beware of deadlocks! */
+ WId id;
+ emit askGetVideo( &id, pi_x, pi_y, pi_width, pi_height );
+ return id;
+}
+
+void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
+ unsigned *pi_width, unsigned *pi_height )
{
/* Request the videoWidget */
- WId ret = videoWidget->request( p_nvout,pi_x, pi_y,
+ WId ret = videoWidget->request( pi_x, pi_y,
pi_width, pi_height, b_keep_size );
+ *p_id = ret;
if( ret ) /* The videoWidget is available */
{
- /* Did we have a bg ? Hide it! */
- if( VISIBLE( bgWidget) )
- {
- bgWasVisible = true;
- emit askBgWidgetToToggle();
- }
- else
- bgWasVisible = false;
-
/* ask videoWidget to show */
- emit askVideoToShow( *pi_width, *pi_height );
+ videoWidget->SetSizing( *pi_width, *pi_height );
/* Consider the video active now */
- videoIsActive = true;
+ showVideo();
+
+ stackCentralW->resize( *pi_width, *pi_height );
emit askUpdate();
}
- return ret;
}
-/* Call from the WindowClose function */
+inline void MainInterface::showTab( int i_tab )
+{
+ stackCentralOldState = stackCentralW->currentIndex();
+
+ stackCentralW->setCurrentIndex( i_tab );
+ if( stackCentralW->isHidden() ) stackCentralW->show();
+}
+
+/* Asynchronous call from the WindowClose function */
void MainInterface::releaseVideo( void )
{
emit askReleaseVideo( );
{
videoWidget->release( );
- if( bgWasVisible )
+ /* Restore the previous State */
+ if( stackCentralOldState == BACKG_TAB )
{
- /* Reset the bg state */
- bgWasVisible = false;
- bgWidget->show();
+ showBg();
+ }
+ else
+ {
+ stackCentralW->hide();
+ stackCentralOldState == -1;
}
-
- videoIsActive = false;
/* Try to resize, except when you are in Fullscreen mode */
- if( !isFullScreen() ) doComponentsUpdate();
+ doComponentsUpdate();
}
-/* Call from WindowControl function */
+/* Asynchronous call from WindowControl function */
int MainInterface::controlVideo( int i_query, va_list args )
{
- int i_ret = VLC_SUCCESS;
switch( i_query )
{
- case VOUT_SET_SIZE:
- {
- unsigned int i_width = va_arg( args, unsigned int );
- unsigned int i_height = va_arg( args, unsigned int );
- emit askVideoToResize( i_width, i_height );
- emit askUpdate();
- break;
- }
- case VOUT_SET_STAY_ON_TOP:
- {
- int i_arg = va_arg( args, int );
- QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
- break;
- }
- default:
- i_ret = VLC_EGENERIC;
- msg_Warn( p_intf, "unsupported control query" );
- break;
+ /* Debug to check if VOUT_WINDOW_SET_SIZE is called? */
+ msg_Dbg( p_intf, "Control Video: %i", i_query );
+ case VOUT_WINDOW_SET_SIZE:
+ {
+ unsigned int i_width = va_arg( args, unsigned int );
+ unsigned int i_height = va_arg( args, unsigned int );
+ emit askVideoToResize( i_width, i_height );
+ emit askUpdate();
+ return VLC_SUCCESS;
+ }
+ case VOUT_WINDOW_SET_ON_TOP:
+ {
+ int i_arg = va_arg( args, int );
+ QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
+ return VLC_SUCCESS;
+ }
+ case VOUT_WINDOW_SET_FULLSCREEN:
+ {
+ bool b_fs = va_arg( args, int );
+ emit askVideoSetFullScreen( b_fs );
+ return VLC_SUCCESS;
+ }
+ default:
+ msg_Warn( p_intf, "unsupported control query" );
+ return VLC_EGENERIC;
}
- return i_ret;
}
/*****************************************************************************
{
playlistWidget = new PlaylistWidget( p_intf );
- i_pl_dock = PL_UNDOCKED;
-/* i_pl_dock = (pl_dock_e)getSettings()
- ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
+ i_pl_dock = PL_BOTTOM;
+ /*i_pl_dock = (pl_dock_e)getSettings()
+ ->value( "pl-dock-status", PL_UNDOCKED ).toInt();*/
if( i_pl_dock == PL_UNDOCKED )
{
}
else
{
- mainLayout->insertWidget( 4, playlistWidget );
+ stackCentralW->insertWidget(PLAYL_TAB, playlistWidget );
+ stackCentralW->setCurrentWidget( playlistWidget );
+ stackCentralW->show();
}
playlistVisible = true;
else
{
/* toggle the visibility of the playlist */
- TOGGLEV( playlistWidget );
+ if( stackCentralW->currentIndex() != PLAYL_TAB )
+ {
+ stackCentralW->insertWidget(PLAYL_TAB, playlistWidget );
+ stackCentralW->setCurrentWidget( playlistWidget );
+ stackCentralW->show();
+ }
+ else
+ stackCentralW->setCurrentIndex( VIDEO_TAB );
playlistVisible = !playlistVisible;
//doComponentsUpdate(); //resize( sizeHint() );
}
if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
i_visualmode != QT_MINIMAL_MODE )
{ /* NORMAL MODE then */
- if( !videoWidget || videoWidget->isHidden() ) emit askBgWidgetToToggle();
+ stackCentralW->show();
+ if( !videoWidget || stackCentralW->currentIndex() != VIDEO_TAB )
+ {
+ showBg();
+ }
else
{
- /* If video is visible, then toggle the status of bgWidget */
- bgWasVisible = !bgWasVisible;
+ /* If video is visible, then toggle the status of bgWidget */ //bgWasVisible = !bgWasVisible;
+ if( stackCentralOldState == BACKG_TAB )
+ stackCentralOldState = HIDDEN_TAB;
+ else
+ stackCentralOldState = BACKG_TAB;
}
}
+ i_bg_height = stackCentralW->height();
+
menuBar()->setVisible( !b_switch );
controls->setVisible( !b_switch );
statusBar()->setVisible( !b_switch );
inputC->setVisible( !b_switch );
+
doComponentsUpdate();
emit minimalViewToggled( b_switch );
}
-/* Video widget cannot do this synchronously as it runs in another thread */
-/* Well, could it, actually ? Probably dangerous ... */
-
-/* This function is called:
- - toggling of minimal View
- - through askUpdate() by Vout thread request video and resize video (zoom)
- - Advanced buttons toggled
- */
-void MainInterface::doComponentsUpdate()
-{
- msg_Dbg( p_intf, "Updating the geometry" );
- /* Here we resize to sizeHint() and not adjustsize because we want
- the videoWidget to be exactly the correctSize */
- resize( sizeHint() );
- // adjustSize() ;
-#ifndef NDEBUG
- debug();
-#endif
-}
-
/* toggling advanced controls buttons */
void MainInterface::toggleAdvanced()
{
/************************************************************************
* Other stuff
************************************************************************/
-void MainInterface::setName( QString name )
+void MainInterface::setName( const QString& name )
{
input_name = name; /* store it for the QSystray use */
/* Display it in the status bar, but also as a Tooltip in case it doesn't
nameLabel->setToolTip( " " + name +" " );
}
+/**
+ * Give the decorations of the Main Window a correct Name.
+ * If nothing is given, set it to VLC...
+ **/
+void MainInterface::setVLCWindowsTitle( const QString& aTitle )
+{
+ if( aTitle.isEmpty() )
+ {
+ setWindowTitle( qtr( "VLC media player" ) );
+ }
+ else
+ {
+ setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
+ }
+}
+
+void MainInterface::showCryptedLabel( bool b_show )
+{
+ if( cryptedLabel == NULL )
+ {
+ cryptedLabel = new QLabel;
+ // The lock icon is not the right one for DRM protection/scrambled.
+ //cryptedLabel->setPixmap( QPixmap( ":/lock" ) );
+ cryptedLabel->setText( "DRM" );
+ statusBar()->addWidget( cryptedLabel );
+ }
+
+ cryptedLabel->setVisible( b_show );
+}
+
/*****************************************************************************
* Systray Icon and Systray Menu
*****************************************************************************/
-
+#ifndef HAVE_MAEMO
/**
* Create a SystemTray icon and a menu that would go with it.
* Connects to a click handler on the icon.
{
QIcon iconVLC;
if( QDate::currentDate().dayOfYear() >= 354 )
- iconVLC = QIcon( QPixmap( ":/vlc128-christmas.png" ) );
+ iconVLC = QIcon( ":/logo/vlc128-christmas.png" );
else
- iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
+ iconVLC = QIcon( ":/logo/vlc128.png" );
sysTray = new QSystemTrayIcon( iconVLC, this );
sysTray->setToolTip( qtr( "VLC media player" ));
* Updates the name of the systray Icon tooltip.
* Doesn't check if the systray exists, check before you call it.
**/
-void MainInterface::updateSystrayTooltipName( QString name )
+void MainInterface::updateSystrayTooltipName( const QString& name )
{
if( name.isEmpty() )
{
break;
}
}
+ QVLCMenu::updateSystrayMenu( this, p_intf );
}
+#endif
/************************************************************************
* D&D Events
void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
{
- const QMimeData *mimeData = event->mimeData();
+ event->setDropAction( Qt::CopyAction );
+ if( !event->possibleActions() & Qt::CopyAction )
+ return;
+
+ const QMimeData *mimeData = event->mimeData();
- /* D&D of a subtitles file, add it on the fly */
- if( mimeData->urls().size() == 1 )
- {
- if( THEMIM->getIM()->hasInput() )
+ /* D&D of a subtitles file, add it on the fly */
+ if( mimeData->urls().size() == 1 && THEMIM->getIM()->hasInput() )
+ {
+ if( !input_AddSubtitle( THEMIM->getInput(),
+ qtu( toNativeSeparators( mimeData->urls()[0].toLocalFile() ) ),
+ true ) )
{
- if( !input_AddSubtitle( THEMIM->getInput(),
- qtu( toNativeSeparators(
- mimeData->urls()[0].toLocalFile() ) ),
- true ) )
- {
- event->acceptProposedAction();
- return;
- }
+ event->accept();
+ return;
}
- }
- bool first = b_play;
- foreach( const QUrl &url, mimeData->urls() )
- {
+ }
+
+ bool first = b_play;
+ foreach( const QUrl &url, mimeData->urls() )
+ {
QString s = toNativeSeparators( url.toLocalFile() );
if( s.length() > 0 ) {
- playlist_Add( THEPL, qtu(s), NULL,
- PLAYLIST_APPEND | (first ? PLAYLIST_GO: 0),
- PLAYLIST_END, true, false );
+ char* psz_uri = make_URI( qtu(s) );
+ playlist_Add( THEPL, psz_uri, NULL,
+ PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
+ PLAYLIST_END, true, pl_Unlocked );
+ free( psz_uri );
first = false;
RecentsMRL::getInstance( p_intf )->addRecent( s );
}
- }
- event->acceptProposedAction();
+ }
+ event->accept();
}
void MainInterface::dragEnterEvent(QDragEnterEvent *event)
{
{
SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
if( p_event->OnTop() )
- setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
+ setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
else
- setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
- show(); /* necessary to apply window flags?? */
+ setWindowFlags( windowFlags() & ~Qt::WindowStaysOnTopHint );
+ show(); /* necessary to apply window flags */
}
}
void MainInterface::keyPressEvent( QKeyEvent *e )
+{
+ handleKeyPress( e );
+}
+
+void MainInterface::handleKeyPress( QKeyEvent *e )
{
if( ( e->modifiers() & Qt::ControlModifier ) && ( e->key() == Qt::Key_H )
- && menuBar()->isHidden() )
+ && !menuBar()->isVisible() )
{
toggleMinimalView( false );
e->accept();
void MainInterface::resizeEvent( QResizeEvent * event )
{
+#if 0
if( b_keep_size )
{
if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
mainBasedSize = size();
}
}
+#endif
+ QVLCMW::resizeEvent( event );
+ msg_Warn( p_intf, "%i", size().height() );
}
void MainInterface::wheelEvent( QWheelEvent *e )
}
-/*****************************************************************************
- * Callbacks
- *****************************************************************************/
-static int InteractCallback( vlc_object_t *p_this,
- const char *psz_var, vlc_value_t old_val,
- vlc_value_t new_val, void *param )
+//moc doesn't know about #ifdef, so we have to build this method for every platform
+void MainInterface::changeThumbbarButtons( int i_status)
{
- intf_dialog_args_t *p_arg = new intf_dialog_args_t;
- p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
- DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
- QApplication::postEvent( THEDP, event );
- return VLC_SUCCESS;
+#ifdef WIN32
+ // Define an array of two buttons. These buttons provide images through an
+ // image list and also provide tooltips.
+ DWORD dwMask = THB_BITMAP | THB_FLAGS;
+
+ THUMBBUTTON thbButtons[3];
+ //prev
+ thbButtons[0].dwMask = dwMask;
+ thbButtons[0].iId = 0;
+ thbButtons[0].iBitmap = 0;
+
+ //play/pause
+ thbButtons[1].dwMask = dwMask;
+ thbButtons[1].iId = 1;
+
+ //next
+ thbButtons[2].dwMask = dwMask;
+ thbButtons[2].iId = 2;
+ thbButtons[2].iBitmap = 3;
+
+ switch( i_status )
+ {
+ case 0:
+ case END_S:
+ {
+ thbButtons[0].dwFlags = THBF_HIDDEN;
+ thbButtons[1].dwFlags = THBF_HIDDEN;
+ thbButtons[2].dwFlags = THBF_HIDDEN;
+ break;
+ }
+ case PLAYING_S:
+ {
+ thbButtons[0].dwFlags = THBF_ENABLED;
+ thbButtons[1].dwFlags = THBF_ENABLED;
+ thbButtons[2].dwFlags = THBF_ENABLED;
+ thbButtons[1].iBitmap = 1;
+ break;
+ }
+ case PAUSE_S:
+ {
+ //thbButtons[0].dwFlags = THBF_ENABLED;
+ //thbButtons[1].dwFlags = THBF_ENABLED;
+ //thbButtons[2].dwFlags = THBF_ENABLED;
+ thbButtons[1].iBitmap = 2;
+ break;
+ }
+ }
+
+ HRESULT hr = p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons);
+ if(S_OK != hr)
+ msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr );
+#else
+ ;
+#endif
}
/*****************************************************************************
/* Show event */
return VLC_SUCCESS;
}
-