Import Login
This commit is contained in:
parent
24459280ce
commit
9e3505969a
8
.idea/.gitignore
vendored
8
.idea/.gitignore
vendored
|
@ -1,8 +0,0 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
|
@ -4,12 +4,42 @@
|
|||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="2">
|
||||
<item index="0" class="java.lang.String" itemvalue="requests" />
|
||||
<item index="1" class="java.lang.String" itemvalue="Pillow" />
|
||||
<list size="6">
|
||||
<item index="0" class="java.lang.String" itemvalue="certifi" />
|
||||
<item index="1" class="java.lang.String" itemvalue="requests" />
|
||||
<item index="2" class="java.lang.String" itemvalue="urllib3" />
|
||||
<item index="3" class="java.lang.String" itemvalue="Pillow" />
|
||||
<item index="4" class="java.lang.String" itemvalue="PyQt5" />
|
||||
<item index="5" class="java.lang.String" itemvalue="legendary_gl" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N802" />
|
||||
<option value="N806" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyStubPackagesAdvertiser" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<list>
|
||||
<option value="PyQt5-stubs==5.15.2.0" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredIdentifiers">
|
||||
<list>
|
||||
<option value="bool.sum" />
|
||||
<option value="PyQt5.QtWidgets.clicked.connect" />
|
||||
<option value="PyQt5.QtWidgets.textChanged.connect" />
|
||||
<option value="PyQt5.QtWidgets.tabBarClicked.connect" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -1,11 +1,12 @@
|
|||
import os
|
||||
from getpass import getuser
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLabel, QButtonGroup, QRadioButton
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
|
||||
logger = getLogger("Import")
|
||||
class ImportWidget(QWidget):
|
||||
success = pyqtSignal(str)
|
||||
|
||||
|
@ -19,54 +20,72 @@ class ImportWidget(QWidget):
|
|||
self.title = QLabel("<h3>Import existing Login session</h3>")
|
||||
self.title.setWordWrap(True)
|
||||
self.layout.addWidget(self.title)
|
||||
appdata_paths = self.get_appdata_paths()
|
||||
|
||||
if len(appdata_paths) == 0:
|
||||
self.infoText = QLabel("Found Installations here. \n<b>Note:</b> You will get logged out there")
|
||||
self.infoText.setWordWrap(True)
|
||||
self.layout.addWidget(self.infoText)
|
||||
|
||||
self.infoText = QLabel(
|
||||
"Found Installations here. \nPlease select prefix, where Epic Games Launcher is installed\nNote: You will get logged out there")
|
||||
self.infoText.setWordWrap(True)
|
||||
self.layout.addWidget(self.infoText)
|
||||
self.import_button = QPushButton(self.tr("Import"))
|
||||
self.data_path = ""
|
||||
if os.name == "nt" and not self.core.egl.appdata_path:
|
||||
if os.path.exists(os.path.expanduser("~/Local Settings/Application "
|
||||
"Data/EpicGamesLauncher/Saved/Config/Windows")):
|
||||
self.prefixes = QLabel(self.tr("Found Data. Do you want to import them?"))
|
||||
self.data_path = os.path.expanduser("~/Local Settings/Application "
|
||||
"Data/EpicGamesLauncher/Saved/Config/Windows")
|
||||
else:
|
||||
self.infoText.setText(self.tr("Could not find any Epic Games login data"))
|
||||
self.import_button.setDisabled(True)
|
||||
else:
|
||||
self.btn_group = QButtonGroup()
|
||||
for i, p in enumerate(appdata_paths):
|
||||
radio_button = QRadioButton(p)
|
||||
if i == 0:
|
||||
radio_button.setChecked(True)
|
||||
self.btn_group.addButton(radio_button)
|
||||
self.layout.addWidget(radio_button)
|
||||
self.radio_buttons = []
|
||||
prefixes = self.get_wine_prefixes()
|
||||
if len(prefixes) == 0:
|
||||
self.infoText.setText(self.tr("Could not find any Epic Games login data"))
|
||||
self.import_button.setDisabled(True)
|
||||
else:
|
||||
self.btn_group = QButtonGroup()
|
||||
for i in prefixes:
|
||||
radio_button = QRadioButton(i)
|
||||
self.radio_buttons.append(radio_button)
|
||||
self.btn_group.addButton(radio_button)
|
||||
self.layout.addWidget(radio_button)
|
||||
radio_button.toggled.connect(self.toggle_radiobutton)
|
||||
|
||||
self.appdata_path_text = QLabel(self.tr("Appdata path: ") + str(self.core.egl.appdata_path))
|
||||
self.appdata_path_text.setWordWrap(True)
|
||||
self.login_text = QLabel("")
|
||||
# self.layout.addWidget(self.btn_group)
|
||||
self.layout.addWidget(self.login_text)
|
||||
self.layout.addStretch(1)
|
||||
self.import_btn = QPushButton("Import")
|
||||
self.layout.addWidget(self.import_btn)
|
||||
self.login_text = QLabel("")
|
||||
self.layout.addWidget(self.login_text)
|
||||
self.layout.addWidget(self.import_button)
|
||||
self.import_button.clicked.connect(self.import_login_data)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def get_appdata_paths(self) -> list:
|
||||
if self.core.egl.appdata_path:
|
||||
return [self.core.egl.appdata_path]
|
||||
def toggle_radiobutton(self):
|
||||
if self.sender().isChecked():
|
||||
self.data_path = self.sender().text()
|
||||
|
||||
else: # Linux
|
||||
wine_paths = []
|
||||
possible_wine_paths = [os.path.expanduser('~/Games/epic-games-store/'),
|
||||
os.path.expanduser('~/.wine/')]
|
||||
if os.environ.get("WINEPREFIX"):
|
||||
possible_wine_paths.append(os.environ.get("WINEPREFIX"))
|
||||
def get_wine_prefixes(self):
|
||||
possible_prefixes = [
|
||||
os.path.expanduser("~/.wine"),
|
||||
os.path.expanduser("~/Games/epic-games-store")
|
||||
]
|
||||
prefixes = []
|
||||
for i in possible_prefixes:
|
||||
if os.path.exists(os.path.join(i, "drive_c/users", getuser(),
|
||||
"Local Settings/Application Data/EpicGamesLauncher/Saved/Config/Windows")):
|
||||
prefixes.append(i)
|
||||
return prefixes
|
||||
|
||||
for i in possible_wine_paths:
|
||||
if os.path.exists(i):
|
||||
if os.path.exists(os.path.join(i, "drive_c/users", getuser(),
|
||||
'Local Settings/Application Data/EpicGamesLauncher',
|
||||
'Saved/Config/Windows')):
|
||||
wine_paths.append(i)
|
||||
|
||||
if len(wine_paths) > 0:
|
||||
appdata_dirs = [
|
||||
os.path.join(i, "drive_c/users", getuser(), 'Local Settings/Application Data/EpicGamesLauncher',
|
||||
'Saved/Config/Windows') for i in wine_paths]
|
||||
return appdata_dirs
|
||||
return []
|
||||
def import_login_data(self):
|
||||
self.import_button.setText(self.tr("Loading..."))
|
||||
self.import_button.setDisabled(True)
|
||||
if os.name != "nt":
|
||||
self.core.egl.appdata_path = os.path.join(self.data_path, f"drive_c/users/{getuser()}/Local Settings/Application Data/EpicGamesLauncher/Saved/Config/Windows")
|
||||
print(self.core.egl.appdata_path)
|
||||
print(os.path.exists(self.core.egl.appdata_path))
|
||||
if self.core.auth_import():
|
||||
logger.info(f"Logged in as {self.core.lgd.userdata['displayName']}")
|
||||
self.success.emit()
|
||||
else:
|
||||
print("Lol")
|
||||
logger.warning("Error: No valid session found")
|
||||
self.login_text.setText(self.tr("Error: No valid session found"))
|
||||
self.import_button.setText(self.tr("Import"))
|
||||
self.import_button.setDisabled(False)
|
|
@ -14,6 +14,9 @@ class LoginDialog(QDialog):
|
|||
|
||||
self.core = core
|
||||
self.setWindowTitle("Rare - Login")
|
||||
self.setFixedWidth(350)
|
||||
self.setFixedHeight(450)
|
||||
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
|
@ -36,7 +39,7 @@ class LoginDialog(QDialog):
|
|||
self.import_login = OptionWidget("Import from existing installation",
|
||||
"Import an existing login session from an Epic Games Launcher installation. You will get logged out there")
|
||||
self.import_login.button.clicked.connect(lambda: self.layout.setCurrentIndex(2))
|
||||
# self.landing_layout.addWidget(self.import_login)
|
||||
self.landing_layout.addWidget(self.import_login)
|
||||
|
||||
self.close_button = QPushButton("Exit App")
|
||||
self.close_button.clicked.connect(self.close)
|
||||
|
|
|
@ -165,7 +165,7 @@ class GameActions(QWidget):
|
|||
uninstall_layout = QHBoxLayout()
|
||||
self.uninstall_game = QLabel(self.tr("Uninstall game"))
|
||||
uninstall_layout.addWidget(self.uninstall_game)
|
||||
self.uninstall_button = QPushButton("Uninstall")
|
||||
self.uninstall_button = QPushButton(self.tr("Uninstall"))
|
||||
self.uninstall_button.setFixedWidth(250)
|
||||
uninstall_layout.addWidget(self.uninstall_button)
|
||||
self.layout.addLayout(uninstall_layout)
|
||||
|
@ -176,7 +176,7 @@ class GameActions(QWidget):
|
|||
self.verify_widget = QStackedWidget()
|
||||
self.verify_widget.setMaximumHeight(20)
|
||||
self.verify_widget.setFixedWidth(250)
|
||||
self.verify_button = QPushButton("Verify")
|
||||
self.verify_button = QPushButton(self.tr("Verify"))
|
||||
self.verify_widget.addWidget(self.verify_button)
|
||||
self.verify_progress_bar = QProgressBar()
|
||||
self.verify_progress_bar.setMaximum(100)
|
||||
|
@ -185,9 +185,9 @@ class GameActions(QWidget):
|
|||
self.layout.addLayout(verify_layout)
|
||||
|
||||
repair_layout = QHBoxLayout()
|
||||
repair_info = QLabel("Repair Game")
|
||||
repair_info = QLabel(self.tr("Repair Game"))
|
||||
repair_layout.addWidget(repair_info)
|
||||
self.repair_button = QPushButton("Repair")
|
||||
self.repair_button = QPushButton(self.tr("Repair"))
|
||||
self.repair_button.setFixedWidth(250)
|
||||
repair_layout.addWidget(self.repair_button)
|
||||
self.layout.addLayout(repair_layout)
|
||||
|
|
Loading…
Reference in a new issue