Skip to content

Commit 8602dc6

Browse files
committed
Add recording options to tray menu
1 parent a832346 commit 8602dc6

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

apps/desktop/src-tauri/src/tray.rs

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use crate::windows::ShowCapWindow;
2-
use crate::{RecordingStarted, RecordingStopped, RequestOpenSettings, recording};
1+
use crate::{
2+
RecordingStarted, RecordingStopped, RequestOpenRecordingPicker, RequestOpenSettings, recording,
3+
recording_settings::RecordingTargetMode, windows::ShowCapWindow,
4+
};
35

46
use std::sync::{
57
Arc,
@@ -18,6 +20,9 @@ use tauri_specta::Event;
1820

1921
pub enum TrayItem {
2022
OpenCap,
23+
RecordDisplay,
24+
RecordWindow,
25+
RecordArea,
2126
PreviousRecordings,
2227
PreviousScreenshots,
2328
OpenSettings,
@@ -29,6 +34,9 @@ impl From<TrayItem> for MenuId {
2934
fn from(value: TrayItem) -> Self {
3035
match value {
3136
TrayItem::OpenCap => "open_cap",
37+
TrayItem::RecordDisplay => "record_display",
38+
TrayItem::RecordWindow => "record_window",
39+
TrayItem::RecordArea => "record_area",
3240
TrayItem::PreviousRecordings => "previous_recordings",
3341
TrayItem::PreviousScreenshots => "previous_screenshots",
3442
TrayItem::OpenSettings => "open_settings",
@@ -45,6 +53,9 @@ impl TryFrom<MenuId> for TrayItem {
4553
fn try_from(value: MenuId) -> Result<Self, Self::Error> {
4654
match value.0.as_str() {
4755
"open_cap" => Ok(TrayItem::OpenCap),
56+
"record_display" => Ok(TrayItem::RecordDisplay),
57+
"record_window" => Ok(TrayItem::RecordWindow),
58+
"record_area" => Ok(TrayItem::RecordArea),
4859
"previous_recordings" => Ok(TrayItem::PreviousRecordings),
4960
"previous_screenshots" => Ok(TrayItem::PreviousScreenshots),
5061
"open_settings" => Ok(TrayItem::OpenSettings),
@@ -59,7 +70,28 @@ pub fn create_tray(app: &AppHandle) -> tauri::Result<()> {
5970
let menu = Menu::with_items(
6071
app,
6172
&[
62-
&MenuItem::with_id(app, TrayItem::OpenCap, "New Recording", true, None::<&str>)?,
73+
&MenuItem::with_id(
74+
app,
75+
TrayItem::OpenCap,
76+
"Open Main Window",
77+
true,
78+
None::<&str>,
79+
)?,
80+
&MenuItem::with_id(
81+
app,
82+
TrayItem::RecordDisplay,
83+
"Record Display",
84+
true,
85+
None::<&str>,
86+
)?,
87+
&MenuItem::with_id(
88+
app,
89+
TrayItem::RecordWindow,
90+
"Record Window",
91+
true,
92+
None::<&str>,
93+
)?,
94+
&MenuItem::with_id(app, TrayItem::RecordArea, "Record Area", true, None::<&str>)?,
6395
&PredefinedMenuItem::separator(app)?,
6496
// &MenuItem::with_id(
6597
// app,
@@ -109,6 +141,24 @@ pub fn create_tray(app: &AppHandle) -> tauri::Result<()> {
109141
.await;
110142
});
111143
}
144+
Ok(TrayItem::RecordDisplay) => {
145+
let _ = RequestOpenRecordingPicker {
146+
target_mode: Some(RecordingTargetMode::Display),
147+
}
148+
.emit(&app_handle);
149+
}
150+
Ok(TrayItem::RecordWindow) => {
151+
let _ = RequestOpenRecordingPicker {
152+
target_mode: Some(RecordingTargetMode::Window),
153+
}
154+
.emit(&app_handle);
155+
}
156+
Ok(TrayItem::RecordArea) => {
157+
let _ = RequestOpenRecordingPicker {
158+
target_mode: Some(RecordingTargetMode::Area),
159+
}
160+
.emit(&app_handle);
161+
}
112162
Ok(TrayItem::PreviousRecordings) => {
113163
let _ = RequestOpenSettings {
114164
page: "recordings".to_string(),

0 commit comments

Comments
 (0)