Auto sync saves on startup if enabled
This commit is contained in:
parent
4378df2791
commit
b4d10cc77e
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
from PyQt5.QtCore import QThread, pyqtSignal, Qt
|
from PyQt5.QtCore import QThread, pyqtSignal, Qt, QSettings
|
||||||
from PyQt5.QtWidgets import QVBoxLayout, QPushButton, QHBoxLayout, QLabel, QGroupBox
|
from PyQt5.QtWidgets import QVBoxLayout, QPushButton, QHBoxLayout, QLabel, QGroupBox
|
||||||
|
|
||||||
from custom_legendary.core import LegendaryCore
|
from custom_legendary.core import LegendaryCore
|
||||||
|
@ -167,6 +167,11 @@ class SyncWidget(QGroupBox):
|
||||||
self.layout.addStretch(1)
|
self.layout.addStretch(1)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
if self.res == SaveGameStatus.REMOTE_NEWER:
|
||||||
|
settings = QSettings()
|
||||||
|
if settings.value(f"{igame.app_name}/auto_sync_cloud", False, bool):
|
||||||
|
self.download()
|
||||||
|
|
||||||
def change_path(self):
|
def change_path(self):
|
||||||
path = PathInputDialog("Select directory", "Select savepath. Warning: Do not change if you are not sure",
|
path = PathInputDialog("Select directory", "Select savepath. Warning: Do not change if you are not sure",
|
||||||
self.igame.save_path).get_path()
|
self.igame.save_path).get_path()
|
||||||
|
|
|
@ -830,7 +830,7 @@ Installationsgröße: {} GB</translation>
|
||||||
<context>
|
<context>
|
||||||
<name>MainWindow</name>
|
<name>MainWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/main_window.py" line="82"/>
|
<location filename="../components/main_window.py" line="84"/>
|
||||||
<source>There is a download active. Do you really want to exit app?</source>
|
<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>
|
<translation>Ein Download läuft noch. Möchtest du die App wirklich beenden?</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -938,85 +938,90 @@ Installationsgröße: {} GB</translation>
|
||||||
<context>
|
<context>
|
||||||
<name>RareSettings</name>
|
<name>RareSettings</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="25"/>
|
<location filename="../components/tabs/settings/rare.py" line="27"/>
|
||||||
<source>Rare settings</source>
|
<source>Rare settings</source>
|
||||||
<translation>Rare Einstellungen</translation>
|
<translation>Rare Einstellungen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="48"/>
|
<location filename="../components/tabs/settings/rare.py" line="51"/>
|
||||||
<source>Save</source>
|
<source>Save</source>
|
||||||
<translation>Speichern</translation>
|
<translation>Speichern</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="50"/>
|
<location filename="../components/tabs/settings/rare.py" line="53"/>
|
||||||
<source>Image Directory</source>
|
<source>Image Directory</source>
|
||||||
<translation>Ordner für Bilder</translation>
|
<translation>Ordner für Bilder</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="61"/>
|
<location filename="../components/tabs/settings/rare.py" line="64"/>
|
||||||
<source>Language</source>
|
<source>Language</source>
|
||||||
<translation>Sprache</translation>
|
<translation>Sprache</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="87"/>
|
<location filename="../components/tabs/settings/rare.py" line="102"/>
|
||||||
<source>Restart Application to activate changes</source>
|
<source>Restart Application to activate changes</source>
|
||||||
<translation>Starte die App neu um die Änderungen zu aktivieren</translation>
|
<translation>Starte die App neu um die Änderungen zu aktivieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="33"/>
|
<location filename="../components/tabs/settings/rare.py" line="36"/>
|
||||||
<source>Confirm launch of game</source>
|
<source>Confirm launch of game</source>
|
||||||
<translation>Start des Spiels bestätigen</translation>
|
<translation>Start des Spiels bestätigen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="30"/>
|
<location filename="../components/tabs/settings/rare.py" line="33"/>
|
||||||
<source>Exit to System Tray Icon</source>
|
<source>Exit to System Tray Icon</source>
|
||||||
<translation>Beim verlassen auf das System Tray Icon minimieren</translation>
|
<translation>Beim verlassen auf das System Tray Icon minimieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="30"/>
|
<location filename="../components/tabs/settings/rare.py" line="33"/>
|
||||||
<source>Hide to System Tray Icon</source>
|
<source>Hide to System Tray Icon</source>
|
||||||
<translation>In das System Tray Icon minimieren</translation>
|
<translation>In das System Tray Icon minimieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="35"/>
|
<location filename="../components/tabs/settings/rare.py" line="38"/>
|
||||||
<source>Auto sync with cloud</source>
|
<source>Auto sync with cloud</source>
|
||||||
<translation>Speicherstände automatisch mit der Cloud synchronisieren</translation>
|
<translation>Speicherstände automatisch mit der Cloud synchronisieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="35"/>
|
<location filename="../components/tabs/settings/rare.py" line="38"/>
|
||||||
<source>Sync with cloud</source>
|
<source>Sync with cloud</source>
|
||||||
<translation>Automatisch Synchronisieren</translation>
|
<translation>Automatisch Synchronisieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="38"/>
|
<location filename="../components/tabs/settings/rare.py" line="41"/>
|
||||||
<source>Save size</source>
|
<source>Save size</source>
|
||||||
<translation>Größe Speichern</translation>
|
<translation>Größe Speichern</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="38"/>
|
<location filename="../components/tabs/settings/rare.py" line="41"/>
|
||||||
<source>Save size of window after restart</source>
|
<source>Save size of window after restart</source>
|
||||||
<translation>Die Fenstergröße nach dem Beenden speichern</translation>
|
<translation>Die Fenstergröße nach dem Beenden speichern</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="31"/>
|
<location filename="../components/tabs/settings/rare.py" line="34"/>
|
||||||
<source>Automatically update Games on startup</source>
|
<source>Automatically update Games on startup</source>
|
||||||
<translation>Spiele automatisch updaten</translation>
|
<translation>Spiele automatisch updaten</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="31"/>
|
<location filename="../components/tabs/settings/rare.py" line="34"/>
|
||||||
<source>Auto updates</source>
|
<source>Auto updates</source>
|
||||||
<translation>Automatische Updates</translation>
|
<translation>Automatische Updates</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="36"/>
|
<location filename="../components/tabs/settings/rare.py" line="39"/>
|
||||||
<source>Show Notifications after Downloads</source>
|
<source>Show Notifications after Downloads</source>
|
||||||
<translation>Benachrichtigung nach Abschluss des Downloads anzeigen</translation>
|
<translation>Benachrichtigung nach Abschluss des Downloads anzeigen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/settings/rare.py" line="36"/>
|
<location filename="../components/tabs/settings/rare.py" line="39"/>
|
||||||
<source>Show notification</source>
|
<source>Show notification</source>
|
||||||
<translation>Benachrichtigung anzeigen</translation>
|
<translation>Benachrichtigung anzeigen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../components/tabs/settings/rare.py" line="76"/>
|
||||||
|
<source>Open Log directory</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SyncSaves</name>
|
<name>SyncSaves</name>
|
||||||
|
@ -1134,22 +1139,22 @@ Installationsgröße: {} GB</translation>
|
||||||
<translation>Pfad ändern</translation>
|
<translation>Pfad ändern</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="181"/>
|
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="186"/>
|
||||||
<source>Uploading...</source>
|
<source>Uploading...</source>
|
||||||
<translation>Hochladen...</translation>
|
<translation>Hochladen...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="189"/>
|
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="194"/>
|
||||||
<source>Upload finished</source>
|
<source>Upload finished</source>
|
||||||
<translation>Hochladen abgeschlossen</translation>
|
<translation>Hochladen abgeschlossen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="199"/>
|
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="204"/>
|
||||||
<source>Downloading...</source>
|
<source>Downloading...</source>
|
||||||
<translation>Runterladen...</translation>
|
<translation>Runterladen...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="205"/>
|
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="210"/>
|
||||||
<source>Download finished</source>
|
<source>Download finished</source>
|
||||||
<translation>Download abgeschlossen</translation>
|
<translation>Download abgeschlossen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -11,14 +11,15 @@ from PyQt5.QtCore import pyqtSignal, QLocale, QSettings
|
||||||
# Windows
|
# Windows
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
|
# Mac not supported
|
||||||
|
|
||||||
from rare import lang_path, __version__, style_path
|
|
||||||
|
from rare import lang_path
|
||||||
from custom_legendary.core import LegendaryCore
|
from custom_legendary.core import LegendaryCore
|
||||||
|
|
||||||
logger = getLogger("Utils")
|
logger = getLogger("Utils")
|
||||||
s = QSettings("Rare", "Rare")
|
s = QSettings("Rare", "Rare")
|
||||||
IMAGE_DIR = s.value("img_dir", os.path.expanduser("~/.cache/rare/images"), type=str)
|
IMAGE_DIR = s.value("img_dir", os.path.expanduser("~/.cache/rare/images"), type=str)
|
||||||
logger.info("IMAGE DIRECTORY: " + IMAGE_DIR)
|
|
||||||
|
|
||||||
|
|
||||||
def download_images(signal: pyqtSignal, core: LegendaryCore):
|
def download_images(signal: pyqtSignal, core: LegendaryCore):
|
||||||
|
@ -38,7 +39,7 @@ def download_images(signal: pyqtSignal, core: LegendaryCore):
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
shutil.rmtree(f"{IMAGE_DIR}/{game.app_name}")
|
shutil.rmtree(f"{IMAGE_DIR}/{game.app_name}")
|
||||||
download_image(game)
|
download_image(game)
|
||||||
signal.emit(i/len(game_list)*100)
|
signal.emit(i / len(game_list) * 100)
|
||||||
|
|
||||||
|
|
||||||
def download_image(game, force=False):
|
def download_image(game, force=False):
|
||||||
|
@ -69,7 +70,7 @@ def download_image(game, force=False):
|
||||||
f.write(requests.get(url).content)
|
f.write(requests.get(url).content)
|
||||||
try:
|
try:
|
||||||
img = Image.open(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
|
img = Image.open(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
|
||||||
img = img.resize((200, int(200*4/3)))
|
img = img.resize((200, int(200 * 4 / 3)))
|
||||||
img.save(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
|
img.save(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
|
||||||
except UnidentifiedImageError as e:
|
except UnidentifiedImageError as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
|
@ -84,7 +85,7 @@ def download_image(game, force=False):
|
||||||
|
|
||||||
bg = Image.open(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png")
|
bg = Image.open(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png")
|
||||||
uninstalledArt = bg.convert('L')
|
uninstalledArt = bg.convert('L')
|
||||||
uninstalledArt = uninstalledArt.resize((200, int(200*4/3)))
|
uninstalledArt = uninstalledArt.resize((200, int(200 * 4 / 3)))
|
||||||
uninstalledArt.save(f'{IMAGE_DIR}/{game.app_name}/UninstalledArt.png')
|
uninstalledArt.save(f'{IMAGE_DIR}/{game.app_name}/UninstalledArt.png')
|
||||||
elif os.path.isfile(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png"):
|
elif os.path.isfile(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png"):
|
||||||
bg: Image.Image = Image.open(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png")
|
bg: Image.Image = Image.open(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png")
|
||||||
|
@ -202,9 +203,11 @@ def create_desktop_link(app_name, core: LegendaryCore, type_of_link="desktop"):
|
||||||
shortcut.WorkingDirectory = os.getcwd()
|
shortcut.WorkingDirectory = os.getcwd()
|
||||||
|
|
||||||
# Icon
|
# Icon
|
||||||
if not os.path.exists(icon+".ico"):
|
if not os.path.exists(icon + ".ico"):
|
||||||
img = Image.open(icon+".png")
|
img = Image.open(icon + ".png")
|
||||||
img.save(icon+".ico")
|
img.save(icon + ".ico")
|
||||||
logger.info("Create Icon")
|
logger.info("Create Icon")
|
||||||
shortcut.IconLocation = os.path.join(icon+ ".ico")
|
shortcut.IconLocation = os.path.join(icon + ".ico")
|
||||||
|
|
||||||
|
# Save shortcut
|
||||||
shortcut.save()
|
shortcut.save()
|
||||||
|
|
Loading…
Reference in a new issue