| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
#ifdef HAVE_CONFIG_H |
|---|
| 27 |
# include "config.h" |
|---|
| 28 |
#endif |
|---|
| 29 |
|
|---|
| 30 |
#include "qt4.hpp" |
|---|
| 31 |
#include "main_interface.hpp" |
|---|
| 32 |
#include "input_manager.hpp" |
|---|
| 33 |
#include "util/qvlcframe.hpp" |
|---|
| 34 |
#include "util/customwidgets.hpp" |
|---|
| 35 |
#include "dialogs_provider.hpp" |
|---|
| 36 |
#include "components/interface_widgets.hpp" |
|---|
| 37 |
#include "components/playlist/playlist.hpp" |
|---|
| 38 |
#include "dialogs/extended.hpp" |
|---|
| 39 |
#include "dialogs/playlist.hpp" |
|---|
| 40 |
#include "menus.hpp" |
|---|
| 41 |
|
|---|
| 42 |
#include <QMenuBar> |
|---|
| 43 |
#include <QCloseEvent> |
|---|
| 44 |
#include <QPushButton> |
|---|
| 45 |
#include <QStatusBar> |
|---|
| 46 |
#include <QKeyEvent> |
|---|
| 47 |
#include <QUrl> |
|---|
| 48 |
#include <QSystemTrayIcon> |
|---|
| 49 |
#include <QSize> |
|---|
| 50 |
#include <QMenu> |
|---|
| 51 |
#include <QLabel> |
|---|
| 52 |
#include <QSlider> |
|---|
| 53 |
#include <QWidgetAction> |
|---|
| 54 |
#include <QToolBar> |
|---|
| 55 |
#include <QGroupBox> |
|---|
| 56 |
#include <QDate> |
|---|
| 57 |
|
|---|
| 58 |
#include <assert.h> |
|---|
| 59 |
#include <vlc_keys.h> |
|---|
| 60 |
#include <vlc_vout.h> |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, |
|---|
| 64 |
vlc_value_t old_val, vlc_value_t new_val, void *param ); |
|---|
| 65 |
static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable, |
|---|
| 66 |
vlc_value_t old_val, vlc_value_t new_val, void *param ); |
|---|
| 67 |
static int InteractCallback( vlc_object_t *, const char *, vlc_value_t, |
|---|
| 68 |
vlc_value_t, void *); |
|---|
| 69 |
|
|---|
| 70 |
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) |
|---|
| 71 |
{ |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
bgWidget = NULL; |
|---|
| 75 |
videoWidget = NULL; |
|---|
| 76 |
playlistWidget = NULL; |
|---|
| 77 |
sysTray = NULL; |
|---|
| 78 |
videoIsActive = false; |
|---|
| 79 |
playlistVisible = false; |
|---|
| 80 |
input_name = ""; |
|---|
| 81 |
fullscreenControls = NULL; |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
askForPrivacy(); |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
setFocusPolicy( Qt::StrongFocus ); |
|---|
| 92 |
setAcceptDrops( true ); |
|---|
| 93 |
setWindowIcon( QApplication::windowIcon() ); |
|---|
| 94 |
setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) ); |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
videoEmbeddedFlag = config_GetInt( p_intf, "embedded-video" ); |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
i_visualmode = config_GetInt( p_intf, "qt-display-mode" ); |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
settings = getSettings(); |
|---|
| 104 |
settings->beginGroup( "MainWindow" ); |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
visualSelectorEnabled = settings->value( "visual-selector", false).toBool(); |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" ); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
setVLCWindowsTitle(); |
|---|
| 116 |
handleMainUi( settings ); |
|---|
| 117 |
|
|---|
| 118 |
#if 0 |
|---|
| 119 |
|
|---|
| 120 |
dockPL = new QDockWidget( qtr( "Playlist" ), this ); |
|---|
| 121 |
dockPL->setSizePolicy( QSizePolicy::Preferred, |
|---|
| 122 |
QSizePolicy::Expanding ); |
|---|
| 123 |
dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures ); |
|---|
| 124 |
dockPL->setAllowedAreas( Qt::LeftDockWidgetArea |
|---|
| 125 |
| Qt::RightDockWidgetArea |
|---|
| 126 |
| Qt::BottomDockWidgetArea ); |
|---|
| 127 |
dockPL->hide(); |
|---|
| 128 |
#endif |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled ); |
|---|
| 134 |
|
|---|
| 135 |
createStatusBar(); |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
MainInputManager::getInstance( p_intf ); |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) ); |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
CONNECT( THEMIM->getIM(), nameChanged( QString ), this, |
|---|
| 159 |
setName( QString ) ); |
|---|
| 160 |
|
|---|
| 161 |
if( sysTray ) |
|---|
| 162 |
{ |
|---|
| 163 |
CONNECT( THEMIM->getIM(), nameChanged( QString ), this, |
|---|
| 164 |
updateSystrayTooltipName( QString ) ); |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
if( config_GetInt( p_intf, "qt-name-in-title" ) ) |
|---|
| 168 |
{ |
|---|
| 169 |
CONNECT( THEMIM->getIM(), nameChanged( QString ), this, |
|---|
| 170 |
setVLCWindowsTitle( QString ) ); |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) ); |
|---|
| 178 |
|
|---|
| 179 |
if( sysTray ) |
|---|
| 180 |
{ |
|---|
| 181 |
CONNECT( THEMIM->getIM(), statusChanged( int ), this, |
|---|
| 182 |
updateSystrayTooltipStatus( int ) ); |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
ON_TIMEOUT( updateOnTimer() ); |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS ); |
|---|
| 197 |
var_AddCallback( p_intf, "interaction", InteractCallback, this ); |
|---|
| 198 |
p_intf->b_interaction = true; |
|---|
| 199 |
|
|---|
| 200 |
var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); |
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); |
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
CONNECT( this, askReleaseVideo( void * ), |
|---|
| 208 |
this, releaseVideoSlot( void * ) ); |
|---|
| 209 |
if( videoWidget ) |
|---|
| 210 |
CONNECT( this, askVideoToResize( unsigned int, unsigned int ), |
|---|
| 211 |
videoWidget, SetSizing( unsigned int, unsigned int ) ); |
|---|
| 212 |
|
|---|
| 213 |
CONNECT( this, askUpdate(), this, doComponentsUpdate() ); |
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
settings->beginGroup( "MainWindow" ); |
|---|
| 217 |
QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) ); |
|---|
| 218 |
|
|---|
| 219 |
bool b_visible = settings->value( "playlist-visible", 0 ).toInt(); |
|---|
| 220 |
settings->endGroup(); |
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
if( b_visible ) togglePlaylist(); |
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
setMinimumWidth( __MAX( controls->sizeHint().width(), |
|---|
| 227 |
menuBar()->sizeHint().width() ) ); |
|---|
| 228 |
show(); |
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
if( i_visualmode == QT_MINIMAL_MODE ) |
|---|
| 233 |
toggleMinimalView(); |
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
updateGeometry(); |
|---|
| 238 |
resize( sizeHint() ); |
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
initSystray(); |
|---|
| 244 |
} |
|---|
| 245 |
|
|---|
| 246 |
MainInterface::~MainInterface() |
|---|
| 247 |
{ |
|---|
| 248 |
msg_Dbg( p_intf, "Destroying the main interface" ); |
|---|
| 249 |
|
|---|
| 250 |
if( videoIsActive ) videoWidget->hide(); |
|---|
| 251 |
|
|---|
| 252 |
if( playlistWidget ) |
|---|
| 253 |
{ |
|---|
| 254 |
if( !isDocked() ) |
|---|
| 255 |
QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget ); |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
settings->beginGroup( "MainWindow" ); |
|---|
| 259 |
|
|---|
| 260 |
settings->setValue( "pl-dock-status", (int)i_pl_dock ); |
|---|
| 261 |
settings->setValue( "playlist-visible", (int)playlistVisible ); |
|---|
| 262 |
settings->setValue( "adv-controls", |
|---|
| 263 |
getControlsVisibilityStatus() & CONTROLS_ADVANCED ); |
|---|
| 264 |
|
|---|
| 265 |
if( bgWidget ) |
|---|
| 266 |
settings->setValue( "backgroundSize", bgWidget->size() ); |
|---|
| 267 |
|
|---|
| 268 |
QVLCTools::saveWidgetPosition(settings, this); |
|---|
| 269 |
settings->endGroup(); |
|---|
| 270 |
|
|---|
| 271 |
var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); |
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); |
|---|
| 275 |
|
|---|
| 276 |
p_intf->b_interaction = false; |
|---|
| 277 |
var_DelCallback( p_intf, "interaction", InteractCallback, this ); |
|---|
| 278 |
|
|---|
| 279 |
p_intf->p_sys->p_mi = NULL; |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
inline void MainInterface::createStatusBar() |
|---|
| 287 |
{ |
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
timeLabel = new TimeLabel( p_intf ); |
|---|
| 293 |
nameLabel = new QLabel; |
|---|
| 294 |
nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse |
|---|
| 295 |
| Qt::TextSelectableByKeyboard ); |
|---|
| 296 |
speedLabel = new SpeedLabel( p_intf, "1.00x" ); |
|---|
| 297 |
speedLabel->setToolTip( |
|---|
| 298 |
qtr( "Current playback speed.\nRight click to adjust" ) ); |
|---|
| 299 |
speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu ); |
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 |
timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel ); |
|---|
| 303 |
speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel ); |
|---|
| 304 |
nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel); |
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
statusBar()->addWidget( nameLabel, 8 ); |
|---|
| 308 |
statusBar()->addPermanentWidget( speedLabel, 0 ); |
|---|
| 309 |
statusBar()->addPermanentWidget( timeLabel, 0 ); |
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() ); |
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
CONNECT( speedLabel, customContextMenuRequested( QPoint ), |
|---|
| 320 |
this, showSpeedMenu( QPoint ) ); |
|---|
| 321 |
} |
|---|
| 322 |
|
|---|
| 323 |
inline void MainInterface::initSystray() |
|---|
| 324 |
{ |
|---|
| 325 |
bool b_createSystray = false; |
|---|
| 326 |
bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable(); |
|---|
| 327 |
if( config_GetInt( p_intf, "qt-start-minimized") ) |
|---|
| 328 |
{ |
|---|
| 329 |
if( b_systrayAvailable ) |
|---|
| 330 |
{ |
|---|
| 331 |
b_createSystray = true; |
|---|
| 332 |
hide(); |
|---|
| 333 |
} |
|---|
| 334 |
else msg_Err( p_intf, "You can't minimize if you haven't a system " |
|---|
| 335 |
"tray bar" ); |
|---|
| 336 |
} |
|---|
| 337 |
if( config_GetInt( p_intf, "qt-system-tray") ) |
|---|
| 338 |
b_createSystray = true; |
|---|
| 339 |
|
|---|
| 340 |
if( b_systrayAvailable && b_createSystray ) |
|---|
| 341 |
createSystray(); |
|---|
| 342 |
} |
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
void MainInterface::setVLCWindowsTitle( QString aTitle ) |
|---|
| 349 |
{ |
|---|
| 350 |
if( aTitle.isEmpty() ) |
|---|
| 351 |
{ |
|---|
| 352 |
setWindowTitle( qtr( "VLC media player" ) ); |
|---|
| 353 |
} |
|---|
| 354 |
else |
|---|
| 355 |
{ |
|---|
| 356 |
setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) ); |
|---|
| 357 |
} |
|---|
| 358 |
} |
|---|
| 359 |
|
|---|
| 360 |
void MainInterface::handleMainUi( QSettings *settings ) |
|---|
| 361 |
{ |
|---|
| 362 |
|
|---|
| 363 |
QWidget *main = new QWidget; |
|---|
| 364 |
setCentralWidget( main ); |
|---|
| 365 |
mainLayout = new QVBoxLayout( main ); |
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
main->setContentsMargins( 0, 0, 0, 0 ); |
|---|
| 369 |
main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); |
|---|
| 370 |
mainLayout->setSpacing( 0 ); |
|---|
| 371 |
mainLayout->setMargin( 0 ); |
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); |
|---|
| 375 |
controls = new ControlsWidget( p_intf, this, |
|---|
| 376 |
settings->value( "adv-controls", false ).toBool(), |
|---|
| 377 |
b_shiny ); |
|---|
| 378 |
CONNECT( controls, advancedControlsToggled( bool ), |
|---|
| 379 |
this, doComponentsUpdate() ); |
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom ); |
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
speedControl = new SpeedControlWidget( p_intf ); |
|---|
| 386 |
speedControlMenu = new QMenu( this ); |
|---|
| 387 |
|
|---|
| 388 |
QWidgetAction *widgetAction = new QWidgetAction( speedControl ); |
|---|
| 389 |
widgetAction->setDefaultWidget( speedControl ); |
|---|
| 390 |
speedControlMenu->addAction( widgetAction ); |
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
#if 0 |
|---|
| 395 |
visualSelector = new VisualSelector( p_intf ); |
|---|
| 396 |
mainLayout->insertWidget( 0, visualSelector ); |
|---|
| 397 |
visualSelector->hide(); |
|---|
| 398 |
#endif |
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
bgWidget = new BackgroundWidget( p_intf ); |
|---|
| 402 |
bgWidget->resize( |
|---|
| 403 |
settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() ); |
|---|
| 404 |
bgWidget->updateGeometry(); |
|---|
| 405 |
mainLayout->insertWidget( 0, bgWidget ); |
|---|
| 406 |
CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() ); |
|---|
| 407 |
|
|---|
| 408 |
if( i_visualmode != QT_ALWAYS_VIDEO_MODE && |
|---|
| 409 |
i_visualmode != QT_MINIMAL_MODE ) |
|---|
| 410 |
{ |
|---|
| 411 |
bgWidget->hide(); |
|---|
| 412 |
} |
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 |
if( videoEmbeddedFlag ) |
|---|
| 416 |
{ |
|---|
| 417 |
videoWidget = new VideoWidget( p_intf ); |
|---|
| 418 |
mainLayout->insertWidget( 0, videoWidget, 10 ); |
|---|
| 419 |
} |
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
main->updateGeometry(); |
|---|
| 423 |
|
|---|
| 424 |
getSettings()->endGroup(); |
|---|
| 425 |
#ifdef WIN32 |
|---|
| 426 |
if ( depth() > 8 ) |
|---|
| 427 |
#endif |
|---|
| 428 |
|
|---|
| 429 |
if( config_GetInt( p_intf, "qt-fs-controller" ) ) |
|---|
| 430 |
{ |
|---|
| 431 |
fullscreenControls = new FullscreenControllerWidget( p_intf, this, |
|---|
| 432 |
settings->value( "adv-controls", false ).toBool(), |
|---|
| 433 |
b_shiny ); |
|---|
| 434 |
CONNECT( fullscreenControls, advancedControlsToggled( bool ), |
|---|
| 435 |
this, doComponentsUpdate() ); |
|---|
| 436 |
} |
|---|
| 437 |
} |
|---|
| 438 |
|
|---|
| 439 |
inline void MainInterface::askForPrivacy() |
|---|
| 440 |
{ |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
if( config_GetInt( p_intf, "qt-privacy-ask") ) |
|---|
| 445 |
{ |
|---|
| 446 |
QList<ConfigControl *> controls; |
|---|
| 447 |
if( privacyDialog( &controls ) == QDialog::Accepted ) |
|---|
| 448 |
{ |
|---|
| 449 |
QList<ConfigControl *>::Iterator i; |
|---|
| 450 |
for( i = controls.begin() ; i != controls.end() ; i++ ) |
|---|
| 451 |
{ |
|---|
| 452 |
ConfigControl *c = qobject_cast<ConfigControl *>(*i); |
|---|
| 453 |
c->doApply( p_intf ); |
|---|
| 454 |
} |
|---|
| 455 |
|
|---|
| 456 |
config_PutInt( p_intf, "qt-privacy-ask" , 0 ); |
|---|
| 457 |
|
|---|
| 458 |
config_SaveConfigFile( p_intf, NULL ); |
|---|
| 459 |
} |
|---|
| 460 |
} |
|---|
| 461 |
} |
|---|
| 462 |
|
|---|
| 463 |
int MainInterface::privacyDialog( QList<ConfigControl *> *controls ) |
|---|
| 464 |
{ |
|---|
| 465 |
QDialog *privacy = new QDialog(); |
|---|
| 466 |
|
|---|
| 467 |
privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) ); |
|---|
| 468 |
|
|---|
| 469 |
QGridLayout *gLayout = new QGridLayout( privacy ); |
|---|
| 470 |
|
|---|
| 471 |
QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) ); |
|---|
| 472 |
QGridLayout *blablaLayout = new QGridLayout( blabla ); |
|---|
| 473 |
QLabel *text = new QLabel( qtr( |
|---|
| 474 |
"<p>The <i>VideoLAN Team</i> doesn't like when an application goes " |
|---|
| 475 |
"online without authorization.</p>\n " |
|---|
| 476 |
"<p><i>VLC media player</i> can retreive limited information from " |
|---|
| 477 |
"the Internet in order to get CD covers or to check " |
|---|
| 478 |
"for available updates.</p>\n" |
|---|
| 479 |
"<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> " |
|---|
| 480 |
"information, even anonymously, about your usage.</p>\n" |
|---|
| 481 |
"<p>Therefore please select from the following options, the default being " |
|---|
| 482 |
"almost no access to the web.</p>\n") ); |
|---|
| 483 |
text->setWordWrap( true ); |
|---|
| 484 |
text->setTextFormat( Qt::RichText ); |
|---|
| 485 |
|
|---|
| 486 |
blablaLayout->addWidget( text, 0, 0 ) ; |
|---|
| 487 |
|
|---|
| 488 |
QGroupBox *options = new QGroupBox; |
|---|
| 489 |
QGridLayout *optionsLayout = new QGridLayout( options ); |
|---|
| 490 |
|
|---|
| 491 |
gLayout->addWidget( blabla, 0, 0, 1, 3 ); |
|---|
| 492 |
gLayout->addWidget( options, 1, 0, 1, 3 ); |
|---|
| 493 |
module_config_t *p_config; |
|---|
| 494 |
ConfigControl *control; |
|---|
| 495 |
int line = 0; |
|---|
| 496 |
|
|---|
| 497 |
#define CONFIG_GENERIC( option, type ) \ |
|---|
| 498 |
p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ |
|---|
| 499 |
if( p_config ) \ |
|---|
| 500 |
{ \ |
|---|
| 501 |
control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ |
|---|
| 502 |
p_config, options, false, optionsLayout, line ); \ |
|---|
| 503 |
controls->append( control ); \ |
|---|
| 504 |
} |
|---|
| 505 |
|
|---|
| 506 |
#define CONFIG_GENERIC_NOBOOL( option, type ) \ |
|---|
| 507 |
p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ |
|---|
| 508 |
if( p_config ) \ |
|---|
| 509 |
{ \ |
|---|
| 510 |
control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ |
|---|
| 511 |
p_config, options, optionsLayout, line ); \ |
|---|
| 512 |
controls->append( control ); \ |
|---|
| 513 |
} |
|---|
| 514 |
|
|---|
| 515 |
CONFIG_GENERIC( "album-art", IntegerList ); line++; |
|---|
| 516 |
#ifdef UPDATE_CHECK |
|---|
| 517 |
CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++; |
|---|
| 518 |
CONFIG_GENERIC_NOBOOL( "qt-updates-days", Integer ); line++; |
|---|
| 519 |
#endif |
|---|
| 520 |
|
|---|
| 521 |
QPushButton *ok = new QPushButton( qtr( "OK" ) ); |
|---|
| 522 |
|
|---|
| 523 |
gLayout->addWidget( ok, 2, 2 ); |
|---|
| 524 |
|
|---|
| 525 |
CONNECT( ok, clicked(), privacy, accept() ); |
|---|
| 526 |
return privacy->exec(); |
|---|
| 527 |
} |
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
|
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 |
QSize MainInterface::sizeHint() const |
|---|
| 544 |
{ |
|---|
| 545 |
int nwidth = controls->sizeHint().width(); |
|---|
| 546 |
int nheight = controls->isVisible() ? |
|---|
| 547 |
controls->size().height() |
|---|
| 548 |
+ menuBar()->size().height() |
|---|
| 549 |
+ statusBar()->size().height() |
|---|
| 550 |
: 0 ; |
|---|
| 551 |
|
|---|
| 552 |
if( VISIBLE( bgWidget ) ) |
|---|
| 553 |
{ |
|---|
| 554 |
nheight += bgWidget->size().height(); |
|---|
| 555 |
nwidth = bgWidget->size().width(); |
|---|
| 556 |
} |
|---|
| 557 |
else if( videoIsActive && videoWidget->isVisible() ) |
|---|
| 558 |
{ |
|---|
| 559 |
nheight += videoWidget->sizeHint().height(); |
|---|
| 560 |
nwidth = videoWidget->sizeHint().width(); |
|---|
| 561 |
} |
|---|
| 562 |
#if 0 |
|---|
| 563 |
if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget() ) |
|---|
| 564 |
{ |
|---|
| 565 |
nheight += dockPL->size().height(); |
|---|
| 566 |
nwidth = __MAX( nwidth, dockPL->size().width() ); |
|---|
| 567 |
msg_Warn( p_intf, "3 %i %i", nheight, nwidth ); |
|---|
| 568 |
} |
|---|
| 569 |
#endif |
|---|
| 570 |
return QSize( nwidth, nheight ); |
|---|
| 571 |
} |
|---|
| 572 |
|
|---|
| 573 |
void MainInterface::toggleFSC() |
|---|
| 574 |
{ |
|---|
| 575 |
if( !fullscreenControls ) return; |
|---|
| 576 |
|
|---|
| 577 |
IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 ); |
|---|
| 578 |
QApplication::postEvent( fullscreenControls, static_cast<QEvent *>(eShow) ); |
|---|
| 579 |
} |
|---|
| 580 |
|
|---|
| 581 |
void MainInterface::debug() |
|---|
| 582 |
{ |
|---|
| 583 |
#ifndef NDEBUG |
|---|
| 584 |
msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); |
|---|
| 585 |
msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); |
|---|
| 586 |
if( videoWidget && videoWidget->isVisible() ) |
|---|
| 587 |
{ |
|---|
| 588 |
msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); |
|---|
| 589 |
msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); |
|---|
| 590 |
} |
|---|
| 591 |
#endif |
|---|
| 592 |
} |
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
|
|---|
| 596 |
|
|---|
| 597 |
void MainInterface::showSpeedMenu( QPoint pos ) |
|---|
| 598 |
{ |
|---|
| 599 |
speedControlMenu->exec( QCursor::pos() - pos |
|---|
| 600 |
+ QPoint( 0, speedLabel->height() ) ); |
|---|
| 601 |
} |
|---|
| 602 |
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 |
|
|---|
| 606 |
|
|---|
| 607 |
|
|---|
| 608 |
|
|---|
| 609 |
class SetVideoOnTopQtEvent : public QEvent |
|---|
| 610 |
{ |
|---|
| 611 |
public: |
|---|
| 612 |
SetVideoOnTopQtEvent( bool _onTop ) : |
|---|
| 613 |
QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop) |
|---|
| 614 |
{} |
|---|
| 615 |
|
|---|
| 616 |
bool OnTop() const { return onTop; } |
|---|
| 617 |
|
|---|
| 618 |
private: |
|---|
| 619 |
bool onTop; |
|---|
| 620 |
}; |
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 |
|
|---|
| 625 |
|
|---|
| 626 |
|
|---|
| 627 |
void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, |
|---|
| 628 |
int *pi_y, unsigned int *pi_width, |
|---|
| 629 |
unsigned int *pi_height ) |
|---|
| 630 |
{ |
|---|
| 631 |
|
|---|
| 632 |
void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height ); |
|---|
| 633 |
if( ret ) |
|---|
| 634 |
{ |
|---|
| 635 |
|
|---|
| 636 |
if( VISIBLE( bgWidget) ) |
|---|
| 637 |
{ |
|---|
| 638 |
bgWasVisible = true; |
|---|
| 639 |
emit askBgWidgetToToggle(); |
|---|
| 640 |
} |
|---|
| 641 |
else |
|---|
| 642 |
bgWasVisible = false; |
|---|
| 643 |
|
|---|
| 644 |
|
|---|
| 645 |
videoIsActive = true; |
|---|
| 646 |
|
|---|
| 647 |
emit askUpdate(); |
|---|
| 648 |
|
|---|
| 649 |
if( fullscreenControls ) fullscreenControls->attachVout( p_nvout ); |
|---|
| 650 |
} |
|---|
| 651 |
return ret; |
|---|
| 652 |
} |
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 |
void MainInterface::releaseVideo( void *p_win ) |
|---|
| 656 |
{ |
|---|
| 657 |
if( fullscreenControls ) fullscreenControls->detachVout(); |
|---|
| 658 |
if( p_win ) |
|---|
| 659 |
emit askReleaseVideo( p_win ); |
|---|
| 660 |
} |
|---|
| 661 |
|
|---|
| 662 |
|
|---|
| 663 |
void MainInterface::releaseVideoSlot( void *p_win ) |
|---|
| 664 |
{ |
|---|
| 665 |
videoWidget->release( p_win ); |
|---|
| 666 |
|
|---|
| 667 |
if( bgWasVisible ) |
|---|
| 668 |
{ |
|---|
| 669 |
|
|---|
| 670 |
bgWasVisible = false; |
|---|
| 671 |
bgWidget->show(); |
|---|
| 672 |
} |
|---|
| 673 |
|
|---|
| 674 |
videoIsActive = false; |
|---|
| 675 |
|
|---|
| 676 |
|
|---|
| 677 |
if( !isFullScreen() ) doComponentsUpdate(); |
|---|
| 678 |
} |
|---|
| 679 |
|
|---|
| 680 |
|
|---|
| 681 |
int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) |
|---|
| 682 |
{ |
|---|
| 683 |
int i_ret = VLC_SUCCESS; |
|---|
| 684 |
switch( i_query ) |
|---|
| 685 |
{ |
|---|
| 686 |
case VOUT_GET_SIZE: |
|---|
| 687 |
{ |
|---|
| 688 |
unsigned int *pi_width = va_arg( args, unsigned int * ); |
|---|
| 689 |
unsigned int *pi_height = va_arg( args, unsigned int * ); |
|---|
| 690 |
*pi_width = videoWidget->videoSize.width(); |
|---|
| 691 |
*pi_height = videoWidget->videoSize.height(); |
|---|
| 692 |
break; |
|---|
| 693 |
} |
|---|
| 694 |
case VOUT_SET_SIZE: |
|---|
| 695 |
{ |
|---|
| 696 |
unsigned int i_width = va_arg( args, unsigned int ); |
|---|
| 697 |
unsigned int i_height = va_arg( args, unsigned int ); |
|---|
| 698 |
emit askVideoToResize( i_width, i_height ); |
|---|
| 699 |
emit askUpdate(); |
|---|
| 700 |
break; |
|---|
| 701 |
} |
|---|
| 702 |
case VOUT_SET_STAY_ON_TOP: |
|---|
| 703 |
{ |
|---|
| 704 |
int i_arg = va_arg( args, int ); |
|---|
| 705 |
QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) ); |
|---|
| 706 |
break; |
|---|
| 707 |
} |
|---|
| 708 |
default: |
|---|
| 709 |
i_ret = VLC_EGENERIC; |
|---|
| 710 |
msg_Warn( p_intf, "unsupported control query" ); |
|---|
| 711 |
break; |
|---|
| 712 |
} |
|---|
| 713 |
return i_ret; |
|---|
| 714 |
} |
|---|
| 715 |
|
|---|
| 716 |
|
|---|
| 717 |
|
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 |
void MainInterface::togglePlaylist() |
|---|
| 723 |
{ |
|---|
| 724 |
|
|---|
| 725 |
|
|---|
| 726 |
if( !playlistWidget ) |
|---|
| 727 |
{ |
|---|
| 728 |
playlistWidget = new PlaylistWidget( p_intf, this ); |
|---|
| 729 |
|
|---|
| 730 |
i_pl_dock = PL_UNDOCKED; |
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
|
|---|
| 734 |
if( i_pl_dock == PL_UNDOCKED ) |
|---|
| 735 |
{ |
|---|
| 736 |
playlistWidget->setParent( this, Qt::Window ); |
|---|
| 737 |
|
|---|
| 738 |
|
|---|
| 739 |
|
|---|
| 740 |
QVLCTools::restoreWidgetPosition( p_intf, "Playlist", |
|---|
| 741 |
playlistWidget, QSize( 600, 300 ) ); |
|---|
| 742 |
|
|---|
| 743 |
playlistWidget->move( |
|---|
| 744 |
getSettings()->value( "Playlist/GlobalPos" ).toPoint() ); |
|---|
| 745 |
} |
|---|
| 746 |
else |
|---|
| 747 |
{ |
|---|
| 748 |
mainLayout->insertWidget( 4, playlistWidget ); |
|---|
| 749 |
} |
|---|
| 750 |
playlistVisible = true; |
|---|
| 751 |
|
|---|
| 752 |
playlistWidget->show(); |
|---|
| 753 |
} |
|---|
| 754 |
else |
|---|
| 755 |
{ |
|---|
| 756 |
|
|---|
| 757 |
TOGGLEV( playlistWidget ); |
|---|
| 758 |
playlistVisible = !playlistVisible; |
|---|
| 759 |
|
|---|
| 760 |
} |
|---|
| 761 |
} |
|---|
| 762 |
|
|---|
| 763 |
|
|---|
| 764 |
void MainInterface::undockPlaylist() |
|---|
| 765 |
{ |
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 |
} |
|---|
| 769 |
|
|---|
| 770 |
void MainInterface::dockPlaylist( pl_dock_e i_pos ) |
|---|
| 771 |
{ |
|---|
| 772 |
} |
|---|
| 773 |
|
|---|
| 774 |
void MainInterface::toggleMinimalView() |
|---|
| 775 |
{ |
|---|
| 776 |
|
|---|
| 777 |
if( !menuBar()->isVisible() ) QVLCMenu::minimalViewAction->toggle(); |
|---|
| 778 |
|
|---|
| 779 |
if( i_visualmode != QT_ALWAYS_VIDEO_MODE && |
|---|
| 780 |
i_visualmode != QT_MINIMAL_MODE ) |
|---|
| 781 |
{ |
|---|
| 782 |
if( videoWidget->isHidden() ) emit askBgWidgetToToggle(); |
|---|
| 783 |
else |
|---|
| 784 |
{ |
|---|
| 785 |
|
|---|
| 786 |
bgWasVisible = !bgWasVisible; |
|---|
| 787 |
} |
|---|
| 788 |
} |
|---|
| 789 |
|
|---|
| 790 |
TOGGLEV( menuBar() ); |
|---|
| 791 |
TOGGLEV( controls ); |
|---|
| 792 |
TOGGLEV( statusBar() ); |
|---|
| 793 |
doComponentsUpdate(); |
|---|
| 794 |
} |
|---|
| 795 |
|
|---|
| 796 |
|
|---|
| 797 |
|
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 |
|
|---|
| 801 |
|
|---|
| 802 |
|
|---|
| 803 |
|
|---|
| 804 |
void MainInterface::doComponentsUpdate() |
|---|
| 805 |
{ |
|---|
| 806 |
msg_Dbg( p_intf, "Updating the geometry" ); |
|---|
| 807 |
|
|---|
| 808 |
|
|---|
| 809 |
resize( sizeHint() ); |
|---|
| 810 |
|
|---|
| 811 |
#ifndef NDEBUG |
|---|
| 812 |
debug(); |
|---|
| 813 |
#endif |
|---|
| 814 |
} |
|---|
| 815 |
|
|---|
| 816 |
|
|---|
| 817 |
void MainInterface::toggleAdvanced() |
|---|
| 818 |
{ |
|---|
| 819 |
controls->toggleAdvanced(); |
|---|
| 820 |
if( fullscreenControls ) fullscreenControls->toggleAdvanced(); |
|---|
| 821 |
} |
|---|
| 822 |
|
|---|
| 823 |
|
|---|
| 824 |
int MainInterface::getControlsVisibilityStatus() |
|---|
| 825 |
{ |
|---|
| 826 |
return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN ) |
|---|
| 827 |
+ CONTROLS_ADVANCED * controls->b_advancedVisible ); |
|---|
| 828 |
} |
|---|
| 829 |
|
|---|
| 830 |
#if 0 |
|---|
| 831 |
void MainInterface::visual() |
|---|
| 832 |
{ |
|---|
| 833 |
if( !VISIBLE( visualSelector) ) |
|---|
| 834 |
{ |
|---|
| 835 |
visualSelector->show(); |
|---|
| 836 |
if( !THEMIM->getIM()->hasVideo() ) |
|---|
| 837 |
{ |
|---|
| 838 |
|
|---|
| 839 |
} |
|---|
| 840 |
visualSelectorEnabled = true; |
|---|
| 841 |
} |
|---|
| 842 |
else |
|---|
| 843 |
{ |
|---|
| 844 |
|
|---|
| 845 |
visualSelector->hide(); |
|---|
| 846 |
visualSelectorEnabled = false; |
|---|
| 847 |
} |
|---|
| 848 |
doComponentsUpdate(); |
|---|
| 849 |
} |
|---|
| 850 |
#endif |
|---|
| 851 |
|
|---|
| 852 |
|
|---|
| 853 |
|
|---|
| 854 |
|
|---|
| 855 |
void MainInterface::setName( QString name ) |
|---|
| 856 |
{ |
|---|
| 857 |
input_name = name; |
|---|
| 858 |
|
|---|
| 859 |
|
|---|
| 860 |
nameLabel->setText( " " + name + " " ); |
|---|
| 861 |
nameLabel->setToolTip( " " + name +" " ); |
|---|
| 862 |
} |
|---|
| 863 |
|
|---|
| 864 |
void MainInterface::setStatus( int status ) |
|---|
| 865 |
{ |
|---|
| 866 |
msg_Dbg( p_intf, "Updating the stream status: %i", status ); |
|---|
| 867 |
|
|---|
| 868 |
|
|---|
| 869 |
controls->setStatus( status ); |
|---|
| 870 |
controls->updateInput(); |
|---|
| 871 |
|
|---|
| 872 |
if( fullscreenControls ) |
|---|
| 873 |
{ |
|---|
| 874 |
fullscreenControls->setStatus( status ); |
|---|
| 875 |
fullscreenControls->updateInput(); |
|---|
| 876 |
} |
|---|
| 877 |
|
|---|
| 878 |
speedControl->setEnable( THEMIM->getIM()->hasInput() ); |
|---|
| 879 |
|
|---|
| 880 |
|
|---|
| 881 |
if( sysTray ) |
|---|
| 882 |
QVLCMenu::updateSystrayMenu( this, p_intf ); |
|---|
| 883 |
} |
|---|
| 884 |
|
|---|
| 885 |
void MainInterface::setRate( int rate ) |
|---|
| 886 |
{ |
|---|
| 887 |
QString str; |
|---|
| 888 |
str.setNum( ( 1000 / (double)rate ), 'f', 2 ); |
|---|
| 889 |
str.append( "x" ); |
|---|
| 890 |
speedLabel->setText( str ); |
|---|
| 891 |
speedLabel->setToolTip( str ); |
|---|
| 892 |
speedControl->updateControls( rate ); |
|---|
| 893 |
} |
|---|
| 894 |
|
|---|
| 895 |
void MainInterface::updateOnTimer() |
|---|
| 896 |
{ |
|---|
| 897 |
|
|---|
| 898 |
if( !vlc_object_alive( p_intf ) ) |
|---|
| 899 |
{ |
|---|
| 900 |
QApplication::closeAllWindows(); |
|---|
| 901 |
QApplication::quit(); |
|---|
| 902 |
} |
|---|
| 903 |
} |
|---|
| 904 |
|
|---|
| 905 |
|
|---|
| 906 |
|
|---|
| 907 |
|
|---|
| 908 |
|
|---|
| 909 |
|
|---|
| 910 |
|
|---|
| 911 |
|
|---|
| 912 |
|
|---|
| 913 |
void MainInterface::createSystray() |
|---|
| 914 |
{ |
|---|
| 915 |
QIcon iconVLC; |
|---|
| 916 |
if( QDate::currentDate().dayOfYear() >= 354 ) |
|---|
| 917 |
iconVLC = QIcon( QPixmap( ":/vlc128-christmas.png" ) ); |
|---|
| 918 |
|
|---|