Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Settings): darken images on dark mode #610

Merged
merged 4 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/dev.geopjr.Tuba.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
<key name="spellchecker-enabled" type="b">
<default>true</default>
</key>
<key name="darken-images-on-dark-mode" type="b">
<default>false</default>
</key>

<key name="window-w" type="i">
<default>600</default>
Expand Down
4 changes: 4 additions & 0 deletions data/style-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
.ttl-post.direct:hover {
background-color: lighter(alpha(@warning_bg_color, .1));
}

.ttl-darken-images avatar:not(:hover), .ttl-darken-images picture:not(:hover) {
filter: brightness(.8) contrast(1.2);
}
5 changes: 5 additions & 0 deletions data/ui/dialogs/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
<property name="title" translatable="yes">Show Link Preview Cards</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="darken_images_on_dark_mode">
<property name="title" translatable="yes">Darken images on dark mode</property>
</object>
</child>
</object>
</child>
<child>
Expand Down
5 changes: 5 additions & 0 deletions src/Dialogs/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ public class Tuba.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable {
app.notify["is-mobile"].connect (update_selected_home_item);
media_viewer.bind_property ("visible", split_view, "can-focus", GLib.BindingFlags.SYNC_CREATE | GLib.BindingFlags.INVERT_BOOLEAN);
media_viewer.notify["visible"].connect (on_media_viewer_toggle);
settings.notify["darken-images-on-dark-mode"].connect (settings_updated);

app.toast.connect (add_toast);
}

private void settings_updated () {
Tuba.toggle_css (split_view, settings.darken_images_on_dark_mode, "ttl-darken-images");
}

private void add_toast (string content, uint timeout = 0) {
toast_overlay.add_toast (new Adw.Toast (content) {
timeout = timeout
Expand Down
2 changes: 2 additions & 0 deletions src/Dialogs/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesWindow {
[GtkChild] unowned Adw.SwitchRow use_blurhash;
[GtkChild] unowned Adw.SwitchRow group_push_notifications;
[GtkChild] unowned Adw.SwitchRow advanced_boost_dialog;
[GtkChild] unowned Adw.SwitchRow darken_images_on_dark_mode;

[GtkChild] unowned Adw.SwitchRow new_followers_notifications_switch;
[GtkChild] unowned Adw.SwitchRow new_follower_requests_notifications_switch;
Expand Down Expand Up @@ -127,6 +128,7 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesWindow {
settings.bind ("use-blurhash", use_blurhash, "active", SettingsBindFlags.DEFAULT);
settings.bind ("group-push-notifications", group_push_notifications, "active", SettingsBindFlags.DEFAULT);
settings.bind ("advanced-boost-dialog", advanced_boost_dialog, "active", SettingsBindFlags.DEFAULT);
settings.bind ("darken-images-on-dark-mode", darken_images_on_dark_mode, "active", SettingsBindFlags.DEFAULT);

post_visibility_combo_row.notify["selected-item"].connect (on_post_visibility_changed);

Expand Down
4 changes: 3 additions & 1 deletion src/Services/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class Tuba.Settings : GLib.Settings {
public bool advanced_boost_dialog { get; set; }
public bool reply_to_old_post_reminder { get; set; }
public bool spellchecker_enabled { get; set; }
public bool darken_images_on_dark_mode { get; set; }

private static string[] keys_to_init = {
"active-account",
Expand All @@ -120,7 +121,8 @@ public class Tuba.Settings : GLib.Settings {
"group-push-notifications",
"advanced-boost-dialog",
"reply-to-old-post-reminder",
"spellchecker-enabled"
"spellchecker-enabled",
"darken-images-on-dark-mode"
};

public Settings () {
Expand Down
Loading