diff --git a/qtgui/designer/mainwindow.py b/qtgui/designer/mainwindow.py index b9bbf23..aacf657 100644 --- a/qtgui/designer/mainwindow.py +++ b/qtgui/designer/mainwindow.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'mainwindow.ui' # -# Created by: PyQt5 UI code generator 5.14.1 +# Created by: PyQt5 UI code generator 5.14.2 # # WARNING! All changes made in this file will be lost! @@ -17,8 +17,17 @@ class Ui_MainWindow(object): self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setSpacing(0) self.verticalLayout.setObjectName("verticalLayout") - self.tabbyCat = QtWidgets.QTabWidget(self.centralwidget) + self.mainPageSwitcher = QtWidgets.QStackedWidget(self.centralwidget) + self.mainPageSwitcher.setLineWidth(0) + self.mainPageSwitcher.setObjectName("mainPageSwitcher") + self.tabPage = QtWidgets.QWidget() + self.tabPage.setObjectName("tabPage") + self.verticalLayout_12 = QtWidgets.QVBoxLayout(self.tabPage) + self.verticalLayout_12.setObjectName("verticalLayout_12") + self.tabbyCat = QtWidgets.QTabWidget(self.tabPage) self.tabbyCat.setObjectName("tabbyCat") self.tab_quick = QtWidgets.QWidget() self.tab_quick.setObjectName("tab_quick") @@ -239,7 +248,18 @@ class Ui_MainWindow(object): self.informationTreeWidget.header().setMinimumSectionSize(50) self.verticalLayout_11.addWidget(self.informationTreeWidget) self.tabbyCat.addTab(self.tab_information, "") - self.verticalLayout.addWidget(self.tabbyCat) + self.verticalLayout_12.addWidget(self.tabbyCat) + self.mainPageSwitcher.addWidget(self.tabPage) + self.messagePage = QtWidgets.QWidget() + self.messagePage.setObjectName("messagePage") + self.verticalLayout_13 = QtWidgets.QVBoxLayout(self.messagePage) + self.verticalLayout_13.setObjectName("verticalLayout_13") + self.messageLabel = QtWidgets.QLabel(self.messagePage) + self.messageLabel.setAlignment(QtCore.Qt.AlignCenter) + self.messageLabel.setObjectName("messageLabel") + self.verticalLayout_13.addWidget(self.messageLabel) + self.mainPageSwitcher.addWidget(self.messagePage) + self.verticalLayout.addWidget(self.mainPageSwitcher) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") @@ -313,6 +333,7 @@ class Ui_MainWindow(object): self.menubar.addAction(self.menuClientNameId.menuAction()) self.retranslateUi(MainWindow) + self.mainPageSwitcher.setCurrentIndex(0) self.tabbyCat.setCurrentIndex(0) self.quickStackedWidget.setCurrentIndex(1) self.detailedStackedWidget.setCurrentIndex(1) @@ -349,6 +370,7 @@ class Ui_MainWindow(object): self.informationTreeWidget.topLevelItem(4).setText(1, _translate("MainWindow", "Last Updated")) self.informationTreeWidget.setSortingEnabled(__sortingEnabled) self.tabbyCat.setTabText(self.tabbyCat.indexOf(self.tab_information), _translate("MainWindow", "Information")) + self.messageLabel.setText(_translate("MainWindow", "Processing")) self.menuControl.setTitle(_translate("MainWindow", "Control")) self.menuSession.setTitle(_translate("MainWindow", "SessionName")) self.menuClientNameId.setTitle(_translate("MainWindow", "ClientNameId")) diff --git a/qtgui/designer/mainwindow.ui b/qtgui/designer/mainwindow.ui index bc2cbc7..947e326 100644 --- a/qtgui/designer/mainwindow.ui +++ b/qtgui/designer/mainwindow.ui @@ -15,139 +15,97 @@ + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + - + + + 0 + 0 - - - Quick View - - + + - + - 1 + 0 - - - - - - Start New Session - - - true - - - true - - - + + + Quick View + + - - - true + + + 1 - - - - 0 - 0 - 98 - 28 - - - + + - - - Qt::Vertical + + + Start New Session - - - 20 - 586 - + + true - + + true + + + + + + + true + + + + + 0 + 0 + 98 + 28 + + + + + + + Qt::Vertical + + + + 20 + 586 + + + + + + + - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Session Name Goes Here - - - Qt::AlignCenter - - - - - - - - 0 - - - 0 - - - - - Save - - - - - - - Save and Close - - - - - - - - - - Qt::Vertical - - - - - 0 - 1 - - - - Session Notes - - + + 0 @@ -164,303 +122,374 @@ 0 - - - - 0 - 0 - + + + Session Name Goes Here + + Qt::AlignCenter + + + + + + + + 0 + + + 0 + + + + + Save + + + + + + + Save and Close + + + + + + + + + + Qt::Vertical + + + + + 0 + 1 + + + + Session Notes + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + + + 0 + 6 + + + + QListView::IconMode + + + true + + - - - - 0 - 6 - - - - QListView::IconMode - - - true - - - - - - - - - Full View - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 1 - - - - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - - - New - - - - - - - Load Selected - - - - - - - Tree View - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 1 - - - - - - - - + + + Full View + + 0 - 9 + 0 - 9 + 0 - 9 + 0 - 9 + 0 - - - Qt::Vertical + + + 1 - - - - 0 - 7 - - - - Qt::Horizontal - - - false - - - - - 0 - 7 - + + + + 6 - - Double-click to load program + + 9 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QAbstractItemView::NoSelection - - - - 64 - 64 - - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - - 1 - - - - - - - - - In current session + + 9 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 3 - - - - true - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel + + 9 + + + 9 + + + + + + + + New + + + + + + + Load Selected + + + + + + + Tree View + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 1 - - - 1 - - - - - - + + + + - - - - 0 - 2 - - - - Session Notes - - + + 0 - 0 + 9 - 0 + 9 - 0 + 9 - 0 + 9 - - - - 0 - 0 - + + + Qt::Vertical + + + + 0 + 7 + + + + Qt::Horizontal + + + false + + + + + 0 + 7 + + + + Double-click to load program + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QAbstractItemView::NoSelection + + + + 64 + 64 + + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + + 1 + + + + + + + + + In current session + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 3 + + + + true + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + + 1 + + + + + + + + + + + 0 + 2 + + + + Session Notes + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + @@ -469,106 +498,120 @@ + + + Information + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::ScrollPerPixel + + + false + + + false + + + 50 + + + 150 + + + + + + + AlignTrailing|AlignVCenter + + + + + + + + + + JACK + + + AlignTrailing|AlignVCenter + + + version and running + + + + + NSM Server Mode + + + AlignTrailing|AlignVCenter + + + Self-started, connected to, environment var + + + + + NSM Url + + + AlignTrailing|AlignVCenter + + + osc.upd ip port + + + + + Session Root + + + AlignTrailing|AlignVCenter + + + /home/usr/NSM Sessions + + + + + Program Database + + + AlignTrailing|AlignVCenter + + + Last Updated + + + + + + - - - Information - - + + - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::ScrollPerPixel + + + Processing - - false + + Qt::AlignCenter - - false - - - 50 - - - 150 - - - - - - - AlignTrailing|AlignVCenter - - - - - - - - - - JACK - - - AlignTrailing|AlignVCenter - - - version and running - - - - - NSM Server Mode - - - AlignTrailing|AlignVCenter - - - Self-started, connected to, environment var - - - - - NSM Url - - - AlignTrailing|AlignVCenter - - - osc.upd ip port - - - - - Session Root - - - AlignTrailing|AlignVCenter - - - /home/usr/NSM Sessions - - - - - Program Database - - - AlignTrailing|AlignVCenter - - - Last Updated - - diff --git a/qtgui/mainwindow.py b/qtgui/mainwindow.py index 6d67c46..c4ba40d 100644 --- a/qtgui/mainwindow.py +++ b/qtgui/mainwindow.py @@ -115,6 +115,8 @@ class MainWindow(QtWidgets.QMainWindow): self.ui.setupUi(self) self.fPalBlue = setPaletteAndFont(self.qtApp) + self.ui.mainPageSwitcher.setCurrentIndex(0) #1 is messageLabel 0 is the tab widget + #TODO: Hide information tab until the feature is ready self.ui.tabbyCat.removeTab(2) @@ -189,7 +191,7 @@ class MainWindow(QtWidgets.QMainWindow): self.toggleVisible(force=True) getattr(self, "raise")() #raise is python syntax. Can't use that directly self.activateWindow() - text = QtCore.QCoreApplication.translate("activateAndRaise", "Another GUI tried to launch.") + text = QtCore.QCoreApplication.translate("mainWindow", "Another GUI tried to launch.") self.systemTray.showMessage("Argodejo", text, QtWidgets.QSystemTrayIcon.Information, 2000) #title, message, icon, timeout. #has messageClicked() signal. def _updateGUIWithCachedPrograms(self): @@ -216,14 +218,14 @@ class MainWindow(QtWidgets.QMainWindow): def updateProgramDatabase(self): """Display a progress-dialog that waits for the database to be build. Automatically called on first start or when instructed by the user""" - text = QtCore.QCoreApplication.translate("updateProgramDatabase", "Updating Program Database") - informativeText = QtCore.QCoreApplication.translate("updateProgramDatabase", "Thank you for your patience.") - title = QtCore.QCoreApplication.translate("updateProgramDatabase", "Updating") + text = QtCore.QCoreApplication.translate("mainWindow", "Updating Program Database.\nThank you for your patience.") + settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"]) settings.remove("programDatabase") logger.info("Asking api to getSystemPrograms while waiting") - diag = WaitDialog(self, title, text, informativeText, api.buildSystemPrograms) #save in local var to keep alive + diag = WaitDialog(self, text, api.buildSystemPrograms) #save in local var to keep alive + settings.setValue("programDatabase", api.getSystemPrograms()) self._updateGUIWithCachedPrograms() diff --git a/qtgui/waitdialog.py b/qtgui/waitdialog.py index 267a4a1..3a0c382 100644 --- a/qtgui/waitdialog.py +++ b/qtgui/waitdialog.py @@ -23,57 +23,50 @@ import logging; logger = logging.getLogger(__name__); logger.info("import") #Standard Library - #Third Party from PyQt5 import QtCore, QtGui, QtWidgets class WaitThread(QtCore.QThread): - def __init__(self, longRunningFunction): + def __init__(self, mainWindow, longRunningFunction): self.longRunningFunction = longRunningFunction + self.mainWindow = mainWindow + self.finished = False QtCore.QThread.__init__(self) def __del__(self): + """This gets called rather early in the objects life but is in the main thread!""" self.wait() + #This is after run + self.finished = True + logger.info(f"Thread done {self.longRunningFunction}") def run(self): + """This is in the side-thread. We can't access qt widgets here""" logger.info(f"Thread running {self.longRunningFunction}") self.longRunningFunction() + self.finished = True - -class WaitDialog(QtWidgets.QMessageBox): - """An information box that closes itself once a task is done. +class WaitDialog(object): + """An information text that closes itself once a task is done. Executes and shows on construction""" - def __init__(self, mainWindow, title, text, informativeText, longRunningFunction): - #text = QtCore.QCoreApplication.translate("AskBeforeQuit", "About to quit but session {} still open").format(nsmSessionName) - #informativeText = QtCore.QCoreApplication.translate("AskBeforeQuit", "Do you want to save?") - #title = QtCore.QCoreApplication.translate("AskBeforeQuit", "About to quit") + def __init__(self, mainWindow, text, longRunningFunction): super().__init__() - logger.info(f"Starting blocking dialog {title} for {longRunningFunction}") - self.mainWindow = mainWindow - self.setWindowFlag(QtCore.Qt.Popup, True) - self.setIcon(self.Information) - self.setText(text) - self.setWindowTitle(title) - self.setInformativeText(informativeText) - self.setStandardButtons(QtWidgets.QMessageBox.NoButton) #no buttons - - wt = WaitThread(longRunningFunction) - wt.finished.connect(self.realClose) + logger.info(f"Starting blocking message for {longRunningFunction}") + self.mainWindow = mainWindow + self.mainWindow.ui.messageLabel.setText(text) + self.mainWindow.ui.mainPageSwitcher.setCurrentIndex(1) #1 is messageLabel 0 is the tab widget + self.mainWindow.ui.menubar.setEnabled(False) #TODO: this will leave the options in the TrayIcon menu available.. but well, who cares... + + wt = WaitThread(mainWindow, longRunningFunction) + #wt.finished.connect(self.threadDone) #does NOT trigger wt.start() + while not wt.finished: + self.mainWindow.qtApp.processEvents() - self.exec() - - def realClose(self): - self.closeEvent = QtWidgets.QMessageBox.closeEvent - logger.info("Thread done") - self.done(True) - - def keyPressEvent(self, event): - event.ignore() + self.mainWindow.ui.menubar.setEnabled(True) + self.mainWindow.ui.mainPageSwitcher.setCurrentIndex(0) #1 is messageLabel 0 is the tab widget - def closeEvent(self, event): - event.ignore() - +