fix view mode

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-03-17 11:27:22 +08:00
parent 450a9cdb35
commit 774694714d
8 changed files with 103 additions and 91 deletions

View File

@@ -10,7 +10,6 @@ use std::time::{Duration, SystemTime};
use async_trait::async_trait;
use bytes::Bytes;
use hbb_common::message_proto::option_message::BoolOption;
use rdev::{Event, EventType::*};
use uuid::Uuid;
@@ -843,37 +842,6 @@ impl<T: InvokeUiSession> Session<T> {
}
false
}
pub fn set_view_only(&self, view_only: bool) {
let mut option = OptionMessage::default();
let f = |b: bool| {
if b {
BoolOption::Yes.into()
} else {
BoolOption::No.into()
}
};
if view_only {
option.disable_keyboard = f(true);
option.disable_clipboard = f(true);
option.show_remote_cursor = f(true);
} else {
option.disable_keyboard = f(false);
option.disable_clipboard = f(self.get_toggle_option("disable-clipboard".to_string()));
option.show_remote_cursor = f(self.get_toggle_option("show-remote-cursor".to_string()));
}
let mut misc = Misc::new();
misc.set_option(option);
let mut msg = Message::new();
msg.set_misc(misc);
self.send(Data::Message(msg));
if self.get_toggle_option("view-only".to_string()) != view_only {
self.lc
.write()
.unwrap()
.toggle_option("view-only".to_string());
}
}
}
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
@@ -905,7 +873,14 @@ pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
only_count: bool,
);
fn confirm_delete_files(&self, id: i32, i: i32, name: String);
fn override_file_confirm(&self, id: i32, file_num: i32, to: String, is_upload: bool, is_identical: bool);
fn override_file_confirm(
&self,
id: i32,
file_num: i32,
to: String,
is_upload: bool,
is_identical: bool,
);
fn update_block_input_state(&self, on: bool);
fn job_progress(&self, id: i32, file_num: i32, speed: f64, finished_size: f64);
fn adapt_size(&self);