1
0
Fork 0
mirror of synced 2024-06-17 10:04:43 +12:00
Rare/rare/components/tabs/account/__init__.py
Stelios Tsampas dc2a99c2ee Terminate threads and handle cleanup.
* Set the `WA_DeleteOnClose` attribute for the MainWindow.
* Handle the case where `programdata_path` exists but is empty.
* Emit a signal from `LaunchDialog` instead of using `exit()`.
* Remove `LoginThread` as it was never deleted and caused a `SIGSEGV` on exit.
* Handle termination and deletion of `SteamThread` and `ImageThread`.
* Rename `finished` to `completed`, to not override the inherited `finished` signal.
* Emit a signal from Account widget to do cleanup instead of immediately quitting.
2021-06-24 20:08:22 +03:00

45 lines
1.6 KiB
Python

import webbrowser
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QMessageBox, QLabel, QPushButton
from custom_legendary.core import LegendaryCore
class MiniWidget(QWidget):
quit_app = pyqtSignal(int)
def __init__(self, core: LegendaryCore):
super(MiniWidget, self).__init__()
self.layout = QVBoxLayout()
self.core = core
self.layout.addWidget(QLabel("Account"))
username = self.core.lgd.userdata.get("display_name")
if not username:
try:
self.core.login()
username = self.core.lgd.userdata.get("display_name")
except Exception:
username = "Offline"
self.layout.addWidget(QLabel(self.tr("Logged in as ") + str(username)))
self.open_browser = QPushButton(self.tr("Account settings"))
self.open_browser.clicked.connect(
lambda: webbrowser.open("https://www.epicgames.com/account/personal?productName=epicgames"))
self.layout.addWidget(self.open_browser)
self.logout_button = QPushButton(self.tr("Logout"))
self.logout_button.clicked.connect(self.logout)
self.layout.addWidget(self.logout_button)
self.setLayout(self.layout)
def logout(self):
reply = QMessageBox.question(self.parent().parent(), 'Message',
self.tr("Do you really want to logout"), QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
self.core.lgd.invalidate_userdata()
self.quit_app.emit(-133742) # restart exit code