refractoring, login bug
This commit is contained in:
parent
235eb19a14
commit
9b465861c1
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
import webbrowser
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
|
@ -7,20 +6,22 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLabel, QLineEdit
|
|||
from legendary.core import LegendaryCore
|
||||
|
||||
logger = getLogger("BrowserLogin")
|
||||
class BrowserLogin(QWidget):
|
||||
|
||||
|
||||
class BrowserLogin(QWidget):
|
||||
success = pyqtSignal()
|
||||
url: str = "https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect"
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(BrowserLogin, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
self.core = core
|
||||
|
||||
self.back = QPushButton("Back") # TODO Icon
|
||||
self.back.clicked.connect(lambda: self.success.emit("back"))
|
||||
self.back = QPushButton("Back") # TODO Icon
|
||||
self.layout.addWidget(self.back)
|
||||
|
||||
self.info_text = QLabel(f"Opens a browser. You login and copy the json code in the field below. Click <a href='{self.url}'>here</a> to open Browser")
|
||||
self.info_text = QLabel(
|
||||
f"Opens a browser. You login and copy the json code in the field below. Click <a href='{self.url}'>here</a> to open Browser")
|
||||
self.info_text.setWordWrap(True)
|
||||
self.info_text.setOpenExternalLinks(True)
|
||||
self.layout.addWidget(self.info_text)
|
||||
|
@ -37,7 +38,6 @@ class BrowserLogin(QWidget):
|
|||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
|
||||
def login(self):
|
||||
self.mini_info.setText("Loading...")
|
||||
sid = self.input_field.text()
|
||||
|
@ -49,4 +49,4 @@ class BrowserLogin(QWidget):
|
|||
logger.info(f"Successfully logged in as {self.core.lgd.userdata['displayName']}")
|
||||
self.success.emit()
|
||||
else:
|
||||
self.mini_info.setText("Login failed")
|
||||
self.mini_info.setText("Login failed")
|
15
Rare/Components/Dialogs/Login/ImportWidget.py
Normal file
15
Rare/Components/Dialogs/Login/ImportWidget.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
|
||||
class ImportWidget(QWidget):
|
||||
success = pyqtSignal(str)
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(ImportWidget, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
self.core = core
|
||||
|
||||
self.back = QPushButton("Back")
|
||||
self.layout.addWidget(self.back)
|
|
@ -1,10 +1,8 @@
|
|||
import time
|
||||
|
||||
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QStackedLayout, QWidget, QPushButton
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare.utils.Dialogs.Login.BrowserLogin import BrowserLogin
|
||||
from Rare.utils.Dialogs.Login.ImportWidget import ImportWidget
|
||||
from Rare.Components.Dialogs.Login import BrowserLogin
|
||||
from Rare.Components.Dialogs.Login import ImportWidget
|
||||
|
||||
|
||||
# Login Opportunities: Browser, Import
|
||||
|
@ -33,6 +31,7 @@ class LoginDialog(QDialog):
|
|||
self.landing_layout.addWidget(self.info_text)
|
||||
|
||||
self.browser_login = OptionWidget("Use Browser", "This opens your default webbrowser. Login and copy the text")
|
||||
|
||||
self.landing_layout.addWidget(self.browser_login)
|
||||
self.browser_login.button.clicked.connect(lambda: self.layout.setCurrentIndex(1))
|
||||
|
||||
|
@ -49,11 +48,11 @@ class LoginDialog(QDialog):
|
|||
self.layout.addWidget(self.landing_widget)
|
||||
|
||||
self.browser_widget = BrowserLogin(self.core)
|
||||
self.browser_widget.success.connect(lambda: self.layout.setCurrentIndex(0))
|
||||
self.browser_widget.success.connect(self.success)
|
||||
self.browser_widget.back.clicked.connect(lambda: self.layout.setCurrentIndex(0))
|
||||
self.layout.addWidget(self.browser_widget)
|
||||
|
||||
self.import_widget = ImportWidget()
|
||||
self.import_widget = ImportWidget(self.core)
|
||||
self.layout.addWidget(self.import_widget)
|
||||
|
||||
self.layout.addWidget(LoginSuccessfulWidget())
|
||||
|
@ -68,7 +67,7 @@ class LoginDialog(QDialog):
|
|||
if self.core.login():
|
||||
self.logged_in = True
|
||||
self.layout.setCurrentIndex(3)
|
||||
time.sleep(1)
|
||||
# time.sleep(1)
|
||||
self.close()
|
||||
|
||||
|
0
Rare/Components/Dialogs/__init__.py
Normal file
0
Rare/Components/Dialogs/__init__.py
Normal file
|
@ -4,7 +4,7 @@ from PyQt5.QtCore import QThread, pyqtSignal
|
|||
from PyQt5.QtWidgets import QDialog, QLabel, QProgressBar, QVBoxLayout
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare.utils.Dialogs.Login.LoginDialog import LoginDialog
|
||||
from Rare.Components.Dialogs.Login import LoginDialog
|
||||
from Rare.utils.utils import download_images
|
||||
logger = getLogger("Login")
|
||||
|
||||
|
@ -62,7 +62,7 @@ class LaunchDialog(QDialog):
|
|||
|
||||
def login(self):
|
||||
if not LoginDialog(core=self.core).login():
|
||||
self.close()
|
||||
exit(0)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from PyQt5.QtCore import QThread, pyqtSignal
|
|||
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare.utils.Dialogs.InstallDialog import InstallInfoDialog
|
||||
from Rare.Components.Dialogs.InstallDialog import InstallInfoDialog
|
||||
|
||||
logger = getLogger("Download")
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import os
|
||||
from logging import getLogger
|
||||
from multiprocessing import Queue as MPQueue
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtGui import QPixmap
|
||||
|
@ -8,7 +7,7 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
|
|||
from legendary.core import LegendaryCore
|
||||
from legendary.models.game import Game
|
||||
|
||||
from Rare.utils.Dialogs.InstallDialog import InstallDialog
|
||||
from Rare.Components.Dialogs.InstallDialog import InstallDialog
|
||||
from Rare.utils.QtExtensions import ClickableLabel
|
||||
from Rare.utils.RareConfig import IMAGE_DIR
|
||||
from Rare.utils.utils import download_image
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
from PyQt5.QtWidgets import QWidget
|
||||
|
||||
|
||||
class ImportWidget(QWidget):
|
||||
def __init__(self):
|
||||
super(ImportWidget, self).__init__()
|
Loading…
Reference in a new issue