]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/qt4.cpp
Qt: allow loop/repeat button to be in a toolbar (part 1)
[vlc] / modules / gui / qt4 / qt4.cpp
index a6b44c3394216fccb75abe9f114832a1138c4d47..4cb7d1cceab3f1372938b6803d0335209f4b6350 100644 (file)
 #endif
 
 #include <QApplication>
-#include <QLocale>
-#include <QTranslator>
 #include <QDate>
-#include <QMutex>
-#include <QMutexLocker>
-#include <QWaitCondition>
 
 #include "qt4.hpp"
 
@@ -51,7 +46,7 @@
 #include "../../../share/vlc32x32-christmas.xpm"
 #include <vlc_plugin.h>
 
-#ifdef WIN32
+#ifdef WIN32 /* For static builds */
  #include <QtPlugin>
  Q_IMPORT_PLUGIN(qjpeg)
  Q_IMPORT_PLUGIN(qtaccessiblewidgets)
@@ -161,6 +156,10 @@ static void ShowDialog   ( intf_thread_t *, int, int, intf_dialog_args_t * );
 #define QT_FULLSCREEN_TEXT N_( "Show a controller in fullscreen mode" )
 #define QT_NATIVEOPEN_TEXT N_( "Embed the file browser in open dialog" )
 
+#define FULLSCREEN_NUMBER_TEXT N_( "Define which screen fullscreen goes" )
+#define FULLSCREEN_NUMBER_LONGTEXT N_( "Screennumber of fullscreen, instead of" \
+                                       "same screen where interface is" )
+
 /* Various modes definition */
 static const int i_mode_list[] =
     { QT_NORMAL_MODE, QT_ALWAYS_VIDEO_MODE, QT_MINIMAL_MODE };
@@ -233,6 +232,9 @@ vlc_module_begin ()
               false )
         change_internal ()
 
+    add_integer( "qt-fullscreen-screennumber", -1, NULL, FULLSCREEN_NUMBER_TEXT,
+               FULLSCREEN_NUMBER_LONGTEXT, false );
+
     add_obsolete_bool( "qt-blingbling" ) /* Suppressed since 1.0.0 */
 
     add_submodule ()
@@ -256,11 +258,7 @@ vlc_module_end ()
 /*****************************************/
 
 /* Ugly, but the Qt4 interface assumes single instance anyway */
-static struct
-{
-    QMutex lock;
-    QWaitCondition ready;
-} iface;
+static vlc_sem_t ready;
 
 /*****************************************************************************
  * Module callbacks
@@ -281,6 +279,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
     XCloseDisplay( p_display );
+    putenv( "XLIB_SKIP_ARGB_VISUALS=1" );
 #endif
 
     /* Allocations of p_sys */
@@ -291,6 +290,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->p_playlist = pl_Hold( p_intf );
 
     /* */
+    vlc_sem_init (&ready, 0);
     if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) )
     {
         pl_Release (p_sys->p_playlist);
@@ -299,13 +299,12 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* */
-    QMutexLocker locker (&iface.lock);
-    vlc_value_t val;
+    vlc_sem_wait (&ready);
+    vlc_sem_destroy (&ready);
 
-    while( p_sys->p_mi == NULL && !p_sys->b_isDialogProvider )
-        iface.ready.wait( &iface.lock );
     if( !p_sys->b_isDialogProvider )
     {
+        vlc_value_t val;
         var_Create (p_this->p_libvlc, "qt4-iface", VLC_VAR_ADDRESS);
         val.p_address = p_this;
         var_Set (p_this->p_libvlc, "qt4-iface", val);
@@ -331,7 +330,9 @@ static void Close( vlc_object_t *p_this )
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
     intf_sys_t *p_sys = p_intf->p_sys;
 
-    var_Destroy (p_this->p_libvlc, "qt4-iface");
+    if( !p_sys->b_isDialogProvider )
+        var_Destroy (p_this->p_libvlc, "qt4-iface");
+
     QVLCApp::triggerQuit();
 
     vlc_join (p_sys->thread, NULL);
@@ -378,9 +379,9 @@ static void *Thread( void *obj )
 
     /* Icon setting */
     if( QDate::currentDate().dayOfYear() >= 352 ) /* One Week before Xmas */
-        app.setWindowIcon( QIcon( QPixmap(vlc_christmas_xpm) ) );
+        app.setWindowIcon( QIcon(vlc_christmas_xpm) );
     else
-        app.setWindowIcon( QIcon( QPixmap(vlc_xpm) ) );
+        app.setWindowIcon( QIcon(vlc_xpm) );
 
     /* Initialize timers and the Dialog Provider */
     DialogsProvider::getInstance( p_intf );
@@ -412,55 +413,25 @@ static void *Thread( void *obj )
         p_mi = NULL;
 
     /* */
-    iface.lock.lock();
     p_intf->p_sys->p_mi = p_mi;
     p_intf->p_sys->b_isDialogProvider = p_mi == NULL;
-    iface.ready.wakeAll();
-    iface.lock.unlock();
+    vlc_sem_post (&ready);
 
     /* Explain to the core how to show a dialog :D */
     p_intf->pf_show_dialog = ShowDialog;
 
-#ifdef ENABLE_NLS
-    // Translation - get locale
-#   if defined (WIN32) || defined (__APPLE__)
-    char* psz_tmp = config_GetPsz( p_intf, "language" );
-    QString lang = qfu( psz_tmp );
-    free( psz_tmp);
-    if (lang == "auto")
-        lang = QLocale::system().name();
-#   else
-    QString lang = QLocale::system().name();
-#   endif
-    // Translations for qt's own dialogs
-    QTranslator qtTranslator( 0 );
-    // Let's find the right path for the translation file
-#if !defined( WIN32 )
-    QString path =  QString( QT4LOCALEDIR );
-#else
-    QString path = QString( QString(config_GetDataDir()) + DIR_SEP +
-                            "locale" + DIR_SEP + "qt4" + DIR_SEP );
-#endif
-    // files depending on locale
-    bool b_loaded = qtTranslator.load( path + "qt_" + lang );
-    if (!b_loaded)
-        msg_Dbg( p_intf, "Error while initializing qt-specific localization" );
-    app.installTranslator( &qtTranslator );
-#endif  //ENABLE_NLS
-
     /* Last settings */
     app.setQuitOnLastWindowClosed( false );
 
     /* Retrieve last known path used in file browsing */
     p_intf->p_sys->filepath =
-         getSettings()->value( "filedialog-path", config_GetHomeDir() ).toString();
+         getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR ) ).toString();
 
     /* Loads and tries to apply the preferred QStyle */
     QString s_style = getSettings()->value( "MainWindow/QtStyle", "" ).toString();
     if( s_style.compare("") != 0 )
         QApplication::setStyle( s_style );
 
-
     /* Launch */
     app.exec();
 
@@ -471,7 +442,7 @@ static void *Thread( void *obj )
 
     if (p_mi != NULL)
     {
-        QMutexLocker locker (&iface.lock);
+        /* FIXME: are we sure that video window is already destroyed? */
 
         msg_Dbg (p_intf, "destroying the main Qt4 interface");
         p_intf->p_sys->p_mi = NULL;
@@ -500,7 +471,6 @@ static void *Thread( void *obj )
     MainInputManager::killInstance();
 
 
-
     /* Delete the application automatically */
 #ifdef Q_WS_X11
     free( display );
@@ -536,8 +506,6 @@ static int WindowOpen( vlc_object_t *p_obj )
     if( p_wnd->cfg->is_standalone )
         return VLC_EGENERIC;
 
-    QMutexLocker( &iface.lock );
-
     vlc_value_t val;
 
     if( var_Get( p_obj->p_libvlc, "qt4-iface", &val ) )
@@ -578,8 +546,6 @@ static int WindowOpen( vlc_object_t *p_obj )
 static int WindowControl( vout_window_t *p_wnd, int i_query, va_list args )
 {
     MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-    QMutexLocker locker(&iface.lock);
-
     return p_mi->controlVideo( i_query, args );
 }
 
@@ -588,8 +554,7 @@ static void WindowClose( vlc_object_t *p_obj )
     vout_window_t *p_wnd = (vout_window_t*)p_obj;
     MainInterface *p_mi = (MainInterface *)p_wnd->sys;
 
-    QMutexLocker locker( &iface.lock );
-
     msg_Dbg( p_obj, "releasing video..." );
     p_mi->releaseVideo();
 }
+