From 668248041e288b2540abb3bcab004e5325a6944c Mon Sep 17 00:00:00 2001 From: chstaiger Date: Tue, 13 Aug 2024 15:48:27 +0200 Subject: [PATCH] some cosmetics --- ibridgesgui/popup_widgets.py | 52 ++++++++++++++++------------ ibridgesgui/ui_files/downloadData.py | 7 ++-- ibridgesgui/ui_files/downloadData.ui | 19 +++++----- ibridgesgui/ui_files/tabSync.py | 4 ++- ibridgesgui/ui_files/tabSync.ui | 5 ++- ibridgesgui/ui_files/uploadData.py | 7 ++-- ibridgesgui/ui_files/uploadData.ui | 19 +++++----- 7 files changed, 66 insertions(+), 47 deletions(-) diff --git a/ibridgesgui/popup_widgets.py b/ibridgesgui/popup_widgets.py index 390a224d..9354d1a6 100644 --- a/ibridgesgui/popup_widgets.py +++ b/ibridgesgui/popup_widgets.py @@ -341,9 +341,7 @@ def _get_upload_params(self): self._start_upload(local_paths) def _start_upload(self, lpaths): - self._enable_buttons(False) self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor)) - self.active_upload = True self.error_label.setText(f"Uploading to {str(self.irods_path)} ....") env_path = Path("~").expanduser().joinpath(".irods", get_last_ienv_path()) @@ -361,9 +359,19 @@ def _start_upload(self, lpaths): ] ) - self.upload_thread = TransferDataThread( - env_path, self.logger, ops, overwrite=self.overwrite.isChecked() - ) + if len(ops.upload) == 0: + self.error_label.setText("Data already present and up to date.") + self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) + else: + self._enable_buttons(False) + self.active_upload = True + self.upload_thread = TransferDataThread( + env_path, self.logger, ops, overwrite=self.overwrite.isChecked() + ) + self.upload_thread.result.connect(self._upload_fetch_result) + self.upload_thread.finished.connect(self._finish_upload) + self.upload_thread.current_progress.connect(self._upload_status) + self.upload_thread.start() except FileExistsError: self.error_label.setText("Data already exists. Check 'overwrite' to overwrite.") @@ -378,13 +386,7 @@ def _start_upload(self, lpaths): self._enable_buttons(True) return - self.upload_thread.result.connect(self._upload_fetch_result) - self.upload_thread.finished.connect(self._finish_upload) - self.upload_thread.current_progress.connect(self._upload_status) - self.upload_thread.start() - def _finish_upload(self): - self._enable_buttons(True) self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) del self.upload_thread @@ -477,6 +479,7 @@ def irods_path_tree(self): def select_folder(self): """Select the download destination.""" + self.error_label.clear() select_dir = Path( QFileDialog.getExistingDirectory( self, "Select Directory", directory=str(Path("~").expanduser()) @@ -511,9 +514,7 @@ def _enable_buttons(self, enable): self.metadata.setEnabled(enable) def _start_download(self, local_path): - self.active_download = True self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor)) - self._enable_buttons(False) self.error_label.setText(f"Downloading to {local_path} ....") env_path = Path("~").expanduser().joinpath(".irods", get_last_ienv_path()) try: @@ -525,9 +526,20 @@ def _start_download(self, local_path): metadata=self.meta_path, dry_run=True, ) - self.download_thread = TransferDataThread( - env_path, self.logger, ops, overwrite=self.overwrite.isChecked() - ) + + if len(ops.download) == 0 and len(ops.meta_download) == 0: + self.error_label.setText("Data already present and up to date.") + self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) + else: + self._enable_buttons(False) + self.active_download = True + self.download_thread = TransferDataThread( + env_path, self.logger, ops, overwrite=self.overwrite.isChecked() + ) + self.download_thread.result.connect(self._download_fetch_result) + self.download_thread.finished.connect(self._finish_download) + self.download_thread.current_progress.connect(self._download_status) + self.download_thread.start() except FileExistsError: self.error_label.setText("Data already exists. Check 'overwrite' to overwrite.") self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) @@ -535,19 +547,13 @@ def _start_download(self, local_path): return except Exception as err: self.error_label.setText( - f"Could not instantiate a new session from {env_path}: {repr(err)}." + f"Could not instantiate thread from {env_path}: {repr(err)}." ) self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) self._enable_buttons(True) return - self.download_thread.result.connect(self._download_fetch_result) - self.download_thread.finished.connect(self._finish_download) - self.download_thread.current_progress.connect(self._download_status) - self.download_thread.start() - def _finish_download(self): - self._enable_buttons(True) self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) del self.download_thread diff --git a/ibridgesgui/ui_files/downloadData.py b/ibridgesgui/ui_files/downloadData.py index ded00489..77df29b8 100644 --- a/ibridgesgui/ui_files/downloadData.py +++ b/ibridgesgui/ui_files/downloadData.py @@ -61,11 +61,11 @@ def setupUi(self, Form): self.download_button = QtWidgets.QPushButton(parent=Form) self.download_button.setObjectName("download_button") self.horizontalLayout.addWidget(self.download_button) + spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) + self.horizontalLayout.addItem(spacerItem) self.hide_button = QtWidgets.QPushButton(parent=Form) self.hide_button.setObjectName("hide_button") self.horizontalLayout.addWidget(self.hide_button) - spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) - self.horizontalLayout.addItem(spacerItem) self.gridLayout.addLayout(self.horizontalLayout, 8, 1, 1, 1) self.metadata = QtWidgets.QCheckBox(parent=Form) self.metadata.setObjectName("metadata") @@ -123,7 +123,8 @@ def setupUi(self, Form): self.gridLayout.addWidget(self.source_browser, 3, 1, 1, 1) self.progress_bar = QtWidgets.QProgressBar(parent=Form) self.progress_bar.setProperty("value", 0) - self.progress_bar.setTextVisible(False) + self.progress_bar.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + self.progress_bar.setTextVisible(True) self.progress_bar.setObjectName("progress_bar") self.gridLayout.addWidget(self.progress_bar, 9, 1, 1, 1) diff --git a/ibridgesgui/ui_files/downloadData.ui b/ibridgesgui/ui_files/downloadData.ui index 170f8c02..13a48341 100644 --- a/ibridgesgui/ui_files/downloadData.ui +++ b/ibridgesgui/ui_files/downloadData.ui @@ -66,13 +66,6 @@ QTabWidget#info_tabs - - - - Close window - - - @@ -86,6 +79,13 @@ QTabWidget#info_tabs + + + + Close window + + + @@ -210,8 +210,11 @@ QTabWidget#info_tabs 0 + + Qt::AlignCenter + - false + true diff --git a/ibridgesgui/ui_files/tabSync.py b/ibridgesgui/ui_files/tabSync.py index 2bb24da9..241dd7b0 100644 --- a/ibridgesgui/ui_files/tabSync.py +++ b/ibridgesgui/ui_files/tabSync.py @@ -24,6 +24,7 @@ def setupUi(self, tabSync): "QProgressBar::chunk\n" "{\n" " background-color: rgb(21, 165, 137);\n" +" width: 5px;\n" "}\n" "\n" "QLabel#error_label\n" @@ -204,7 +205,8 @@ def setupUi(self, tabSync): self.verticalLayout_11.addWidget(self.error_label) self.progress_bar = QtWidgets.QProgressBar(parent=self.layoutWidget) self.progress_bar.setProperty("value", 0) - self.progress_bar.setTextVisible(False) + self.progress_bar.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + self.progress_bar.setTextVisible(True) self.progress_bar.setObjectName("progress_bar") self.verticalLayout_11.addWidget(self.progress_bar) spacerItem10 = QtWidgets.QSpacerItem(20, 10, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum) diff --git a/ibridgesgui/ui_files/tabSync.ui b/ibridgesgui/ui_files/tabSync.ui index 3e6c9877..d00cf795 100644 --- a/ibridgesgui/ui_files/tabSync.ui +++ b/ibridgesgui/ui_files/tabSync.ui @@ -429,8 +429,11 @@ QTabWidget#info_tabs 0 + + Qt::AlignCenter + - false + true diff --git a/ibridgesgui/ui_files/uploadData.py b/ibridgesgui/ui_files/uploadData.py index 5770c050..1f943c2a 100644 --- a/ibridgesgui/ui_files/uploadData.py +++ b/ibridgesgui/ui_files/uploadData.py @@ -110,11 +110,11 @@ def setupUi(self, Form): self.upload_button = QtWidgets.QPushButton(parent=Form) self.upload_button.setObjectName("upload_button") self.horizontalLayout.addWidget(self.upload_button) + spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) + self.horizontalLayout.addItem(spacerItem1) self.hide_button = QtWidgets.QPushButton(parent=Form) self.hide_button.setObjectName("hide_button") self.horizontalLayout.addWidget(self.hide_button) - spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) - self.horizontalLayout.addItem(spacerItem1) self.gridLayout.addLayout(self.horizontalLayout, 4, 2, 1, 1) self.sources_list = QtWidgets.QTextBrowser(parent=Form) self.sources_list.setObjectName("sources_list") @@ -122,7 +122,8 @@ def setupUi(self, Form): self.progress_bar = QtWidgets.QProgressBar(parent=Form) self.progress_bar.setMaximum(100) self.progress_bar.setProperty("value", 0) - self.progress_bar.setTextVisible(False) + self.progress_bar.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + self.progress_bar.setTextVisible(True) self.progress_bar.setObjectName("progress_bar") self.gridLayout.addWidget(self.progress_bar, 5, 2, 1, 1) diff --git a/ibridgesgui/ui_files/uploadData.ui b/ibridgesgui/ui_files/uploadData.ui index 41a74b01..5519eed7 100644 --- a/ibridgesgui/ui_files/uploadData.ui +++ b/ibridgesgui/ui_files/uploadData.ui @@ -167,13 +167,6 @@ QTabWidget#info_tabs - - - - Close Window - - - @@ -187,6 +180,13 @@ QTabWidget#info_tabs + + + + Close Window + + + @@ -200,8 +200,11 @@ QTabWidget#info_tabs 0 + + Qt::AlignCenter + - false + true