LoginDialog: Update to legendary 0.20.28
This commit is contained in:
parent
2c36ffcd51
commit
fb708ce5fd
|
@ -113,7 +113,7 @@ class App(RareApp):
|
|||
)
|
||||
|
||||
# launch app
|
||||
self.launch_dialog = LaunchDialog()
|
||||
self.launch_dialog = LaunchDialog(parent=None)
|
||||
self.launch_dialog.quit_app.connect(self.launch_dialog.close)
|
||||
self.launch_dialog.quit_app.connect(lambda ec: exit(ec))
|
||||
self.launch_dialog.start_app.connect(self.start_app)
|
||||
|
|
|
@ -82,14 +82,13 @@ class ApiRequestWorker(LaunchWorker):
|
|||
self.signals.result.emit(result, "32bit")
|
||||
|
||||
|
||||
class LaunchDialog(QDialog, Ui_LaunchDialog):
|
||||
class LaunchDialog(QDialog):
|
||||
quit_app = pyqtSignal(int)
|
||||
start_app = pyqtSignal()
|
||||
completed = 0
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(LaunchDialog, self).__init__(parent=parent)
|
||||
self.setupUi(self)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose, True)
|
||||
self.setWindowFlags(
|
||||
Qt.Window
|
||||
|
@ -101,6 +100,8 @@ class LaunchDialog(QDialog, Ui_LaunchDialog):
|
|||
| Qt.MSWindowsFixedSizeDialogHint
|
||||
)
|
||||
self.setWindowModality(Qt.WindowModal)
|
||||
self.ui = Ui_LaunchDialog()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.core = LegendaryCoreSingleton()
|
||||
self.args = ArgumentsSingleton()
|
||||
|
@ -143,7 +144,7 @@ class LaunchDialog(QDialog, Ui_LaunchDialog):
|
|||
def launch(self):
|
||||
|
||||
if not self.args.offline:
|
||||
self.image_info.setText(self.tr("Downloading Images"))
|
||||
self.ui.image_info.setText(self.tr("Downloading Images"))
|
||||
image_worker = ImageWorker()
|
||||
image_worker.signals.result.connect(self.handle_api_worker_result)
|
||||
image_worker.signals.progress.connect(self.update_image_progbar)
|
||||
|
@ -202,13 +203,13 @@ class LaunchDialog(QDialog, Ui_LaunchDialog):
|
|||
self.finish()
|
||||
|
||||
def update_image_progbar(self, i: int):
|
||||
self.image_prog_bar.setValue(i)
|
||||
self.ui.image_prog_bar.setValue(i)
|
||||
|
||||
def finish(self):
|
||||
self.completed += 1
|
||||
if self.completed == 2:
|
||||
logger.info("App starting")
|
||||
self.image_info.setText(self.tr("Starting..."))
|
||||
self.ui.image_info.setText(self.tr("Starting..."))
|
||||
ApiResultsSingleton(self.api_results)
|
||||
self.completed += 1
|
||||
self.start_app.emit()
|
||||
|
|
|
@ -36,8 +36,6 @@ class LoginDialog(QDialog):
|
|||
|
||||
def __init__(self, core: LegendaryCore, parent=None):
|
||||
super(LoginDialog, self).__init__(parent=parent)
|
||||
self.ui = Ui_LoginDialog()
|
||||
self.ui.setupUi(self)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose, True)
|
||||
self.setWindowFlags(
|
||||
Qt.Window
|
||||
|
@ -50,6 +48,8 @@ class LoginDialog(QDialog):
|
|||
| Qt.MSWindowsFixedSizeDialogHint
|
||||
)
|
||||
self.setWindowModality(Qt.WindowModal)
|
||||
self.ui = Ui_LoginDialog()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.core = core
|
||||
self.args = ArgumentsSingleton()
|
||||
|
@ -76,7 +76,10 @@ class LoginDialog(QDialog):
|
|||
self.ui.back_button.setEnabled(False)
|
||||
|
||||
self.landing_page.ui.login_browser_radio.clicked.connect(lambda: self.ui.next_button.setEnabled(True))
|
||||
self.landing_page.ui.login_browser_radio.clicked.connect(self.browser_radio_clicked)
|
||||
self.landing_page.ui.login_import_radio.clicked.connect(lambda: self.ui.next_button.setEnabled(True))
|
||||
self.landing_page.ui.login_import_radio.clicked.connect(self.import_radio_clicked)
|
||||
|
||||
self.ui.exit_button.clicked.connect(self.close)
|
||||
self.ui.back_button.clicked.connect(self.back_clicked)
|
||||
self.ui.next_button.clicked.connect(self.next_clicked)
|
||||
|
@ -90,15 +93,22 @@ class LoginDialog(QDialog):
|
|||
self.ui.next_button.setEnabled(True)
|
||||
self.login_stack.slideInIndex(self.pages.landing)
|
||||
|
||||
def browser_radio_clicked(self):
|
||||
self.login_stack.slideInIndex(self.pages.browser)
|
||||
self.ui.back_button.setEnabled(True)
|
||||
self.ui.next_button.setEnabled(False)
|
||||
|
||||
def import_radio_clicked(self):
|
||||
self.login_stack.slideInIndex(self.pages.import_egl)
|
||||
self.ui.back_button.setEnabled(True)
|
||||
self.ui.next_button.setEnabled(self.import_page.is_valid())
|
||||
|
||||
def next_clicked(self):
|
||||
if self.login_stack.currentIndex() == self.pages.landing:
|
||||
if self.landing_page.ui.login_browser_radio.isChecked():
|
||||
self.login_stack.slideInIndex(self.pages.browser)
|
||||
self.ui.next_button.setEnabled(False)
|
||||
self.browser_radio_clicked()
|
||||
if self.landing_page.ui.login_import_radio.isChecked():
|
||||
self.login_stack.slideInIndex(self.pages.import_egl)
|
||||
self.ui.next_button.setEnabled(self.import_page.is_valid())
|
||||
self.ui.back_button.setEnabled(True)
|
||||
self.import_radio_clicked()
|
||||
elif self.login_stack.currentIndex() == self.pages.browser:
|
||||
self.browser_page.do_login()
|
||||
elif self.login_stack.currentIndex() == self.pages.import_egl:
|
||||
|
|
|
@ -18,9 +18,6 @@ logger = getLogger("BrowserLogin")
|
|||
class BrowserLogin(QFrame):
|
||||
success = pyqtSignal()
|
||||
changed = pyqtSignal()
|
||||
login_url = (
|
||||
"https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect"
|
||||
)
|
||||
|
||||
def __init__(self, core: LegendaryCore, parent=None):
|
||||
super(BrowserLogin, self).__init__(parent=parent)
|
||||
|
@ -29,9 +26,10 @@ class BrowserLogin(QFrame):
|
|||
self.ui.setupUi(self)
|
||||
|
||||
self.core = core
|
||||
self.login_url = self.core.egs.get_auth_url()
|
||||
|
||||
self.sid_edit = IndicatorLineEdit(
|
||||
placeholder=self.tr("Insert SID here"), edit_func=self.text_changed, parent=self
|
||||
placeholder=self.tr("Insert authorizationCode here"), edit_func=self.text_changed, parent=self
|
||||
)
|
||||
self.ui.link_text.setText(self.login_url)
|
||||
self.ui.copy_button.setIcon(icon("mdi.content-copy", "fa.copy"))
|
||||
|
@ -56,7 +54,7 @@ class BrowserLogin(QFrame):
|
|||
text = text.strip()
|
||||
if text.startswith("{") and text.endswith("}"):
|
||||
try:
|
||||
text = json.loads(text).get("sid")
|
||||
text = json.loads(text).get("authorizationCode")
|
||||
except json.JSONDecodeError:
|
||||
return False, text, IndicatorLineEdit.reasons.wrong_format
|
||||
elif '"' in text:
|
||||
|
@ -67,10 +65,9 @@ class BrowserLogin(QFrame):
|
|||
|
||||
def do_login(self):
|
||||
self.ui.status_label.setText(self.tr("Logging in..."))
|
||||
sid = self.sid_edit.text()
|
||||
auth_code = self.sid_edit.text()
|
||||
try:
|
||||
token = self.core.auth_sid(sid)
|
||||
if self.core.auth_code(token):
|
||||
if self.core.auth_code(auth_code):
|
||||
logger.info(f"Successfully logged in as {self.core.lgd.userdata['displayName']}")
|
||||
self.success.emit()
|
||||
else:
|
||||
|
@ -80,13 +77,11 @@ class BrowserLogin(QFrame):
|
|||
logger.warning(e)
|
||||
|
||||
def open_browser(self):
|
||||
if webview_login.webview_available is False:
|
||||
logger.warning("You don't have webengine installed, " "you will need to manually copy the SID.")
|
||||
if not webview_login.webview_available:
|
||||
logger.warning("You don't have webengine installed, you will need to manually copy the authorizationCode.")
|
||||
QDesktopServices.openUrl(QUrl(self.login_url))
|
||||
else:
|
||||
if webview_login.do_webview_login(
|
||||
callback_sid=self.core.auth_sid, callback_code=self.core.auth_code
|
||||
):
|
||||
if webview_login.do_webview_login(callback_code=self.core.auth_ex_token):
|
||||
logger.info("Successfully logged in as " f"{self.core.lgd.userdata['displayName']}")
|
||||
self.success.emit()
|
||||
else:
|
||||
|
|
|
@ -14,12 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||
class Ui_BrowserLogin(object):
|
||||
def setupUi(self, BrowserLogin):
|
||||
BrowserLogin.setObjectName("BrowserLogin")
|
||||
BrowserLogin.resize(400, 200)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(BrowserLogin.sizePolicy().hasHeightForWidth())
|
||||
BrowserLogin.setSizePolicy(sizePolicy)
|
||||
BrowserLogin.resize(182, 210)
|
||||
BrowserLogin.setWindowTitle("BrowserLogin")
|
||||
self.browser_layout = QtWidgets.QGridLayout(BrowserLogin)
|
||||
self.browser_layout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
|
||||
|
@ -78,7 +73,7 @@ class Ui_BrowserLogin(object):
|
|||
_translate = QtCore.QCoreApplication.translate
|
||||
self.open_button.setText(_translate("BrowserLogin", "Open Browser"))
|
||||
self.title_label.setText(_translate("BrowserLogin", "Login through browser"))
|
||||
self.info_label.setText(_translate("BrowserLogin", "Click the button to open the login page in a browser or copy the link and paste it in a browser. After logging in, copy the SID code in the input above."))
|
||||
self.info_label.setText(_translate("BrowserLogin", "Click the button to open the login page in a browser or copy the link and paste it in a browser. After logging in, copy the <b><code>authorizationCode</code></b> in the input above."))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>246</width>
|
||||
<height>184</height>
|
||||
<width>182</width>
|
||||
<height>210</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -94,7 +94,7 @@
|
|||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Click the button to open the login page in a browser or copy the link and paste it in a browser. After logging in, copy the SID code in the input above.</string>
|
||||
<string>Click the button to open the login page in a browser or copy the link and paste it in a browser. After logging in, copy the <b><code>authorizationCode</code></b> in the input above.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
|
|
@ -20,7 +20,6 @@ class RareApp(QApplication):
|
|||
def __init__(self):
|
||||
super(RareApp, self).__init__(sys.argv)
|
||||
self.setQuitOnLastWindowClosed(False)
|
||||
self.core = LegendaryCore()
|
||||
if hasattr(Qt, "AA_UseHighDpiPixmaps"):
|
||||
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
||||
|
||||
|
@ -36,7 +35,6 @@ class RareApp(QApplication):
|
|||
# lk: this is a bit silly but serves well until we have a class
|
||||
# lk: store the default qt style name from the system on startup as a property for later reference
|
||||
self.setProperty("rareDefaultQtStyle", self.style().objectName())
|
||||
|
||||
if (
|
||||
self.settings.value("color_scheme", None) is None
|
||||
and self.settings.value("style_sheet", None) is None
|
||||
|
|
Loading…
Reference in a new issue