Skip to content

Commit

Permalink
some cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
chStaiger committed Aug 13, 2024
1 parent 06d3fc8 commit 6682480
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 47 deletions.
52 changes: 29 additions & 23 deletions ibridgesgui/popup_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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.")
Expand All @@ -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

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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:
Expand All @@ -525,29 +526,34 @@ 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))
self._enable_buttons(True)
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

Expand Down
7 changes: 4 additions & 3 deletions ibridgesgui/ui_files/downloadData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down
19 changes: 11 additions & 8 deletions ibridgesgui/ui_files/downloadData.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ QTabWidget#info_tabs
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hide_button">
<property name="text">
<string>Close window</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
Expand All @@ -86,6 +79,13 @@ QTabWidget#info_tabs
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="hide_button">
<property name="text">
<string>Close window</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
Expand Down Expand Up @@ -210,8 +210,11 @@ QTabWidget#info_tabs
<property name="value">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textVisible">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down
4 changes: 3 additions & 1 deletion ibridgesgui/ui_files/tabSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion ibridgesgui/ui_files/tabSync.ui
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,11 @@ QTabWidget#info_tabs
<property name="value">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textVisible">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down
7 changes: 4 additions & 3 deletions ibridgesgui/ui_files/uploadData.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,20 @@ 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")
self.gridLayout.addWidget(self.sources_list, 1, 2, 1, 1)
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)

Expand Down
19 changes: 11 additions & 8 deletions ibridgesgui/ui_files/uploadData.ui
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ QTabWidget#info_tabs
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hide_button">
<property name="text">
<string>Close Window</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
Expand All @@ -187,6 +180,13 @@ QTabWidget#info_tabs
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="hide_button">
<property name="text">
<string>Close Window</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
Expand All @@ -200,8 +200,11 @@ QTabWidget#info_tabs
<property name="value">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textVisible">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down

0 comments on commit 6682480

Please sign in to comment.