#include <QLabel>
#include <QSlider>
#include <QWidgetAction>
+#if 0
#include <QDockWidget>
+#endif
#include <QToolBar>
#include <QGroupBox>
#include <QDate>
{
/* Variables initialisation */
// need_components_update = false;
- bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
+ bgWidget = NULL;
+ videoWidget = NULL;
+ playlistWidget = NULL;
+ sysTray = NULL;
videoIsActive = false;
- input_name = "";
playlistVisible = false;
+ input_name = "";
/* Ask for privacy */
- privacy();
+ askForPrivacy();
/**
* Configuration and settings
* Pre-building of interface
**/
- settings = new QSettings( "vlc", "vlc-qt-interface" );
- settings->beginGroup( "MainWindow" );
-
/* Main settings */
setFocusPolicy( Qt::StrongFocus );
setAcceptDrops( true );
i_visualmode = config_GetInt( p_intf, "qt-display-mode" );
/* Set the other interface settings */
+ settings = new QSettings( "vlc", "vlc-qt-interface" );
+ settings->beginGroup( "MainWindow" );
+
//TODO: I don't like that code
visualSelectorEnabled = settings->value( "visual-selector", false ).toBool();
- notificationEnabled = config_GetInt( p_intf, "qt-notification" )
- ? true : false;
+ notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
/**************************
* UI and Widgets design
setVLCWindowsTitle();
handleMainUi( settings );
+#if 0
/* Create a Dock to get the playlist */
- dockPL = new QDockWidget( qtr( "Playlist" ), this );
+/* dockPL = new QDockWidget( qtr( "Playlist" ), this );
dockPL->setSizePolicy( QSizePolicy::Preferred,
QSizePolicy::Expanding );
dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
dockPL->setAllowedAreas( Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
| Qt::BottomDockWidgetArea );
- dockPL->hide();
+ dockPL->hide();*/
+#endif
/************
* Menu Bar
************/
QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled );
- /****************
- * Status Bar *
- ****************/
- /* Widgets Creation*/
- b_remainingTime = false;
- timeLabel = new TimeLabel;
- timeLabel->setText( " --:--/--:-- " );
- timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- nameLabel = new QLabel;
- nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
- | Qt::TextSelectableByKeyboard );
- speedLabel = new QLabel( "1.00x" );
- speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
-
- /* Styling those labels */
- timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
- speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
- nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel);
-
- pgBar = new QProgressBar;
- pgBar->hide();
-
- /* and adding those */
- statusBar()->addWidget( nameLabel, 8 );
- statusBar()->addPermanentWidget( speedLabel, 0 );
- statusBar()->addPermanentWidget( pgBar, 0 );
- statusBar()->addPermanentWidget( timeLabel, 0 );
-
-
- /* timeLabel behaviour:
- - double clicking opens the goto time dialog
- - right-clicking and clicking just toggle between remaining and
- elapsed time.*/
- CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
- CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
- CONNECT( timeLabel, timeLabelDoubleClicked(), this, toggleTimeDisplay() );
-
- /* Speed Label behaviour:
- - right click gives the vertical speed slider */
- CONNECT( speedLabel, customContextMenuRequested( QPoint ),
- this, showSpeedMenu( QPoint ) );
+ /* StatusBar Creation */
+ createStatusBar();
- /**********************
- * Systray Management *
- **********************/
- sysTray = NULL;
- bool b_createSystray = false;
- bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
- if( config_GetInt( p_intf, "qt-start-minimized") )
- {
- if( b_systrayAvailable )
- {
- b_createSystray = true;
- hide(); //FIXME BUG HERE
- }
- else msg_Warn( p_intf, "You can't minize if you haven't a system "
- "tray bar" );
- }
- if( config_GetInt( p_intf, "qt-system-tray") )
- b_createSystray = true;
-
- if( b_systrayAvailable && b_createSystray )
- createSystray();
/********************
* Input Manager *
updateSystrayTooltipStatus( int ) );
}
+ /* END CONNECTS ON IM */
+
+
/** OnTimeOut **/
- // TODO
+ /* TODO Remove this function, but so far, there is no choice because there
+ is no intf-should-die variable */
ON_TIMEOUT( updateOnTimer() );
//ON_TIMEOUT( debug() );
}
/* VideoWidget connect mess to avoid different threads speaking to each other */
- CONNECT( this, askReleaseVideo( void * ), this, releaseVideoSlot( void * ) );
+ CONNECT( this, askReleaseVideo( void * ),
+ this, releaseVideoSlot( void * ) );
CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
videoWidget, SetSizing( unsigned int, unsigned int ) );
+
CONNECT( this, askUpdate(), this, doComponentsUpdate() );
- CONNECT( dockPL, topLevelChanged( bool ), this, doComponentsUpdate() );
CONNECT( controls, advancedControlsToggled( bool ),
this, doComponentsUpdate() );
-
/* Size and placement of interface */
move( settings->value( "pos", QPoint( 0, 0 ) ).toPoint() );
QSize newSize = settings->value( "size", QSize( 350, 60 ) ).toSize();
if( newSize.isValid() )
- {
resize( newSize );
- }
else
- {
msg_Warn( p_intf, "Invalid size in constructor" );
- }
/* Playlist */
- int tgPlay = settings->value( "playlist-visible", 0 ).toInt();
+ if( settings->value( "playlist-visible", 0 ).toInt() ) togglePlaylist();
settings->endGroup();
- if( tgPlay )
- {
- togglePlaylist();
- }
-
show();
- if( i_visualmode == QT_MINIMAL_MODE )
- toggleMinimalView();
+ if( i_visualmode == QT_MINIMAL_MODE )
+ toggleMinimalView();
- /* Update the geometry TODO: is it useful */
+ /* Update the geometry TODO: is it useful ?*/
updateGeometry();
+
+ /*****************************************************
+ * End everything by creating the Systray Management *
+ *****************************************************/
+ initSystray();
}
MainInterface::~MainInterface()
msg_Dbg( p_intf, "Destroying the main interface" );
if( playlistWidget ) playlistWidget->savingSettings( settings );
- if( ExtendedDialog::exists() )
- ExtendedDialog::getInstance( p_intf )->savingSettings();
settings->beginGroup( "MainWindow" );
- settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) );
+// settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) );
settings->setValue( "playlist-visible", (int)playlistVisible );
settings->setValue( "adv-controls",
getControlsVisibilityStatus() & CONTROLS_ADVANCED );
settings->setValue( "pos", pos() );
- settings->setValue( "size", size() );
+ if( !videoIsActive )
+ settings->setValue( "size", size() );
if( bgWidget )
settings->setValue( "backgroundSize", bgWidget->size() );
* Main UI handling *
*****************************/
+inline void MainInterface::createStatusBar()
+{
+ /****************
+ * Status Bar *
+ ****************/
+ /* Widgets Creation*/
+ b_remainingTime = false;
+ timeLabel = new TimeLabel;
+ timeLabel->setText( " --:--/--:-- " );
+ timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ nameLabel = new QLabel;
+ nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
+ | Qt::TextSelectableByKeyboard );
+ speedLabel = new SpeedLabel( p_intf, "1.00x" );
+ speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
+
+ /* Styling those labels */
+ timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
+ speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
+ nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel);
+
+ pgBar = new QProgressBar;
+ pgBar->hide();
+
+ /* and adding those */
+ statusBar()->addWidget( nameLabel, 8 );
+ statusBar()->addPermanentWidget( speedLabel, 0 );
+ statusBar()->addPermanentWidget( pgBar, 0 );
+ statusBar()->addPermanentWidget( timeLabel, 0 );
+
+ /* timeLabel behaviour:
+ - double clicking opens the goto time dialog
+ - right-clicking and clicking just toggle between remaining and
+ elapsed time.*/
+ CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
+ CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
+ CONNECT( timeLabel, timeLabelDoubleClicked(), this, toggleTimeDisplay() );
+
+ /* Speed Label behaviour:
+ - right click gives the vertical speed slider */
+ CONNECT( speedLabel, customContextMenuRequested( QPoint ),
+ this, showSpeedMenu( QPoint ) );
+}
+
+inline void MainInterface::initSystray()
+{
+ bool b_createSystray = false;
+ bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
+ if( config_GetInt( p_intf, "qt-start-minimized") )
+ {
+ if( b_systrayAvailable )
+ {
+ b_createSystray = true;
+ hide();
+ }
+ else msg_Err( p_intf, "You can't minimize if you haven't a system "
+ "tray bar" );
+ }
+ if( config_GetInt( p_intf, "qt-system-tray") )
+ b_createSystray = true;
+
+ if( b_systrayAvailable && b_createSystray )
+ createSystray();
+}
+
/**
* Give the decorations of the Main Window a correct Name.
* If nothing is given, set it to VLC...
/* Margins, spacing */
main->setContentsMargins( 0, 0, 0, 0 );
- // main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+ main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
mainLayout->setMargin( 0 );
/* Create the CONTROLS Widget */
}
/* Finish the sizing */
- updateGeometry();
+ main->updateGeometry();
}
-inline void MainInterface::privacy()
+inline void MainInterface::askForPrivacy()
{
/**
* Ask for the network policy on FIRST STARTUP
}
config_PutInt( p_intf, "qt-privacy-ask" , 0 );
+ /* We have to save here because the user may not launch Prefs */
config_SaveConfigFile( p_intf, NULL );
}
}
CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
CONFIG_GENERIC_NOBOOL( "qt-updates-days", Integer ); line++;
#endif
+ CONFIG_GENERIC( "security-policy", IntegerList ); line++;
+
QPushButton *ok = new QPushButton( qtr( "Ok" ) );
gLayout->addWidget( ok, 2, 2 );
return privacy->exec();
}
-//FIXME remove me at the end...
-void MainInterface::debug()
-{
- msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
- msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
-}
/**********************************************************************
* Handling of sizing of the components
ask _parent->isFloating()...
If you think this would be better, please FIXME it...
*/
+#if 0
QSize MainInterface::sizeHint() const
{
int nwidth = controls->sizeHint().width();
nwidth = videoWidget->size().width();
msg_Dbg( p_intf, "2 %i %i", nheight, nwidth );
}
- if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget() )
+/* if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget() )
{
nheight += dockPL->size().height();
nwidth = __MAX( nwidth, dockPL->size().width() );
msg_Dbg( p_intf, "3 %i %i", nheight, nwidth );
- }
+ }*/
msg_Dbg( p_intf, "4 %i %i", nheight, nwidth );
return QSize( nwidth, nheight );
}
-
+#endif
#if 0
/* FIXME This is dead code and need to be removed AT THE END */
void MainInterface::resizeEvent( QResizeEvent *e )
}
#endif
+void MainInterface::requestLayoutUpdate()
+{
+ emit askUpdate();
+}
+
+//FIXME remove me at the end...
+void MainInterface::debug()
+{
+ msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
+ msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
+ if( videoWidget->isVisible() )
+ {
+// sleep( 10 );
+ msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
+ msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
+ }
+ adjustSize();
+}
+
/****************************************************************************
* Small right-click menu for rate control
****************************************************************************/
bool onTop;
};
+/**
+ * README
+ * README
+ * Thou shall not call/resize/hide widgets from on another thread.
+ * This is wrong, and this is TEH reason to emit signals on those Video Functions
+ **/
/* function called from ::DoRequest in order to show a nice VideoWidget
at the good size */
void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
if( bgWidget )// WORONG
bgWidget->show();
+ adjustSize();
videoIsActive = false;
- emit askUpdate();
}
int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
{
- int i_ret = VLC_EGENERIC;
+ int i_ret = VLC_SUCCESS;
switch( i_query )
{
case VOUT_GET_SIZE:
{
unsigned int *pi_width = va_arg( args, unsigned int * );
unsigned int *pi_height = va_arg( args, unsigned int * );
- *pi_width = videoWidget->width();
- *pi_height = videoWidget->height();
- i_ret = VLC_SUCCESS;
+ *pi_width = videoWidget->videoSize.width();
+ *pi_height = videoWidget->videoSize.height();
break;
}
case VOUT_SET_SIZE:
unsigned int i_height = va_arg( args, unsigned int );
emit askVideoToResize( i_width, i_height );
emit askUpdate();
- updateGeometry();
- i_ret = VLC_SUCCESS;
break;
}
case VOUT_SET_STAY_ON_TOP:
{
int i_arg = va_arg( args, int );
QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
- i_ret = VLC_SUCCESS;
break;
}
default:
+ i_ret = VLC_EGENERIC;
msg_Warn( p_intf, "unsupported control query" );
break;
}
**/
void MainInterface::togglePlaylist()
{
+ THEDP->playlistDialog();
+#if 0
/* CREATION
If no playlist exist, then create one and attach it to the DockPL*/
if( !playlistWidget )
resize( sizeHint() );
playlistVisible = !playlistVisible;
}
+ #endif
}
/* Function called from the menu to undock the playlist */
void MainInterface::undockPlaylist()
{
- dockPL->setFloating( true );
- resize( sizeHint() );
+// dockPL->setFloating( true );
+ adjustSize();
}
void MainInterface::toggleMinimalView()
/* Well, could it, actually ? Probably dangerous ... */
void MainInterface::doComponentsUpdate()
{
- resize( sizeHint() );
msg_Dbg( p_intf, "Updating the geometry" );
- updateGeometry();
+// resize( sizeHint() );
+ debug();
}
/* toggling advanced controls buttons */
void MainInterface::setStatus( int status )
{
+ msg_Dbg( p_intf, "I was here, updating your status" );
/* Forward the status to the controls to toggle Play/Pause */
controls->setStatus( status );
+
+ controls->updateInput();
+ speedControl->setEnable( THEMIM->getIM()->hasInput() );
+
/* And in the systray for the menu */
if( sysTray )
QVLCMenu::updateSystrayMenu( this, p_intf );
str.setNum( ( 1000 / (double)rate ), 'f', 2 );
str.append( "x" );
speedLabel->setText( str );
+ speedLabel->setToolTip( str );
speedControl->updateControls( rate );
}
void MainInterface::updateOnTimer()
{
+ /* No event for dying */
if( intf_ShouldDie( p_intf ) )
{
QApplication::closeAllWindows();
QApplication::quit();
}
-#if 0
- if( need_components_update )
- {
- doComponentsUpdate();
- need_components_update = false;
- }
-#endif
}
/*****************************************************************************
{
intf_thread_t *p_intf = (intf_thread_t *)param;
msg_Dbg( p_this, "Intf Show Requested" ); // DEBUG to track the non disparition of the menu...
- //p_intf->p_sys->b_intf_show = VLC_TRUE;
+ p_intf->p_sys->p_mi->requestLayoutUpdate();
return VLC_SUCCESS;
}