ImportLogin: Fix failure to login using EGL data
This commit is contained in:
parent
fb708ce5fd
commit
0388d4bf9d
|
@ -2,7 +2,7 @@ import platform
|
|||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSignal, QRunnable, QObject, QThreadPool, QSettings
|
||||
from PyQt5.QtWidgets import QDialog, qApp
|
||||
from PyQt5.QtWidgets import QDialog, QApplication
|
||||
from requests.exceptions import ConnectionError, HTTPError
|
||||
|
||||
from rare.components.dialogs.login import LoginDialog
|
||||
|
@ -108,23 +108,29 @@ class LaunchDialog(QDialog):
|
|||
self.thread_pool = QThreadPool().globalInstance()
|
||||
self.api_results = ApiResults()
|
||||
|
||||
self.login_dialog = LoginDialog(core=self.core, parent=self)
|
||||
|
||||
def login(self):
|
||||
do_launch = True
|
||||
try:
|
||||
if self.args.offline:
|
||||
pass
|
||||
else:
|
||||
qApp.processEvents()
|
||||
QApplication.instance().processEvents()
|
||||
if self.core.login():
|
||||
logger.info("You are logged in")
|
||||
else:
|
||||
raise ValueError("You are not logged in. Open Login Window")
|
||||
except ValueError as e:
|
||||
logger.info(str(e))
|
||||
# Force an update check and notice in case there are API changes
|
||||
self.core.check_for_updates(force=True)
|
||||
self.core.force_show_update = True
|
||||
# Do not set parent, because it won't show a task bar icon
|
||||
# Update: Inherit the same parent as LaunchDialog
|
||||
do_launch = LoginDialog(core=self.core, parent=self.parent()).login()
|
||||
except ConnectionError as e:
|
||||
do_launch = self.login_dialog.login()
|
||||
self.login_dialog.deleteLater()
|
||||
except (HTTPError, ConnectionError) as e:
|
||||
logger.warning(e)
|
||||
self.args.offline = True
|
||||
finally:
|
||||
|
|
|
@ -5,6 +5,7 @@ from logging import getLogger
|
|||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QFrame, QFileDialog
|
||||
from legendary.core import LegendaryCore
|
||||
from legendary.utils.wine_helpers import read_registry, get_shell_folders
|
||||
|
||||
from rare.ui.components.dialogs.login.import_login import Ui_ImportLogin
|
||||
|
||||
|
@ -18,7 +19,7 @@ class ImportLogin(QFrame):
|
|||
localappdata = os.path.expandvars("%LOCALAPPDATA%")
|
||||
else:
|
||||
localappdata = os.path.join("drive_c/users", getuser(), "Local Settings/Application Data")
|
||||
appdata_path = os.path.join(localappdata, "EpicGamesLauncher/Saved/Config/Windows")
|
||||
egl_appdata = os.path.join(localappdata, "EpicGamesLauncher", "Saved", "Config", "Windows")
|
||||
found = False
|
||||
|
||||
def __init__(self, core: LegendaryCore, parent=None):
|
||||
|
@ -33,16 +34,18 @@ class ImportLogin(QFrame):
|
|||
self.text_egl_notfound = self.tr("Could not find EGL Program Data. ")
|
||||
|
||||
if os.name == "nt":
|
||||
if not self.core.egl.appdata_path and os.path.exists(self.appdata_path):
|
||||
self.core.egl.appdata_path = self.appdata_path
|
||||
if not self.core.egl.appdata_path and os.path.exists(self.egl_appdata):
|
||||
self.core.egl.appdata_path = self.egl_appdata
|
||||
if not self.core.egl.appdata_path:
|
||||
self.ui.status_label.setText(self.text_egl_notfound)
|
||||
else:
|
||||
self.ui.status_label.setText(self.text_egl_found)
|
||||
self.found = True
|
||||
else:
|
||||
if wine_pfx := self.core.egl.programdata_path.split("drive_c"):
|
||||
self.ui.prefix_combo.addItems(wine_pfx)
|
||||
self.ui.info_label.setText(
|
||||
self.tr("Please select the Wine prefix" " where Epic Games Launcher is installed. ")
|
||||
self.tr("Please select the Wine prefix where Epic Games Launcher is installed. ")
|
||||
+ self.ui.info_label.text()
|
||||
)
|
||||
prefixes = self.get_wine_prefixes()
|
||||
|
@ -62,7 +65,7 @@ class ImportLogin(QFrame):
|
|||
]
|
||||
prefixes = []
|
||||
for prefix in possible_prefixes:
|
||||
if os.path.exists(os.path.join(prefix, self.appdata_path)):
|
||||
if os.path.exists(os.path.join(prefix, self.egl_appdata)):
|
||||
prefixes.append(prefix)
|
||||
return prefixes
|
||||
|
||||
|
@ -73,18 +76,28 @@ class ImportLogin(QFrame):
|
|||
names = prefix_dialog.selectedFiles()
|
||||
self.ui.prefix_combo.setCurrentText(names[0])
|
||||
|
||||
def is_valid(self):
|
||||
def is_valid(self) -> bool:
|
||||
if os.name == "nt":
|
||||
return self.found
|
||||
else:
|
||||
return os.path.exists(os.path.join(self.ui.prefix_combo.currentText(), self.appdata_path))
|
||||
egl_wine_pfx = self.ui.prefix_combo.currentText()
|
||||
try:
|
||||
wine_folders = get_shell_folders(read_registry(egl_wine_pfx), egl_wine_pfx)
|
||||
self.egl_appdata = os.path.realpath(
|
||||
os.path.join(wine_folders['Local AppData'], 'EpicGamesLauncher', 'Saved', 'Config', 'Windows'))
|
||||
if path_exists := os.path.exists(self.egl_appdata):
|
||||
self.ui.status_label.setText(self.text_egl_found)
|
||||
return path_exists
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
def do_login(self):
|
||||
self.ui.status_label.setText(self.tr("Loading..."))
|
||||
if os.name == "nt":
|
||||
pass
|
||||
else:
|
||||
self.core.egl.appdata_path = os.path.join(self.ui.prefix_combo.currentText(), self.appdata_path)
|
||||
logger.info(f'Using EGL appdata path at "{self.egl_appdata}"')
|
||||
self.core.egl.appdata_path = self.egl_appdata
|
||||
try:
|
||||
if self.core.auth_import():
|
||||
logger.info(f"Logged in as {self.core.lgd.userdata['displayName']}")
|
||||
|
|
|
@ -14,12 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||
class Ui_ImportLogin(object):
|
||||
def setupUi(self, ImportLogin):
|
||||
ImportLogin.setObjectName("ImportLogin")
|
||||
ImportLogin.resize(400, 200)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(ImportLogin.sizePolicy().hasHeightForWidth())
|
||||
ImportLogin.setSizePolicy(sizePolicy)
|
||||
ImportLogin.resize(242, 120)
|
||||
ImportLogin.setWindowTitle("ImportLogin")
|
||||
self.import_layout = QtWidgets.QGridLayout(ImportLogin)
|
||||
self.import_layout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
|
||||
|
@ -51,6 +46,7 @@ class Ui_ImportLogin(object):
|
|||
font.setItalic(True)
|
||||
self.status_label.setFont(font)
|
||||
self.status_label.setText("")
|
||||
self.status_label.setWordWrap(True)
|
||||
self.status_label.setObjectName("status_label")
|
||||
self.import_layout.addWidget(self.status_label, 2, 1, 1, 2)
|
||||
self.info_label = QtWidgets.QLabel(ImportLogin)
|
||||
|
@ -68,7 +64,7 @@ class Ui_ImportLogin(object):
|
|||
|
||||
def retranslateUi(self, ImportLogin):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
self.prefix_label.setText(_translate("ImportLogin", "Select path"))
|
||||
self.prefix_label.setText(_translate("ImportLogin", "Select prefix"))
|
||||
self.title_label.setText(_translate("ImportLogin", "Import existing session from EGL"))
|
||||
self.prefix_tool.setText(_translate("ImportLogin", "Browse"))
|
||||
self.info_label.setText(_translate("ImportLogin", "You will get logged out from EGL in the process."))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>235</width>
|
||||
<width>242</width>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="prefix_label">
|
||||
<property name="text">
|
||||
<string>Select path</string>
|
||||
<string>Select prefix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue