Skip to content

Commit f6d0c32

Browse files
committed
[*] improve ui
1 parent b81087d commit f6d0c32

File tree

13 files changed

+245
-27
lines changed

13 files changed

+245
-27
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ This is a screen recording tool for `Linux` and `Windows`. It is based on `Rust`
5959
- Program dependencies: `ffmpeg` related libraries and `libx264.dll`. You can download the program from the release page, which includes the necessary dependencies.
6060
- `git bash` examples:
6161
```bash
62-
export FFMPEG_DIR=C:/ffmpeg-8.0.1-full_build-shared
63-
export LIBCLANG_PATH="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/Llvm/x64/bin"
64-
make desktop-build-release desktop-features=desktop-windows
62+
export FFMPEG_DIR=C:/ffmpeg-8.0.1-full_build-shared
63+
export LIBCLANG_PATH="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/Llvm/x64/bin"
64+
make desktop-build-release desktop-features=desktop-windows
6565
```
6666

6767
### Reference

README.zh-CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
- 运行程序依赖:`ffmpeg` 相关库和 `libx264.dll`。可以到发布页面下载程序,里面包含了相关依赖。
5454
- `git bash` 示例:
5555
```bash
56-
export FFMPEG_DIR=C:/ffmpeg-8.0.1-full_build-shared
57-
export LIBCLANG_PATH="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/Llvm/x64/bin"
58-
make desktop-build-release desktop-features=desktop-windows
56+
export FFMPEG_DIR=C:/ffmpeg-8.0.1-full_build-shared
57+
export LIBCLANG_PATH="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/Llvm/x64/bin"
58+
make desktop-build-release desktop-features=desktop-windows
5959
```
6060

6161
### 参考

tr-helper/src/tr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ fn cn() -> &'static HashMap<&'static str, &'static str> {
290290
("video file duration is 0", "视频文件时长为0"),
291291
("Note", "注意"),
292292
("To enable the mouse tracking feature, you need to download the wayshot-cursor program from the Github release page and run it with administrator privileges. This program is used to capture the mouse position. The command is as follows:", "启用鼠标跟随功能需要到Github发布页面下载wayshot-cursor程序。并且使用管理员权限运行。这个程序的作用是获取鼠标位置。命令如下: "),
293+
("Hide Statistic", "隐藏统计信息"),
294+
("Show Statistic", "显示统计信息"),
295+
("Hide Preview", "隐藏预览"),
296+
("Show Preview", "显示预览"),
293297
])
294298
})
295299
}

wayshot/src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ pub struct Control {
158158

159159
#[derivative(Default(value = "true"))]
160160
pub enable_speaker: bool,
161+
162+
#[serde(default = "true_func")]
163+
#[derivative(Default(value = "true"))]
164+
pub enable_stats: bool,
165+
166+
#[serde(default = "true_func")]
167+
#[derivative(Default(value = "true"))]
168+
pub enable_preview: bool,
161169
}
162170

163171
#[derive(Serialize, Deserialize, Debug, Clone, Derivative, SlintFromConvert)]
@@ -343,6 +351,10 @@ fn resolution_default() -> UIResolution {
343351
UIResolution::Original
344352
}
345353

354+
fn true_func() -> bool {
355+
true
356+
}
357+
346358
/// Initializes the global configuration
347359
///
348360
/// This should be called once at application startup.

wayshot/src/logic/popup_action.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
//! Popup action menu logic module
2-
//!
3-
//! Handles actions triggered from popup context menus.
4-
51
use crate::{
62
global_logic,
73
slint_generatedAppWindow::{AppWindow, PopupActionSetting},
84
};
95
use slint::ComponentHandle;
106

11-
/// Initializes popup action menu callbacks
12-
///
13-
/// Sets up handlers for different popup menu actions.
14-
///
15-
/// # Parameters
16-
/// - `ui`: Reference to the application window
177
pub fn init(ui: &AppWindow) {
188
let ui_weak = ui.as_weak();
199
ui.global::<PopupActionSetting>()
2010
.on_action(move |action, _user_data| {
2111
let ui = ui_weak.unwrap();
2212

23-
#[allow(clippy::single_match)]
2413
match action.as_str() {
2514
"remove-caches" => {
2615
global_logic!(ui).invoke_remove_caches();
2716
}
17+
"toggle-control-enable-stats" => {
18+
global_logic!(ui).invoke_toggle_control_enable_stats();
19+
}
20+
"toggle-control-enable-preview" => {
21+
global_logic!(ui).invoke_toggle_control_enable_preview();
22+
}
2823
_ => (),
2924
}
3025
});

wayshot/src/logic/recorder.rs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ macro_rules! store_sources {
8181
pub fn init(ui: &AppWindow) {
8282
inner_init(&ui);
8383

84+
logic_cb!(toggle_control_enable_stats, ui);
85+
logic_cb!(toggle_control_enable_preview, ui);
86+
8487
logic_cb!(init_sources_dialog, ui);
8588
logic_cb!(choose_save_dir, ui);
8689
logic_cb!(update_sources, ui, setting);
@@ -329,6 +332,25 @@ fn init_video(ui: &AppWindow) -> Result<()> {
329332
Ok(())
330333
}
331334

335+
fn toggle_control_enable_stats(ui: &AppWindow) {
336+
let mut setting = global_store!(ui).get_setting_control();
337+
setting.enable_stats = !setting.enable_stats;
338+
global_store!(ui).set_setting_control(setting.clone());
339+
global_logic!(ui).invoke_set_setting_control(setting);
340+
}
341+
342+
fn toggle_control_enable_preview(ui: &AppWindow) {
343+
let mut setting = global_store!(ui).get_setting_control();
344+
setting.enable_preview = !setting.enable_preview;
345+
346+
if !setting.enable_preview {
347+
global_store!(ui).set_preview_image(Default::default());
348+
}
349+
350+
global_store!(ui).set_setting_control(setting.clone());
351+
global_logic!(ui).invoke_set_setting_control(setting);
352+
}
353+
332354
fn init_sources_dialog(ui: &AppWindow) {
333355
if let Err(e) = inner_init_sources_dialog(ui) {
334356
log::warn!("{e}");
@@ -640,13 +662,18 @@ fn inner_start_recording(ui_weak: Weak<AppWindow>) -> Result<()> {
640662
);
641663

642664
_ = ui_weak_clone.upgrade_in_event_loop(move |ui| {
643-
let buffer = SharedPixelBuffer::<slint::Rgb8Pixel>::clone_from_slice(
644-
&frame.buffer.as_raw(),
645-
frame.buffer.width(),
646-
frame.buffer.height(),
647-
);
648-
let img = slint::Image::from_rgb8(buffer);
649-
global_store!(ui).set_preview_image(img);
665+
if global_store!(ui).get_setting_control().enable_preview {
666+
let buffer = SharedPixelBuffer::<slint::Rgb8Pixel>::clone_from_slice(
667+
&frame.buffer.as_raw(),
668+
frame.buffer.width(),
669+
frame.buffer.height(),
670+
);
671+
let img = slint::Image::from_rgb8(buffer);
672+
global_store!(ui).set_preview_image(img);
673+
} else {
674+
global_store!(ui).set_preview_image(Default::default());
675+
}
676+
650677
global_store!(ui).set_start_recording_timer(true);
651678

652679
let mut sinfo = global_store!(ui).get_stats_info();

wayshot/src/logic/tr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ fn cn() -> &'static HashMap<&'static str, &'static str> {
292292
("video file duration is 0", "视频文件时长为0"),
293293
("Note", "注意"),
294294
("To enable the mouse tracking feature, you need to download the wayshot-cursor program from the Github release page and run it with administrator privileges. This program is used to capture the mouse position. The command is as follows:", "启用鼠标跟随功能需要到Github发布页面下载wayshot-cursor程序。并且使用管理员权限运行。这个程序的作用是获取鼠标位置。命令如下: "),
295+
("Hide Statistic", "隐藏统计信息"),
296+
("Show Statistic", "显示统计信息"),
297+
("Hide Preview", "隐藏预览"),
298+
("Show Preview", "显示预览"),
295299
])
296300
})
297301
}

wayshot/src/version.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pub static VERSION: &str = "v0.3.0";
2-
1+
pub static VERSION: &str = "v0.3.0";

0 commit comments

Comments
 (0)