1
0
Fork 0
mirror of synced 2024-06-22 04:20:25 +12:00

AccountWidget: Refuse to logout if there are active downloads

Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
This commit is contained in:
loathingKernel 2022-10-23 00:54:11 +03:00
parent 28b2b7ea9b
commit 3c413c4e1f
2 changed files with 17 additions and 3 deletions

View file

@ -54,7 +54,7 @@ class TabWidget(QTabWidget):
self.addTab(self.account, "")
self.setTabEnabled(disabled_tab + 1, False)
self.account_widget = AccountWidget()
self.account_widget = AccountWidget(self, self.downloads_tab)
account_action = QWidgetAction(self)
account_action.setDefaultWidget(self.account_widget)
account_button = TabButtonWidget("mdi.account-circle", "Account", fallback_icon="fa.user")

View file

@ -7,10 +7,13 @@ from rare.utils.misc import icon
class AccountWidget(QWidget):
def __init__(self):
super(AccountWidget, self).__init__()
def __init__(self, parent, downloads_tab):
super(AccountWidget, self).__init__(parent=parent)
self.core = LegendaryCoreSingleton()
self.signals = GlobalSignalsSingleton()
# FIXME: This is why widgets should be decoupled from procedures.
# FIXME: pass downloads tab as argument to check if there are active downloads
self.downloads_tab = downloads_tab
username = self.core.lgd.userdata.get("display_name")
if not username:
@ -32,6 +35,17 @@ class AccountWidget(QWidget):
layout.addWidget(self.logout_button)
def logout(self):
# FIXME: Don't allow logging out if there are active downloads
if self.downloads_tab.is_download_active:
warning = QMessageBox.warning(
self,
self.tr("Logout"),
self.tr("There are active downloads. Stop them before logging out."),
buttons=(QMessageBox.Ok),
defaultButton=QMessageBox.Ok
)
return
# FIXME: End of FIXME
reply = QMessageBox.question(
self,
self.tr("Logout"),