Skip to content

Commit ddb87ea

Browse files
committed
Open dialog with last open dir
1 parent 35489b0 commit ddb87ea

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

admeshcontroller.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ admeshController::admeshController(QObject *parent) :
3939
hiddenIcon = QIcon("://Resources/hide.svg");
4040
QSettings settings;
4141
history.setLimitSize(settings.value("sizeLimit", HISTORY_LIMIT).toInt());
42+
openPath = settings.value("openPath", QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0)).value<QString>();
4243
setDrawColor(settings.value("color",QColor(Qt::green)).value<QColor>(), settings.value("badColor",QColor(Qt::red)).value<QColor>());
4344
}
4445

@@ -434,11 +435,12 @@ QString admeshController::getInfo()
434435

435436
void admeshController::openSTL()
436437
{
437-
QStringList fileNameList = QFileDialog::getOpenFileNames((QWidget*)parent(), _("Open STL"), QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0), _("STL (*.stl *.STL)"));
438+
QStringList fileNameList = QFileDialog::getOpenFileNames((QWidget*)parent(), _("Open STL"), openPath, _("STL (*.stl *.STL)"));
438439
int opened = 0;
439440
renewList();
441+
QString fileName;
440442
for(QStringList::Iterator it = fileNameList.begin(); it != fileNameList.end(); it++){
441-
QString fileName = *it;
443+
fileName = *it;
442444
if(!fileName.isEmpty()){
443445
MeshObject* tmp = new MeshObject;
444446
if(!tmp->loadGeometry(fileName)){
@@ -454,10 +456,10 @@ void admeshController::openSTL()
454456
}
455457
count++;
456458
}
457-
}
459+
}
458460
pushHistory();
459461
if(opened>0){
460-
462+
openPath = QFileInfo(fileName).path(); // save path used
461463
statusBar->setText(QString(ngettext("Status: %1 file opened", "Status: %1 files opened", opened)).arg(opened));
462464
reCalculatePosition();
463465
reDrawSignal();
@@ -644,8 +646,10 @@ void admeshController::exportSTL()
644646
}
645647

646648
void admeshController::writeSettings()
647-
{ QSettings settings;
649+
{
650+
QSettings settings;
648651
settings.setValue("rendermode", mode);
652+
settings.setValue("openPath", openPath);
649653
}
650654

651655
float admeshController::getMaxDiameter()

admeshcontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ public slots:
502502
QList <MeshObject*>::size_type count; ///< Count of all objects.
503503
QIcon hiddenIcon; ///< Hidden icon
504504
QIcon visibleIcon; ///< Visible icon
505+
QString openPath; ///< Last path used for file open
505506
int mode; ///< Solid or wireframe or both mode
506507
float versor[3]; ///< Scale versor
507508
bool useVersor; ///< Use versor or not

0 commit comments

Comments
 (0)