Pārlūkot izejas kodu

Keep the last directory for the open and save file dialog

Rémi Synave 2 gadi atpakaļ
vecāks
revīzija
4571fe152b
1 mainītis faili ar 7 papildinājumiem un 7 dzēšanām
  1. 7 7
      dsl/MainWindow.cpp

+ 7 - 7
dsl/MainWindow.cpp

@@ -3,6 +3,7 @@
 #include <QWidget>
 #include <QMenuBar>
 #include <QFileDialog>
+#include <QUrl>
 
 #include <QDebug>
 
@@ -35,9 +36,9 @@ MainWindow::open ()
 						   QObject::
 						   tr ("Open image file"),
 						   QDir::currentPath (),
-						   QObject::
-						   tr
-						   ("Images files (*.jpg *.png);;All files (*.*)"));
+						   QObject::tr("Images files (*.jpg *.png);;All files (*.*)"));
+  
+  QDir::setCurrent(QString(filename).remove(QUrl(filename).fileName()));
   wa->loadImage (filename.toStdString ());
   setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
 }
@@ -45,12 +46,11 @@ MainWindow::open ()
 void
 MainWindow::save ()
 {
+  //QFileInfo
   QString filename = QFileDialog::getSaveFileName (this,
 						   QObject::tr ("Save file"),
-						   QDir::currentPath (),
-						   QObject::
-						   tr
-						   ("JSON file (*.json);;All files (*.*)"));
+						   QDir::currentPath ().append("/test.json"),
+						   QObject::tr("JSON file (*.json);;All files (*.*)"));
   if(!filename.endsWith(".json"))
     filename.append(".json");
   wa->saveStrengthLine (filename.toStdString ());