Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/desktop/src-tauri/src/general_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ pub enum PostDeletionBehaviour {
ReopenRecordingWindow,
}

#[derive(Default, Serialize, Deserialize, Type, Debug, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum PostSettingsCloseBehaviour {
DoNothing,
#[default]
OpenRecordingWindow,
}

impl MainWindowRecordingStartBehaviour {
pub fn perform(&self, window: &tauri::WebviewWindow) -> tauri::Result<()> {
match self {
Expand Down Expand Up @@ -116,6 +124,8 @@ pub struct GeneralSettingsStore {
pub recording_picker_preference_set: bool,
#[serde(default)]
pub post_deletion_behaviour: PostDeletionBehaviour,
#[serde(default)]
pub post_settings_close_behaviour: PostSettingsCloseBehaviour,
#[serde(default = "default_excluded_windows")]
pub excluded_windows: Vec<WindowExclusion>,
#[serde(default)]
Expand Down Expand Up @@ -184,6 +194,7 @@ impl Default for GeneralSettingsStore {
enable_new_recording_flow: default_enable_new_recording_flow(),
recording_picker_preference_set: false,
post_deletion_behaviour: PostDeletionBehaviour::DoNothing,
post_settings_close_behaviour: PostSettingsCloseBehaviour::OpenRecordingWindow,
excluded_windows: default_excluded_windows(),
delete_instant_recordings_after_upload: false,
instant_mode_max_resolution: 1920,
Expand Down
18 changes: 15 additions & 3 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
use cpal::StreamError;
use editor_window::{EditorInstances, WindowEditorInstance};
use ffmpeg::ffi::AV_TIME_BASE;
use general_settings::GeneralSettingsStore;
use general_settings::{GeneralSettingsStore, PostSettingsCloseBehaviour};
use kameo::{Actor, actor::ActorRef};
use notifications::NotificationType;
use recording::{InProgressRecording, RecordingEvent, RecordingInputKind};
Expand Down Expand Up @@ -2683,21 +2683,33 @@
}
}
CapWindowId::Settings => {
let settings = GeneralSettingsStore::get(&app)

Check warning on line 2686 in apps/desktop/src-tauri/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy (aarch64-apple-darwin, macos-latest)

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> apps/desktop/src-tauri/src/lib.rs:2686:74 | 2686 | ... let settings = GeneralSettingsStore::get(&app) | ^^^^ help: change this to: `app` | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
.ok()
.flatten()
.unwrap_or_default();

let should_open_main = matches!(
settings.post_settings_close_behaviour,
PostSettingsCloseBehaviour::OpenRecordingWindow
);

for (label, window) in app.webview_windows() {
if let Ok(id) = CapWindowId::from_str(&label)
&& matches!(
id,
CapWindowId::TargetSelectOverlay { .. }
| CapWindowId::Main
| CapWindowId::Camera
)
{
let _ = window.show();
if should_open_main {
let _ = window.show();
}
}

Check failure on line 2708 in apps/desktop/src-tauri/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy (aarch64-apple-darwin, macos-latest)

this `if` statement can be collapsed

error: this `if` statement can be collapsed --> apps/desktop/src-tauri/src/lib.rs:2697:37 | 2697 | / ... if let Ok(id) = CapWindowId::from_str(&label) 2698 | | ... && matches!( 2699 | | ... id, 2700 | | ... CapWindowId::TargetSelectOverlay { .. } ... | 2708 | | ... } | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#collapsible_if = note: requested on the command line with `-D clippy::collapsible-if` help: collapse nested if block | 2703 ~ ) 2704 ~ && should_open_main { 2705 | let _ = window.show(); 2706 ~ } |
}

#[cfg(target_os = "windows")]
if !has_open_editor_window(&app) {
if should_open_main && !has_open_editor_window(&app) {
reopen_main_window(&app);
}

Expand Down
17 changes: 17 additions & 0 deletions apps/desktop/src/routes/(window-chrome)/settings/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
type GeneralSettingsStore,
type MainWindowRecordingStartBehaviour,
type PostDeletionBehaviour,
type PostSettingsCloseBehaviour,
type PostStudioRecordingBehaviour,
type WindowExclusion,
} from "~/utils/tauri";
Expand Down Expand Up @@ -359,6 +360,7 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
| MainWindowRecordingStartBehaviour
| PostStudioRecordingBehaviour
| PostDeletionBehaviour
| PostSettingsCloseBehaviour
| number,
>(props: {
label: string;
Expand Down Expand Up @@ -558,6 +560,21 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
},
]}
/>
<SelectSettingItem
label="After Closing Settings Window"
description="What should Cap do when you close the settings window?"
value={settings.postSettingsCloseBehaviour ?? "openRecordingWindow"}
onChange={(value) =>
handleChange("postSettingsCloseBehaviour", value)
}
options={[
{ text: "Do Nothing", value: "doNothing" },
{
text: "Open Recording Window",
value: "openRecordingWindow",
},
]}
/>
<ToggleSettingItem
label="Delete instant mode recordings after upload"
description="After finishing an instant recording, should Cap will delete it from your device?"
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/utils/tauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export type ExportSettings = ({ format: "Mp4" } & Mp4ExportSettings) | ({ format
export type FileType = "recording" | "screenshot"
export type Flags = { captions: boolean }
export type FramesRendered = { renderedCount: number; totalFrames: number; type: "FramesRendered" }
export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; recordingPickerPreferenceSet?: boolean; postDeletionBehaviour?: PostDeletionBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number }
export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; recordingPickerPreferenceSet?: boolean; postDeletionBehaviour?: PostDeletionBehaviour; postSettingsCloseBehaviour?: PostSettingsCloseBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number }
export type GifExportSettings = { fps: number; resolution_base: XY<number>; quality: GifQuality | null }
export type GifQuality = {
/**
Expand Down Expand Up @@ -443,6 +443,7 @@ export type PhysicalSize = { width: number; height: number }
export type Plan = { upgraded: boolean; manual: boolean; last_checked: number }
export type Platform = "MacOS" | "Windows"
export type PostDeletionBehaviour = "doNothing" | "reopenRecordingWindow"
export type PostSettingsCloseBehaviour = "doNothing" | "openRecordingWindow"
export type PostStudioRecordingBehaviour = "openEditor" | "showOverlay"
export type Preset = { name: string; config: ProjectConfiguration }
export type PresetsStore = { presets: Preset[]; default: number | null }
Expand Down
Loading