Add link text to browser login
This commit is contained in:
parent
087032f890
commit
662c8ed04c
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -17,3 +17,5 @@ __pycache__
|
|||
/.eggs
|
||||
/appimage-builder-cache/
|
||||
/AppDir/
|
||||
/System Volume Information/
|
||||
/test_files/
|
||||
|
|
|
@ -4,11 +4,12 @@ from typing import Tuple
|
|||
|
||||
from PyQt5.QtCore import pyqtSignal, QUrl
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
from PyQt5.QtWidgets import QWidget, QApplication
|
||||
|
||||
from legendary.core import LegendaryCore
|
||||
from rare.ui.components.dialogs.login.browser_login import Ui_BrowserLogin
|
||||
from rare.utils.extra_widgets import IndicatorLineEdit
|
||||
from rare.utils.utils import icon
|
||||
|
||||
logger = getLogger("BrowserLogin")
|
||||
|
||||
|
@ -27,11 +28,20 @@ class BrowserLogin(QWidget, Ui_BrowserLogin):
|
|||
self.sid_edit = IndicatorLineEdit(
|
||||
ph_text=self.tr("Insert SID here"), edit_func=self.text_changed, parent=self
|
||||
)
|
||||
self.link_text.setText(self.login_url)
|
||||
self.copy_button.setIcon(icon("mdi.content-copy", "fa.copy"))
|
||||
self.copy_button.clicked.connect(self.copy_link)
|
||||
|
||||
self.sid_layout.addWidget(self.sid_edit)
|
||||
|
||||
self.open_button.clicked.connect(self.open_browser)
|
||||
self.sid_edit.textChanged.connect(self.changed.emit)
|
||||
|
||||
def copy_link(self):
|
||||
clipboard = QApplication.instance().clipboard()
|
||||
clipboard.setText(self.login_url)
|
||||
self.status_label.setText(self.tr("Copied to clipboard"))
|
||||
|
||||
def is_valid(self):
|
||||
return self.sid_edit.is_valid
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'rare/ui/components/dialogs/login/browser_login.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.15.4
|
||||
# Created by: PyQt5 UI code generator 5.15.6
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
@ -14,39 +14,64 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||
class Ui_BrowserLogin(object):
|
||||
def setupUi(self, BrowserLogin):
|
||||
BrowserLogin.setObjectName("BrowserLogin")
|
||||
BrowserLogin.resize(382, 178)
|
||||
BrowserLogin.resize(426, 210)
|
||||
BrowserLogin.setWindowTitle("BrowserLogin")
|
||||
self.browser_layout = QtWidgets.QGridLayout(BrowserLogin)
|
||||
self.browser_layout.setObjectName("browser_layout")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.link_text = QtWidgets.QLineEdit(BrowserLogin)
|
||||
self.link_text.setText("")
|
||||
self.link_text.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
||||
self.link_text.setReadOnly(True)
|
||||
self.link_text.setPlaceholderText("")
|
||||
self.link_text.setObjectName("link_text")
|
||||
self.horizontalLayout.addWidget(self.link_text)
|
||||
self.copy_button = QtWidgets.QPushButton(BrowserLogin)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.copy_button.sizePolicy().hasHeightForWidth())
|
||||
self.copy_button.setSizePolicy(sizePolicy)
|
||||
self.copy_button.setText("")
|
||||
self.copy_button.setObjectName("copy_button")
|
||||
self.horizontalLayout.addWidget(self.copy_button)
|
||||
self.browser_layout.addLayout(self.horizontalLayout, 2, 0, 1, 3)
|
||||
self.open_button = QtWidgets.QPushButton(BrowserLogin)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.open_button.sizePolicy().hasHeightForWidth())
|
||||
self.open_button.setSizePolicy(sizePolicy)
|
||||
self.open_button.setObjectName("open_button")
|
||||
self.browser_layout.addWidget(self.open_button, 1, 0, 1, 1)
|
||||
self.title_label = QtWidgets.QLabel(BrowserLogin)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.title_label.setFont(font)
|
||||
self.title_label.setObjectName("title_label")
|
||||
self.browser_layout.addWidget(self.title_label, 0, 0, 1, 2, QtCore.Qt.AlignTop)
|
||||
self.info_label = QtWidgets.QLabel(BrowserLogin)
|
||||
font = QtGui.QFont()
|
||||
font.setItalic(True)
|
||||
self.info_label.setFont(font)
|
||||
self.info_label.setWordWrap(True)
|
||||
self.info_label.setObjectName("info_label")
|
||||
self.browser_layout.addWidget(self.info_label, 3, 0, 1, 2, QtCore.Qt.AlignBottom)
|
||||
self.browser_layout.addWidget(self.info_label, 4, 0, 1, 3)
|
||||
self.title_label = QtWidgets.QLabel(BrowserLogin)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.title_label.setFont(font)
|
||||
self.title_label.setObjectName("title_label")
|
||||
self.browser_layout.addWidget(self.title_label, 0, 0, 1, 3, QtCore.Qt.AlignTop)
|
||||
self.status_label = QtWidgets.QLabel(BrowserLogin)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.status_label.sizePolicy().hasHeightForWidth())
|
||||
self.status_label.setSizePolicy(sizePolicy)
|
||||
self.status_label.setText("")
|
||||
self.status_label.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft)
|
||||
self.status_label.setObjectName("status_label")
|
||||
self.browser_layout.addWidget(self.status_label, 2, 1, 1, 1)
|
||||
self.browser_layout.addWidget(self.status_label, 3, 0, 1, 3)
|
||||
self.sid_layout = QtWidgets.QHBoxLayout()
|
||||
self.sid_layout.setObjectName("sid_layout")
|
||||
self.browser_layout.addLayout(self.sid_layout, 1, 1, 1, 1)
|
||||
self.browser_layout.addLayout(self.sid_layout, 1, 1, 1, 2)
|
||||
|
||||
self.retranslateUi(BrowserLogin)
|
||||
QtCore.QMetaObject.connectSlotsByName(BrowserLogin)
|
||||
|
@ -54,8 +79,9 @@ class Ui_BrowserLogin(object):
|
|||
def retranslateUi(self, BrowserLogin):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
self.open_button.setText(_translate("BrowserLogin", "Open 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.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. After logging in, copy the SID code in the input above."))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -6,22 +6,78 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>382</width>
|
||||
<height>178</height>
|
||||
<width>426</width>
|
||||
<height>210</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">BrowserLogin</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="browser_layout">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="link_text">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="copy_button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="open_button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Browser</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2" alignment="Qt::AlignTop">
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QLabel" name="info_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</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>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3" alignment="Qt::AlignTop">
|
||||
<widget class="QLabel" name="title_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
|
@ -34,25 +90,10 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" alignment="Qt::AlignBottom">
|
||||
<widget class="QLabel" name="info_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Click the button to open the login page in a browser. After logging in, copy the SID code in the input above.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="status_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -60,9 +101,12 @@
|
|||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="sid_layout"/>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'rare/ui/components/dialogs/login/login_dialog.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.15.4
|
||||
# Created by: PyQt5 UI code generator 5.15.6
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
@ -22,12 +22,12 @@ class Ui_LoginDialog(object):
|
|||
LoginDialog.setSizePolicy(sizePolicy)
|
||||
self.dialog_layout = QtWidgets.QVBoxLayout(LoginDialog)
|
||||
self.dialog_layout.setObjectName("dialog_layout")
|
||||
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.dialog_layout.addItem(spacerItem)
|
||||
self.welcome_label = QtWidgets.QLabel(LoginDialog)
|
||||
self.welcome_label.setObjectName("welcome_label")
|
||||
self.dialog_layout.addWidget(self.welcome_label)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.dialog_layout.addItem(spacerItem1)
|
||||
self.login_stack = QtWidgets.QStackedWidget(LoginDialog)
|
||||
self.login_stack.setEnabled(True)
|
||||
|
@ -67,6 +67,8 @@ class Ui_LoginDialog(object):
|
|||
self.login_import_radio.setSizePolicy(sizePolicy)
|
||||
self.login_import_radio.setObjectName("login_import_radio")
|
||||
self.login_page_layout.addWidget(self.login_import_radio, 2, 0, 1, 1)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.login_page_layout.addItem(spacerItem2, 1, 2, 2, 1)
|
||||
self.login_browser_radio = QtWidgets.QRadioButton(self.login_page)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
|
@ -75,8 +77,6 @@ class Ui_LoginDialog(object):
|
|||
self.login_browser_radio.setSizePolicy(sizePolicy)
|
||||
self.login_browser_radio.setObjectName("login_browser_radio")
|
||||
self.login_page_layout.addWidget(self.login_browser_radio, 1, 0, 1, 1)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.login_page_layout.addItem(spacerItem2, 1, 2, 2, 1)
|
||||
self.login_stack.addWidget(self.login_page)
|
||||
self.dialog_layout.addWidget(self.login_stack)
|
||||
self.button_layout = QtWidgets.QHBoxLayout()
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -134,32 +134,32 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="login_browser_radio">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browser</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" rowspan="2">
|
||||
<spacer name="login_hspacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="login_browser_radio">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browser</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -525,7 +525,7 @@ class CloudWorker(QRunnable):
|
|||
def run(self) -> None:
|
||||
try:
|
||||
result = shared.core.get_save_games()
|
||||
except HTTPError():
|
||||
except HTTPError:
|
||||
result = None
|
||||
self.signals.result_ready.emit(result)
|
||||
|
||||
|
|
Loading…
Reference in a new issue