summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofiledialog.cpp
Unidiff
Diffstat (limited to 'libopie2/opieui/fileselector/ofiledialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp
index beb4d6c..ebce0ef 100644
--- a/libopie2/opieui/fileselector/ofiledialog.cpp
+++ b/libopie2/opieui/fileselector/ofiledialog.cpp
@@ -70,7 +70,10 @@ void saveLastDir( const QString& key, const QString& file )
70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); 70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
71 cfg.setGroup( key ); 71 cfg.setGroup( key );
72 QFileInfo inf( file ); 72 QFileInfo inf( file );
73 cfg.writeEntry("LastDir", inf.dirPath( true ) ); 73 if ( inf.isFile() )
74 cfg.writeEntry("LastDir", inf.dirPath( true ) );
75 else
76 cfg.writeEntry("LastDir", file );
74} 77}
75}; 78};
76 79
@@ -204,6 +207,36 @@ QString OFileDialog::getSaveFileName(int selector,
204 return ret; 207 return ret;
205} 208}
206 209
210/**
211 * This opens up a filedialog in select directory mode
212 *
213 * @param selector the Selector Mode
214 * @param startDir Where to start from
215 * @param wid the parent
216 * @param caption of the dialog if QString::null tr("Open") will be used
217 * @return the directoryName or QString::null
218 */
219QString OFileDialog::getDirectory(int selector,
220 const QString &_startDir,
221 QWidget *wid,
222 const QString &caption )
223{
224 QString ret;
225 QString startDir = _startDir;
226 if ( startDir.isEmpty() )
227 startDir = lastUsedDir( "FileDialog-SELECTDIR" );
228
229 OFileDialog dlg( caption.isEmpty() ? tr( "Select Directory" ) : caption,
230 wid, OFileSelector::DirectorySelector, selector, startDir );
231 dlg.showMaximized();
232 if ( dlg.exec() )
233 {
234 ret = dlg.fileName();
235 saveLastDir( "FileDialog-SELECTDIR", ret );
236 }
237 return ret;
238}
239
207void OFileDialog::slotFileSelected(const QString & ) 240void OFileDialog::slotFileSelected(const QString & )
208{ 241{
209 accept(); 242 accept();