c3c9b0f059
is unavailable (for example running in a gamescope session) * Do not show the launch window while instantiating the application. This probably was causing numerous issues because it was running outside of the applications event loop. This also fixes the exit button on the login dialog requiring `sys.exit()` to quit Rare. Now it goes through the proper cleanup procedures. * Make slot and signal names more uniform * Fix a problem with RareCore connecting RareGames to the same signals multiple times when the library was refreshed.
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
import webbrowser
|
|
from enum import IntEnum
|
|
|
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QPushButton
|
|
|
|
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
|
|
from rare.utils.misc import icon
|
|
|
|
|
|
class AccountWidget(QWidget):
|
|
exit_app: pyqtSignal = pyqtSignal(int)
|
|
logout: pyqtSignal = pyqtSignal()
|
|
|
|
class ExitCodes(IntEnum):
|
|
EXIT = 0
|
|
LOGOUT = -133742
|
|
|
|
def __init__(self, parent):
|
|
super(AccountWidget, self).__init__(parent=parent)
|
|
self.core = LegendaryCoreSingleton()
|
|
self.signals = GlobalSignalsSingleton()
|
|
|
|
username = self.core.lgd.userdata.get("displayName")
|
|
if not username:
|
|
username = "Offline"
|
|
|
|
self.open_browser = QPushButton(icon("fa.external-link"), self.tr("Account settings"))
|
|
self.open_browser.clicked.connect(
|
|
lambda: webbrowser.open(
|
|
"https://www.epicgames.com/account/personal?productName=epicgames"
|
|
)
|
|
)
|
|
self.logout_button = QPushButton(self.tr("Logout"), parent=self)
|
|
self.logout_button.clicked.connect(self.__on_logout)
|
|
self.quit_button = QPushButton(self.tr("Quit"), parent=self)
|
|
self.quit_button.clicked.connect(self.__on_quit)
|
|
|
|
layout = QVBoxLayout(self)
|
|
layout.addWidget(QLabel(self.tr("Account")))
|
|
layout.addWidget(QLabel(self.tr("Logged in as <b>{}</b>").format(username)))
|
|
layout.addWidget(self.open_browser)
|
|
layout.addWidget(self.logout_button)
|
|
layout.addWidget(self.quit_button)
|
|
|
|
@pyqtSlot()
|
|
def __on_quit(self):
|
|
self.exit_app.emit(AccountWidget.ExitCodes.EXIT)
|
|
|
|
@pyqtSlot()
|
|
def __on_logout(self):
|
|
self.exit_app.emit(AccountWidget.ExitCodes.LOGOUT)
|