]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/qt4.cpp
s/pl_Yield/pl_Hold/
[vlc] / modules / gui / qt4 / qt4.cpp
index e5d3e280dca1a238cd7d9e24ca4955d5999d4dbc..2109367e32de9534a59394d84a772c06ba155d0d 100644 (file)
 #include "../../../share/vlc32x32-christmas.xpm"
 #include <vlc_plugin.h>
 
+#ifdef WIN32
+ #include <QtPlugin>
+ Q_IMPORT_PLUGIN(qjpeg)
+#endif
+
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
@@ -158,7 +163,7 @@ vlc_module_begin();
 
         add_integer( "qt-display-mode", QT_NORMAL_MODE, NULL,
                      QT_MODE_TEXT, QT_MODE_LONGTEXT, false );
-            change_integer_list( i_mode_list, psz_mode_list_text, 0 );
+            change_integer_list( i_mode_list, psz_mode_list_text, NULL );
 
         add_bool( "qt-notification", true, NULL, NOTIFICATION_TEXT,
                   NOTIFICATION_LONGTEXT, false );
@@ -208,9 +213,11 @@ vlc_module_begin();
 
         set_callbacks( OpenDialogs, Close );
 
+#if 0
     add_submodule();
         set_capability( "vout window", 50 );
         set_callbacks( WindowOpen, WindowClose );
+#endif
 vlc_module_end();
 
 /*****************************************************************************
@@ -239,9 +246,10 @@ static int Open( vlc_object_t *p_this )
     memset( p_intf->p_sys, 0, sizeof( intf_sys_t ) );
 
     p_intf->pf_run = Run;
+    p_intf->p_sys->p_mi = NULL;
 
     /* Access to the playlist */
-    p_intf->p_sys->p_playlist = pl_Yield( p_intf );
+    p_intf->p_sys->p_playlist = pl_Hold( p_intf );
     /* Listen to the messages */
     p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
     /* one settings to rule them all */
@@ -265,15 +273,14 @@ static void Close( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
 
-    vlc_object_lock( p_intf );
-    p_intf->b_dead = true;
-    vlc_object_unlock( p_intf );
-
     if( p_intf->p_sys->b_isDialogProvider )
     {
-        DialogEvent *event = new DialogEvent( INTF_DIALOG_EXIT, 0, NULL );
-        QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
-
+        if( DialogsProvider::isAlive() )
+        {
+            msg_Dbg( p_intf, "Asking the DP to quit nicely" );
+            DialogEvent *event = new DialogEvent( INTF_DIALOG_EXIT, 0, NULL );
+            QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
+        }
         vlc_thread_join( p_intf );
     }
 
@@ -294,7 +301,11 @@ static void Run( intf_thread_t *p_intf )
             msg_Err( p_intf, "failed to create Qt dialogs thread" );
     }
     else
+    {
+        int canc = vlc_savecancel ();
         Init( VLC_OBJECT(p_intf) );
+        vlc_restorecancel( canc );
+    }
 }
 
 static QMutex windowLock;
@@ -307,6 +318,7 @@ static void *Init( vlc_object_t *obj )
     char dummy[] = "";
     char *argv[] = { dummy };
     int argc = 1;
+    int canc = vlc_savecancel ();
 
     Q_INIT_RESOURCE( vlc );
 
@@ -333,8 +345,7 @@ static void *Init( vlc_object_t *obj )
 #endif
             QSettings::UserScope, "vlc", "vlc-qt-interface" );
 
-    /* Icon setting
-       FIXME: use a bigger icon ? */
+    /* Icon setting */
     if( QDate::currentDate().dayOfYear() >= 354 )
         app->setWindowIcon( QIcon( QPixmap(vlc_christmas_xpm) ) );
     else
@@ -345,6 +356,22 @@ static void *Init( vlc_object_t *obj )
 
     QPointer<MainInterface> *miP = NULL;
 
+#ifdef UPDATE_CHECK
+    /* Checking for VLC updates */
+    if( config_GetInt( p_intf, "qt-updates-notif" ) &&
+        !config_GetInt( p_intf, "qt-privacy-ask" ) )
+    {
+        int interval = config_GetInt( p_intf, "qt-updates-days" );
+        if( QDate::currentDate() >
+             getSettings()->value( "updatedate" ).toDate().addDays( interval ) )
+        {
+            /* The constructor of the update Dialog will do the 1st request */
+            UpdateDialog::getInstance( p_intf );
+            getSettings()->setValue( "updatedate", QDate::currentDate() );
+        }
+    }
+#endif
+
     /* Create the normal interface in non-DP mode */
     if( !p_intf->pf_show_dialog )
     {
@@ -370,7 +397,15 @@ static void *Init( vlc_object_t *obj )
 
 #ifdef ENABLE_NLS
     // Translation - get locale
-    QLocale ql = QLocale::system();
+#   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
@@ -381,7 +416,7 @@ static void *Init( vlc_object_t *obj )
                             "locale" + DIR_SEP + "qt4" + DIR_SEP );
 #endif
     // files depending on locale
-    bool b_loaded = qtTranslator.load( path + "qt_" + ql.name());
+    bool b_loaded = qtTranslator.load( path + "qt_" + lang );
     if (!b_loaded)
         msg_Dbg( p_intf, "Error while initializing qt-specific localization" );
     app->installTranslator( &qtTranslator );
@@ -395,25 +430,11 @@ static void *Init( vlc_object_t *obj )
     p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? psz_path
                                                         : config_GetHomeDir();
 
-#ifdef UPDATE_CHECK
-    /* Checking for VLC updates */
-    if( config_GetInt( p_intf, "qt-updates-notif" ) )
-    {
-        int interval = config_GetInt( p_intf, "qt-updates-days" );
-        if( QDate::currentDate() >
-             getSettings()->value( "updatedate" ).toDate().addDays( interval ) )
-        {
-            /* The constructor of the update Dialog will do the 1st request */
-            UpdateDialog::getInstance( p_intf );
-            getSettings()->setValue( "updatedate", QDate::currentDate() );
-        }
-    }
-#endif
-
     /* Launch */
     app->exec();
 
     /* And quit */
+    msg_Dbg( p_intf, "Quitting the Qt4 Interface" );
 
     if (miP)
     {
@@ -432,22 +453,27 @@ static void *Init( vlc_object_t *obj )
        in the MainInputManager */
     delete p_intf->p_sys->p_mi;
 
-    /* Destroy then other windows, because some are connected to some slots
-       in the MainInputManager */
+    /* Destroy all remaining windows,
+       because some are connected to some slots
+       in the MainInputManager
+       Settings must be destroyed after that.
+     */
     DialogsProvider::killInstance();
 
+    /* Delete the configuration. Application has to be deleted after that. */
+    delete p_intf->p_sys->mainSettings;
+
     /* Destroy the MainInputManager */
     MainInputManager::killInstance();
 
-    /* Delete the configuration */
-    delete p_intf->p_sys->mainSettings;
-
     /* Delete the application */
     delete app;
 
     /* Save the path */
     config_PutPsz( p_intf, "qt-filedialog-path", p_intf->p_sys->psz_filepath );
     free( psz_path );
+    vlc_restorecancel (canc);
+    return NULL;
 }
 
 /*****************************************************************************