Skip to content

Commit

Permalink
bug fixes after merge ... work on recent maps ...
Browse files Browse the repository at this point in the history
  • Loading branch information
cudmore committed Oct 12, 2024
1 parent 47886fb commit c8c601f
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 222 deletions.
25 changes: 14 additions & 11 deletions pymapmanager/interface2/mainMenus.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def _onAboutMenuAction(self, name):

def _refreshEditMenu(self):
"""Manage undo/redo menus.
20241011, redo is always off.
"""

self.editMenu.clear()
Expand Down Expand Up @@ -300,7 +302,8 @@ def _refreshEditMenu(self):
redoAction = QtWidgets.QAction("Redo " + nextRedo, self.getApp())
redoAction.setCheckable(False) # setChecked is True by default?
redoAction.setShortcut("Shift+Ctrl+Z")
redoAction.setEnabled(enableRedo)
# redoAction.setEnabled(enableRedo)
redoAction.setEnabled(False)
redoAction.triggered.connect(self.getApp()._redo_action)
self.editMenu.addAction(redoAction)

Expand Down Expand Up @@ -437,25 +440,25 @@ def _refreshOpenRecent(self):

self.openRecentMenu.clear()

# add files
for recentFile in configDict.getRecentStacks():
# add recent mmap files
for recentFile in configDict.getRecentMaps():
loadFileAction = QtWidgets.QAction(recentFile, self.getApp())
loadFileAction.triggered.connect(
partial(self.getApp().loadStackWidget, recentFile)
)

self.openRecentMenu.addAction(loadFileAction)

self.openRecentMenu.addSeparator()
# self.openRecentMenu.addSeparator()

# add folders
for recentFolder in configDict.getRecentMaps():
loadFolderAction = QtWidgets.QAction(recentFolder, self.getApp())
loadFolderAction.triggered.connect(
partial(self.getApp().loadMapWidget, recentFolder)
)
# add recent folders
# for recentFolder in configDict.getRecentMaps():
# loadFolderAction = QtWidgets.QAction(recentFolder, self.getApp())
# loadFolderAction.triggered.connect(
# partial(self.getApp().loadMapWidget, recentFolder)
# )

self.openRecentMenu.addAction(loadFolderAction)
# self.openRecentMenu.addAction(loadFolderAction)

def _refreshAnalysisParameters(self):
"""
Expand Down
42 changes: 16 additions & 26 deletions pymapmanager/interface2/openFirstWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,37 +97,27 @@ def _makeRecentTable(self, pathList : List[str], headerStr = ''):
myTableWidget.setRowHeight(idx, _rowHeight + int(.7 * _rowHeight))

return myTableWidget

def _old_on_recent_stack_click(self, rowIdx : int):
"""On double-click, open a file and close self.
"""
path = self.recentStackList[rowIdx]
logger.info(f'rowId:{rowIdx} path:{path}')

# abj: Changed this to check if it is a directory instead of a file
# if os.path.isfile(path):
if os.path.isdir(path):
self.getApp().loadStackWidget(path)
else:
logger.error(f'did not find path: {path}')

def _on_recent_map_click(self, rowIdx : int):
"""On double-click, open a folder and close self.
"""On double-click, open a mmap and close self.
"""
path = self.recentMapList[rowIdx]
logger.info(f'rowId:{rowIdx} path:{path}')

if os.path.isdir(path):
self.getApp().loadMapWidget(path)
# if os.path.isdir(path):
if os.path.isfile(path):
self.getApp().loadStackWidget(path)
else:
logger.error(f'did not find path: {path}')
logger.error(f'did not find dir path: {path}')

def _on_open_button_click(self, name : str):
logger.info(name)
if name == 'Open...':
self._app.loadStackWidget()
elif name == 'Open Folder...':
self._app.loadMapWidget()

# TODO: implement this
# elif name == 'Open Folder...':
# self._app.loadFolder() # load a folder of mmap

def _buildUI(self):
# typical wrapper for PyQt, we can't use setLayout(), we need to use setCentralWidget()
Expand All @@ -152,22 +142,22 @@ def _buildUI(self):

name = 'Open...'
aButton = QtWidgets.QPushButton(name)
aButton.setFixedSize(QtCore.QSize(200, 60))
aButton.setToolTip('Open an image.')
aButton.setFixedSize(QtCore.QSize(180, 40))
aButton.setToolTip('Open a tif or mmap file.')
aButton.clicked.connect(partial(self._on_open_button_click, name))
hBoxLayout.addWidget(aButton, alignment=QtCore.Qt.AlignLeft)

name = 'Open Map...'
name = 'Open Folder...'
aButton = QtWidgets.QPushButton(name)
aButton.setFixedSize(QtCore.QSize(200, 60))
aButton.setToolTip('Open a map.')
aButton.setFixedSize(QtCore.QSize(180, 40))
aButton.setToolTip('Open a folder of mmap files.')
aButton.clicked.connect(partial(self._on_open_button_click, name))
hBoxLayout.addWidget(aButton, alignment=QtCore.Qt.AlignLeft)

name = 'Drag and Drop'
aButton = DragAndDropWidget(name, self._app)
aButton.setFixedSize(QtCore.QSize(200, 60))
aButton.setToolTip('Drag and Drop Tif File.')
aButton.setFixedSize(QtCore.QSize(180, 40))
aButton.setToolTip('Drag and drop a tif or mmap file.')
# aButton.clicked.connect(partial(self._on_open_button_click, name))
hBoxLayout.addWidget(aButton, alignment=QtCore.Qt.AlignLeft)

Expand Down
39 changes: 13 additions & 26 deletions pymapmanager/interface2/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def getStackWindowGeometry(self) -> List[int]:
theRet = [x, y, width, height]
return theRet

def getMostRecentStack(self):
return self.configDict["mostRecentStack"]
# def getMostRecentStack(self):
# return self.configDict["mostRecentStack"]

def getRecentStacks(self):
return self.configDict["recentStacks"]
# def getRecentStacks(self):
# return self.configDict["recentStacks"]

def getMostRecentMap(self):
def getMostRecentMap(self) -> str:
return self.configDict["mostRecentMap"]

def getRecentMaps(self):
Expand All @@ -62,32 +62,16 @@ def __getitem__(self, key):
return
return self._configDict[key]

def _old_addStackPath(self, stackPath : str):
"""Add a single timepoint stack.
Similar to addMapPath.
"""

if stackPath not in self.configDict["recentStacks"]:
self.configDict["recentStacks"].append(stackPath)
# limit list to last _maxNumUndo
self.configDict["recentStacks"] = self.configDict["recentStacks"][
-self._maxRecent :
]

# always set as the most recent file
self.configDict["mostRecentStack"] = stackPath

self.save()

def addMapPath(self, mapPath : str):
"""Add a map path.
Similar to addMapPath.
"""Add a map path to recent maps
"""

if mapPath not in self.configDict["recentMaps"]:
self.configDict["recentMaps"].append(mapPath)
# limit list to last _maxNumUndo

# reduce/limit list to last _maxRecent
self.configDict["recentMaps"] = self.configDict["recentMaps"][-self._maxRecent :]

# always set as the most recent file
Expand Down Expand Up @@ -168,8 +152,8 @@ def getDefaults(self) -> dict:
configDict["version"] = self._version
configDict["theme"] = 'dark' # in ['dark', 'light', 'auto']

configDict["recentStacks"] = []
configDict["mostRecentStack"] = ""
# configDict["recentStacks"] = []
# configDict["mostRecentStack"] = ""

configDict["recentMaps"] = []
configDict["mostRecentMap"] = ""
Expand All @@ -185,3 +169,6 @@ def getDefaults(self) -> dict:
configDict['logLevel'] = 'INFO'

return configDict

def getRecentMapsDataframe(self):
pass
Loading

0 comments on commit c8c601f

Please sign in to comment.