Release v0.2.10
This commit is contained in:
parent
ae1f0c7c4a
commit
f7c67c1a79
9 changed files with 87 additions and 15 deletions
|
|
@ -12,6 +12,7 @@ pub struct AppConfig {
|
|||
pub fast_image_loading: bool,
|
||||
pub case_insensitive_sort: bool,
|
||||
pub viewer_mode: ViewerMode,
|
||||
pub two_page_right_to_left: bool,
|
||||
pub locations: Vec<LocationProfile>,
|
||||
pub favorites: Vec<FavoriteEntry>,
|
||||
}
|
||||
|
|
@ -23,6 +24,7 @@ impl Default for AppConfig {
|
|||
fast_image_loading: true,
|
||||
case_insensitive_sort: true,
|
||||
viewer_mode: ViewerMode::FitWidth,
|
||||
two_page_right_to_left: true,
|
||||
locations: Vec::new(),
|
||||
favorites: Vec::new(),
|
||||
}
|
||||
|
|
@ -179,6 +181,7 @@ mod tests {
|
|||
fast_image_loading: true,
|
||||
case_insensitive_sort: true,
|
||||
viewer_mode: ViewerMode::FitWidth,
|
||||
two_page_right_to_left: true,
|
||||
locations: vec![LocationProfile {
|
||||
name: "테스트".into(),
|
||||
kind: LocationKind::Sftp,
|
||||
|
|
@ -215,6 +218,7 @@ mod tests {
|
|||
assert!(decoded.fast_image_loading);
|
||||
assert!(decoded.case_insensitive_sort);
|
||||
assert_eq!(decoded.viewer_mode, ViewerMode::FitWidth);
|
||||
assert!(decoded.two_page_right_to_left);
|
||||
assert!(decoded.favorites.is_empty());
|
||||
}
|
||||
|
||||
|
|
@ -231,4 +235,17 @@ mod tests {
|
|||
}
|
||||
assert_eq!(ViewerMode::from_dropdown_index(99), ViewerMode::FitWidth);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_page_direction_defaults_to_rtl_and_round_trips_ltr() {
|
||||
let existing: AppConfig = toml::from_str("cache_quota_gb = 10\n").unwrap();
|
||||
assert!(existing.two_page_right_to_left);
|
||||
|
||||
let config = AppConfig {
|
||||
two_page_right_to_left: false,
|
||||
..AppConfig::default()
|
||||
};
|
||||
let decoded: AppConfig = toml::from_str(&toml::to_string(&config).unwrap()).unwrap();
|
||||
assert!(!decoded.two_page_right_to_left);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,6 +223,11 @@ pub struct ViewModeControl {
|
|||
pub change: Rc<dyn Fn(u32)>,
|
||||
}
|
||||
|
||||
pub struct TwoPageDirectionControl {
|
||||
pub selected: u32,
|
||||
pub change: Rc<dyn Fn(u32) -> bool>,
|
||||
}
|
||||
|
||||
pub struct FileViewerControls {
|
||||
pub sibling_navigator: Option<SiblingNavigator>,
|
||||
pub favorite_control: FavoriteControl,
|
||||
|
|
@ -230,6 +235,7 @@ pub struct FileViewerControls {
|
|||
pub file_drop_control: FileDropControl,
|
||||
pub reuse_window: Option<gtk::ApplicationWindow>,
|
||||
pub view_mode_control: Option<ViewModeControl>,
|
||||
pub two_page_direction_control: Option<TwoPageDirectionControl>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -274,7 +280,10 @@ impl ViewerWindow {
|
|||
file_drop_control,
|
||||
reuse_window,
|
||||
view_mode_control: _,
|
||||
two_page_direction_control,
|
||||
} = controls;
|
||||
let direction_control = two_page_direction_control
|
||||
.expect("archive viewer requires a two-page direction control");
|
||||
let title = source.display_name.clone();
|
||||
let file_list_query = reuse_window
|
||||
.as_ref()
|
||||
|
|
@ -326,7 +335,8 @@ impl ViewerWindow {
|
|||
let page_label = gtk::Label::new(Some("- / -"));
|
||||
page_label.set_hexpand(true);
|
||||
let direction_dropdown = gtk::DropDown::from_strings(&["좌→우", "우→좌"]);
|
||||
direction_dropdown.set_selected(1);
|
||||
let direction_selected = direction_control.selected.min(1);
|
||||
direction_dropdown.set_selected(direction_selected);
|
||||
let mode_dropdown = gtk::DropDown::from_strings(&[
|
||||
"100%",
|
||||
"폭 맞춤",
|
||||
|
|
@ -451,6 +461,8 @@ impl ViewerWindow {
|
|||
download_button,
|
||||
file_download: download_control.download,
|
||||
view_mode_change: view_mode_control.change,
|
||||
direction_change: direction_control.change,
|
||||
direction_selected: Cell::new(direction_selected),
|
||||
seek_hide_timer: RefCell::new(None),
|
||||
seek_interacting: Cell::new(false),
|
||||
last_pointer_position: Cell::new(None),
|
||||
|
|
@ -620,6 +632,8 @@ struct ViewerController {
|
|||
download_button: gtk::Button,
|
||||
file_download: Rc<dyn Fn(gtk::Window, gtk::Label)>,
|
||||
view_mode_change: Rc<dyn Fn(u32)>,
|
||||
direction_change: Rc<dyn Fn(u32) -> bool>,
|
||||
direction_selected: Cell<u32>,
|
||||
seek_hide_timer: RefCell<Option<glib::SourceId>>,
|
||||
seek_interacting: Cell<bool>,
|
||||
last_pointer_position: Cell<Option<(f64, f64)>>,
|
||||
|
|
@ -677,11 +691,18 @@ impl ViewerController {
|
|||
}
|
||||
});
|
||||
let controller = Rc::downgrade(self);
|
||||
self.direction_dropdown.connect_selected_notify(move |_| {
|
||||
if let Some(controller) = controller.upgrade() {
|
||||
controller.render();
|
||||
}
|
||||
});
|
||||
self.direction_dropdown
|
||||
.connect_selected_notify(move |dropdown| {
|
||||
if let Some(controller) = controller.upgrade() {
|
||||
let selected = dropdown.selected().min(1);
|
||||
if (controller.direction_change)(selected) {
|
||||
controller.direction_selected.set(selected);
|
||||
controller.render();
|
||||
} else {
|
||||
dropdown.set_selected(controller.direction_selected.get());
|
||||
}
|
||||
}
|
||||
});
|
||||
let controller = Rc::downgrade(self);
|
||||
self.favorite_button.connect_clicked(move |_| {
|
||||
if let Some(controller) = controller.upgrade() {
|
||||
|
|
@ -2184,6 +2205,7 @@ impl MediaViewerWindow {
|
|||
file_drop_control,
|
||||
reuse_window,
|
||||
view_mode_control,
|
||||
two_page_direction_control: _,
|
||||
} = controls;
|
||||
let title = source.display_name.clone();
|
||||
let file_list_query = reuse_window
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ use crate::source::{
|
|||
};
|
||||
use crate::viewer::{
|
||||
FavoriteControl, FileDownloadControl, FileDropControl, FileViewerControls, MediaViewerWindow,
|
||||
SiblingFile, SiblingFileActions, SiblingNavigator, SiblingTarget, ViewModeControl,
|
||||
ViewerWindow, install_file_drop_target, set_viewer_header, set_viewer_loading,
|
||||
SiblingFile, SiblingFileActions, SiblingNavigator, SiblingTarget, TwoPageDirectionControl,
|
||||
ViewModeControl, ViewerWindow, install_file_drop_target, set_viewer_header, set_viewer_loading,
|
||||
};
|
||||
use crate::zip_cache::ZipCache;
|
||||
|
||||
|
|
@ -997,6 +997,7 @@ impl BrowserController {
|
|||
let Some(application) = controller.window.application() else {
|
||||
return;
|
||||
};
|
||||
let direction_control = controller.two_page_direction_control();
|
||||
ViewerWindow::open(
|
||||
&application,
|
||||
source,
|
||||
|
|
@ -1011,6 +1012,7 @@ impl BrowserController {
|
|||
file_drop_control: controller.file_drop_control(),
|
||||
reuse_window,
|
||||
view_mode_control: None,
|
||||
two_page_direction_control: Some(direction_control),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -1075,6 +1077,7 @@ impl BrowserController {
|
|||
file_drop_control: controller.file_drop_control(),
|
||||
reuse_window,
|
||||
view_mode_control,
|
||||
two_page_direction_control: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -1461,6 +1464,33 @@ impl BrowserController {
|
|||
}
|
||||
}
|
||||
|
||||
fn two_page_direction_control(self: &Rc<Self>) -> TwoPageDirectionControl {
|
||||
let selected = u32::from(self.config.borrow().two_page_right_to_left);
|
||||
let controller = Rc::downgrade(self);
|
||||
TwoPageDirectionControl {
|
||||
selected,
|
||||
change: Rc::new(move |index| {
|
||||
let Some(controller) = controller.upgrade() else {
|
||||
return false;
|
||||
};
|
||||
let right_to_left = index == 1;
|
||||
if controller.config.borrow().two_page_right_to_left == right_to_left {
|
||||
return true;
|
||||
}
|
||||
let mut updated = controller.config.borrow().clone();
|
||||
updated.two_page_right_to_left = right_to_left;
|
||||
if let Err(error) = updated.save(&controller.config_path) {
|
||||
controller
|
||||
.status_label
|
||||
.set_text(&format!("2페이지 방향을 저장할 수 없습니다: {error:#}"));
|
||||
return false;
|
||||
}
|
||||
*controller.config.borrow_mut() = updated;
|
||||
true
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_favorite(&self, entry: &BrowserEntry, profile: &LocationProfile) -> bool {
|
||||
let mut updated = self.config.borrow().clone();
|
||||
let was_active = self.is_favorite(&entry.uri);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue