1
0
Fork 0
mirror of synced 2024-06-21 12:00:25 +12:00

AccountWidget: Remove dead signals after the offline mode fix

Signals, if they carry the same datatype, can be chained simply
with `signal.connect(othersignal)` without the need to use a `lambda`
expression and `emit()`

TabWidget: Fix error because the `exit_app` signal was called directly
This commit is contained in:
loathingKernel 2022-10-31 16:57:35 +02:00
parent 435d560b5c
commit 891804ae37
2 changed files with 6 additions and 12 deletions

View file

@ -1,4 +1,4 @@
from PyQt5.QtCore import QSize, pyqtSignal
from PyQt5.QtCore import QSize, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import QMenu, QTabWidget, QWidget, QWidgetAction, QShortcut, QMessageBox
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton, ArgumentsSingleton
@ -23,9 +23,7 @@ class TabWidget(QTabWidget):
self.args = ArgumentsSingleton()
disabled_tab = 3 if not self.args.offline else 1
self.setTabBar(MainTabBar(disabled_tab))
# lk: Figure out why this adds a white line at the top
# lk: despite setting qproperty-drawBase to 0 in the stylesheet
# self.setDocumentMode(True)
# Generate Tabs
self.games_tab = GamesTab()
self.addTab(self.games_tab, self.tr("Games"))
@ -58,7 +56,6 @@ class TabWidget(QTabWidget):
self.setTabEnabled(disabled_tab + 1, False)
self.account_widget = AccountWidget(self)
self.account_widget.exit_app.connect(self.exit_app)
self.account_widget.logout.connect(self.logout)
account_action = QWidgetAction(self)
account_action.setDefaultWidget(self.account_widget)
@ -115,6 +112,7 @@ class TabWidget(QTabWidget):
self.tabBar().setMinimumWidth(self.width())
super(TabWidget, self).resizeEvent(event)
@pyqtSlot()
def logout(self):
# FIXME: Don't allow logging out if there are active downloads
if self.downloads_tab.is_download_active:
@ -135,4 +133,4 @@ class TabWidget(QTabWidget):
if reply == QMessageBox.Yes:
self.core.lgd.invalidate_userdata()
self.exit_app(-133742) # restart exit code
self.exit_app.emit(-133742) # restart exit code

View file

@ -8,16 +8,12 @@ from rare.utils.misc import icon
class AccountWidget(QWidget):
# int: exit code
exit_app: pyqtSignal = pyqtSignal(int)
logout = pyqtSignal()
logout: pyqtSignal = pyqtSignal()
def __init__(self, parent):
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
username = self.core.lgd.userdata.get("display_name")
if not username:
@ -30,7 +26,7 @@ class AccountWidget(QWidget):
)
)
self.logout_button = QPushButton(self.tr("Logout"))
self.logout_button.clicked.connect(lambda: self.logout.emit())
self.logout_button.clicked.connect(self.logout)
layout = QVBoxLayout(self)
layout.addWidget(QLabel(self.tr("Account")))