1 /*****************************************************************************
2 * qt.cpp : Qt interface
3 ****************************************************************************
4 * Copyright © 2006-2009 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #define VLC_MODULE_LICENSE VLC_LICENSE_GPL_2_PLUS
31 #include <QApplication>
37 #include "input_manager.hpp" /* THEMIM destruction */
38 #include "dialogs_provider.hpp" /* THEDP creation */
40 # include "main_interface_win32.hpp"
42 # include "main_interface.hpp" /* MainInterface creation */
44 #include "extensions_manager.hpp" /* Extensions manager */
45 #include "managers/addons_manager.hpp" /* Addons manager */
46 #include "dialogs/help.hpp" /* Launch Update */
47 #include "recents.hpp" /* Recents Item destruction */
48 #include "util/qvlcapp.hpp" /* QVLCApplication definition */
49 #include "components/playlist/playlist_model.hpp" /* for ~PLModel() */
51 #include <vlc_plugin.h>
52 #include <vlc_vout_window.h>
54 #ifdef _WIN32 /* For static builds */
57 #ifdef QT_STATICPLUGIN
58 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin
)
59 Q_IMPORT_PLUGIN(QSvgIconPlugin
)
60 Q_IMPORT_PLUGIN(QSvgPlugin
)
62 Q_IMPORT_PLUGIN(AccessibleFactory
)
67 /*****************************************************************************
69 *****************************************************************************/
70 static int OpenIntf ( vlc_object_t
* );
71 static int OpenDialogs ( vlc_object_t
* );
72 static int Open ( vlc_object_t
*, bool );
73 static void Close ( vlc_object_t
* );
74 static int WindowOpen ( vout_window_t
*, const vout_window_cfg_t
* );
75 static void WindowClose ( vout_window_t
* );
76 static void ShowDialog ( intf_thread_t
*, int, int, intf_dialog_args_t
* );
78 /*****************************************************************************
80 *****************************************************************************/
81 #define ADVANCED_PREFS_TEXT N_( "Show advanced preferences over simple ones" )
82 #define ADVANCED_PREFS_LONGTEXT N_( "Show advanced preferences and not simple "\
83 "preferences when opening the preferences "\
86 #define SYSTRAY_TEXT N_( "Systray icon" )
87 #define SYSTRAY_LONGTEXT N_( "Show an icon in the systray " \
88 "allowing you to control VLC media player " \
89 "for basic actions." )
91 #define MINIMIZED_TEXT N_( "Start VLC with only a systray icon" )
92 #define MINIMIZED_LONGTEXT N_( "VLC will start with just an icon in " \
95 #define KEEPSIZE_TEXT N_( "Resize interface to the native video size" )
96 #define KEEPSIZE_LONGTEXT N_( "You have two choices:\n" \
97 " - The interface will resize to the native video size\n" \
98 " - The video will fit to the interface size\n " \
99 "By default, interface resize to the native video size." )
101 #define TITLE_TEXT N_( "Show playing item name in window title" )
102 #define TITLE_LONGTEXT N_( "Show the name of the song or video in the " \
103 "controller window title." )
105 #define NOTIFICATION_TEXT N_( "Show notification popup on track change" )
106 #define NOTIFICATION_LONGTEXT N_( \
107 "Show a notification popup with the artist and track name when " \
108 "the current playlist item changes, when VLC is minimized or hidden." )
110 #define OPACITY_TEXT N_( "Windows opacity between 0.1 and 1" )
111 #define OPACITY_LONGTEXT N_( "Sets the windows opacity between 0.1 and 1 " \
112 "for main interface, playlist and extended panel."\
113 " This option only works with Windows and " \
114 "X11 with composite extensions." )
116 #define OPACITY_FS_TEXT N_( "Fullscreen controller opacity between 0.1 and 1" )
117 #define OPACITY_FS_LONGTEXT N_( "Sets the fullscreen controller opacity between 0.1 and 1 " \
118 "for main interface, playlist and extended panel."\
119 " This option only works with Windows and " \
120 "X11 with composite extensions." )
123 #define ERROR_TEXT N_( "Show unimportant error and warnings dialogs" )
125 #define UPDATER_TEXT N_( "Activate the updates availability notification" )
126 #define UPDATER_LONGTEXT N_( "Activate the automatic notification of new " \
127 "versions of the software. It runs once every " \
129 #define UPDATER_DAYS_TEXT N_("Number of days between two update checks")
131 #define PRIVACY_TEXT N_( "Ask for network policy at start" )
133 #define RECENTPLAY_TEXT N_( "Save the recently played items in the menu" )
135 #define RECENTPLAY_FILTER_TEXT N_( "List of words separated by | to filter" )
136 #define RECENTPLAY_FILTER_LONGTEXT N_( "Regular expression used to filter " \
137 "the recent items played in the player" )
139 #define SLIDERCOL_TEXT N_( "Define the colors of the volume slider" )
140 #define SLIDERCOL_LONGTEXT N_( "Define the colors of the volume slider\n" \
141 "By specifying the 12 numbers separated by a ';'\n" \
142 "Default is '255;255;255;20;226;20;255;176;15;235;30;20'\n" \
143 "An alternative can be '30;30;50;40;40;100;50;50;160;150;150;255'")
145 #define QT_MODE_TEXT N_( "Selection of the starting mode and look" )
146 #define QT_MODE_LONGTEXT N_( "Start VLC with:\n" \
148 " - a zone always present to show information " \
149 "as lyrics, album arts...\n" \
150 " - minimal mode with limited controls" )
152 #define QT_FULLSCREEN_TEXT N_( "Show a controller in fullscreen mode" )
153 #define QT_NATIVEOPEN_TEXT N_( "Embed the file browser in open dialog" )
155 #define FULLSCREEN_NUMBER_TEXT N_( "Define which screen fullscreen goes" )
156 #define FULLSCREEN_NUMBER_LONGTEXT N_( "Screennumber of fullscreen, instead of " \
157 "same screen where interface is" )
159 #define QT_AUTOLOAD_EXTENSIONS_TEXT N_( "Load extensions on startup" )
160 #define QT_AUTOLOAD_EXTENSIONS_LONGTEXT N_( "Automatically load the "\
161 "extensions module on startup" )
163 #define QT_MINIMAL_MODE_TEXT N_("Start in minimal view (without menus)" )
165 #define QT_BGCONE_TEXT N_( "Display background cone or art" )
166 #define QT_BGCONE_LONGTEXT N_( "Display background cone or current album art " \
167 "when not playing. " \
168 "Can be disabled to prevent burning screen." )
169 #define QT_BGCONE_EXPANDS_TEXT N_( "Expanding background cone or art." )
170 #define QT_BGCONE_EXPANDS_LONGTEXT N_( "Background art fits window's size" )
172 #define QT_DISABLE_VOLUME_KEYS_TEXT N_( "Ignore keyboard volume buttons." )
173 #define QT_DISABLE_VOLUME_KEYS_LONGTEXT N_( \
174 "With this option checked, the volume up, volume down and mute buttons on your " \
175 "keyboard will always change your system volume. With this option unchecked, the " \
176 "volume buttons will change VLC's volume when VLC is selected and change the " \
177 "system volume when VLC is not selected." )
179 #define QT_PAUSE_MINIMIZED_TEXT N_( "Pause the video playback when minimized" )
180 #define QT_PAUSE_MINIMIZED_LONGTEXT N_( \
181 "With this option enabled, the playback will be automatically paused when minimizing the window." )
183 #define ICONCHANGE_TEXT N_( "Allow automatic icon changes")
184 #define ICONCHANGE_LONGTEXT N_( \
185 "This option allows the interface to change its icon on various occasions.")
187 #define VOLUME_MAX_TEXT N_( "Maximum Volume displayed" )
189 #define AUTORAISE_ON_PLAYBACK_TEXT N_( "When to raise the interface" )
190 #define AUTORAISE_ON_PLAYBACK_LONGTEXT N_( "This option allows the interface to be raised automatically " \
191 "when a video/audio playback starts, or never" )
193 #define FULLSCREEN_CONTROL_PIXELS N_( "Fullscreen controller mouse sensitivity" )
195 #define CONTINUE_PLAYBACK_TEXT N_("Continue playback?")
197 static const int i_notification_list
[] =
198 { NOTIFICATION_NEVER
, NOTIFICATION_MINIMIZED
, NOTIFICATION_ALWAYS
};
200 static const char *const psz_notification_list_text
[] =
201 { N_("Never"), N_("When minimized"), N_("Always") };
203 static const int i_continue_list
[] =
206 static const char *const psz_continue_list_text
[] =
207 { N_("Never"), N_("Ask"), N_("Always") };
209 static const int i_raise_list
[] =
210 { MainInterface::RAISE_NEVER
, MainInterface::RAISE_VIDEO
, \
211 MainInterface::RAISE_AUDIO
, MainInterface::RAISE_AUDIOVIDEO
, };
213 static const char *const psz_raise_list_text
[] =
214 { N_( "Never" ), N_( "Video" ), N_( "Audio" ), _( "Audio/Video" ) };
216 /**********************************************************************/
218 set_shortname( "Qt" )
219 set_description( N_("Qt interface") )
220 set_category( CAT_INTERFACE
)
221 set_subcategory( SUBCAT_INTERFACE_MAIN
)
222 set_capability( "interface", 151 )
223 set_callbacks( OpenIntf
, Close
)
227 add_bool( "qt-minimal-view", false, QT_MINIMAL_MODE_TEXT
,
228 QT_MINIMAL_MODE_TEXT
, false );
230 add_bool( "qt-system-tray", true, SYSTRAY_TEXT
, SYSTRAY_LONGTEXT
, false)
232 add_integer( "qt-notification", NOTIFICATION_MINIMIZED
,
234 NOTIFICATION_LONGTEXT
, false )
235 change_integer_list( i_notification_list
, psz_notification_list_text
)
237 add_bool( "qt-start-minimized", false, MINIMIZED_TEXT
,
238 MINIMIZED_LONGTEXT
, true)
239 add_bool( "qt-pause-minimized", false, QT_PAUSE_MINIMIZED_TEXT
,
240 QT_PAUSE_MINIMIZED_LONGTEXT
, false )
242 add_float_with_range( "qt-opacity", 1., 0.1, 1., OPACITY_TEXT
,
243 OPACITY_LONGTEXT
, false )
244 add_float_with_range( "qt-fs-opacity", 0.8, 0.1, 1., OPACITY_FS_TEXT
,
245 OPACITY_FS_LONGTEXT
, false )
247 add_bool( "qt-video-autoresize", true, KEEPSIZE_TEXT
,
248 KEEPSIZE_LONGTEXT
, false )
249 add_bool( "qt-name-in-title", true, TITLE_TEXT
,
250 TITLE_LONGTEXT
, false )
251 add_bool( "qt-fs-controller", true, QT_FULLSCREEN_TEXT
,
252 QT_FULLSCREEN_TEXT
, false )
254 add_bool( "qt-recentplay", true, RECENTPLAY_TEXT
,
255 RECENTPLAY_TEXT
, false )
256 add_string( "qt-recentplay-filter", "",
257 RECENTPLAY_FILTER_TEXT
, RECENTPLAY_FILTER_LONGTEXT
, false )
258 add_integer( "qt-continue", 1, CONTINUE_PLAYBACK_TEXT
, CONTINUE_PLAYBACK_TEXT
, false )
259 change_integer_list(i_continue_list
, psz_continue_list_text
)
262 add_bool( "qt-updates-notif", true, UPDATER_TEXT
,
263 UPDATER_LONGTEXT
, false )
264 add_integer_with_range( "qt-updates-days", 3, 0, 180,
265 UPDATER_DAYS_TEXT
, UPDATER_DAYS_TEXT
, false )
269 add_bool( "qt-disable-volume-keys" /* name */,
270 true /* default value */,
271 QT_DISABLE_VOLUME_KEYS_TEXT
/* text */,
272 QT_DISABLE_VOLUME_KEYS_LONGTEXT
/* longtext */,
273 false /* advanced mode only */)
276 add_bool( "qt-embedded-open", false, QT_NATIVEOPEN_TEXT
,
277 QT_NATIVEOPEN_TEXT
, false )
280 add_bool( "qt-advanced-pref", false, ADVANCED_PREFS_TEXT
,
281 ADVANCED_PREFS_LONGTEXT
, false )
282 add_bool( "qt-error-dialogs", true, ERROR_TEXT
,
285 add_string( "qt-slider-colours", "153;210;153;20;210;20;255;199;15;245;39;29",
286 SLIDERCOL_TEXT
, SLIDERCOL_LONGTEXT
, false )
288 add_bool( "qt-privacy-ask", true, PRIVACY_TEXT
, PRIVACY_TEXT
,
292 add_integer( "qt-fullscreen-screennumber", -1, FULLSCREEN_NUMBER_TEXT
,
293 FULLSCREEN_NUMBER_LONGTEXT
, false );
295 add_bool( "qt-autoload-extensions", true,
296 QT_AUTOLOAD_EXTENSIONS_TEXT
, QT_AUTOLOAD_EXTENSIONS_LONGTEXT
,
299 add_bool( "qt-bgcone", true, QT_BGCONE_TEXT
, QT_BGCONE_LONGTEXT
, true )
300 add_bool( "qt-bgcone-expands", false, QT_BGCONE_EXPANDS_TEXT
,
301 QT_BGCONE_EXPANDS_LONGTEXT
, true )
303 add_bool( "qt-icon-change", true, ICONCHANGE_TEXT
, ICONCHANGE_LONGTEXT
, true )
305 add_integer_with_range( "qt-max-volume", 125, 60, 300, VOLUME_MAX_TEXT
, VOLUME_MAX_TEXT
, true)
307 add_integer_with_range( "qt-fs-sensitivity", 3, 0, 4000, FULLSCREEN_CONTROL_PIXELS
,
308 FULLSCREEN_CONTROL_PIXELS
, true)
310 add_obsolete_bool( "qt-blingbling" ) /* Suppressed since 1.0.0 */
311 add_obsolete_integer( "qt-display-mode" ) /* Suppressed since 1.1.0 */
313 add_obsolete_bool( "qt-adv-options" ) /* Since 2.0.0 */
314 add_obsolete_bool( "qt-volume-complete" ) /* Since 2.0.0 */
315 add_obsolete_integer( "qt-startvolume" ) /* Since 2.0.0 */
317 add_integer( "qt-auto-raise", MainInterface::RAISE_VIDEO
, AUTORAISE_ON_PLAYBACK_TEXT
,
318 AUTORAISE_ON_PLAYBACK_LONGTEXT
, false )
319 change_integer_list( i_raise_list
, psz_raise_list_text
)
321 cannot_unload_broken_library()
324 set_description( "Dialogs provider" )
325 set_capability( "dialogs provider", 51 )
327 set_callbacks( OpenDialogs
, Close
)
330 set_capability( "vout window", 0 )
331 set_callbacks( WindowOpen
, WindowClose
)
335 /*****************************************/
337 /* Ugly, but the Qt interface assumes single instance anyway */
338 static vlc_sem_t ready
;
340 static bool busy
= false;
341 static bool active
= false;
343 /*****************************************************************************
345 *****************************************************************************/
347 static void *ThreadPlatform( void *, char * );
349 static void *Thread( void *data
)
351 return ThreadPlatform( data
, NULL
);
355 /* Used to abort the app.exec() on OSX after libvlc_Quit is called */
356 #include "../../../lib/libvlc_internal.h" /* libvlc_SetExitHandler */
357 static void Abort( void *obj
)
359 QVLCApp::triggerQuit();
363 #if defined (QT5_HAS_X11)
364 # include <vlc_xlib.h>
366 static void *ThreadXCB( void *data
)
368 char platform_name
[] = "xcb";
369 return ThreadPlatform( data
, platform_name
);
372 static bool HasX11( vlc_object_t
*obj
)
374 if( !vlc_xlib_init( obj
) )
377 Display
*dpy
= XOpenDisplay( NULL
);
381 XCloseDisplay( dpy
);
386 #ifdef QT5_HAS_WAYLAND
387 # include <wayland-client.h>
389 static void *ThreadWayland( void *data
)
391 char platform_name
[] = "wayland";
392 return ThreadPlatform( data
, platform_name
);
395 static bool HasWayland( void )
397 struct wl_display
*dpy
= wl_display_connect( NULL
);
401 wl_display_disconnect( dpy
);
407 static int Open( vlc_object_t
*p_this
, bool isDialogProvider
)
409 intf_thread_t
*p_intf
= (intf_thread_t
*)p_this
;
410 void *(*thread
)(void *) = Thread
;
412 #ifdef QT5_HAS_WAYLAND
414 thread
= ThreadWayland
;
418 if( HasX11( p_this
) )
422 #if defined (QT5_HAS_X11) || defined (QT5_HAS_WAYLAND)
426 QMutexLocker
locker (&lock
);
429 msg_Err (p_this
, "cannot start Qt multiple times");
433 /* Allocations of p_sys */
434 intf_sys_t
*p_sys
= p_intf
->p_sys
= new intf_sys_t
;
435 p_sys
->b_isDialogProvider
= isDialogProvider
;
437 p_sys
->pl_model
= NULL
;
439 /* set up the playlist to work on */
440 if( isDialogProvider
)
441 p_sys
->p_playlist
= pl_Get( (intf_thread_t
*)p_intf
->obj
.parent
);
443 p_sys
->p_playlist
= pl_Get( p_intf
);
446 vlc_sem_init (&ready
, 0);
448 /* Run mainloop on the main thread as Cocoa requires */
449 libvlc_SetExitHandler( p_intf
->obj
.libvlc
, Abort
, p_intf
);
450 thread( (void *)p_intf
);
452 if( vlc_clone( &p_sys
->thread
, thread
, p_intf
, VLC_THREAD_PRIORITY_LOW
) )
459 /* Wait for the interface to be ready. This prevents the main
460 * LibVLC thread from starting video playback before we can create
461 * an embedded video window. */
462 vlc_sem_wait (&ready
);
463 vlc_sem_destroy (&ready
);
464 busy
= active
= true;
469 /* Open Qt interface */
470 static int OpenIntf( vlc_object_t
*p_this
)
472 return Open( p_this
, false );
475 /* Open Dialog Provider */
476 static int OpenDialogs( vlc_object_t
*p_this
)
478 return Open( p_this
, true );
481 static void Close( vlc_object_t
*p_this
)
483 intf_thread_t
*p_intf
= (intf_thread_t
*)p_this
;
484 intf_sys_t
*p_sys
= p_intf
->p_sys
;
486 if( !p_sys
->b_isDialogProvider
)
488 playlist_t
*pl
= THEPL
;
490 playlist_Deactivate (pl
); /* release window provider if needed */
494 msg_Dbg( p_this
, "requesting exit..." );
495 QVLCApp::triggerQuit();
497 msg_Dbg( p_this
, "waiting for UI thread..." );
499 vlc_join (p_sys
->thread
, NULL
);
503 QMutexLocker
locker (&lock
);
508 static void *ThreadPlatform( void *obj
, char *platform_name
)
510 intf_thread_t
*p_intf
= (intf_thread_t
*)obj
;
511 intf_sys_t
*p_sys
= p_intf
->p_sys
;
512 char vlc_name
[] = "vlc"; /* for WM_CLASS */
513 char platform_parm
[] = "-platform";
517 argv
[argc
++] = vlc_name
;
518 if( platform_name
!= NULL
)
520 argv
[argc
++] = platform_parm
;
521 argv
[argc
++] = platform_name
;
525 Q_INIT_RESOURCE( vlc
);
528 QApplication::setAttribute( Qt::AA_EnableHighDpiScaling
);
529 QApplication::setAttribute( Qt::AA_UseHighDpiPixmaps
);
532 /* Start the QApplication here */
533 QVLCApp
app( argc
, argv
);
535 /* Set application direction to locale direction,
536 * necessary for RTL locales */
537 app
.setLayoutDirection(QLocale().textDirection());
542 /* All the settings are in the .conf/.ini style */
544 char *cConfigDir
= config_GetUserDir( VLC_CONFIG_DIR
);
545 QString configDir
= cConfigDir
;
547 if( configDir
.endsWith( "\\vlc" ) )
548 configDir
.chop( 4 ); /* the "\vlc" dir is added again by QSettings */
549 QSettings::setPath( QSettings::IniFormat
, QSettings::UserScope
, configDir
);
552 p_sys
->mainSettings
= new QSettings(
554 QSettings::IniFormat
,
556 QSettings::NativeFormat
,
558 QSettings::UserScope
, "vlc", "vlc-qt-interface" );
560 /* Icon setting, Mac uses icon from .icns */
562 if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY
&& var_InheritBool( p_intf
, "qt-icon-change" ) )
563 app
.setWindowIcon( QIcon::fromTheme( "vlc-xmas", QIcon( ":/logo/vlc128-xmas.png" ) ) );
565 app
.setWindowIcon( QIcon::fromTheme( "vlc", QIcon( ":/logo/vlc256.png" ) ) );
568 /* Initialize the Dialog Provider and the Main Input Manager */
569 DialogsProvider::getInstance( p_intf
);
570 MainInputManager
* mim
= MainInputManager::getInstance( p_intf
);
571 mim
->probeCurrentInput();
574 /* Checking for VLC updates */
575 if( var_InheritBool( p_intf
, "qt-updates-notif" ) &&
576 !var_InheritBool( p_intf
, "qt-privacy-ask" ) )
578 int interval
= var_InheritInteger( p_intf
, "qt-updates-days" );
579 if( QDate::currentDate() >
580 getSettings()->value( "updatedate" ).toDate().addDays( interval
) )
582 /* The constructor of the update Dialog will do the 1st request */
583 UpdateDialog::getInstance( p_intf
);
584 getSettings()->setValue( "updatedate", QDate::currentDate() );
589 /* Create the normal interface in non-DP mode */
590 MainInterface
*p_mi
= NULL
;
592 if( !p_sys
->b_isDialogProvider
)
595 p_mi
= new MainInterfaceWin32( p_intf
);
597 p_mi
= new MainInterface( p_intf
);
601 /* Check window type from the Qt platform back-end */
602 p_sys
->voutWindowType
= VOUT_WINDOW_TYPE_INVALID
;
603 QString platform
= app
.platformName();
604 if( platform
== qfu("xcb") )
605 p_sys
->voutWindowType
= VOUT_WINDOW_TYPE_XID
;
606 else if( platform
== qfu("wayland") )
607 p_sys
->voutWindowType
= VOUT_WINDOW_TYPE_WAYLAND
;
608 else if( platform
== qfu("windows") )
609 p_sys
->voutWindowType
= VOUT_WINDOW_TYPE_HWND
;
610 else if( platform
== qfu("cocoa" ) )
611 p_sys
->voutWindowType
= VOUT_WINDOW_TYPE_NSOBJECT
;
613 msg_Err( p_intf
, "unknown Qt platform: %s", qtu(platform
) );
615 var_Create( THEPL
, "qt4-iface", VLC_VAR_ADDRESS
);
616 var_SetAddress( THEPL
, "qt4-iface", p_intf
);
617 var_Create( THEPL
, "window", VLC_VAR_STRING
);
618 if( p_sys
->voutWindowType
!= VOUT_WINDOW_TYPE_INVALID
)
619 var_SetString( THEPL
, "window", "qt,any" );
622 /* Explain how to show a dialog :D */
623 p_intf
->pf_show_dialog
= ShowDialog
;
625 /* Tell the main LibVLC thread we are ready */
626 vlc_sem_post (&ready
);
629 /* We took over main thread, register and start here */
630 if( !p_sys
->b_isDialogProvider
)
631 playlist_Play( THEPL
);
635 app
.setQuitOnLastWindowClosed( false );
637 /* Retrieve last known path used in file browsing */
639 getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR
) ).toString();
641 /* Loads and tries to apply the preferred QStyle */
642 QString s_style
= getSettings()->value( "MainWindow/QtStyle", "" ).toString();
643 if( s_style
.compare("") != 0 )
644 QApplication::setStyle( s_style
);
649 msg_Dbg( p_intf
, "QApp exec() finished" );
652 var_Destroy( THEPL
, "window" );
653 var_Destroy( THEPL
, "qt4-iface" );
655 QMutexLocker
locker (&lock
);
659 /* Destroy first the main interface because it is connected to some
660 slots in the MainInputManager */
665 ExtensionsManager::killInstance();
666 AddonsManager::killInstance();
668 /* Destroy all remaining windows,
669 because some are connected to some slots
670 in the MainInputManager
671 Settings must be destroyed after that.
673 DialogsProvider::killInstance();
675 /* Delete the recentsMRL object before the configuration */
676 RecentsMRL::killInstance();
678 /* Save the path or delete if recent play are disabled */
679 if( var_InheritBool( p_intf
, "qt-recentplay" ) )
680 getSettings()->setValue( "filedialog-path", p_sys
->filepath
);
682 getSettings()->remove( "filedialog-path" );
685 delete p_sys
->pl_model
;
687 /* Destroy the MainInputManager */
688 MainInputManager::killInstance();
690 /* Delete the configuration. Application has to be deleted after that. */
691 delete p_sys
->mainSettings
;
693 /* Delete the application automatically */
697 /*****************************************************************************
698 * Callback to show a dialog
699 *****************************************************************************/
700 static void ShowDialog( intf_thread_t
*p_intf
, int i_dialog_event
, int i_arg
,
701 intf_dialog_args_t
*p_arg
)
703 VLC_UNUSED( p_intf
);
704 DialogEvent
*event
= new DialogEvent( i_dialog_event
, i_arg
, p_arg
);
705 QApplication::postEvent( THEDP
, event
);
709 * Video output window provider
711 * TODO move it out of here ?
713 static int WindowControl( vout_window_t
*, int i_query
, va_list );
715 static int WindowOpen( vout_window_t
*p_wnd
, const vout_window_cfg_t
*cfg
)
717 if( cfg
->is_standalone
)
720 intf_thread_t
*p_intf
=
721 (intf_thread_t
*)var_InheritAddress( p_wnd
, "qt4-iface" );
723 { /* If another interface is used, this plugin cannot work */
724 msg_Dbg( p_wnd
, "Qt interface not found" );
728 if( cfg
->type
!= VOUT_WINDOW_TYPE_INVALID
729 && cfg
->type
!= p_intf
->p_sys
->voutWindowType
)
732 switch( p_intf
->p_sys
->voutWindowType
)
734 case VOUT_WINDOW_TYPE_XID
:
735 if( var_InheritBool( p_wnd
, "video-wallpaper" ) )
740 QMutexLocker
locker (&lock
);
741 if (unlikely(!active
))
744 MainInterface
*p_mi
= p_intf
->p_sys
->p_mi
;
745 msg_Dbg( p_wnd
, "requesting video window..." );
747 if( !p_mi
->getVideo( p_wnd
, cfg
->width
, cfg
->height
, cfg
->is_fullscreen
) )
750 p_wnd
->info
.has_double_click
= true;
751 p_wnd
->control
= WindowControl
;
752 p_wnd
->sys
= (vout_window_sys_t
*)p_mi
;
756 static int WindowControl( vout_window_t
*p_wnd
, int i_query
, va_list args
)
758 MainInterface
*p_mi
= (MainInterface
*)p_wnd
->sys
;
759 QMutexLocker
locker (&lock
);
761 if (unlikely(!active
))
763 msg_Warn (p_wnd
, "video already released before control");
766 return p_mi
->controlVideo( i_query
, args
);
769 static void WindowClose( vout_window_t
*p_wnd
)
771 MainInterface
*p_mi
= (MainInterface
*)p_wnd
->sys
;
772 QMutexLocker
locker (&lock
);
774 /* Normally, the interface terminates after the video. In the contrary, the
775 * Qt main loop is gone, so we cannot send any event to the user interface
776 * widgets. Ideally, we would keep the Qt main loop running until after
777 * the video window is released. But it is far simpler to just have the Qt
778 * thread destroy the window early, and to turn this function into a stub.
780 * That assumes the video output will behave sanely if it window is
781 * destroyed asynchronously.
782 * XCB and Xlib-XCB are fine with that. Plain Xlib wouldn't, */
783 if (unlikely(!active
))
785 msg_Warn (p_wnd
, "video already released");
788 msg_Dbg (p_wnd
, "releasing video...");
789 p_mi
->releaseVideo();