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
tv
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
self.addDockWidget(Qt.RightDockWidgetArea, self.filedock)
self.filedock.setFeatures(QDockWidget.DockWidgetFloatable)
self.dockFeatures = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable
self.dock.setFeatures(self.dock.features() ^ self.dockFeatures)
@ -460,6 +460,10 @@ class MainWindow(QMainWindow, WindowMixin):
self.labelCoordinates = QLabel('')
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 ##
def noShapes(self):
@ -1081,20 +1085,20 @@ class MainWindow(QMainWindow, WindowMixin):
filename = filename[0]
self.loadPascalXMLByFilename(filename)
def openDirDialog(self, _value=False):
def openDirDialog(self, _value=False, dirpath=None):
if not self.mayContinue():
return
defaultOpenDirPath = '.'
defaultOpenDirPath = dirpath if dirpath else '.'
if self.lastOpenDir and os.path.exists(self.lastOpenDir):
defaultOpenDirPath = self.lastOpenDir
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,
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
self.importDirImages(dirpath)
self.importDirImages(targetDirPath)
def importDirImages(self, dirpath):
if not self.mayContinue() or not dirpath: