Qt4 - unification of the common used path for QFileDialogs...
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 21 Jan 2008 20:50:43 +0000 (20:50 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 21 Jan 2008 20:50:43 +0000 (20:50 +0000)
modules/gui/qt4/components/open_panels.cpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/qt4.cpp
modules/gui/qt4/qt4.hpp

index dfca117..ae42c7d 100644 (file)
@@ -65,14 +65,9 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     ADD_FILTER_ALL( fileTypes );
     fileTypes.replace( QString(";*"), QString(" *"));
 
-    /* retrieve last known path used in file browsing */
-    char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
-
     // Make this QFileDialog a child of tempWidget from the ui.
     dialogBox = new FileOpenBox( ui.tempWidget, NULL,
-            qfu( EMPTY_STR( psz_filepath ) ?
-                 psz_filepath : p_intf->p_libvlc->psz_homedir ), fileTypes );
-    delete psz_filepath;
+            qfu( p_intf->p_sys->psz_filepath ), fileTypes );
 
     dialogBox->setFileMode( QFileDialog::ExistingFiles );
     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
@@ -138,7 +133,9 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
 }
 
-FileOpenPanel::~FileOpenPanel(){}
+FileOpenPanel::~FileOpenPanel()
+{
+}
 
 /* Show a fileBrowser to select a subtitle */
 void FileOpenPanel::browseFileSub()
@@ -178,15 +175,7 @@ void FileOpenPanel::updateMRL()
 void FileOpenPanel::accept()
 {
     //TODO set the completer
-    const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
-    if( ( NULL == psz_filepath )
-      || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
-    {
-        /* set dialog box current directory as last known path */
-        config_PutPsz( p_intf, "qt-filedialog-path",
-                       qtu( dialogBox->directory().absolutePath() ) );
-    }
-    delete psz_filepath;
+    p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
 }
 
 void FileOpenBox::accept()
index aaecaba..5de8158 100644 (file)
@@ -284,7 +284,7 @@ QStringList DialogsProvider::showSimpleOpen( QString help,
     fileTypes.replace(QString(";*"), QString(" *"));
     return QFileDialog::getOpenFileNames( NULL,
         help.isNull() ? qfu(I_OP_SEL_FILES ) : help,
-        path.isNull() ? qfu( p_intf->p_libvlc->psz_homedir ) : path,
+        path.isNull() ? qfu( p_intf->p_sys->psz_filepath ) : path,
         fileTypes );
 }
 
@@ -373,7 +373,7 @@ void DialogsProvider::saveAPlaylist()
 {
     QFileDialog *qfd = new QFileDialog( NULL,
                                    qtr( "Choose a filename to save playlist" ),
-                                   qfu( p_intf->p_libvlc->psz_homedir ),
+                                   qfu( p_intf->p_sys->psz_filepath ),
                                    qtr( "XSPF playlist (*.xspf);; " ) +
                                    qtr( "M3U playlist (*.m3u);; Any (*.*) " ) );
     qfd->setFileMode( QFileDialog::AnyFile );
index 2ad0d0e..d647ba1 100644 (file)
@@ -331,6 +331,12 @@ static void Init( intf_thread_t *p_intf )
     /* Last settings */
     app->setQuitOnLastWindowClosed( false );
 
+    /*        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
+                           : p_intf->p_libvlc->psz_homedir;
+    delete psz_path;
+
     /* Launch */
     app->exec();
 
@@ -347,6 +353,8 @@ static void Init( intf_thread_t *p_intf )
     /* Destroy the MainInputManager */
     MainInputManager::killInstance();
 
+    delete p_intf->p_sys->psz_filepath;
+
     delete app;
 }
 
index 7670514..5f0f712 100644 (file)
@@ -51,8 +51,8 @@ struct intf_sys_t
     msg_subscription_t *p_sub; ///< Subscription to the message bank
 
     VideoWidget *p_video;
-    int i_saved_height, i_saved_width;
 
+    char *psz_filepath;
     QMenu * p_popup_menu;
 };