From 89c1a4eaf4c16b9b68dec1a8a8eae58f2d41fe51 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:38:51 +0200 Subject: [PATCH] Launcher: Refactor cloud sync dialog to use ButtonDialog base class --- rare/components/dialogs/cloud_save_dialog.py | 94 ---------------- .../tabs/games/game_info/cloud_saves.py | 30 ++--- rare/launcher/__init__.py | 37 +++++-- rare/launcher/cloud_sync_dialog.py | 103 ++++++++++++++++++ rare/launcher/console.py | 2 +- .../ui/components/dialogs/sync_save_dialog.py | 56 ---------- .../ui/components/dialogs/sync_save_dialog.ui | 61 ----------- .../games/game_info/cloud_settings_widget.py | 52 +++++++++ .../games/game_info/cloud_settings_widget.ui | 53 +++++++++ .../{sync_widget.py => cloud_sync_widget.py} | 76 ++++++------- .../{sync_widget.ui => cloud_sync_widget.ui} | 10 +- .../tabs/games/game_info/cloud_widget.py | 44 -------- .../tabs/games/game_info/cloud_widget.ui | 38 ------- .../extra => launcher}/__init__.py | 0 .../extra => launcher}/console_env.py | 0 .../extra => launcher}/console_env.ui | 0 16 files changed, 294 insertions(+), 362 deletions(-) delete mode 100644 rare/components/dialogs/cloud_save_dialog.py create mode 100644 rare/launcher/cloud_sync_dialog.py delete mode 100644 rare/ui/components/dialogs/sync_save_dialog.py delete mode 100644 rare/ui/components/dialogs/sync_save_dialog.ui create mode 100644 rare/ui/components/tabs/games/game_info/cloud_settings_widget.py create mode 100644 rare/ui/components/tabs/games/game_info/cloud_settings_widget.ui rename rare/ui/components/tabs/games/game_info/{sync_widget.py => cloud_sync_widget.py} (60%) rename rare/ui/components/tabs/games/game_info/{sync_widget.ui => cloud_sync_widget.ui} (94%) delete mode 100644 rare/ui/components/tabs/games/game_info/cloud_widget.py delete mode 100644 rare/ui/components/tabs/games/game_info/cloud_widget.ui rename rare/ui/{components/extra => launcher}/__init__.py (100%) rename rare/ui/{components/extra => launcher}/console_env.py (100%) rename rare/ui/{components/extra => launcher}/console_env.ui (100%) diff --git a/rare/components/dialogs/cloud_save_dialog.py b/rare/components/dialogs/cloud_save_dialog.py deleted file mode 100644 index 56067950..00000000 --- a/rare/components/dialogs/cloud_save_dialog.py +++ /dev/null @@ -1,94 +0,0 @@ -import datetime -import sys -from logging import getLogger - -from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QDialog, QSizePolicy, QLayout, QApplication, QWidget -from legendary.core import LegendaryCore -from legendary.models.game import InstalledGame - -from rare.ui.components.dialogs.sync_save_dialog import Ui_SyncSaveDialog -from rare.ui.components.tabs.games.game_info.sync_widget import Ui_SyncWidget -from rare.utils.misc import icon - -logger = getLogger("Cloud Saves") - - -class CloudSaveDialog(QDialog, Ui_SyncSaveDialog): - DOWNLOAD = 2 - UPLOAD = 1 - CANCEL = 0 - SKIP = 3 - - def __init__( - self, - igame: InstalledGame, - dt_local: datetime.datetime, - dt_remote: datetime.datetime, - ): - super(CloudSaveDialog, self).__init__() - self.setupUi(self) - - self.sync_widget = QWidget() - self.sync_ui = Ui_SyncWidget() - self.sync_ui.setupUi(self.sync_widget) - - self.sync_widget_layout.addWidget(self.sync_widget) - - self.setAttribute(Qt.WA_DeleteOnClose, True) - self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint) - - self.status = self.CANCEL - - self.title_label.setText(f"

{self.title_label.text()} {igame.title}

") - - newer = self.tr("Newer") - if dt_remote and dt_local: - self.sync_ui.age_label_local.setText( - f"{newer}" if dt_remote < dt_local else " " - ) - self.sync_ui.age_label_remote.setText( - f"{newer}" if dt_remote > dt_local else " " - ) - # Set status, if one of them is None - elif dt_remote and not dt_local: - self.status = self.DOWNLOAD - elif not dt_remote and dt_local: - self.status = self.UPLOAD - else: - self.status = self.SKIP - - self.sync_ui.date_info_local.setText(dt_local.strftime("%A, %d. %B %Y %X") if dt_local else "None") - self.sync_ui.date_info_remote.setText(dt_remote.strftime("%A, %d. %B %Y %X") if dt_remote else "None") - - self.sync_ui.icon_local.setPixmap(icon("mdi.harddisk", "fa.desktop").pixmap(128, 128)) - self.sync_ui.icon_remote.setPixmap(icon("mdi.cloud-outline", "ei.cloud").pixmap(128, 128)) - - self.sync_ui.upload_button.clicked.connect(lambda: self.btn_clicked(self.UPLOAD)) - self.sync_ui.download_button.clicked.connect(lambda: self.btn_clicked(self.DOWNLOAD)) - self.cancel_button.clicked.connect(self.close) - - self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) - self.layout().setSizeConstraint(QLayout.SetFixedSize) - - def get_action(self): - if self.status == self.SKIP: - return self.SKIP - self.exec_() - return self.status - - def btn_clicked(self, status): - self.status = status - self.close() - - -def test_dialog(): - app = QApplication(sys.argv) - core = LegendaryCore() - dlg = CloudSaveDialog(core.get_installed_list()[0], datetime.datetime.now(), - datetime.datetime.strptime("2021,1", "%Y,%M")) - print(dlg.get_action()) - - -if __name__ == '__main__': - test_dialog() diff --git a/rare/components/tabs/games/game_info/cloud_saves.py b/rare/components/tabs/games/game_info/cloud_saves.py index d9cd9f23..87143f71 100644 --- a/rare/components/tabs/games/game_info/cloud_saves.py +++ b/rare/components/tabs/games/game_info/cloud_saves.py @@ -13,15 +13,15 @@ from PyQt5.QtWidgets import ( QMessageBox, QGroupBox, QVBoxLayout, - QSpacerItem, + QSpacerItem, QFormLayout, ) from legendary.models.game import SaveGameStatus from rare.models.game import RareGame from rare.shared import RareCore from rare.shared.workers.wine_resolver import WineResolver -from rare.ui.components.tabs.games.game_info.cloud_widget import Ui_CloudWidget -from rare.ui.components.tabs.games.game_info.sync_widget import Ui_SyncWidget +from rare.ui.components.tabs.games.game_info.cloud_settings_widget import Ui_CloudSettingsWidget +from rare.ui.components.tabs.games.game_info.cloud_sync_widget import Ui_CloudSyncWidget from rare.utils.misc import icon from rare.widgets.indicator_edit import PathEdit, IndicatorReasonsCommon from rare.widgets.loading_widget import LoadingWidget @@ -35,7 +35,7 @@ class CloudSaves(QWidget, SideTabContents): super(CloudSaves, self).__init__(parent=parent) self.sync_widget = QWidget(self) - self.sync_ui = Ui_SyncWidget() + self.sync_ui = Ui_CloudSyncWidget() self.sync_ui.setupUi(self.sync_widget) self.info_label = QLabel(self.tr("This game doesn't support cloud saves")) @@ -56,7 +56,7 @@ class CloudSaves(QWidget, SideTabContents): self.rgame: RareGame = None self.cloud_widget = QGroupBox(self) - self.cloud_ui = Ui_CloudWidget() + self.cloud_ui = Ui_CloudSettingsWidget() self.cloud_ui.setupUi(self.cloud_widget) self.cloud_save_path_edit = PathEdit( @@ -66,16 +66,20 @@ class CloudSaves(QWidget, SideTabContents): edit_func=self.edit_save_path, save_func=self.save_save_path, ) - self.cloud_ui.cloud_layout.addRow(QLabel(self.tr("Save path")), self.cloud_save_path_edit) + self.cloud_ui.main_layout.setWidget( + self.cloud_ui.main_layout.getWidgetPosition(self.cloud_ui.path_label)[0], + QFormLayout.FieldRole, + self.cloud_save_path_edit + ) self.compute_save_path_button = QPushButton(icon("fa.magic"), self.tr("Calculate path")) self.compute_save_path_button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.compute_save_path_button.clicked.connect(self.compute_save_path) - self.cloud_ui.cloud_layout.addRow(None, self.compute_save_path_button) + self.cloud_ui.main_layout.addRow(None, self.compute_save_path_button) - self.cloud_ui.cloud_sync.stateChanged.connect( + self.cloud_ui.sync_check.stateChanged.connect( lambda: self.settings.setValue( - f"{self.rgame.app_name}/auto_sync_cloud", self.cloud_ui.cloud_sync.isChecked() + f"{self.rgame.app_name}/auto_sync_cloud", self.cloud_ui.sync_check.isChecked() ) ) @@ -172,7 +176,7 @@ class CloudSaves(QWidget, SideTabContents): self.sync_ui.age_label_local.setText("None") self.sync_ui.date_info_remote.setText("None") self.sync_ui.age_label_remote.setText("None") - self.cloud_ui.cloud_sync.setChecked(False) + self.cloud_ui.sync_check.setChecked(False) self.cloud_save_path_edit.setText("") return @@ -203,9 +207,9 @@ class CloudSaves(QWidget, SideTabContents): self.sync_ui.upload_button.setDisabled(not dt_local) self.sync_ui.download_button.setDisabled(not dt_remote) - self.cloud_ui.cloud_sync.blockSignals(True) - self.cloud_ui.cloud_sync.setChecked(self.rgame.auto_sync_saves) - self.cloud_ui.cloud_sync.blockSignals(False) + self.cloud_ui.sync_check.blockSignals(True) + self.cloud_ui.sync_check.setChecked(self.rgame.auto_sync_saves) + self.cloud_ui.sync_check.blockSignals(False) self.cloud_save_path_edit.setText(self.rgame.save_path if self.rgame.save_path else "") if platform.system() == "Windows" and not self.rgame.save_path: diff --git a/rare/launcher/__init__.py b/rare/launcher/__init__.py index a453bd6f..13a258ba 100644 --- a/rare/launcher/__init__.py +++ b/rare/launcher/__init__.py @@ -14,11 +14,11 @@ from PyQt5.QtNetwork import QLocalServer, QLocalSocket from PyQt5.QtWidgets import QApplication from legendary.models.game import SaveGameStatus -from rare.components.dialogs.cloud_save_dialog import CloudSaveDialog from rare.lgndr.core import LegendaryCore from rare.models.base_game import RareGameSlim from rare.models.launcher import ErrorModel, Actions, FinishedModel, BaseModel, StateChangedModel from rare.widgets.rare_app import RareApp, RareAppException +from .cloud_sync_dialog import CloudSyncDialog, CloudSyncDialogResult from .console import Console from .lgd_helper import get_launch_args, InitArgs, get_configured_process, LaunchArgs, GameArgsError @@ -45,9 +45,9 @@ class PreLaunchThread(QRunnable): def run(self) -> None: self.logger.info(f"Sync action: {self.sync_action}") - if self.sync_action == CloudSaveDialog.UPLOAD: + if self.sync_action == CloudSyncDialogResult.UPLOAD: self.rgame.upload_saves(False) - elif self.sync_action == CloudSaveDialog.DOWNLOAD: + elif self.sync_action == CloudSyncDialogResult.DOWNLOAD: self.rgame.download_saves(False) else: self.logger.info("No sync action") @@ -212,15 +212,22 @@ class RareLauncher(RareApp): state, (dt_local, dt_remote) = self.rgame.save_game_state if state == SaveGameStatus.LOCAL_NEWER and not self.no_sync_on_exit: - action = CloudSaveDialog.UPLOAD + action = CloudSyncDialogResult.UPLOAD + self.__check_saved_finished(exit_code, action) else: - action = CloudSaveDialog(self.rgame.igame, dt_local, dt_remote).get_action() + sync_dialog = CloudSyncDialog(self.rgame.igame, dt_local, dt_remote) + sync_dialog.result_ready.connect(lambda a: self.__check_saved_finished(exit_code, a)) + sync_dialog.open() - if action == CloudSaveDialog.UPLOAD: + @pyqtSlot(int, int) + @pyqtSlot(int, CloudSyncDialogResult) + def __check_saved_finished(self, exit_code, action): + action = CloudSyncDialogResult(action) + if action == CloudSyncDialogResult.UPLOAD: if self.console: self.console.log("Uploading saves...") self.rgame.upload_saves() - elif action == CloudSaveDialog.DOWNLOAD: + elif action == CloudSyncDialogResult.DOWNLOAD: if self.console: self.console.log("Downloading saves...") self.rgame.download_saves() @@ -325,14 +332,20 @@ class RareLauncher(RareApp): return _, (dt_local, dt_remote) = self.rgame.save_game_state - dlg = CloudSaveDialog(self.rgame.igame, dt_local, dt_remote) - action = dlg.get_action() - if action == CloudSaveDialog.CANCEL: + sync_dialog = CloudSyncDialog(self.rgame.igame, dt_local, dt_remote) + sync_dialog.result_ready.connect(self.__sync_ready) + sync_dialog.open() + + @pyqtSlot(int) + @pyqtSlot(CloudSyncDialogResult) + def __sync_ready(self, action: CloudSyncDialogResult): + action = CloudSyncDialogResult(action) + if action == CloudSyncDialogResult.CANCEL: self.no_sync_on_exit = True if self.console: - if action == CloudSaveDialog.DOWNLOAD: + if action == CloudSyncDialogResult.DOWNLOAD: self.console.log("Downloading saves...") - elif action == CloudSaveDialog.UPLOAD: + elif action == CloudSyncDialogResult.UPLOAD: self.console.log("Uploading saves...") self.start_prepare(action) diff --git a/rare/launcher/cloud_sync_dialog.py b/rare/launcher/cloud_sync_dialog.py new file mode 100644 index 00000000..741298c1 --- /dev/null +++ b/rare/launcher/cloud_sync_dialog.py @@ -0,0 +1,103 @@ +import sys +from datetime import datetime +from enum import IntEnum +from logging import getLogger + +from PyQt5.QtCore import pyqtSignal, pyqtSlot +from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QDialog +from legendary.core import LegendaryCore +from legendary.models.game import InstalledGame + +from rare.ui.components.tabs.games.game_info.cloud_sync_widget import Ui_CloudSyncWidget +from rare.utils.misc import icon +from rare.widgets.dialogs import ButtonDialog, dialog_title_game + +logger = getLogger("CloudSyncDialog") + + +class CloudSyncDialogResult(IntEnum): + DOWNLOAD = 2 + UPLOAD = 1 + CANCEL = 0 + SKIP = 3 + + +class CloudSyncDialog(ButtonDialog): + result_ready: pyqtSignal = pyqtSignal(CloudSyncDialogResult) + + def __init__(self, igame: InstalledGame, dt_local: datetime, dt_remote: datetime, parent=None): + super(CloudSyncDialog, self).__init__(parent=parent) + header = self.tr("Cloud saves for") + self.setWindowTitle(dialog_title_game(header, igame.title)) + + title_label = QLabel(f"

{dialog_title_game(header, igame.title)}

", self) + + sync_widget = QWidget(self) + self.sync_ui = Ui_CloudSyncWidget() + self.sync_ui.setupUi(sync_widget) + + layout = QVBoxLayout() + layout.addWidget(title_label) + layout.addWidget(sync_widget) + + self.accept_button.setText(self.tr("Skip")) + self.accept_button.setIcon(icon("fa.chevron-right")) + + self.setCentralLayout(layout) + + self.status = CloudSyncDialogResult.CANCEL + + newer = self.tr("Newer") + if dt_remote and dt_local: + self.sync_ui.age_label_local.setText(f"{newer}" if dt_remote < dt_local else " ") + self.sync_ui.age_label_remote.setText(f"{newer}" if dt_remote > dt_local else " ") + # Set status, if one of them is None + elif dt_remote and not dt_local: + self.status = CloudSyncDialogResult.DOWNLOAD + elif not dt_remote and dt_local: + self.status = CloudSyncDialogResult.UPLOAD + else: + self.status = CloudSyncDialogResult.SKIP + + self.sync_ui.date_info_local.setText(dt_local.strftime("%A, %d. %B %Y %X") if dt_local else "None") + self.sync_ui.date_info_remote.setText(dt_remote.strftime("%A, %d. %B %Y %X") if dt_remote else "None") + + self.sync_ui.icon_local.setPixmap(icon("mdi.harddisk", "fa.desktop").pixmap(128, 128)) + self.sync_ui.icon_remote.setPixmap(icon("mdi.cloud-outline", "ei.cloud").pixmap(128, 128)) + + self.sync_ui.upload_button.clicked.connect(self.__on_upload) + self.sync_ui.download_button.clicked.connect(self.__on_download) + + if self.status == CloudSyncDialogResult.SKIP: + self.accept() + + def __on_upload(self): + self.status = CloudSyncDialogResult.UPLOAD + self.done(QDialog.Accepted) + + def __on_download(self): + self.status = CloudSyncDialogResult.DOWNLOAD + self.done(QDialog.Accepted) + + def done_handler(self): + self.result_ready.emit(self.status) + + def accept_handler(self): + self.status = CloudSyncDialogResult.SKIP + + def reject_handler(self): + self.status = CloudSyncDialogResult.CANCEL + + +if __name__ == "__main__": + app = QApplication(sys.argv) + core = LegendaryCore() + + @pyqtSlot(int) + def __callback(status: int): + print(repr(CloudSyncDialogResult(status))) + + dlg = CloudSyncDialog(core.get_installed_list()[0], datetime.now(), datetime.strptime("2021,1", "%Y,%M")) + dlg.result_ready.connect(__callback) + dlg.open() + app.exec() diff --git a/rare/launcher/console.py b/rare/launcher/console.py index 06412fb1..44d3797b 100644 --- a/rare/launcher/console.py +++ b/rare/launcher/console.py @@ -14,7 +14,7 @@ from PyQt5.QtWidgets import ( QSizePolicy, QTableWidgetItem, QHeaderView, QApplication, ) -from rare.ui.components.extra.console_env import Ui_ConsoleEnv +from rare.ui.launcher.console_env import Ui_ConsoleEnv class Console(QDialog): diff --git a/rare/ui/components/dialogs/sync_save_dialog.py b/rare/ui/components/dialogs/sync_save_dialog.py deleted file mode 100644 index 1db591aa..00000000 --- a/rare/ui/components/dialogs/sync_save_dialog.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'rare/ui/components/dialogs/sync_save_dialog.ui' -# -# Created by: PyQt5 UI code generator 5.15.7 -# -# 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. - - -from PyQt5 import QtCore, QtGui, QtWidgets - - -class Ui_SyncSaveDialog(object): - def setupUi(self, SyncSaveDialog): - SyncSaveDialog.setObjectName("SyncSaveDialog") - SyncSaveDialog.resize(648, 394) - self.verticalLayout = QtWidgets.QVBoxLayout(SyncSaveDialog) - self.verticalLayout.setObjectName("verticalLayout") - self.title_label = QtWidgets.QLabel(SyncSaveDialog) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.title_label.sizePolicy().hasHeightForWidth()) - self.title_label.setSizePolicy(sizePolicy) - self.title_label.setObjectName("title_label") - self.verticalLayout.addWidget(self.title_label) - self.sync_widget_layout = QtWidgets.QHBoxLayout() - self.sync_widget_layout.setObjectName("sync_widget_layout") - self.verticalLayout.addLayout(self.sync_widget_layout) - self.horizontalLayout_2 = QtWidgets.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem) - self.cancel_button = QtWidgets.QPushButton(SyncSaveDialog) - self.cancel_button.setObjectName("cancel_button") - self.horizontalLayout_2.addWidget(self.cancel_button) - self.verticalLayout.addLayout(self.horizontalLayout_2) - - self.retranslateUi(SyncSaveDialog) - - def retranslateUi(self, SyncSaveDialog): - _translate = QtCore.QCoreApplication.translate - SyncSaveDialog.setWindowTitle(_translate("SyncSaveDialog", "Sync saves with cloud")) - self.title_label.setText(_translate("SyncSaveDialog", "Select save, you want to use for ")) - self.cancel_button.setText(_translate("SyncSaveDialog", "Cancel")) - - -if __name__ == "__main__": - import sys - app = QtWidgets.QApplication(sys.argv) - SyncSaveDialog = QtWidgets.QDialog() - ui = Ui_SyncSaveDialog() - ui.setupUi(SyncSaveDialog) - SyncSaveDialog.show() - sys.exit(app.exec_()) diff --git a/rare/ui/components/dialogs/sync_save_dialog.ui b/rare/ui/components/dialogs/sync_save_dialog.ui deleted file mode 100644 index d7c86479..00000000 --- a/rare/ui/components/dialogs/sync_save_dialog.ui +++ /dev/null @@ -1,61 +0,0 @@ - - - SyncSaveDialog - - - - 0 - 0 - 648 - 394 - - - - Sync saves with cloud - - - - - - - 0 - 0 - - - - Select save, you want to use for - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Cancel - - - - - - - - - - diff --git a/rare/ui/components/tabs/games/game_info/cloud_settings_widget.py b/rare/ui/components/tabs/games/game_info/cloud_settings_widget.py new file mode 100644 index 00000000..12036c80 --- /dev/null +++ b/rare/ui/components/tabs/games/game_info/cloud_settings_widget.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'rare/ui/components/tabs/games/game_info/cloud_settings_widget.ui' +# +# Created by: PyQt5 UI code generator 5.15.10 +# +# 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. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_CloudSettingsWidget(object): + def setupUi(self, CloudSettingsWidget): + CloudSettingsWidget.setObjectName("CloudSettingsWidget") + CloudSettingsWidget.resize(388, 78) + CloudSettingsWidget.setWindowTitle("CloudSettingsWidget") + self.main_layout = QtWidgets.QFormLayout(CloudSettingsWidget) + self.main_layout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.main_layout.setObjectName("main_layout") + self.sync_label = QtWidgets.QLabel(CloudSettingsWidget) + self.sync_label.setObjectName("sync_label") + self.main_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.sync_label) + self.sync_check = QtWidgets.QCheckBox(CloudSettingsWidget) + font = QtGui.QFont() + font.setItalic(True) + self.sync_check.setFont(font) + self.sync_check.setText("Automatically synchronize saves with the cloud") + self.sync_check.setObjectName("sync_check") + self.main_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.sync_check) + self.path_label = QtWidgets.QLabel(CloudSettingsWidget) + self.path_label.setObjectName("path_label") + self.main_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.path_label) + + self.retranslateUi(CloudSettingsWidget) + + def retranslateUi(self, CloudSettingsWidget): + _translate = QtCore.QCoreApplication.translate + CloudSettingsWidget.setTitle(_translate("CloudSettingsWidget", "Settings")) + self.sync_label.setText(_translate("CloudSettingsWidget", "Enable sync")) + self.path_label.setText(_translate("CloudSettingsWidget", "Saves path")) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + CloudSettingsWidget = QtWidgets.QGroupBox() + ui = Ui_CloudSettingsWidget() + ui.setupUi(CloudSettingsWidget) + CloudSettingsWidget.show() + sys.exit(app.exec_()) diff --git a/rare/ui/components/tabs/games/game_info/cloud_settings_widget.ui b/rare/ui/components/tabs/games/game_info/cloud_settings_widget.ui new file mode 100644 index 00000000..b4bbb26d --- /dev/null +++ b/rare/ui/components/tabs/games/game_info/cloud_settings_widget.ui @@ -0,0 +1,53 @@ + + + CloudSettingsWidget + + + + 0 + 0 + 388 + 78 + + + + CloudSettingsWidget + + + Settings + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + Enable sync + + + + + + + + true + + + + Automatically synchronize saves with the cloud + + + + + + + Saves path + + + + + + + + diff --git a/rare/ui/components/tabs/games/game_info/sync_widget.py b/rare/ui/components/tabs/games/game_info/cloud_sync_widget.py similarity index 60% rename from rare/ui/components/tabs/games/game_info/sync_widget.py rename to rare/ui/components/tabs/games/game_info/cloud_sync_widget.py index 6a53cbbc..c368a9aa 100644 --- a/rare/ui/components/tabs/games/game_info/sync_widget.py +++ b/rare/ui/components/tabs/games/game_info/cloud_sync_widget.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'rare/ui/components/tabs/games/game_info/sync_widget.ui' +# Form implementation generated from reading ui file 'rare/ui/components/tabs/games/game_info/cloud_sync_widget.ui' # -# Created by: PyQt5 UI code generator 5.15.9 +# Created by: PyQt5 UI code generator 5.15.10 # # 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. @@ -11,29 +11,29 @@ from PyQt5 import QtCore, QtGui, QtWidgets -class Ui_SyncWidget(object): - def setupUi(self, SyncWidget): - SyncWidget.setObjectName("SyncWidget") - SyncWidget.resize(438, 137) +class Ui_CloudSyncWidget(object): + def setupUi(self, CloudSyncWidget): + CloudSyncWidget.setObjectName("CloudSyncWidget") + CloudSyncWidget.resize(438, 137) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(SyncWidget.sizePolicy().hasHeightForWidth()) - SyncWidget.setSizePolicy(sizePolicy) - SyncWidget.setWindowTitle("SyncWidget") - self.sync_layout = QtWidgets.QHBoxLayout(SyncWidget) - self.sync_layout.setContentsMargins(0, 0, 0, 0) - self.sync_layout.setObjectName("sync_layout") - self.local_gb = QtWidgets.QGroupBox(SyncWidget) - self.local_gb.setObjectName("local_gb") - self.local_layout = QtWidgets.QVBoxLayout(self.local_gb) + sizePolicy.setHeightForWidth(CloudSyncWidget.sizePolicy().hasHeightForWidth()) + CloudSyncWidget.setSizePolicy(sizePolicy) + CloudSyncWidget.setWindowTitle("SyncWidget") + self.main_layout = QtWidgets.QHBoxLayout(CloudSyncWidget) + self.main_layout.setContentsMargins(0, 0, 0, 0) + self.main_layout.setObjectName("main_layout") + self.local_group = QtWidgets.QGroupBox(CloudSyncWidget) + self.local_group.setObjectName("local_group") + self.local_layout = QtWidgets.QVBoxLayout(self.local_group) self.local_layout.setObjectName("local_layout") - self.date_info_local = QtWidgets.QLabel(self.local_gb) + self.date_info_local = QtWidgets.QLabel(self.local_group) self.date_info_local.setText("") self.date_info_local.setAlignment(QtCore.Qt.AlignCenter) self.date_info_local.setObjectName("date_info_local") self.local_layout.addWidget(self.date_info_local) - self.icon_local = QtWidgets.QLabel(self.local_gb) + self.icon_local = QtWidgets.QLabel(self.local_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -43,26 +43,26 @@ class Ui_SyncWidget(object): self.icon_local.setAlignment(QtCore.Qt.AlignCenter) self.icon_local.setObjectName("icon_local") self.local_layout.addWidget(self.icon_local) - self.age_label_local = QtWidgets.QLabel(self.local_gb) + self.age_label_local = QtWidgets.QLabel(self.local_group) self.age_label_local.setText("") self.age_label_local.setAlignment(QtCore.Qt.AlignCenter) self.age_label_local.setObjectName("age_label_local") self.local_layout.addWidget(self.age_label_local) - self.upload_button = QtWidgets.QPushButton(self.local_gb) + self.upload_button = QtWidgets.QPushButton(self.local_group) self.upload_button.setMinimumSize(QtCore.QSize(192, 0)) self.upload_button.setObjectName("upload_button") self.local_layout.addWidget(self.upload_button) - self.sync_layout.addWidget(self.local_gb) - self.cloud_gb = QtWidgets.QGroupBox(SyncWidget) - self.cloud_gb.setObjectName("cloud_gb") - self.cloud_layout = QtWidgets.QVBoxLayout(self.cloud_gb) + self.main_layout.addWidget(self.local_group) + self.cloud_group = QtWidgets.QGroupBox(CloudSyncWidget) + self.cloud_group.setObjectName("cloud_group") + self.cloud_layout = QtWidgets.QVBoxLayout(self.cloud_group) self.cloud_layout.setObjectName("cloud_layout") - self.date_info_remote = QtWidgets.QLabel(self.cloud_gb) + self.date_info_remote = QtWidgets.QLabel(self.cloud_group) self.date_info_remote.setText("") self.date_info_remote.setAlignment(QtCore.Qt.AlignCenter) self.date_info_remote.setObjectName("date_info_remote") self.cloud_layout.addWidget(self.date_info_remote) - self.icon_remote = QtWidgets.QLabel(self.cloud_gb) + self.icon_remote = QtWidgets.QLabel(self.cloud_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -72,32 +72,32 @@ class Ui_SyncWidget(object): self.icon_remote.setAlignment(QtCore.Qt.AlignCenter) self.icon_remote.setObjectName("icon_remote") self.cloud_layout.addWidget(self.icon_remote) - self.age_label_remote = QtWidgets.QLabel(self.cloud_gb) + self.age_label_remote = QtWidgets.QLabel(self.cloud_group) self.age_label_remote.setText("") self.age_label_remote.setAlignment(QtCore.Qt.AlignCenter) self.age_label_remote.setObjectName("age_label_remote") self.cloud_layout.addWidget(self.age_label_remote) - self.download_button = QtWidgets.QPushButton(self.cloud_gb) + self.download_button = QtWidgets.QPushButton(self.cloud_group) self.download_button.setMinimumSize(QtCore.QSize(192, 0)) self.download_button.setObjectName("download_button") self.cloud_layout.addWidget(self.download_button) - self.sync_layout.addWidget(self.cloud_gb) + self.main_layout.addWidget(self.cloud_group) - self.retranslateUi(SyncWidget) + self.retranslateUi(CloudSyncWidget) - def retranslateUi(self, SyncWidget): + def retranslateUi(self, CloudSyncWidget): _translate = QtCore.QCoreApplication.translate - self.local_gb.setTitle(_translate("SyncWidget", "Local")) - self.upload_button.setText(_translate("SyncWidget", "Upload")) - self.cloud_gb.setTitle(_translate("SyncWidget", "Cloud")) - self.download_button.setText(_translate("SyncWidget", "Download")) + self.local_group.setTitle(_translate("CloudSyncWidget", "Local")) + self.upload_button.setText(_translate("CloudSyncWidget", "Upload")) + self.cloud_group.setTitle(_translate("CloudSyncWidget", "Cloud")) + self.download_button.setText(_translate("CloudSyncWidget", "Download")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) - SyncWidget = QtWidgets.QWidget() - ui = Ui_SyncWidget() - ui.setupUi(SyncWidget) - SyncWidget.show() + CloudSyncWidget = QtWidgets.QWidget() + ui = Ui_CloudSyncWidget() + ui.setupUi(CloudSyncWidget) + CloudSyncWidget.show() sys.exit(app.exec_()) diff --git a/rare/ui/components/tabs/games/game_info/sync_widget.ui b/rare/ui/components/tabs/games/game_info/cloud_sync_widget.ui similarity index 94% rename from rare/ui/components/tabs/games/game_info/sync_widget.ui rename to rare/ui/components/tabs/games/game_info/cloud_sync_widget.ui index f67b8614..72c1d910 100644 --- a/rare/ui/components/tabs/games/game_info/sync_widget.ui +++ b/rare/ui/components/tabs/games/game_info/cloud_sync_widget.ui @@ -1,7 +1,7 @@ - SyncWidget - + CloudSyncWidget + 0 @@ -19,7 +19,7 @@ SyncWidget - + 0 @@ -33,7 +33,7 @@ 0 - + Local @@ -91,7 +91,7 @@ - + Cloud diff --git a/rare/ui/components/tabs/games/game_info/cloud_widget.py b/rare/ui/components/tabs/games/game_info/cloud_widget.py deleted file mode 100644 index aa8ab79e..00000000 --- a/rare/ui/components/tabs/games/game_info/cloud_widget.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'rare/ui/components/tabs/games/game_info/cloud_widget.ui' -# -# Created by: PyQt5 UI code generator 5.15.7 -# -# 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. - - -from PyQt5 import QtCore, QtGui, QtWidgets - - -class Ui_CloudWidget(object): - def setupUi(self, CloudWidget): - CloudWidget.setObjectName("CloudWidget") - CloudWidget.resize(251, 93) - CloudWidget.setWindowTitle("GroupBox") - self.cloud_layout = QtWidgets.QFormLayout(CloudWidget) - self.cloud_layout.setObjectName("cloud_layout") - self.cloud_sync_label = QtWidgets.QLabel(CloudWidget) - self.cloud_sync_label.setObjectName("cloud_sync_label") - self.cloud_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.cloud_sync_label) - self.cloud_sync = QtWidgets.QCheckBox(CloudWidget) - self.cloud_sync.setText("") - self.cloud_sync.setObjectName("cloud_sync") - self.cloud_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.cloud_sync) - - self.retranslateUi(CloudWidget) - - def retranslateUi(self, CloudWidget): - _translate = QtCore.QCoreApplication.translate - CloudWidget.setTitle(_translate("CloudWidget", "Options")) - self.cloud_sync_label.setText(_translate("CloudWidget", "Sync with cloud")) - - -if __name__ == "__main__": - import sys - app = QtWidgets.QApplication(sys.argv) - CloudWidget = QtWidgets.QGroupBox() - ui = Ui_CloudWidget() - ui.setupUi(CloudWidget) - CloudWidget.show() - sys.exit(app.exec_()) diff --git a/rare/ui/components/tabs/games/game_info/cloud_widget.ui b/rare/ui/components/tabs/games/game_info/cloud_widget.ui deleted file mode 100644 index ee753f6b..00000000 --- a/rare/ui/components/tabs/games/game_info/cloud_widget.ui +++ /dev/null @@ -1,38 +0,0 @@ - - - CloudWidget - - - - 0 - 0 - 251 - 93 - - - - GroupBox - - - Options - - - - - - Sync with cloud - - - - - - - - - - - - - - - diff --git a/rare/ui/components/extra/__init__.py b/rare/ui/launcher/__init__.py similarity index 100% rename from rare/ui/components/extra/__init__.py rename to rare/ui/launcher/__init__.py diff --git a/rare/ui/components/extra/console_env.py b/rare/ui/launcher/console_env.py similarity index 100% rename from rare/ui/components/extra/console_env.py rename to rare/ui/launcher/console_env.py diff --git a/rare/ui/components/extra/console_env.ui b/rare/ui/launcher/console_env.ui similarity index 100% rename from rare/ui/components/extra/console_env.ui rename to rare/ui/launcher/console_env.ui