AccountWidget: Refuse to logout if there are active downloads
Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
This commit is contained in:
parent
28b2b7ea9b
commit
3c413c4e1f
2 changed files with 17 additions and 3 deletions
|
@ -54,7 +54,7 @@ class TabWidget(QTabWidget):
|
||||||
self.addTab(self.account, "")
|
self.addTab(self.account, "")
|
||||||
self.setTabEnabled(disabled_tab + 1, False)
|
self.setTabEnabled(disabled_tab + 1, False)
|
||||||
|
|
||||||
self.account_widget = AccountWidget()
|
self.account_widget = AccountWidget(self, self.downloads_tab)
|
||||||
account_action = QWidgetAction(self)
|
account_action = QWidgetAction(self)
|
||||||
account_action.setDefaultWidget(self.account_widget)
|
account_action.setDefaultWidget(self.account_widget)
|
||||||
account_button = TabButtonWidget("mdi.account-circle", "Account", fallback_icon="fa.user")
|
account_button = TabButtonWidget("mdi.account-circle", "Account", fallback_icon="fa.user")
|
||||||
|
|
|
@ -7,10 +7,13 @@ from rare.utils.misc import icon
|
||||||
|
|
||||||
|
|
||||||
class AccountWidget(QWidget):
|
class AccountWidget(QWidget):
|
||||||
def __init__(self):
|
def __init__(self, parent, downloads_tab):
|
||||||
super(AccountWidget, self).__init__()
|
super(AccountWidget, self).__init__(parent=parent)
|
||||||
self.core = LegendaryCoreSingleton()
|
self.core = LegendaryCoreSingleton()
|
||||||
self.signals = GlobalSignalsSingleton()
|
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")
|
username = self.core.lgd.userdata.get("display_name")
|
||||||
if not username:
|
if not username:
|
||||||
|
@ -32,6 +35,17 @@ class AccountWidget(QWidget):
|
||||||
layout.addWidget(self.logout_button)
|
layout.addWidget(self.logout_button)
|
||||||
|
|
||||||
def logout(self):
|
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(
|
reply = QMessageBox.question(
|
||||||
self,
|
self,
|
||||||
self.tr("Logout"),
|
self.tr("Logout"),
|
||||||
|
|
Loading…
Reference in a new issue