1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00

Save window size (#32)

Save window size
This commit is contained in:
Dummerle 2021-04-10 15:05:03 +02:00 committed by GitHub
parent 6631703997
commit 28106cf9a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 46 deletions

View file

@ -8,17 +8,29 @@ from rare.components.tab_widget import TabWidget
class MainWindow(QMainWindow):
def __init__(self, core):
super(MainWindow, self).__init__()
self.setGeometry(0, 0, 1200, 800)
settings = QSettings()
width, height = 1200, 800
if settings.value("save_size", False):
width, height = settings.value("window_size", (1200, 800), tuple)
self.setGeometry(0, 0, width, height)
self.setWindowTitle("Rare - GUI for legendary")
self.tab_widget = TabWidget(core)
self.setCentralWidget(self.tab_widget)
self.show()
def closeEvent(self, e: QCloseEvent):
if QSettings().value("sys_tray", True, bool):
settings = QSettings()
if settings.value("sys_tray", True, bool):
self.hide()
e.ignore()
elif self.tab_widget.downloadTab.active_game is not None and QMessageBox.question(self, "Close", self.tr("There is a download active. Do you really want to exit app?"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes:
e.accept()
else:
e.accept()
return
elif self.tab_widget.downloadTab.active_game is not None:
if not QMessageBox.question(self, "Close", self.tr("There is a download active. Do you really want to exit app?"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes:
e.ignore()
return
if settings.value("save_size", False, bool):
size = self.size().width(), self.size().height()
settings.setValue("window_size", size)
e.accept()

View file

@ -56,9 +56,9 @@ class GameInfo(QScrollArea):
self.layout = QVBoxLayout()
self.setWidgetResizable(True)
# TODO More Information: Image text settings needs_verification platform
top_layout = QHBoxLayout()
# No Game at start. Game is set when clicked info
self.image = QLabel()
top_layout.addWidget(self.image)

View file

@ -26,9 +26,9 @@ class RareSettings(QScrollArea):
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setWidgetResizable(True)
self.layout = QVBoxLayout()
settings = QSettings()
img_dir = settings.value("img_dir", os.path.expanduser("~/.cache/rare/images/"), type=str)
language = settings.value("language", get_lang(), type=str)
self.settings = QSettings()
img_dir = self.settings.value("img_dir", os.path.expanduser("~/.cache/rare/images/"), type=str)
language = self.settings.value("language", get_lang(), type=str)
# select Image dir
self.select_path = PathEdit(img_dir, type_of_file=QFileDialog.DirectoryOnly)
self.select_path.text_edit.textChanged.connect(lambda t: self.save_path_button.setDisabled(False))
@ -50,43 +50,48 @@ class RareSettings(QScrollArea):
self.layout.addWidget(self.lang_widget)
self.exit_to_sys_tray = QCheckBox(self.tr("Hide to System Tray Icon"))
self.exit_to_sys_tray.setChecked(settings.value("sys_tray", True, bool))
self.exit_to_sys_tray.stateChanged.connect(lambda x: self.update_checkbox(x, "sys_tray"))
self.exit_to_sys_tray.setChecked(self.settings.value("sys_tray", True, bool))
self.exit_to_sys_tray.stateChanged.connect(lambda: self.settings.setValue("sys_tray", self.exit_to_sys_tray.isChecked()))
self.sys_tray_widget = SettingsWidget(self.tr("Exit to System Tray Icon"), self.exit_to_sys_tray)
self.layout.addWidget(self.sys_tray_widget)
self.game_start_accept = QCheckBox(self.tr("Confirm launch of game"))
self.game_start_accept.stateChanged.connect(lambda x: self.update_checkbox(x, "confirm_start"))
self.game_start_accept.stateChanged.connect(lambda x: self.settings.setValue("confirm_start", self.game_start_accept.isChecked()))
self.game_start_accept_widget = SettingsWidget(self.tr("Confirm launch of game"), self.game_start_accept)
self.layout.addWidget(self.game_start_accept_widget)
self.cloud_sync = QCheckBox("Sync with cloud")
self.cloud_sync.setChecked(settings.value("auto_sync_cloud", True, bool))
self.cloud_sync = QCheckBox(self.tr("Sync with cloud"))
self.cloud_sync.setChecked(self.settings.value("auto_sync_cloud", True, bool))
self.cloud_sync_widget = SettingsWidget(self.tr("Auto sync with cloud"), self.cloud_sync)
self.layout.addWidget(self.cloud_sync_widget)
self.cloud_sync.stateChanged.connect(lambda: self.settings.setValue(f"auto_sync_cloud",
self.cloud_sync.isChecked()))
self.save_size = QCheckBox(self.tr("Save size"))
self.save_size.setChecked(self.settings.value("save_size", False, bool))
self.save_size_widget = SettingsWidget(self.tr("Save size of window after restart"), self.save_size)
self.layout.addWidget(self.save_size_widget)
self.save_size.stateChanged.connect(self.save_window_size)
self.layout.addWidget(self.save_size_widget)
self.layout.addStretch()
self.widget.setLayout(self.layout)
self.setWidget(self.widget)
def update_checkbox(self, checked, setting_name):
settings = QSettings()
settings.setValue(setting_name, checked != 0)
def save_window_size(self):
self.settings.setValue("save_size", self.save_size.isChecked())
self.settings.remove("window_size")
def save_path(self):
self.save_path_button.setDisabled(True)
self.update_path()
def update_lang(self, i: int):
settings = QSettings()
settings.setValue("language", languages[i][0])
self.settings.setValue("language", languages[i][0])
self.lang_widget.info_text.setText(self.tr("Restart Application to activate changes"))
def update_path(self):
settings = QSettings()
old_path = settings.value("img_dir", type=str)
old_path = self.settings.value("img_dir", type=str)
new_path = self.select_path.text()
if old_path != new_path:
@ -99,4 +104,4 @@ class RareSettings(QScrollArea):
for i in os.listdir(old_path):
shutil.move(os.path.join(old_path, i), os.path.join(new_path, i))
os.rmdir(old_path)
settings.setValue("img_dir", new_path)
self.settings.setValue("img_dir", new_path)

View file

@ -5,9 +5,6 @@ class SettingsWidget(QGroupBox):
def __init__(self, text: str, widget: QWidget, accept_button: QPushButton = None):
super(SettingsWidget, self).__init__()
self.setObjectName("settings_widget")
self.setStyleSheet("""QGroupBox{border: 1px solid gray;
border-radius: 3px;
margin-top: 1ex;}""")
self.layout = QVBoxLayout()
self.info_text = QLabel("")
self.setTitle(text)

View file

@ -50,7 +50,7 @@
<context>
<name>BaseInstalledWidget</name>
<message>
<location filename="../components/tabs/games/game_widgets/base_installed_widget.py" line="34"/>
<location filename="../components/tabs/games/game_widgets/base_installed_widget.py" line="32"/>
<source>Do you want to launch {}</source>
<translation>Möchtest du {} starten</translation>
</message>
@ -309,12 +309,12 @@
<context>
<name>GameList</name>
<message>
<location filename="../components/tabs/games/game_list.py" line="162"/>
<location filename="../components/tabs/games/game_list.py" line="161"/>
<source>Launch</source>
<translation>Starten</translation>
</message>
<message>
<location filename="../components/tabs/games/game_list.py" line="177"/>
<location filename="../components/tabs/games/game_list.py" line="176"/>
<source>Game running</source>
<translation>Spiel läuft</translation>
</message>
@ -324,7 +324,7 @@
<translation>Installierte Spiele: {} Verfügbare Spiele: {}</translation>
</message>
<message>
<location filename="../components/tabs/games/game_list.py" line="172"/>
<location filename="../components/tabs/games/game_list.py" line="171"/>
<source>Sync CLoud saves</source>
<translation>Spielstand synchronisieren</translation>
</message>
@ -360,40 +360,50 @@
<translation>Überprüfung nach Updates beim Start überspringen</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="77"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="86"/>
<source>Save</source>
<translation>Speichern</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="53"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="62"/>
<source>Wrapper (e.g. optirun)</source>
<translation>Wrapper (z.B. optirun)</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="73"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="82"/>
<source>Proton Wrapper</source>
<translation>Proton Version</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="79"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="88"/>
<source>Proton prefix</source>
<translation>Protonprefix</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="170"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="178"/>
<source>No permission to create folder</source>
<translation>Keine Berechtigung den Ordner zu erstellen</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="214"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="222"/>
<source>Please select path for proton prefix</source>
<translation>Bitte wähle den Pfad zum Protonprefix</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="43"/>
<location filename="../components/tabs/games/game_info/game_settings.py" line="51"/>
<source>Auto sync with cloud</source>
<translation>Speicherstände automatisch mit der Cloud synchronisieren</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="43"/>
<source>Start parameter</source>
<translation>Start Parameter</translation>
</message>
<message>
<location filename="../components/tabs/games/game_info/game_settings.py" line="45"/>
<source>Launch parameters</source>
<translation>Start Parameter</translation>
</message>
</context>
<context>
<name>GameWidgetInstalled</name>
@ -709,7 +719,7 @@ Installationsgröße: {} GB</translation>
<context>
<name>MainWindow</name>
<message>
<location filename="../components/main_window.py" line="21"/>
<location filename="../components/main_window.py" line="29"/>
<source>There is a download active. Do you really want to exit app?</source>
<translation>Ein Download läuft noch. Möchtest du die App wirklich beenden?</translation>
</message>
@ -781,7 +791,7 @@ Installationsgröße: {} GB</translation>
<translation>Sprache</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="85"/>
<location filename="../components/tabs/settings/rare.py" line="91"/>
<source>Restart Application to activate changes</source>
<translation>Starte die App neu um die Änderungen zu aktivieren</translation>
</message>
@ -805,41 +815,56 @@ Installationsgröße: {} GB</translation>
<source>Auto sync with cloud</source>
<translation>Speicherstände automatisch mit der Cloud synchronisieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="63"/>
<source>Sync with cloud</source>
<translation>Automatisch Synchronisieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="70"/>
<source>Save size</source>
<translation>Größe Speichern</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="72"/>
<source>Save size of window after restart</source>
<translation>Die Fenstergröße nach dem Beenden speichern</translation>
</message>
</context>
<context>
<name>SyncSaves</name>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="62"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="63"/>
<source>Cloud Saves</source>
<translation>Cloud Speicherstände</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="52"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="53"/>
<source>Found Saves for folowing Games</source>
<translation>Spielstände für folgende Spiele gefunden</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="62"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="63"/>
<source>Your games does not support Cloud Saves</source>
<translation>Deine Spiele unterstützen keine Online Speicherstände</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="67"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="68"/>
<source>Sync all games</source>
<translation>Alle Spiele synchronisieren</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="134"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="140"/>
<source>Found no savepath</source>
<translation>Kein Speicherort gefunden</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="134"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="140"/>
<source>No save path was found. Please select path or skip</source>
<translation>Kein Speicherort wurde gefunden. Wähle einen Ordner oder überspringe</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/__init__.py" line="118"/>
<location filename="../components/tabs/cloud_saves/__init__.py" line="124"/>
<source>You finished playing game, but Remote game is newer. Do you want to download anyway? This could remove your game progress. Please check your save path or make a backup</source>
<translation>Das Spiel wurde beendet, aber der Onlinespeicherstand ist aktueller. Willst du den wirklich runterladen? Dies könnte deinen Spielfortschritt zurücksetzen. Prüfe bitte den Speicherpfad oder mache ein Backup</translation>
</message>