]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/qt4.cpp
New recently played menu.
[vlc] / modules / gui / qt4 / qt4.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 59ea681..fb4fb49
@@ -39,6 +39,7 @@
 #include "input_manager.hpp"
 #include "main_interface.hpp"
 #include "dialogs/help.hpp" /* update */
+#include "recents.hpp"
 
 #ifdef HAVE_X11_XLIB_H
 #include <X11/Xlib.h>
 #include "../../../share/vlc32x32-christmas.xpm"
 #include <vlc_plugin.h>
 
+#ifdef WIN32
+ #include <QtPlugin>
+ Q_IMPORT_PLUGIN(qjpeg)
+#endif
+
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
@@ -118,6 +124,9 @@ static void ShowDialog   ( intf_thread_t *, int, int, intf_dialog_args_t * );
 
 #define PRIVACY_TEXT N_( "Ask for network policy at start" )
 
+#define RECENTPLAY_TEXT N_( "Save the recently played items in the menu" )
+#define RECENTPLAY_FILTER_TEXT N_( "List of words separated by | to filter" )
+
 #define SLIDERCOL_TEXT N_( "Define the colors of the volume slider " )
 #define SLIDERCOL_LONGTEXT N_( "Define the colors of the volume slider\n" \
                        "By specifying the 12 numbers separated by a ';'\n" \
@@ -158,7 +167,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 );
@@ -204,15 +213,34 @@ vlc_module_begin();
 
         add_bool( "qt-privacy-ask", true, NULL, PRIVACY_TEXT, PRIVACY_TEXT,
                 false );
+        add_bool( "qt-recentplay", true, NULL, RECENTPLAY_TEXT,
+                RECENTPLAY_TEXT, false );
+        add_string( "qt-recentplay-filter", NULL, NULL,
+                RECENTPLAY_FILTER_TEXT, RECENTPLAY_FILTER_TEXT, false );
             change_internal();
 
         set_callbacks( OpenDialogs, Close );
 
+#if !defined (Q_WS_X11) || HAS_QT43
     add_submodule();
         set_capability( "vout window", 50 );
         set_callbacks( WindowOpen, WindowClose );
+#endif
 vlc_module_end();
 
+#if defined(Q_WS_WIN)
+bool WinQtApp::winEventFilter( MSG *msg, long *result )
+{
+    switch( msg->message )
+    {
+        case 0x0319: /* WM_APPCOMMAND 0x0319 */
+        DefWindowProc( msg->hwnd, msg->message, msg->wParam, msg->lParam );
+        break;
+    }
+    return false;
+}
+#endif /* Q_WS_WIN */
+
 /*****************************************************************************
  * Module callbacks
  *****************************************************************************/
@@ -242,9 +270,7 @@ static int Open( vlc_object_t *p_this )
     p_intf->p_sys->p_mi = NULL;
 
     /* Access to the playlist */
-    p_intf->p_sys->p_playlist = pl_Yield( p_intf );
-    /* Listen to the messages */
-    p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
+    p_intf->p_sys->p_playlist = pl_Hold( p_intf );
     /* one settings to rule them all */
 
     var_Create( p_this, "window_widget", VLC_VAR_ADDRESS );
@@ -266,10 +292,6 @@ 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 )
     {
         if( DialogsProvider::isAlive() )
@@ -282,7 +304,6 @@ static void Close( vlc_object_t *p_this )
     }
 
     vlc_object_release( p_intf->p_sys->p_playlist );
-    msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
     free( p_intf->p_sys );
 }
 
@@ -298,12 +319,21 @@ static void Run( intf_thread_t *p_intf )
             msg_Err( p_intf, "failed to create Qt dialogs thread" );
     }
     else
+    {
         Init( VLC_OBJECT(p_intf) );
+    }
 }
 
 static QMutex windowLock;
 static QWaitCondition windowWait;
 
+static void ThreadCleanup( void *param)
+{
+    intf_thread_t *p_intf = (intf_thread_t *)param;
+    QCloseEvent *event = new QCloseEvent();
+    QApplication::postEvent( p_intf->p_sys->p_mi, event );
+}
+
 static void *Init( vlc_object_t *obj )
 {
     intf_thread_t *p_intf = (intf_thread_t *)obj;
@@ -311,7 +341,10 @@ static void *Init( vlc_object_t *obj )
     char dummy[] = "";
     char *argv[] = { dummy };
     int argc = 1;
+    int canc = vlc_savecancel ();
 
+    msg_Dbg( p_intf, "Setting ThreadCleanup");
+    vlc_cleanup_push( ThreadCleanup, (void*)p_intf );
     Q_INIT_RESOURCE( vlc );
 
 #if !defined(WIN32) && !defined(__APPLE__)
@@ -326,7 +359,11 @@ static void *Init( vlc_object_t *obj )
 #endif
 
     /* Start the QApplication here */
+#ifdef WIN32
+    WinQtApp *app = new WinQtApp( argc, argv , true );
+#else
     QApplication *app = new QApplication( argc, argv , true );
+#endif
     p_intf->p_sys->p_app = app;
 
     p_intf->p_sys->mainSettings = new QSettings(
@@ -337,8 +374,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
@@ -420,13 +456,15 @@ static void *Init( vlc_object_t *obj )
 
     /* Retrieve last known path used in file browsing */
     char *psz_path = config_GetPsz( p_intf, "qt-filedialog-path" );
-    p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? psz_path
-                                                        : config_GetHomeDir();
+    p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? config_GetHomeDir()
+                                                        : psz_path;
 
+    vlc_restorecancel (canc);
     /* Launch */
     app->exec();
 
     /* And quit */
+    canc = vlc_savecancel ();
     msg_Dbg( p_intf, "Quitting the Qt4 Interface" );
 
     if (miP)
@@ -453,6 +491,9 @@ static void *Init( vlc_object_t *obj )
      */
     DialogsProvider::killInstance();
 
+    /* Delete the recentsMRL object before the configuration */
+    RecentsMRL::killInstance();
+
     /* Delete the configuration. Application has to be deleted after that. */
     delete p_intf->p_sys->mainSettings;
 
@@ -465,6 +506,9 @@ static void *Init( vlc_object_t *obj )
     /* Save the path */
     config_PutPsz( p_intf, "qt-filedialog-path", p_intf->p_sys->psz_filepath );
     free( psz_path );
+    vlc_restorecancel (canc);
+    vlc_cleanup_pop();
+    return NULL;
 }
 
 /*****************************************************************************