Add Silent option for openDirDialog
Add Silent option for openDirDialog to facilitate opening a directory at start up
if the filePath provided is a directory without opening the file selector UI.
This commit is contained in:
parent
53a78e2c93
commit
157a4173f3
@ -474,7 +474,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
|
|
||||||
# Open Dir if deafult file
|
# Open Dir if deafult file
|
||||||
if self.filePath and os.path.isdir(self.filePath):
|
if self.filePath and os.path.isdir(self.filePath):
|
||||||
self.openDirDialog(dirpath=self.filePath)
|
self.openDirDialog(dirpath=self.filePath, silent=True)
|
||||||
|
|
||||||
def keyReleaseEvent(self, event):
|
def keyReleaseEvent(self, event):
|
||||||
if event.key() == Qt.Key_Control:
|
if event.key() == Qt.Key_Control:
|
||||||
@ -1170,7 +1170,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
filename = filename[0]
|
filename = filename[0]
|
||||||
self.loadPascalXMLByFilename(filename)
|
self.loadPascalXMLByFilename(filename)
|
||||||
|
|
||||||
def openDirDialog(self, _value=False, dirpath=None):
|
def openDirDialog(self, _value=False, dirpath=None, silent=False):
|
||||||
if not self.mayContinue():
|
if not self.mayContinue():
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1179,10 +1179,13 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
defaultOpenDirPath = self.lastOpenDir
|
defaultOpenDirPath = self.lastOpenDir
|
||||||
else:
|
else:
|
||||||
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
|
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
|
||||||
|
if silent!=True :
|
||||||
targetDirPath = ustr(QFileDialog.getExistingDirectory(self,
|
targetDirPath = ustr(QFileDialog.getExistingDirectory(self,
|
||||||
'%s - Open Directory' % __appname__, defaultOpenDirPath,
|
'%s - Open Directory' % __appname__, defaultOpenDirPath,
|
||||||
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
|
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
|
||||||
|
else:
|
||||||
|
targetDirPath = ustr(defaultOpenDirPath)
|
||||||
|
|
||||||
self.importDirImages(targetDirPath)
|
self.importDirImages(targetDirPath)
|
||||||
|
|
||||||
def importDirImages(self, dirpath):
|
def importDirImages(self, dirpath):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user