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 @@