mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2024-11-23 17:13:11 +03:00
fix(#22): ask before overwrite the file
This commit is contained in:
parent
fdb6765918
commit
77ab1d62d2
@ -1,6 +1,8 @@
|
|||||||
extern crate subprocess;
|
extern crate subprocess;
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
|
use gettextrs::gettext;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::{ButtonsType, DialogFlags, MessageDialog, MessageType, ResponseType};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
CheckButton, ComboBoxText, Entry, FileChooser, ProgressBar, SpinButton, Window, WindowPosition,
|
CheckButton, ComboBoxText, Entry, FileChooser, ProgressBar, SpinButton, Window, WindowPosition,
|
||||||
WindowType,
|
WindowType,
|
||||||
@ -15,8 +17,6 @@ use std::time::Duration;
|
|||||||
use subprocess::Exec;
|
use subprocess::Exec;
|
||||||
use zbus::dbus_proxy;
|
use zbus::dbus_proxy;
|
||||||
use zvariant::Value;
|
use zvariant::Value;
|
||||||
use gtk::{ButtonsType, DialogFlags, MessageType, MessageDialog, ResponseType};
|
|
||||||
use gettextrs::gettext;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ProgressWidget {
|
pub struct ProgressWidget {
|
||||||
@ -139,17 +139,24 @@ impl Ffmpeg {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let is_file_already_exists = std::path::Path::new(format!("{}", self.saved_filename.unwrap()))
|
let is_file_already_exists =
|
||||||
.exists();
|
std::path::Path::new(format!("{}", self.saved_filename.clone().unwrap()).as_str())
|
||||||
|
.exists();
|
||||||
|
|
||||||
if is_file_already_exists {
|
if is_file_already_exists {
|
||||||
if MessageDialog::new(None::<&Window>,
|
let message_dialog = MessageDialog::new(
|
||||||
|
None::<&Window>,
|
||||||
DialogFlags::empty(),
|
DialogFlags::empty(),
|
||||||
MessageType::Question,
|
MessageType::Warning,
|
||||||
ButtonsType::Ok,
|
ButtonsType::OkCancel,
|
||||||
&gettext("Would you like to overwrite this file?")).run() != ResponseType::Ok {
|
&gettext("Would you like to overwrite this file?"),
|
||||||
return (None, None);
|
);
|
||||||
}
|
|
||||||
|
if message_dialog.run() != ResponseType::Ok {
|
||||||
|
message_dialog.hide();
|
||||||
|
return (None, None);
|
||||||
|
}
|
||||||
|
message_dialog.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.record_audio.get_active() {
|
if self.record_audio.get_active() {
|
||||||
@ -182,7 +189,7 @@ impl Ffmpeg {
|
|||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
height
|
height,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +229,6 @@ impl Ffmpeg {
|
|||||||
ffmpeg_command.arg("-follow_mouse");
|
ffmpeg_command.arg("-follow_mouse");
|
||||||
ffmpeg_command.arg("centered");
|
ffmpeg_command.arg("centered");
|
||||||
}
|
}
|
||||||
|
|
||||||
ffmpeg_command.arg("-crf");
|
ffmpeg_command.arg("-crf");
|
||||||
ffmpeg_command.arg("1");
|
ffmpeg_command.arg("1");
|
||||||
ffmpeg_command.arg(self.saved_filename.as_ref().unwrap().to_string());
|
ffmpeg_command.arg(self.saved_filename.as_ref().unwrap().to_string());
|
||||||
|
22
src/main.rs
22
src/main.rs
@ -356,18 +356,24 @@ fn main() {
|
|||||||
let _record_button = record_button.clone();
|
let _record_button = record_button.clone();
|
||||||
record_button.connect_clicked(move |_| {
|
record_button.connect_clicked(move |_| {
|
||||||
let _area_capture = _area_capture.borrow_mut().clone();
|
let _area_capture = _area_capture.borrow_mut().clone();
|
||||||
_ffmpeg_record_interface.borrow_mut().start_record(
|
match _ffmpeg_record_interface.borrow_mut().start_record(
|
||||||
_area_capture.x,
|
_area_capture.x,
|
||||||
_area_capture.y,
|
_area_capture.y,
|
||||||
_area_capture.width,
|
_area_capture.width,
|
||||||
_area_capture.height,
|
_area_capture.height,
|
||||||
);
|
) {
|
||||||
_indicator
|
(None, None) => {
|
||||||
.borrow_mut()
|
// do nothing if the start_record function return nothing
|
||||||
.set_status(AppIndicatorStatus::Active);
|
}
|
||||||
|
_ => {
|
||||||
_record_button.hide();
|
_indicator
|
||||||
_stop_button.show();
|
.borrow_mut()
|
||||||
|
.set_status(AppIndicatorStatus::Active);
|
||||||
|
|
||||||
|
_record_button.hide();
|
||||||
|
_stop_button.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
|
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user