Commit a7838c2b authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - unification of the common used path for QFileDialogs...

parent d64f6aac
...@@ -65,14 +65,9 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -65,14 +65,9 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
ADD_FILTER_ALL( fileTypes ); ADD_FILTER_ALL( fileTypes );
fileTypes.replace( QString(";*"), QString(" *")); 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. // Make this QFileDialog a child of tempWidget from the ui.
dialogBox = new FileOpenBox( ui.tempWidget, NULL, dialogBox = new FileOpenBox( ui.tempWidget, NULL,
qfu( EMPTY_STR( psz_filepath ) ? qfu( p_intf->p_sys->psz_filepath ), fileTypes );
psz_filepath : p_intf->p_libvlc->psz_homedir ), fileTypes );
delete psz_filepath;
dialogBox->setFileMode( QFileDialog::ExistingFiles ); dialogBox->setFileMode( QFileDialog::ExistingFiles );
dialogBox->setAcceptMode( QFileDialog::AcceptOpen ); dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
...@@ -138,7 +133,9 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -138,7 +133,9 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() ); CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
} }
FileOpenPanel::~FileOpenPanel(){} FileOpenPanel::~FileOpenPanel()
{
}
/* Show a fileBrowser to select a subtitle */ /* Show a fileBrowser to select a subtitle */
void FileOpenPanel::browseFileSub() void FileOpenPanel::browseFileSub()
...@@ -178,15 +175,7 @@ void FileOpenPanel::updateMRL() ...@@ -178,15 +175,7 @@ void FileOpenPanel::updateMRL()
void FileOpenPanel::accept() void FileOpenPanel::accept()
{ {
//TODO set the completer //TODO set the completer
const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" ); p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
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;
} }
void FileOpenBox::accept() void FileOpenBox::accept()
......
...@@ -284,7 +284,7 @@ QStringList DialogsProvider::showSimpleOpen( QString help, ...@@ -284,7 +284,7 @@ QStringList DialogsProvider::showSimpleOpen( QString help,
fileTypes.replace(QString(";*"), QString(" *")); fileTypes.replace(QString(";*"), QString(" *"));
return QFileDialog::getOpenFileNames( NULL, return QFileDialog::getOpenFileNames( NULL,
help.isNull() ? qfu(I_OP_SEL_FILES ) : help, 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 ); fileTypes );
} }
...@@ -373,7 +373,7 @@ void DialogsProvider::saveAPlaylist() ...@@ -373,7 +373,7 @@ void DialogsProvider::saveAPlaylist()
{ {
QFileDialog *qfd = new QFileDialog( NULL, QFileDialog *qfd = new QFileDialog( NULL,
qtr( "Choose a filename to save playlist" ), 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( "XSPF playlist (*.xspf);; " ) +
qtr( "M3U playlist (*.m3u);; Any (*.*) " ) ); qtr( "M3U playlist (*.m3u);; Any (*.*) " ) );
qfd->setFileMode( QFileDialog::AnyFile ); qfd->setFileMode( QFileDialog::AnyFile );
......
...@@ -331,6 +331,12 @@ static void Init( intf_thread_t *p_intf ) ...@@ -331,6 +331,12 @@ static void Init( intf_thread_t *p_intf )
/* Last settings */ /* Last settings */
app->setQuitOnLastWindowClosed( false ); 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 */ /* Launch */
app->exec(); app->exec();
...@@ -347,6 +353,8 @@ static void Init( intf_thread_t *p_intf ) ...@@ -347,6 +353,8 @@ static void Init( intf_thread_t *p_intf )
/* Destroy the MainInputManager */ /* Destroy the MainInputManager */
MainInputManager::killInstance(); MainInputManager::killInstance();
delete p_intf->p_sys->psz_filepath;
delete app; delete app;
} }
......
...@@ -51,8 +51,8 @@ struct intf_sys_t ...@@ -51,8 +51,8 @@ struct intf_sys_t
msg_subscription_t *p_sub; ///< Subscription to the message bank msg_subscription_t *p_sub; ///< Subscription to the message bank
VideoWidget *p_video; VideoWidget *p_video;
int i_saved_height, i_saved_width;
char *psz_filepath;
QMenu * p_popup_menu; QMenu * p_popup_menu;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment