]> git.sesse.net Git - vlc/commitdiff
- Qt4: remember last directory browsed in file dialog
authorDamien Fouilleul <damienf@videolan.org>
Wed, 9 May 2007 16:11:33 +0000 (16:11 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Wed, 9 May 2007 16:11:33 +0000 (16:11 +0000)
modules/gui/qt4/components/open.cpp
modules/gui/qt4/qt4.cpp

index 4ed1bd03432217008b4e852234244956dfbaf8ae..8576213f5f99ecb23ba192c6b951610ab9015e29 100644 (file)
@@ -61,6 +61,14 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 /*    dialogBox->setFileMode( QFileDialog::ExistingFiles );*/
     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
 
+    /* retrieve last known path used in file browsing */
+    char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
+    if( psz_filepath )
+    {
+        dialogBox->setDirectory( QString::fromUtf8(psz_filepath) );
+        delete psz_filepath;
+    }
+
     /* We don't want to see a grip in the middle of the window, do we? */
     dialogBox->setSizeGripEnabled( false );
     dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ));
@@ -172,6 +180,17 @@ void FileOpenPanel::updateMRL()
         int size = ui.sizeSubComboBox->itemData( ui.sizeSubComboBox->currentIndex() ).toInt();
         mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
     }
+
+    const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
+    if( (NULL == psz_filepath)
+      || strcmp(psz_filepath,dialogBox->directory().absolutePath().toUtf8()) )
+    {
+        /* set dialog box current directory as last known path */
+        config_PutPsz( p_intf, "qt-filedialog-path",
+                       dialogBox->directory().absolutePath().toUtf8() );
+    }
+    delete psz_filepath;
+
     emit mrlUpdated( mrl );
     emit methodChanged( "file-caching" );
 }
index c86537117d53d2d166114fd7b83d9d3debd68dfe..02b1cd5d23c8b39759e4bea7c7d27188aadf1eca 100644 (file)
@@ -57,6 +57,10 @@ static void ShowDialog   ( intf_thread_t *, int, int, intf_dialog_args_t * );
 #define MINIMIZED_LONGTEXT N_("When you launch VLC with that option" \
                             "VLC will start just with an icon in" \
                             "your taskbar")
+
+#define FILEDIALOG_PATH_TEXT N_("path to use in file dialog")
+#define FILEDIALOG_PATH_LONGTEXT N_("path to use in file dialog")
+
 vlc_module_begin();
     set_shortname( (char *)"Qt" );
     set_description( (char*)_("Qt interface") );
@@ -79,6 +83,10 @@ vlc_module_begin();
                 SYSTRAY_LONGTEXT, VLC_FALSE);
         add_bool( "qt-start-mininimized", VLC_FALSE, NULL, MINIMIZED_TEXT,
                 MINIMIZED_LONGTEXT, VLC_TRUE);
+        add_string( "qt-filedialog-path", NULL, NULL, FILEDIALOG_PATH_TEXT,
+                FILEDIALOG_PATH_LONGTEXT, VLC_TRUE);
+            change_autosave();
+            change_internal();
         set_callbacks( OpenDialogs, Close );
 vlc_module_end();