From fe82e321549368ef41b7fadbd576adf90874b673 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sun, 27 Feb 2022 20:21:11 +0100 Subject: [PATCH] Better download dialog --- qtgui/chooseDownloadDirectory.py | 29 ++- qtgui/designer/chooseDownloadDirectory.py | 92 +++++---- qtgui/designer/chooseDownloadDirectory.ui | 224 +++++++++++++--------- qtgui/mainwindow.py | 2 +- template/documentation/readme.template | 3 +- template/qtgui/mainwindow.py | 1 - 6 files changed, 208 insertions(+), 143 deletions(-) diff --git a/qtgui/chooseDownloadDirectory.py b/qtgui/chooseDownloadDirectory.py index 7734e26..5f1073f 100644 --- a/qtgui/chooseDownloadDirectory.py +++ b/qtgui/chooseDownloadDirectory.py @@ -73,11 +73,16 @@ class ChooseDownloadDirectory(QtWidgets.QDialog): self.ui.pathComboBox.setCurrentText("") self.ui.buttonBox.accepted.connect(self.accept) - self.ui.buttonBox.rejected.connect(self.reject) + self.ui.buttonBox.rejected.connect(self.reject) #For the hidden cancel button - self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Rescan Sample Directory")) - self._cancelDefaultText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Don't rescan") - self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText(self._cancelDefaultText) + self._rescanButtonDefaultText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Rescan and Close Dialog") + self._rescanButtonPleaseWaitForDownloadText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Please wait for download to finish") + + self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(self._rescanButtonDefaultText) + #self._cancelDefaultText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Don't rescan") + #self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText(self._cancelDefaultText) + self.ui.abortDownloadButton.hide() + self.ui.abortDownloadButton.clicked.connect(self.reject) self.ui.openFileDialogButton.setText("") self.ui.openFileDialogButton.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DialogOpenButton"))) @@ -85,6 +90,8 @@ class ChooseDownloadDirectory(QtWidgets.QDialog): self.ui.downloadPushButton.setEnabled(True) self._downloadDefaultText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Download and Update Instrument Libraries") + + self._pauseText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Pause Download") self._resumeText = QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Resume Download") self.ui.downloadPushButton.setText(self._downloadDefaultText) @@ -125,12 +132,13 @@ class ChooseDownloadDirectory(QtWidgets.QDialog): super().accept() def reject(self): - #During Download the button says "Abort". We make sure all downloads are actually stopped and then exist as normal. + #We make sure all downloads are actually stopped and then exist as normal. self._abortDownloadNOW = True #just to be safe if self.currentSmartDL: self.currentSmartDL.unpause() #Just stopping here while paused will freeze Qt. With setting the abort switch above we can let it play out. + self.path = None super().reject() @@ -154,9 +162,6 @@ class ChooseDownloadDirectory(QtWidgets.QDialog): http://itaybb.github.io/pySmartDL/examples.html#example-6-use-the-nonblocking-flag-and-get-information-during-the-download-process """ - #hier weiter machen. Während des Downloads muss der Download button ein pause/resume werden. - #und abort tatsächlich zuverlässig den momentanen und alle zukünftigen downloads in der queue abbrechen - def _resetDialog(message): self.ui.pathComboBox.setEnabled(True) @@ -173,7 +178,9 @@ class ChooseDownloadDirectory(QtWidgets.QDialog): self.ui.buttonBox.setEnabled(True) self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) - self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText(self._cancelDefaultText) + self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(self._rescanButtonDefaultText) + self.ui.abortDownloadButton.hide() + #self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText(self._cancelDefaultText) self.currentSmartDL = None #TODO: Make sure all downloads are stopped @@ -216,7 +223,9 @@ class ChooseDownloadDirectory(QtWidgets.QDialog): self.ui.downloadPushButton.setEnabled(False) #self.ui.buttonBox.setEnabled(False) self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False) - self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText(QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Abort Download")) + self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(self._rescanButtonPleaseWaitForDownloadText) + self.ui.abortDownloadButton.show() + #self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText(QtCore.QCoreApplication.translate("ChooseDownloadDirectory", "Abort Download")) self.ui.pathComboBox.setEnabled(False) diff --git a/qtgui/designer/chooseDownloadDirectory.py b/qtgui/designer/chooseDownloadDirectory.py index c5e1669..fec683e 100644 --- a/qtgui/designer/chooseDownloadDirectory.py +++ b/qtgui/designer/chooseDownloadDirectory.py @@ -14,31 +14,26 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_ChooseDownloadDirectory(object): def setupUi(self, ChooseDownloadDirectory): ChooseDownloadDirectory.setObjectName("ChooseDownloadDirectory") - ChooseDownloadDirectory.resize(410, 391) + ChooseDownloadDirectory.resize(453, 578) self.verticalLayout = QtWidgets.QVBoxLayout(ChooseDownloadDirectory) + self.verticalLayout.setSpacing(20) self.verticalLayout.setObjectName("verticalLayout") - self.layoutWidget = QtWidgets.QWidget(ChooseDownloadDirectory) - self.layoutWidget.setObjectName("layoutWidget") - self.formLayout = QtWidgets.QFormLayout(self.layoutWidget) - self.formLayout.setContentsMargins(-1, -1, -1, 0) - self.formLayout.setObjectName("formLayout") - self.label = QtWidgets.QLabel(self.layoutWidget) - self.label.setWordWrap(True) - self.label.setObjectName("label") - self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.label) - self.verticalLayout.addWidget(self.layoutWidget) + self.groupBox_2 = QtWidgets.QGroupBox(ChooseDownloadDirectory) + self.groupBox_2.setObjectName("groupBox_2") + self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.groupBox_2) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.label_2 = QtWidgets.QLabel(self.groupBox_2) + self.label_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.label_2.setWordWrap(True) + self.label_2.setObjectName("label_2") + self.verticalLayout_3.addWidget(self.label_2) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.pathComboBox = QtWidgets.QComboBox(ChooseDownloadDirectory) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pathComboBox.sizePolicy().hasHeightForWidth()) - self.pathComboBox.setSizePolicy(sizePolicy) + self.pathComboBox = QtWidgets.QComboBox(self.groupBox_2) self.pathComboBox.setEditable(True) self.pathComboBox.setObjectName("pathComboBox") self.horizontalLayout_2.addWidget(self.pathComboBox) - self.openFileDialogButton = QtWidgets.QPushButton(ChooseDownloadDirectory) + self.openFileDialogButton = QtWidgets.QPushButton(self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -47,18 +42,36 @@ class Ui_ChooseDownloadDirectory(object): self.openFileDialogButton.setFlat(False) self.openFileDialogButton.setObjectName("openFileDialogButton") self.horizontalLayout_2.addWidget(self.openFileDialogButton) - self.verticalLayout.addLayout(self.horizontalLayout_2) - spacerItem = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) - self.verticalLayout.addItem(spacerItem) - self.progressLabel = QtWidgets.QLabel(ChooseDownloadDirectory) + self.verticalLayout_3.addLayout(self.horizontalLayout_2) + self.verticalLayout.addWidget(self.groupBox_2) + self.groupBox = QtWidgets.QGroupBox(ChooseDownloadDirectory) + self.groupBox.setObjectName("groupBox") + self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.label_3 = QtWidgets.QLabel(self.groupBox) + self.label_3.setWordWrap(True) + self.label_3.setObjectName("label_3") + self.verticalLayout_2.addWidget(self.label_3) + self.downloadPushButton = QtWidgets.QPushButton(self.groupBox) + self.downloadPushButton.setObjectName("downloadPushButton") + self.verticalLayout_2.addWidget(self.downloadPushButton) + self.abortDownloadButton = QtWidgets.QPushButton(self.groupBox) + self.abortDownloadButton.setObjectName("abortDownloadButton") + self.verticalLayout_2.addWidget(self.abortDownloadButton) + self.progressLabel = QtWidgets.QLabel(self.groupBox) self.progressLabel.setAlignment(QtCore.Qt.AlignCenter) self.progressLabel.setObjectName("progressLabel") - self.verticalLayout.addWidget(self.progressLabel) - self.widget = QtWidgets.QWidget(ChooseDownloadDirectory) + self.verticalLayout_2.addWidget(self.progressLabel) + self.widget = QtWidgets.QWidget(self.groupBox) self.widget.setObjectName("widget") self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget) self.horizontalLayout.setObjectName("horizontalLayout") self.progressBar = QtWidgets.QProgressBar(self.widget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.progressBar.sizePolicy().hasHeightForWidth()) + self.progressBar.setSizePolicy(sizePolicy) self.progressBar.setProperty("value", 24) self.progressBar.setTextVisible(True) self.progressBar.setOrientation(QtCore.Qt.Horizontal) @@ -69,24 +82,35 @@ class Ui_ChooseDownloadDirectory(object): self.labelSpeed = QtWidgets.QLabel(self.widget) self.labelSpeed.setObjectName("labelSpeed") self.horizontalLayout.addWidget(self.labelSpeed) - self.verticalLayout.addWidget(self.widget) - self.downloadPushButton = QtWidgets.QPushButton(ChooseDownloadDirectory) - self.downloadPushButton.setObjectName("downloadPushButton") - self.verticalLayout.addWidget(self.downloadPushButton) - self.buttonBox = QtWidgets.QDialogButtonBox(ChooseDownloadDirectory) + self.verticalLayout_2.addWidget(self.widget) + self.verticalLayout.addWidget(self.groupBox) + self.groupBox_3 = QtWidgets.QGroupBox(ChooseDownloadDirectory) + self.groupBox_3.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.groupBox_3.setFlat(False) + self.groupBox_3.setObjectName("groupBox_3") + self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.groupBox_3) + self.verticalLayout_4.setObjectName("verticalLayout_4") + self.buttonBox = QtWidgets.QDialogButtonBox(self.groupBox_3) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") - self.verticalLayout.addWidget(self.buttonBox) + self.verticalLayout_4.addWidget(self.buttonBox) + self.verticalLayout.addWidget(self.groupBox_3) self.retranslateUi(ChooseDownloadDirectory) QtCore.QMetaObject.connectSlotsByName(ChooseDownloadDirectory) def retranslateUi(self, ChooseDownloadDirectory): _translate = QtCore.QCoreApplication.translate - ChooseDownloadDirectory.setWindowTitle(_translate("ChooseDownloadDirectory", "Choose Session Directory")) - self.label.setText(_translate("ChooseDownloadDirectory", "

Please choose a directory for your sample files. The location will be shared by all sessions.

The instrument sample files are around 10 Gigabytes in size.

You can either use this integrated downloader or get the files manually from: https://laborejo.org/downloads/tembro-instruments/

The downloader can be used to update instruments at any time and will not download the same instrument/version twice.

")) + ChooseDownloadDirectory.setWindowTitle(_translate("ChooseDownloadDirectory", "Instrument Location and Download")) + self.groupBox_2.setTitle(_translate("ChooseDownloadDirectory", "Step 1: Choose Instrument Directory")) + self.label_2.setText(_translate("ChooseDownloadDirectory", "

Please choose a directory for you instrument libaries.

This location will be shared among all Tembro-sessions.

")) self.openFileDialogButton.setText(_translate("ChooseDownloadDirectory", "Choose Directory")) + self.groupBox.setTitle(_translate("ChooseDownloadDirectory", "Step 2: Download Instruments")) + self.label_3.setText(_translate("ChooseDownloadDirectory", "

Click the button below to download all instrument libraries from our servers.

You can skip this and copy the files manually into the directory chosen in Step 1.

Please visit https://laborejo.org/downloads/tembro-instruments/ for direct downloads.

At a later date you can start the download again to check for new instruments. Only new and updated libraries will be downloaded again.

")) + self.downloadPushButton.setText(_translate("ChooseDownloadDirectory", "Download")) + self.abortDownloadButton.setText(_translate("ChooseDownloadDirectory", "Abort Download and Close")) self.progressLabel.setText(_translate("ChooseDownloadDirectory", "Library 4 of 10: Kazoo Ensemble")) self.labelSpeed.setText(_translate("ChooseDownloadDirectory", "TextLabel")) - self.downloadPushButton.setText(_translate("ChooseDownloadDirectory", "Download")) + self.groupBox_3.setTitle(_translate("ChooseDownloadDirectory", "Step 3: Rescan the instrument directory")) diff --git a/qtgui/designer/chooseDownloadDirectory.ui b/qtgui/designer/chooseDownloadDirectory.ui index 870f370..8092e87 100644 --- a/qtgui/designer/chooseDownloadDirectory.ui +++ b/qtgui/designer/chooseDownloadDirectory.ui @@ -6,139 +6,173 @@ 0 0 - 410 - 391 + 453 + 578 - Choose Session Directory + Instrument Location and Download + + 20 + - - - - 0 - - - + + + Step 1: Choose Instrument Directory + + + + - <html><head/><body><p>Please choose a directory for your sample files. The location will be shared by all sessions. </p><p>The instrument sample files are around 10 Gigabytes in size.</p><p>You can either use this integrated downloader or get the files manually from: <a href="https://laborejo.org/downloads/tembro-instruments/"><span style=" text-decoration: underline; color:#00ffff;">https://laborejo.org/downloads/tembro-instruments/ </span></a></p><p>The downloader can be used to update instruments at any time and will not download the same instrument/version twice.</p></body></html> + <html><head/><body><p>Please choose a directory for you instrument libaries.</p><p>This location will be shared among all Tembro-sessions.</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop true + + + + + + true + + + + + + + + 0 + 0 + + + + Choose Directory + + + false + + + + + - - - - - - 0 - 0 - - - - true - - - - - - - - 0 - 0 - - - - Choose Directory - - - false - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 30 - - - - - - - - Library 4 of 10: Kazoo Ensemble + + + Step 2: Download Instruments - - Qt::AlignCenter - - - - - - + - - - 24 + + + <html><head/><body><p>Click the button below to download all instrument libraries from our servers. </p><p>You can skip this and copy the files manually into the directory chosen in Step 1.</p><p>Please visit <a href="https://laborejo.org/downloads/tembro-instruments/"><span style=" text-decoration: underline; color:#0000ff;">https://laborejo.org/downloads/tembro-instruments/</span></a> for direct downloads.</p><p>At a later date you can start the download again to check for new instruments. Only new and updated libraries will be downloaded again.</p></body></html> - + true - - Qt::Horizontal - - - false + + + + + + Download - - %p% + + + + + + Abort Download and Close - + - TextLabel + Library 4 of 10: Kazoo Ensemble + + Qt::AlignCenter + + + + + + + + + + + 0 + 0 + + + + 24 + + + true + + + Qt::Horizontal + + + false + + + %p% + + + + + + + TextLabel + + + + - - - Download + + + Step 3: Rescan the instrument directory - - - - - - Qt::Horizontal + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + false + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + true + + + + diff --git a/qtgui/mainwindow.py b/qtgui/mainwindow.py index fa649e1..9395c74 100644 --- a/qtgui/mainwindow.py +++ b/qtgui/mainwindow.py @@ -177,7 +177,7 @@ class MainWindow(TemplateMainWindow): #New menu entries and template-menu overrides #self.menu.connectMenuEntry("actionAbout", lambda: print("About Dialog Menu deactivated")) #deactivates the original function #self.menu.addMenuEntry("menuEdit", "actionNils", "Nils", lambda: print("Merle")) - self.menu.addMenuEntry("menuEdit", "actionSampleDirPathDialog", "Sample Files Location", lambda: ChooseDownloadDirectory(parentMainWindow=self)) + self.menu.addMenuEntry("menuEdit", "actionSampleDirPathDialog", "Instrument Location and Download", lambda: ChooseDownloadDirectory(parentMainWindow=self)) self.menu.addMenuEntry("menuEdit", "actionLoadSamples", QtCore.QCoreApplication.translate("Menu", "Load all Instrument Samples (slow!)"), api.loadAllInstrumentSamples) self.menu.addMenuEntry("menuEdit", "actionUnloadSamples", QtCore.QCoreApplication.translate("Menu", "Unload all Instrument Samples (also slow.)"), api.unloadAllInstrumentSamples) diff --git a/template/documentation/readme.template b/template/documentation/readme.template index c058d1f..7a1da05 100644 --- a/template/documentation/readme.template +++ b/template/documentation/readme.template @@ -1,7 +1,7 @@ [//]: # (Generated . Changes belong into template/documentation/readme.template) -# +# Program version @@ -120,4 +120,3 @@ Or even shorter: This is the minimal run mode which is only useful for testing and development. But if you only want to look at the GUI and are not in the mood to install anything -including dependencies-, go ahead. - diff --git a/template/qtgui/mainwindow.py b/template/qtgui/mainwindow.py index 84f8077..8e6f4a3 100644 --- a/template/qtgui/mainwindow.py +++ b/template/qtgui/mainwindow.py @@ -30,7 +30,6 @@ from sys import exit as sysexit #Third Party from PyQt5 import QtCore, QtGui, QtWidgets logger.info(f"PyQt Version: {QtCore.PYQT_VERSION_STR}") -#from PyQt5 import QtOpenGL #Template Modules from .nsmclient import NSMClient