Skip to content

Commit

Permalink
Save last used export directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Ábel Kőszeghy authored and Ábel Kőszeghy committed Jun 14, 2018
1 parent fb77847 commit 2561282
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion qconsolidatedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
QDir,
QFile,
QFileInfo,
QSettings,
)
from qgis.PyQt.QtWidgets import (
QCheckBox,
Expand Down Expand Up @@ -74,6 +75,9 @@ def __init__(self):
if project_name:
self.project_name_le.setText(project_name)

self.btnOk.setEnabled(bool(self.project_name_le.text()) and
bool(self.leOutputDir.text()))

self.btnBrowse.clicked.connect(self.setOutDirectory)

def initGui(self):
Expand All @@ -86,6 +90,11 @@ def initGui(self):

self.label = QLabel("Output directory")
self.leOutputDir = QLineEdit()

s = QSettings()
lastdir = s.value("qconsolidate3/lastdir", "")
self.leOutputDir.setText(lastdir)

self.btnBrowse = QPushButton("Browse...")
self.buttonBox = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
Expand Down Expand Up @@ -126,11 +135,14 @@ def set_ok_button(self):
bool(self.leOutputDir.text()))

def setOutDirectory(self):
s = QSettings()
lastdir = s.value("qconsolidate3/lastdir", ".")
outDir = QFileDialog.getExistingDirectory(
self, self.tr("Select output directory"), ".")
self, self.tr("Select output directory"), lastdir)
if not outDir:
return

s.setValue("qconsolidate3/lastdir", outDir)
self.leOutputDir.setText(outDir)

def accept(self):
Expand Down

0 comments on commit 2561282

Please sign in to comment.