allow opening of directory on launch

This commit is contained in:
tzutalin 2018-01-29 15:45:40 +08:00
parent 1270b2c778
commit d43613d9c4
2 changed files with 19 additions and 5 deletions

View File

@ -3,3 +3,13 @@ person
cat cat
tv tv
car car
meatballs
marinara sauce
tomato soup
chicken noodle soup
french onion soup
chicken breast
ribs
pulled pork
hamburger
cavity

View File

@ -199,7 +199,7 @@ class MainWindow(QMainWindow, WindowMixin):
# Tzutalin 20160906 : Add file list and dock to move faster # Tzutalin 20160906 : Add file list and dock to move faster
self.addDockWidget(Qt.RightDockWidgetArea, self.filedock) self.addDockWidget(Qt.RightDockWidgetArea, self.filedock)
self.filedock.setFeatures(QDockWidget.DockWidgetFloatable) self.filedock.setFeatures(QDockWidget.DockWidgetFloatable)
self.dockFeatures = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable self.dockFeatures = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable
self.dock.setFeatures(self.dock.features() ^ self.dockFeatures) self.dock.setFeatures(self.dock.features() ^ self.dockFeatures)
@ -460,6 +460,10 @@ class MainWindow(QMainWindow, WindowMixin):
self.labelCoordinates = QLabel('') self.labelCoordinates = QLabel('')
self.statusBar().addPermanentWidget(self.labelCoordinates) self.statusBar().addPermanentWidget(self.labelCoordinates)
# Open Dir if deafult file
if self.filePath and os.path.isdir(self.filePath):
self.openDirDialog(dirpath=self.filePath)
## Support Functions ## ## Support Functions ##
def noShapes(self): def noShapes(self):
@ -1081,20 +1085,20 @@ class MainWindow(QMainWindow, WindowMixin):
filename = filename[0] filename = filename[0]
self.loadPascalXMLByFilename(filename) self.loadPascalXMLByFilename(filename)
def openDirDialog(self, _value=False): def openDirDialog(self, _value=False, dirpath=None):
if not self.mayContinue(): if not self.mayContinue():
return return
defaultOpenDirPath = '.' defaultOpenDirPath = dirpath if dirpath else '.'
if self.lastOpenDir and os.path.exists(self.lastOpenDir): if self.lastOpenDir and os.path.exists(self.lastOpenDir):
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 '.'
dirpath = 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))
self.importDirImages(dirpath) self.importDirImages(targetDirPath)
def importDirImages(self, dirpath): def importDirImages(self, dirpath):
if not self.mayContinue() or not dirpath: if not self.mayContinue() or not dirpath: