1
0
Fork 0
mirror of synced 2024-05-26 07:20:13 +12:00
Rare/rare/components/tabs/account/__init__.py

46 lines
1.6 KiB
Python
Raw Normal View History

2021-02-10 23:48:25 +13:00
import webbrowser
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QMessageBox, QLabel, QPushButton
2021-03-19 00:45:59 +13:00
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
from rare.utils.misc import icon
2021-02-10 23:48:25 +13:00
2022-08-14 03:53:00 +12:00
class AccountWidget(QWidget):
2021-10-08 07:19:24 +13:00
def __init__(self):
2022-08-14 03:53:00 +12:00
super(AccountWidget, self).__init__()
self.core = LegendaryCoreSingleton()
self.signals = GlobalSignalsSingleton()
2022-08-14 03:53:00 +12:00
2021-04-08 00:53:55 +12:00
username = self.core.lgd.userdata.get("display_name")
2021-03-12 00:56:38 +13:00
if not username:
2021-10-08 07:19:24 +13:00
username = "Offline"
2021-03-12 00:56:38 +13:00
2022-03-16 09:25:54 +13:00
self.open_browser = QPushButton(icon("fa.external-link"), self.tr("Account settings"))
self.open_browser.clicked.connect(
2021-12-24 22:09:50 +13:00
lambda: webbrowser.open(
"https://www.epicgames.com/account/personal?productName=epicgames"
)
)
2021-03-01 08:01:15 +13:00
self.logout_button = QPushButton(self.tr("Logout"))
2021-02-10 23:48:25 +13:00
self.logout_button.clicked.connect(self.logout)
2022-08-14 03:53:00 +12:00
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)
2021-02-10 23:48:25 +13:00
def logout(self):
2021-12-24 22:09:50 +13:00
reply = QMessageBox.question(
self.parent().parent(),
"Message",
self.tr("Do you really want to logout"),
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No,
)
2021-02-10 23:48:25 +13:00
if reply == QMessageBox.Yes:
self.core.lgd.invalidate_userdata()
2021-10-15 10:05:00 +13:00
self.signals.exit_app.emit(-133742) # restart exit code