mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Merge branch 'fileopen' of github.com:heliocastro/subsurface
This commit is contained in:
commit
bd8470ebcf
1 changed files with 18 additions and 1 deletions
|
@ -87,10 +87,27 @@ void MainWindow::on_actionNew_triggered()
|
|||
|
||||
void MainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter());
|
||||
QSettings settings;
|
||||
QString lastDir = QDir::homePath();
|
||||
|
||||
settings.beginGroup("FileDialog");
|
||||
if (settings.contains("LastDir")) {
|
||||
if(QDir::setCurrent(settings.value("LastDir").toString())) {
|
||||
lastDir = settings.value("LastDir").toString();
|
||||
}
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), lastDir, filter());
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
|
||||
// Keep last open dir
|
||||
QFileInfo fileInfo(filename);
|
||||
settings.beginGroup("FileDialog");
|
||||
settings.setValue("LastDir",fileInfo.dir().path());
|
||||
settings.endGroup();
|
||||
|
||||
// Needed to convert to char*
|
||||
QByteArray fileNamePtr = filename.toLocal8Bit();
|
||||
|
||||
|
|
Loading…
Reference in a new issue