|
|
@ -39,13 +39,19 @@ class SessionButton(QtWidgets.QPushButton): |
|
|
|
self.sessionDict = sessionDict |
|
|
|
super().__init__(sessionDict["nsmSessionName"]) |
|
|
|
self.clicked.connect(self.openSession) |
|
|
|
#width = self.fontMetrics().boundingRect(sessionDict["nsmSessionName"]).width()+10 |
|
|
|
#self.setFixedSize(width, 40) |
|
|
|
self.setFixedHeight(40) |
|
|
|
#self.setFlat(True) |
|
|
|
|
|
|
|
font = self.font() |
|
|
|
font.setPixelSize(font.pixelSize() * 1.2 ) |
|
|
|
self.setFont(font) |
|
|
|
|
|
|
|
#width = self.fontMetrics().boundingRect(sessionDict["nsmSessionName"]).width()+10 |
|
|
|
#width = self.fontMetrics().boundingRect(longestSessionName).width()+10 |
|
|
|
#width = parent.geometry().width() |
|
|
|
#self.setFixedSize(width, 40) |
|
|
|
self.setFixedHeight(40) |
|
|
|
|
|
|
|
|
|
|
|
def openSession(self): |
|
|
|
name = self.sessionDict["nsmSessionName"] |
|
|
|
api.sessionOpen(name) |
|
|
@ -56,6 +62,7 @@ class QuickSessionController(object): |
|
|
|
def __init__(self, mainWindow): |
|
|
|
self.mainWindow = mainWindow |
|
|
|
self.layout = mainWindow.ui.quickSessionChooser.layout() |
|
|
|
#self.layout.setAlignment(QtCore.Qt.AlignHCenter) |
|
|
|
newSessionButton = mainWindow.ui.quickNewSession |
|
|
|
|
|
|
|
font = newSessionButton.font() |
|
|
@ -67,6 +74,12 @@ class QuickSessionController(object): |
|
|
|
newSessionButton.clicked.connect(self._newTimestampSession) |
|
|
|
api.callbacks.sessionsChanged.append(self._reactCallback_sessionsChanged) |
|
|
|
|
|
|
|
#self.layout.geometry().width() #very small |
|
|
|
#self.mainWindow.ui.quickSessionChooser.geometry().width() #too small |
|
|
|
#self.mainWindow.ui.scrollArea.geometry().width() |
|
|
|
#mainWindow.geometry().width() |
|
|
|
|
|
|
|
|
|
|
|
logger.info("Quick Session Chooser ready") |
|
|
|
|
|
|
|
def _clear(self): |
|
|
@ -77,6 +90,8 @@ class QuickSessionController(object): |
|
|
|
child.setParent(None) |
|
|
|
del child |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _reactCallback_sessionsChanged(self, sessionDicts:list): |
|
|
|
"""Main callback for new, added, removed, moved sessions etc.""" |
|
|
|
logger.info("Rebuilding session buttons") |
|
|
@ -84,6 +99,11 @@ class QuickSessionController(object): |
|
|
|
|
|
|
|
spacer = self.layout.takeAt(0) |
|
|
|
|
|
|
|
#longestSessionName = "" |
|
|
|
#for sessionDict in sessionDicts: |
|
|
|
# if len(sessionDict["nsmSessionName"]) > len(longestSessionName): |
|
|
|
# longestSessionName = sessionDict["nsmSessionName"] |
|
|
|
|
|
|
|
for sessionDict in sorted(sessionDicts, key=lambda d: d["nsmSessionName"]): |
|
|
|
self.layout.addWidget(SessionButton(sessionDict)) |
|
|
|
|
|
|
|