From a1bf94904c07aa4b4ce8b843e741332e68f75890 Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Sat, 25 Mar 2023 19:52:26 +0100 Subject: [PATCH] Add option to save game covers losslessly --- data/gtk/preferences.blp | 16 ++++++++++++---- data/hu.kramo.Cartridges.gschema.xml | 3 +++ src/preferences.py | 26 ++++++++++++++++++-------- src/utils/save_cover.py | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/data/gtk/preferences.blp b/data/gtk/preferences.blp index a32d358..94c6b00 100644 --- a/data/gtk/preferences.blp +++ b/data/gtk/preferences.blp @@ -6,7 +6,7 @@ template PreferencesWindow : Adw.PreferencesWindow { default-height: 500; Adw.PreferencesPage page { - Adw.PreferencesGroup { + Adw.PreferencesGroup general_group { title: _("General"); Adw.ActionRow { @@ -16,6 +16,14 @@ template PreferencesWindow : Adw.PreferencesWindow { valign: center; } } + Adw.ActionRow { + title: _("High Quality Images"); + subtitle: _("Save game covers losslessly at the cost of storage"); + + Switch high_quality_images_switch { + valign: center; + } + } } Adw.PreferencesGroup steam_group { @@ -72,7 +80,7 @@ template PreferencesWindow : Adw.PreferencesWindow { Adw.ActionRow { title: _("Import Epic Games"); - Switch import_epic_games_switch { + Switch heroic_epic_switch { valign: center; } } @@ -80,7 +88,7 @@ template PreferencesWindow : Adw.PreferencesWindow { Adw.ActionRow { title: _("Import GOG Games"); - Switch import_gog_games_switch { + Switch heroic_gog_switch { valign: center; } } @@ -88,7 +96,7 @@ template PreferencesWindow : Adw.PreferencesWindow { Adw.ActionRow { title: _("Import Sideloaded Games"); - Switch import_sideload_games_switch { + Switch heroic_sideloaded_switch { valign: center; } } diff --git a/data/hu.kramo.Cartridges.gschema.xml b/data/hu.kramo.Cartridges.gschema.xml index 22b1f79..06ae1aa 100644 --- a/data/hu.kramo.Cartridges.gschema.xml +++ b/data/hu.kramo.Cartridges.gschema.xml @@ -24,6 +24,9 @@ "~/.var/app/com.usebottles.bottles/data/bottles/" + + + false diff --git a/src/preferences.py b/src/preferences.py index abb1744..71b20ad 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -27,20 +27,24 @@ class PreferencesWindow(Adw.PreferencesWindow): __gtype_name__ = "PreferencesWindow" page = Gtk.Template.Child() - bottles_group = Gtk.Template.Child() exit_after_launch_switch = Gtk.Template.Child() - import_epic_games_switch = Gtk.Template.Child() - import_gog_games_switch = Gtk.Template.Child() - import_sideload_games_switch = Gtk.Template.Child() steam_file_chooser_button = Gtk.Template.Child() steam_extra_file_chooser_button = Gtk.Template.Child() - steam_clear_button = Gtk.Template.Child() steam_clear_button_revealer = Gtk.Template.Child() + steam_clear_button = Gtk.Template.Child() + heroic_file_chooser_button = Gtk.Template.Child() + heroic_epic_switch = Gtk.Template.Child() + heroic_gog_switch = Gtk.Template.Child() + heroic_sideloaded_switch = Gtk.Template.Child() + + bottles_group = Gtk.Template.Child() bottles_file_chooser_button = Gtk.Template.Child() + high_quality_images_switch = Gtk.Template.Child() + def __init__(self, parent_widget, **kwargs): super().__init__(**kwargs) @@ -54,19 +58,25 @@ class PreferencesWindow(Adw.PreferencesWindow): ) schema.bind( "heroic-import-epic", - self.import_epic_games_switch, + self.heroic_epic_switch, "active", Gio.SettingsBindFlags.DEFAULT, ) schema.bind( "heroic-import-gog", - self.import_gog_games_switch, + self.heroic_gog_switch, "active", Gio.SettingsBindFlags.DEFAULT, ) schema.bind( "heroic-import-sideload", - self.import_sideload_games_switch, + self.heroic_sideloaded_switch, + "active", + Gio.SettingsBindFlags.DEFAULT, + ) + schema.bind( + "high-quality-images", + self.high_quality_images_switch, "active", Gio.SettingsBindFlags.DEFAULT, ) diff --git a/src/utils/save_cover.py b/src/utils/save_cover.py index c0d9c2c..70599ea 100644 --- a/src/utils/save_cover.py +++ b/src/utils/save_cover.py @@ -48,6 +48,6 @@ def save_cover(game, parent_widget, file_path, pixbuf=None, game_id=None): open_file.replace(None, False, Gio.FileCreateFlags.NONE), "tiff", ["compression"], - ["7"], + ["8"] if parent_widget.schema.get_boolean("high-quality-images") else ["7"], callback=cover_callback, )