mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
[processing] Fix initial directory shown in model open file dialogs
should be the users home file, or the last used model directory
This commit is contained in:
parent
8486afbdd1
commit
e748877a59
@ -24,7 +24,7 @@ __copyright__ = '(C) 201, Victor Olaya'
|
||||
import os
|
||||
import shutil
|
||||
from qgis.PyQt.QtWidgets import QFileDialog, QMessageBox
|
||||
from qgis.PyQt.QtCore import QFileInfo, QCoreApplication
|
||||
from qgis.PyQt.QtCore import QFileInfo, QCoreApplication, QDir
|
||||
|
||||
from qgis.core import QgsApplication, QgsSettings, QgsProcessingModelAlgorithm
|
||||
|
||||
@ -45,7 +45,7 @@ class AddModelFromFileAction(ToolboxAction):
|
||||
|
||||
def execute(self):
|
||||
settings = QgsSettings()
|
||||
lastDir = settings.value('Processing/lastModelsDir', '')
|
||||
lastDir = settings.value('Processing/lastModelsDir', QDir.homePath())
|
||||
filename, selected_filter = QFileDialog.getOpenFileName(self.toolbox,
|
||||
self.tr('Open Model', 'AddModelFromFileAction'), lastDir,
|
||||
self.tr('Processing models (*.model3 *.MODEL3)', 'AddModelFromFileAction'))
|
||||
|
||||
@ -32,7 +32,8 @@ from qgis.PyQt.QtCore import (
|
||||
QPoint,
|
||||
QPointF,
|
||||
pyqtSignal,
|
||||
QUrl)
|
||||
QUrl,
|
||||
QFileInfo)
|
||||
from qgis.PyQt.QtWidgets import (QMessageBox,
|
||||
QFileDialog)
|
||||
from qgis.core import (Qgis,
|
||||
@ -218,11 +219,15 @@ class ModelerDialog(QgsModelDesignerDialog):
|
||||
if not self.checkForUnsavedChanges():
|
||||
return
|
||||
|
||||
settings = QgsSettings()
|
||||
last_dir = settings.value('Processing/lastModelsDir', QDir.homePath())
|
||||
filename, selected_filter = QFileDialog.getOpenFileName(self,
|
||||
self.tr('Open Model'),
|
||||
ModelerUtils.modelsFolders()[0],
|
||||
last_dir,
|
||||
self.tr('Processing models (*.model3 *.MODEL3)'))
|
||||
if filename:
|
||||
settings.setValue('Processing/lastModelsDir',
|
||||
QFileInfo(filename).absoluteDir().absolutePath())
|
||||
self.loadModel(filename)
|
||||
|
||||
def repaintModel(self, showControls=True):
|
||||
|
||||
@ -23,7 +23,7 @@ __copyright__ = '(C) 2018, Nyall Dawson'
|
||||
|
||||
import os
|
||||
from qgis.PyQt.QtWidgets import QFileDialog
|
||||
from qgis.PyQt.QtCore import QFileInfo, QCoreApplication
|
||||
from qgis.PyQt.QtCore import QFileInfo, QCoreApplication, QDir
|
||||
|
||||
from qgis.core import QgsApplication, QgsSettings
|
||||
from qgis.utils import iface
|
||||
@ -44,7 +44,7 @@ class OpenModelFromFileAction(ToolboxAction):
|
||||
|
||||
def execute(self):
|
||||
settings = QgsSettings()
|
||||
lastDir = settings.value('Processing/lastModelsDir', '')
|
||||
lastDir = settings.value('Processing/lastModelsDir', QDir.homePath())
|
||||
filename, selected_filter = QFileDialog.getOpenFileName(self.toolbox,
|
||||
self.tr('Open Model', 'AddModelFromFileAction'), lastDir,
|
||||
self.tr('Processing models (*.model3 *.MODEL3)', 'AddModelFromFileAction'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user