mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2025-03-31 23:04:55 +03:00
update overwrite
This commit is contained in:
parent
0cc65c0f7e
commit
3258f761d3
@ -4,9 +4,27 @@ use adw::gtk::{Button, ToggleButton, Label, SpinButton};
|
||||
use adw::gtk::glib;
|
||||
use adw::gtk::prelude::*;
|
||||
use adw::Window;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
// Check for record_button.emit_clicked()
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct RecordClick {
|
||||
pub is_record_button_clicked: bool,
|
||||
}
|
||||
|
||||
impl RecordClick {
|
||||
pub fn set_clicked(&mut self, status: bool) {
|
||||
self.is_record_button_clicked = status;
|
||||
}
|
||||
|
||||
pub fn is_clicked(&mut self) -> bool {
|
||||
self.is_record_button_clicked
|
||||
}
|
||||
}
|
||||
|
||||
pub fn recording_delay(delay_spin: SpinButton, mut delay_time: u16, delay_window: Window, delay_window_button: ToggleButton,
|
||||
delay_window_label: Label, record_button: Button) {
|
||||
delay_window_label: Label, record_button: Button, record_click: Rc<RefCell<RecordClick>>) {
|
||||
// Keep time label alive and update every 1sec
|
||||
let default_value = delay_time;
|
||||
let capture_delay_label = move || {
|
||||
@ -25,7 +43,11 @@ pub fn recording_delay(delay_spin: SpinButton, mut delay_time: u16, delay_window
|
||||
// Hide delay window and start recording
|
||||
delay_window.hide();
|
||||
delay_spin.set_value(0.0);
|
||||
// Inform that record button is on second click
|
||||
record_click.borrow_mut().set_clicked(true);
|
||||
record_button.emit_clicked();
|
||||
// Revert record_click
|
||||
record_click.borrow_mut().set_clicked(false);
|
||||
// Keep the input value
|
||||
delay_spin.set_value(default_value as f64);
|
||||
glib::source::Continue(false)
|
||||
|
@ -8,7 +8,7 @@ use anyhow::Result;
|
||||
use blue_recorder_core::ffmpeg_linux::Ffmpeg;
|
||||
#[cfg(target_os = "windows")]
|
||||
use blue_recorder_core::ffmpeg_windows::Ffmpeg;
|
||||
use blue_recorder_core::utils::{is_wayland, play_record, RecordMode};
|
||||
use blue_recorder_core::utils::{is_overwrite, is_wayland, play_record, RecordMode};
|
||||
use cpal::traits::{DeviceTrait, HostTrait};
|
||||
use std::cell::RefCell;
|
||||
use std::ops::Add;
|
||||
@ -16,7 +16,7 @@ use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::{area_capture, config_management, fluent::get_bundle};
|
||||
use crate::timer::{recording_delay, start_timer, stop_timer};
|
||||
use crate::timer::{RecordClick, recording_delay, start_timer, stop_timer};
|
||||
|
||||
pub fn run_ui(application: &Application) {
|
||||
// Error dialog
|
||||
@ -783,6 +783,9 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
let _video_switch = video_switch.clone();
|
||||
//let wayland_record = main_context.block_on(WaylandRecorder::new());
|
||||
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
|
||||
let second_click: Rc<RefCell<RecordClick>> = Rc::new(RefCell::new(RecordClick {
|
||||
is_record_button_clicked: false,
|
||||
}));
|
||||
record_button.connect_clicked(move |_| {
|
||||
match _ffmpeg_record_interface.borrow_mut().get_filename() {
|
||||
Err(error) => {
|
||||
@ -794,21 +797,33 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
Ok(_) => {
|
||||
if !_audio_input_switch.is_active() &&
|
||||
!_audio_output_switch.is_active() &&
|
||||
!_video_switch.is_active()
|
||||
!_video_switch.is_active() ||
|
||||
!is_overwrite(&get_bundle("already-exist", None),
|
||||
&_ffmpeg_record_interface.borrow_mut().saved_filename,
|
||||
_main_window.clone()
|
||||
) && !second_click.borrow_mut().is_clicked() && _delay_spin.value() as u16 == 0
|
||||
{
|
||||
// Do nothing
|
||||
} else {
|
||||
_delay_window_button.set_active(false);
|
||||
if _delay_spin.value() as u16 > 0 {
|
||||
recording_delay(
|
||||
_delay_spin.clone(),
|
||||
_delay_spin.value() as u16,
|
||||
delay_window.clone(),
|
||||
_delay_window_button.clone(),
|
||||
delay_window_label.clone(),
|
||||
_record_button.clone(),
|
||||
);
|
||||
} else if _delay_spin.value() as u16 == 0 {
|
||||
if !is_overwrite(&get_bundle("already-exist", None),
|
||||
&_ffmpeg_record_interface.borrow_mut().saved_filename,
|
||||
_main_window.clone())
|
||||
{
|
||||
//Do nothing
|
||||
} else {
|
||||
recording_delay(
|
||||
_delay_spin.clone(),
|
||||
_delay_spin.value() as u16,
|
||||
delay_window.clone(),
|
||||
_delay_window_button.clone(),
|
||||
delay_window_label.clone(),
|
||||
_record_button.clone(),
|
||||
second_click.clone(),
|
||||
);
|
||||
}
|
||||
} else if _delay_spin.value() as u16 == 0 && !is_wayland() {
|
||||
let _area_capture = area_capture.borrow_mut();
|
||||
_audio_input_switch.set_sensitive(false);
|
||||
_audio_output_switch.set_sensitive(false);
|
||||
|
Loading…
Reference in New Issue
Block a user