Skip to content

Commit

Permalink
Add refresh option
Browse files Browse the repository at this point in the history
Signed-off-by: tsukinaha <sakuovds@gmail.com>
  • Loading branch information
tsukinaha committed Nov 20, 2024
1 parent 6054521 commit 83e9474
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions resources/moe.tsuna.tsukimi.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,9 @@
<summary>any item picture scale</summary>
<default>0.900</default>
</key>
<key name="is-refresh" type="b">
<summary>Frefresh when returning to home page</summary>
<default>false</default>
</key>
</schema>
</schemalist>
5 changes: 5 additions & 0 deletions resources/ui/account_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@
</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="refresh_control">
<property name="title" translatable="yes">Refresh when returning to home page</property>
</object>
</child>
</object>
</child>
<child>
Expand Down
5 changes: 5 additions & 0 deletions src/ui/models/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ impl Settings {
const KEY_MPV_VIDEO_SCALE: &'static str = "mpv-video-scale"; // i32
const KEY_MPV_CONFIG_DIR: &'static str = "mpv-config-path"; // String
const KEY_POST_SCALE: &'static str = "post-scale"; // f64
const KEY_IS_REFRESH: &'static str = "is-refresh"; // bool

pub fn is_refresh(&self) -> bool {
self.boolean(Self::KEY_IS_REFRESH)
}

pub fn post_scale(&self) -> f64 {
self.double(Self::KEY_POST_SCALE)
Expand Down
5 changes: 5 additions & 0 deletions src/ui/widgets/account_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ mod imp {
#[template_child]
pub threadspinrow: TemplateChild<adw::SpinRow>,
#[template_child]
pub refresh_control: TemplateChild<adw::SwitchRow>,
#[template_child]
pub selectlastcontrol: TemplateChild<adw::SwitchRow>,
#[template_child]
pub backgroundblurspinrow: TemplateChild<adw::SpinRow>,
Expand Down Expand Up @@ -451,6 +453,9 @@ impl AccountSettings {
SETTINGS
.bind("post-scale", &imp.post_spinrow.get(), "value")
.build();
SETTINGS
.bind("is-refresh", &imp.refresh_control.get(), "active")
.build();

let action_group = gio::SimpleActionGroup::new();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl Window {

imp.popbutton.set_visible(false);
imp.navipage.set_title("");
if imp.insidestack.visible_child_name() == Some("homepage".into()) {
if imp.insidestack.visible_child_name() == Some("homepage".into()) && SETTINGS.is_refresh() {
let binding = imp.homepage.child();
let Some(homepage) = binding.and_downcast_ref::<HomePage>() else {
return;
Expand Down

0 comments on commit 83e9474

Please sign in to comment.