Merge pull request #430 from 21pages/refactor-edge-scroll-edge-thickness
optioin `edge-scroll-edge-thickness`
This commit is contained in:
@@ -247,13 +247,18 @@ pub struct PeerConfig {
|
||||
skip_serializing_if = "String::is_empty"
|
||||
)]
|
||||
pub view_style: String,
|
||||
// Image scroll style, scrollbar or scroll auto
|
||||
// Image scroll style, scrolledge, scrollbar or scroll auto
|
||||
#[serde(
|
||||
default = "PeerConfig::default_scroll_style",
|
||||
deserialize_with = "PeerConfig::deserialize_scroll_style",
|
||||
skip_serializing_if = "String::is_empty"
|
||||
)]
|
||||
pub scroll_style: String,
|
||||
#[serde(
|
||||
default = "PeerConfig::default_edge_scroll_edge_thickness",
|
||||
deserialize_with = "PeerConfig::deserialize_edge_scroll_edge_thickness"
|
||||
)]
|
||||
pub edge_scroll_edge_thickness: i32,
|
||||
#[serde(
|
||||
default = "PeerConfig::default_image_quality",
|
||||
deserialize_with = "PeerConfig::deserialize_image_quality",
|
||||
@@ -362,6 +367,7 @@ impl Default for PeerConfig {
|
||||
size_pf: Default::default(),
|
||||
view_style: Self::default_view_style(),
|
||||
scroll_style: Self::default_scroll_style(),
|
||||
edge_scroll_edge_thickness: Self::default_edge_scroll_edge_thickness(),
|
||||
image_quality: Self::default_image_quality(),
|
||||
custom_image_quality: Self::default_custom_image_quality(),
|
||||
show_remote_cursor: Default::default(),
|
||||
@@ -1582,8 +1588,7 @@ impl PeerConfig {
|
||||
|
||||
fn default_options() -> HashMap<String, String> {
|
||||
let mut mp: HashMap<String, String> = Default::default();
|
||||
let _ =
|
||||
[
|
||||
let _ = [
|
||||
keys::OPTION_CODEC_PREFERENCE,
|
||||
keys::OPTION_CUSTOM_FPS,
|
||||
keys::OPTION_ZOOM_CURSOR,
|
||||
@@ -1614,6 +1619,24 @@ impl PeerConfig {
|
||||
Ok(Self::default_trackpad_speed())
|
||||
}
|
||||
}
|
||||
|
||||
fn default_edge_scroll_edge_thickness() -> i32 {
|
||||
UserDefaultConfig::read(keys::OPTION_EDGE_SCROLL_EDGE_THICKNESS)
|
||||
.parse()
|
||||
.unwrap_or(100)
|
||||
}
|
||||
|
||||
fn deserialize_edge_scroll_edge_thickness<'de, D>(deserializer: D) -> Result<i32, D::Error>
|
||||
where
|
||||
D: de::Deserializer<'de>,
|
||||
{
|
||||
let v: i32 = de::Deserialize::deserialize(deserializer)?;
|
||||
if v >= 20 && v <= 150 {
|
||||
Ok(v)
|
||||
} else {
|
||||
Ok(Self::default_edge_scroll_edge_thickness())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serde_field_bool!(
|
||||
@@ -1948,7 +1971,9 @@ impl UserDefaultConfig {
|
||||
keys::OPTION_VIEW_STYLE => self.get_string(key, "adaptive", vec!["original"]),
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
keys::OPTION_VIEW_STYLE => self.get_string(key, "original", vec!["adaptive"]),
|
||||
keys::OPTION_SCROLL_STYLE => self.get_string(key, "scrollauto", vec!["scrolledge", "scrollbar"]),
|
||||
keys::OPTION_SCROLL_STYLE => {
|
||||
self.get_string(key, "scrollauto", vec!["scrolledge", "scrollbar"])
|
||||
}
|
||||
keys::OPTION_IMAGE_QUALITY => {
|
||||
self.get_string(key, "balanced", vec!["best", "low", "custom"])
|
||||
}
|
||||
@@ -1958,6 +1983,7 @@ impl UserDefaultConfig {
|
||||
keys::OPTION_CUSTOM_IMAGE_QUALITY => self.get_num_string(key, 50.0, 10.0, 0xFFF as f64),
|
||||
keys::OPTION_CUSTOM_FPS => self.get_num_string(key, 30.0, 5.0, 120.0),
|
||||
keys::OPTION_ENABLE_FILE_COPY_PASTE => self.get_string(key, "Y", vec!["", "N"]),
|
||||
keys::OPTION_EDGE_SCROLL_EDGE_THICKNESS => self.get_num_string(key, 100, 20, 150),
|
||||
keys::OPTION_TRACKPAD_SPEED => self.get_num_string(key, 100, 10, 1000),
|
||||
_ => self
|
||||
.get_after(key)
|
||||
@@ -2447,6 +2473,7 @@ pub mod keys {
|
||||
"use_all_my_displays_for_the_remote_session";
|
||||
pub const OPTION_VIEW_STYLE: &str = "view_style";
|
||||
pub const OPTION_SCROLL_STYLE: &str = "scroll_style";
|
||||
pub const OPTION_EDGE_SCROLL_EDGE_THICKNESS: &str = "edge-scroll-edge-thickness";
|
||||
pub const OPTION_IMAGE_QUALITY: &str = "image_quality";
|
||||
pub const OPTION_CUSTOM_IMAGE_QUALITY: &str = "custom_image_quality";
|
||||
pub const OPTION_CUSTOM_FPS: &str = "custom-fps";
|
||||
@@ -2614,6 +2641,7 @@ pub mod keys {
|
||||
OPTION_VIEW_STYLE,
|
||||
OPTION_TERMINAL_PERSISTENT,
|
||||
OPTION_SCROLL_STYLE,
|
||||
OPTION_EDGE_SCROLL_EDGE_THICKNESS,
|
||||
OPTION_IMAGE_QUALITY,
|
||||
OPTION_CUSTOM_IMAGE_QUALITY,
|
||||
OPTION_CUSTOM_FPS,
|
||||
|
||||
Reference in New Issue
Block a user