Disable irrelevant widgets depending on case in EGLSync
This commit is contained in:
parent
9e86c3a59b
commit
d0c676d44a
5 changed files with 269 additions and 169 deletions
|
@ -42,8 +42,8 @@ class ImportSyncWidget(QWidget):
|
|||
def __init__(self, widget: QWidget, title: str, info: str, parent=None):
|
||||
super(ImportSyncWidget, self).__init__(parent=parent)
|
||||
self.layout = QVBoxLayout()
|
||||
self.title = QLabel(f"<h2>{title}</h2")
|
||||
self.layout.addWidget(self.title)
|
||||
# self.title = QLabel(f"<h2>{title}</h2")
|
||||
# self.layout.addWidget(self.title)
|
||||
self.group = widget
|
||||
self.layout.addWidget(self.group)
|
||||
self.info = QLabel(f"<h4>{info}</h4>")
|
||||
|
|
|
@ -6,7 +6,7 @@ from logging import getLogger
|
|||
|
||||
from PyQt5.QtCore import Qt, QThread
|
||||
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, QGroupBox, \
|
||||
QCheckBox, QPushButton, QListWidgetItem, QDialog, QFileDialog
|
||||
QCheckBox, QPushButton, QListWidgetItem, QDialog, QFileDialog, QSizePolicy
|
||||
|
||||
import rare.shared as shared
|
||||
from rare.ui.components.tabs.games.import_sync.egl_sync_widget import Ui_EGLSyncGroup
|
||||
|
@ -68,6 +68,7 @@ class EGLSyncGroup(QGroupBox, Ui_EGLSyncGroup):
|
|||
egl_path = str()
|
||||
self.egl_path_edit = PathEdit(
|
||||
path=egl_path,
|
||||
ph_text=estimated_path,
|
||||
file_type=QFileDialog.DirectoryOnly,
|
||||
edit_func=self.egl_path_edit_cb,
|
||||
save_func=self.egl_path_save_cb,
|
||||
|
@ -112,7 +113,7 @@ class EGLSyncGroup(QGroupBox, Ui_EGLSyncGroup):
|
|||
# path is a wine prefix
|
||||
path = os.path.join(path, 'dosdevices/c:', 'ProgramData/Epic/EpicGamesLauncher/Data/Manifests')
|
||||
elif not path.endswith('ProgramData/Epic/EpicGamesLauncher/Data/Manifests'):
|
||||
# lower() might not be needed here
|
||||
# lower() might or might not be needed in the check
|
||||
return False, path
|
||||
if os.path.exists(path):
|
||||
return True, path
|
||||
|
@ -149,18 +150,27 @@ class EGLSyncGroup(QGroupBox, Ui_EGLSyncGroup):
|
|||
self.core.lgd.save_config()
|
||||
|
||||
def update_lists(self):
|
||||
self.export_list.setVisible(bool(shared.core.egl.programdata_path))
|
||||
self.import_list.setVisible(bool(shared.core.egl.programdata_path))
|
||||
if not shared.core.egl.programdata_path:
|
||||
have_path = bool(shared.core.egl.programdata_path)
|
||||
self.egl_sync_label.setEnabled(have_path)
|
||||
self.egl_sync_check.setEnabled(have_path)
|
||||
|
||||
self.export_import_widget.setEnabled(have_path)
|
||||
|
||||
self.export_label.setVisible(not have_path)
|
||||
self.export_list.setVisible(have_path)
|
||||
self.export_buttons_widget.setVisible(have_path)
|
||||
|
||||
self.import_label.setVisible(not have_path)
|
||||
self.import_list.setVisible(have_path)
|
||||
self.import_buttons_widget.setVisible(have_path)
|
||||
|
||||
if not have_path:
|
||||
return
|
||||
|
||||
self.update_export_list()
|
||||
self.update_import_list()
|
||||
|
||||
def update_export_list(self):
|
||||
self.export_button.setDisabled(not bool(shared.core.egl.programdata_path))
|
||||
self.export_select_all_button.setDisabled(not bool(shared.core.egl.programdata_path))
|
||||
self.export_select_none_button.setDisabled(not bool(shared.core.egl.programdata_path))
|
||||
|
||||
self.export_list.clear()
|
||||
self.exportable_items.clear()
|
||||
exportable_games = shared.core.egl_get_exportable()
|
||||
|
@ -168,15 +178,12 @@ class EGLSyncGroup(QGroupBox, Ui_EGLSyncGroup):
|
|||
ew = EGLSyncItem(igame, True, self.export_list)
|
||||
self.exportable_items.append(ew)
|
||||
self.export_list.addItem(ew)
|
||||
for btn in self.export_buttons_layout.children():
|
||||
btn.setEnabled(bool(exportable_games))
|
||||
self.export_label.setVisible(not bool(exportable_games))
|
||||
have_exportable = bool(exportable_games)
|
||||
self.export_label.setVisible(not have_exportable)
|
||||
self.export_list.setVisible(have_exportable)
|
||||
self.export_buttons_widget.setVisible(have_exportable)
|
||||
|
||||
def update_import_list(self):
|
||||
self.import_button.setDisabled(not bool(shared.core.egl.programdata_path))
|
||||
self.import_select_all_button.setDisabled(not bool(shared.core.egl.programdata_path))
|
||||
self.import_select_none_button.setDisabled(not bool(shared.core.egl.programdata_path))
|
||||
|
||||
self.import_list.clear()
|
||||
self.importable_items.clear()
|
||||
importable_games = shared.core.egl_get_importable()
|
||||
|
@ -184,9 +191,10 @@ class EGLSyncGroup(QGroupBox, Ui_EGLSyncGroup):
|
|||
iw = EGLSyncItem(game, False, self.import_list)
|
||||
self.importable_items.append(iw)
|
||||
self.import_list.addItem(iw)
|
||||
for btn in self.import_buttons_layout.children():
|
||||
btn.setEnabled(bool(importable_games))
|
||||
self.import_label.setVisible(not bool(importable_games))
|
||||
have_importable = bool(importable_games)
|
||||
self.import_label.setVisible(not have_importable)
|
||||
self.import_list.setVisible(have_importable)
|
||||
self.import_buttons_widget.setVisible(have_importable)
|
||||
|
||||
@staticmethod
|
||||
def select_items(item_list, state):
|
||||
|
|
|
@ -32,11 +32,21 @@ class Ui_EGLSyncGroup(object):
|
|||
self.egl_path_info.setObjectName("egl_path_info")
|
||||
self.egl_sync_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.egl_path_info)
|
||||
self.egl_sync_check = QtWidgets.QCheckBox(EGLSyncGroup)
|
||||
self.egl_sync_check.setText("")
|
||||
self.egl_sync_check.setObjectName("egl_sync_check")
|
||||
self.egl_sync_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.egl_sync_check)
|
||||
self.export_import_layout = QtWidgets.QHBoxLayout()
|
||||
self.egl_path_layout = QtWidgets.QHBoxLayout()
|
||||
self.egl_path_layout.setObjectName("egl_path_layout")
|
||||
self.egl_sync_layout.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.egl_path_layout)
|
||||
self.egl_sync_label = QtWidgets.QLabel(EGLSyncGroup)
|
||||
self.egl_sync_label.setObjectName("egl_sync_label")
|
||||
self.egl_sync_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.egl_sync_label)
|
||||
self.export_import_widget = QtWidgets.QWidget(EGLSyncGroup)
|
||||
self.export_import_widget.setObjectName("export_import_widget")
|
||||
self.export_import_layout = QtWidgets.QHBoxLayout(self.export_import_widget)
|
||||
self.export_import_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.export_import_layout.setObjectName("export_import_layout")
|
||||
self.export_group = QtWidgets.QGroupBox(EGLSyncGroup)
|
||||
self.export_group = QtWidgets.QGroupBox(self.export_import_widget)
|
||||
self.export_group.setObjectName("export_group")
|
||||
self.export_layout = QtWidgets.QVBoxLayout(self.export_group)
|
||||
self.export_layout.setObjectName("export_layout")
|
||||
|
@ -47,22 +57,27 @@ class Ui_EGLSyncGroup(object):
|
|||
self.export_list.setAlternatingRowColors(True)
|
||||
self.export_list.setObjectName("export_list")
|
||||
self.export_layout.addWidget(self.export_list)
|
||||
self.export_buttons_layout = QtWidgets.QHBoxLayout()
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.export_layout.addItem(spacerItem)
|
||||
self.export_buttons_widget = QtWidgets.QWidget(self.export_group)
|
||||
self.export_buttons_widget.setObjectName("export_buttons_widget")
|
||||
self.export_buttons_layout = QtWidgets.QHBoxLayout(self.export_buttons_widget)
|
||||
self.export_buttons_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.export_buttons_layout.setObjectName("export_buttons_layout")
|
||||
self.export_select_all_button = QtWidgets.QPushButton(self.export_group)
|
||||
self.export_select_all_button = QtWidgets.QPushButton(self.export_buttons_widget)
|
||||
self.export_select_all_button.setObjectName("export_select_all_button")
|
||||
self.export_buttons_layout.addWidget(self.export_select_all_button)
|
||||
self.export_select_none_button = QtWidgets.QPushButton(self.export_group)
|
||||
self.export_select_none_button = QtWidgets.QPushButton(self.export_buttons_widget)
|
||||
self.export_select_none_button.setObjectName("export_select_none_button")
|
||||
self.export_buttons_layout.addWidget(self.export_select_none_button)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.export_buttons_layout.addItem(spacerItem)
|
||||
self.export_button = QtWidgets.QPushButton(self.export_group)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.export_buttons_layout.addItem(spacerItem1)
|
||||
self.export_button = QtWidgets.QPushButton(self.export_buttons_widget)
|
||||
self.export_button.setObjectName("export_button")
|
||||
self.export_buttons_layout.addWidget(self.export_button)
|
||||
self.export_layout.addLayout(self.export_buttons_layout)
|
||||
self.export_layout.addWidget(self.export_buttons_widget)
|
||||
self.export_import_layout.addWidget(self.export_group)
|
||||
self.import_group = QtWidgets.QGroupBox(EGLSyncGroup)
|
||||
self.import_group = QtWidgets.QGroupBox(self.export_import_widget)
|
||||
self.import_group.setObjectName("import_group")
|
||||
self.import_layout = QtWidgets.QVBoxLayout(self.import_group)
|
||||
self.import_layout.setObjectName("import_layout")
|
||||
|
@ -73,25 +88,27 @@ class Ui_EGLSyncGroup(object):
|
|||
self.import_list.setAlternatingRowColors(True)
|
||||
self.import_list.setObjectName("import_list")
|
||||
self.import_layout.addWidget(self.import_list)
|
||||
self.import_buttons_layout = QtWidgets.QHBoxLayout()
|
||||
spacerItem2 = QtWidgets.QSpacerItem(40, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.import_layout.addItem(spacerItem2)
|
||||
self.import_buttons_widget = QtWidgets.QWidget(self.import_group)
|
||||
self.import_buttons_widget.setObjectName("import_buttons_widget")
|
||||
self.import_buttons_layout = QtWidgets.QHBoxLayout(self.import_buttons_widget)
|
||||
self.import_buttons_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.import_buttons_layout.setObjectName("import_buttons_layout")
|
||||
self.import_select_all_button = QtWidgets.QPushButton(self.import_group)
|
||||
self.import_select_all_button = QtWidgets.QPushButton(self.import_buttons_widget)
|
||||
self.import_select_all_button.setObjectName("import_select_all_button")
|
||||
self.import_buttons_layout.addWidget(self.import_select_all_button)
|
||||
self.import_select_none_button = QtWidgets.QPushButton(self.import_group)
|
||||
self.import_select_none_button = QtWidgets.QPushButton(self.import_buttons_widget)
|
||||
self.import_select_none_button.setObjectName("import_select_none_button")
|
||||
self.import_buttons_layout.addWidget(self.import_select_none_button)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.import_buttons_layout.addItem(spacerItem1)
|
||||
self.import_button = QtWidgets.QPushButton(self.import_group)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.import_buttons_layout.addItem(spacerItem3)
|
||||
self.import_button = QtWidgets.QPushButton(self.import_buttons_widget)
|
||||
self.import_button.setObjectName("import_button")
|
||||
self.import_buttons_layout.addWidget(self.import_button)
|
||||
self.import_layout.addLayout(self.import_buttons_layout)
|
||||
self.import_layout.addWidget(self.import_buttons_widget)
|
||||
self.export_import_layout.addWidget(self.import_group)
|
||||
self.egl_sync_layout.setLayout(3, QtWidgets.QFormLayout.SpanningRole, self.export_import_layout)
|
||||
self.egl_path_layout = QtWidgets.QHBoxLayout()
|
||||
self.egl_path_layout.setObjectName("egl_path_layout")
|
||||
self.egl_sync_layout.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.egl_path_layout)
|
||||
self.egl_sync_layout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.export_import_widget)
|
||||
|
||||
self.retranslateUi(EGLSyncGroup)
|
||||
QtCore.QMetaObject.connectSlotsByName(EGLSyncGroup)
|
||||
|
@ -102,7 +119,7 @@ class Ui_EGLSyncGroup(object):
|
|||
EGLSyncGroup.setTitle(_translate("EGLSyncGroup", "Sync with Epic Games Launcher"))
|
||||
self.egl_path_label.setText(_translate("EGLSyncGroup", "Prefix/Manifest path"))
|
||||
self.egl_path_info_label.setText(_translate("EGLSyncGroup", "Estimated path"))
|
||||
self.egl_sync_check.setText(_translate("EGLSyncGroup", "Enable automatic sync"))
|
||||
self.egl_sync_label.setText(_translate("EGLSyncGroup", "Enable automatic sync"))
|
||||
self.export_group.setTitle(_translate("EGLSyncGroup", "Exportable games"))
|
||||
self.export_label.setText(_translate("EGLSyncGroup", "No games to export to EGS"))
|
||||
self.export_list.setSortingEnabled(True)
|
||||
|
|
|
@ -52,13 +52,36 @@
|
|||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="egl_sync_check">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="egl_path_layout"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="egl_sync_label">
|
||||
<property name="text">
|
||||
<string>Enable automatic sync</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QWidget" name="export_import_widget" native="true">
|
||||
<layout class="QHBoxLayout" name="export_import_layout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="export_group">
|
||||
<property name="title">
|
||||
|
@ -83,7 +106,33 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="export_group_hspacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>4</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="export_buttons_widget" native="true">
|
||||
<layout class="QHBoxLayout" name="export_buttons_layout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="export_select_all_button">
|
||||
<property name="text">
|
||||
|
@ -119,6 +168,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -147,7 +197,33 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="import_group_hspacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>4</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="import_buttons_widget" native="true">
|
||||
<layout class="QHBoxLayout" name="import_buttons_layout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="import_select_all_button">
|
||||
<property name="text">
|
||||
|
@ -183,14 +259,13 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="egl_path_layout"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -153,7 +153,7 @@ class IndicatorLineEdit(QWidget):
|
|||
|
||||
if not ph_text:
|
||||
_translate = QCoreApplication.translate
|
||||
self.line_edit.setPlaceholderText(_translate("PathEdit", "Default"))
|
||||
self.line_edit.setPlaceholderText(_translate(self.__class__.__name__, "Default"))
|
||||
|
||||
if text:
|
||||
self.line_edit.setText(text)
|
||||
|
|
Loading…
Reference in a new issue