mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-25 21:35:33 +00:00
Implemented loading virtual drives from JSON.
This commit is contained in:
@@ -68,7 +68,7 @@ inline void init_default_settings()
|
||||
rconfig::set_default_data("gui/show_smart_capable_only", false); // show smart-capable drives only
|
||||
rconfig::set_default_data("gui/scan_on_startup", true); // scan drives on startup
|
||||
|
||||
rconfig::set_default_data("gui/smartctl_output_filename_format", "{model}_{serial}_{date}.txt"); // when suggesting filename
|
||||
rconfig::set_default_data("gui/smartctl_output_filename_format", "{model}_{serial}_{date}.json"); // when suggesting filename
|
||||
|
||||
rconfig::set_default_data("gui/icons_show_device_name", false); // text under icons
|
||||
rconfig::set_default_data("gui/icons_show_serial_number", false); // text under icons
|
||||
|
||||
@@ -153,7 +153,7 @@ hz::ExpectedVoid<SmartctlParserError> SmartctlTextBasicParser::parse(std::string
|
||||
model = hz::string_remove_adjacent_duplicates_copy(hz::string_trim_copy(model), ' ');
|
||||
StorageProperty p;
|
||||
p.set_name("Device Model", "model_name", "Device Model");
|
||||
p.value = p.reported_value; // string-type value
|
||||
p.value = model; // string-type value
|
||||
add_property(p);
|
||||
|
||||
} else if (app_pcre_match("/^(?:Device|Product):[ \\t]*(.*)$/mi", output, &model)) { // usb flash drives
|
||||
|
||||
@@ -417,7 +417,7 @@ hz::ExpectedVoid<StorageDeviceError> StorageDevice::parse_any_data_for_virtual()
|
||||
}
|
||||
|
||||
// This will add some properties and emit signal_changed().
|
||||
auto basic_parse_status = this->parse_basic_data();
|
||||
auto basic_parse_status = basic_parser->parse(this->full_output_);
|
||||
if (!basic_parse_status) {
|
||||
return hz::Unexpected(StorageDeviceError::ParseError,
|
||||
std::vformat(_("Cannot parse smartctl output: {}"), std::make_format_args(basic_parse_status.error().message())));
|
||||
|
||||
@@ -197,7 +197,8 @@ void GscExecutorLogWindow::on_window_save_current_button_clicked()
|
||||
int result = 0;
|
||||
|
||||
const Glib::RefPtr<Gtk::FileFilter> specific_filter = Gtk::FileFilter::create();
|
||||
specific_filter->set_name(_("Text Files"));
|
||||
specific_filter->set_name(_("JSON and Text Files"));
|
||||
specific_filter->add_pattern("*.json");
|
||||
specific_filter->add_pattern("*.txt");
|
||||
|
||||
const Glib::RefPtr<Gtk::FileFilter> all_filter = Gtk::FileFilter::create();
|
||||
@@ -237,7 +238,7 @@ void GscExecutorLogWindow::on_window_save_current_button_clicked()
|
||||
if (!last_dir.empty())
|
||||
dialog.set_current_folder(last_dir);
|
||||
|
||||
dialog.set_current_name(".txt");
|
||||
dialog.set_current_name(".json");
|
||||
|
||||
// Show the dialog and wait for a user response
|
||||
result = dialog.run(); // the main cycle blocks here
|
||||
@@ -257,8 +258,8 @@ void GscExecutorLogWindow::on_window_save_current_button_clicked()
|
||||
#endif
|
||||
rconfig::set_data("gui/drive_data_open_save_dir", last_dir);
|
||||
|
||||
if (file.extension() != ".txt") {
|
||||
file += ".txt";
|
||||
if (file.extension() != ".json" && file.extension() != ".txt") {
|
||||
file += ".json";
|
||||
}
|
||||
|
||||
auto ec = hz::fs_file_put_contents(file, entry->std_output);
|
||||
|
||||
@@ -836,7 +836,8 @@ void GscInfoWindow::on_save_info_button_clicked()
|
||||
const std::string filename = drive->get_save_filename();
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> specific_filter = Gtk::FileFilter::create();
|
||||
specific_filter->set_name(_("Text Files"));
|
||||
specific_filter->set_name(_("JSON and Text Files"));
|
||||
specific_filter->add_pattern("*.json");
|
||||
specific_filter->add_pattern("*.txt");
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> all_filter = Gtk::FileFilter::create();
|
||||
@@ -898,8 +899,8 @@ void GscInfoWindow::on_save_info_button_clicked()
|
||||
#endif
|
||||
rconfig::set_data("gui/drive_data_open_save_dir", last_dir);
|
||||
|
||||
if (file.extension() != ".txt") {
|
||||
file += ".txt";
|
||||
if (file.extension() != ".json" && file.extension() != ".txt") {
|
||||
file += ".json";
|
||||
}
|
||||
|
||||
std::string data = this->drive->get_full_output();
|
||||
|
||||
@@ -1303,7 +1303,8 @@ void GscMainWindow::show_load_virtual_file_chooser()
|
||||
int result = 0;
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> specific_filter = Gtk::FileFilter::create();
|
||||
specific_filter->set_name(_("Text Files"));
|
||||
specific_filter->set_name(_("JSON and Text Files"));
|
||||
specific_filter->add_pattern("*.json");
|
||||
specific_filter->add_pattern("*.txt");
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> all_filter = Gtk::FileFilter::create();
|
||||
|
||||
@@ -159,7 +159,8 @@ class GscTextWindow : public AppBuilderWidget<GscTextWindow<InstanceSwitch>, Ins
|
||||
int result = 0;
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> specific_filter = Gtk::FileFilter::create();
|
||||
specific_filter->set_name(_("Text Files"));
|
||||
specific_filter->set_name(_("JSON and Text Files"));
|
||||
specific_filter->add_pattern("*.json");
|
||||
specific_filter->add_pattern("*.txt");
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> all_filter = Gtk::FileFilter::create();
|
||||
@@ -221,8 +222,8 @@ class GscTextWindow : public AppBuilderWidget<GscTextWindow<InstanceSwitch>, Ins
|
||||
#endif
|
||||
rconfig::set_data("gui/drive_data_open_save_dir", last_dir);
|
||||
|
||||
if (file.extension() != ".txt") {
|
||||
file += ".txt";
|
||||
if (file.extension() != ".json" && file.extension() != ".txt") {
|
||||
file += ".json";
|
||||
}
|
||||
|
||||
std::string text;
|
||||
|
||||
Reference in New Issue
Block a user