Начата работа по реализации сохранения и загрузки

pull/11/head
Igor Belitskiy 3 years ago
parent 08f8d9fb36
commit ede3f7b003

@ -79,10 +79,13 @@ void MainWindow::settings(){
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
if (this->check_root() == 0) {
this->fill_in_view();
this->download_local_cfg();
this->download_globl_cfg();
this->event();
}
else{
this->event();
boxWidgetAll->set_sensitive(false);
btnLoad->set_sensitive(false);
boxSave->set_sensitive(false);
@ -111,26 +114,39 @@ void MainWindow::fill_in_view() {
}
void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&)
{
template_item_selected(path, list_store_kernel);
void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
auto selection_IPT = treeViewIPT->get_selection();
auto selection_OTT = treeViewOTT->get_selection();
selection_IPT->unselect_all();
selection_OTT->unselect_all();
template_item_selected(map_cmd_selection_kernel, path, list_store_kernel);\
string str_flags = this->dynamic_update_entry(map_cmd_selection_kernel,map_global_cmd_selection_kernel,map_local_cmd_selection_kernel);
entryKernel->set_text(str_flags);
}
void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&)
{
template_item_selected(path, list_store_OTT);
void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
auto selection_kernel = treeViewKernel->get_selection();
auto selection_IPT = treeViewIPT->get_selection();
selection_kernel->unselect_all();
selection_IPT->unselect_all();
template_item_selected(map_cmd_selection_OTT , path, list_store_OTT);
string str_flags = this->dynamic_update_entry(map_cmd_selection_OTT, map_global_cmd_selection_OTT,map_local_cmd_selection_OTT);
entryOTT->set_text(str_flags);
}
void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&)
{
template_item_selected(path, list_store_IPT);
void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
auto selection_kernel = treeViewKernel->get_selection();
auto selection_OTT = treeViewOTT->get_selection();
selection_kernel->unselect_all();
selection_OTT->unselect_all();
template_item_selected(map_cmd_selection_IPT , path, list_store_IPT);
string str_flags = this->dynamic_update_entry(map_cmd_selection_IPT, map_global_cmd_selection_IPT,map_local_cmd_selection_IPT);
entryIPT->set_text(str_flags);
}
void MainWindow::template_item_selected(const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store) {
void MainWindow::template_item_selected(std::map<string, string> &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store) {
const auto iter = list_store->get_iter(path);
if(iter) {
const auto row = *iter;
@ -146,10 +162,28 @@ void MainWindow::template_item_selected(const Gtk::TreeModel::Path& path, Glib::
}
Glib::ustring name = row[m_columns.name];
cout << cmd << " " << name << endl;
cmd_selection_global[name] = cmd;
map_view[name] = cmd;
}
}
string MainWindow::dynamic_update_entry(std::map<string, string> &map_view, std::map<string, string> &map_global_view, std::map<string, string> &map_local_view) {
string keys = "";
for(auto &it: map_view) {
string key = it.first;
if (flag_load == true && map_global_view.find(key) != map_global_view.end()) {
if (map_global_view[key] != map_view[key]){
keys += string(key) + ", ";
}
}
else if (flag_load == false && map_local_view.find(key) != map_local_view.end()) {
if (map_local_view[key] != map_view[key]){
keys += string(key) + ", ";
}
}
}
return keys;
}
void MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
std::array<std::vector<std::string>, 5> arr_view = read_csv(path_resources + "/" + file_name);
@ -208,8 +242,8 @@ void MainWindow::get_builder(){
builder->get_widget("spbSecond", spbSecond);
builder->get_widget("entryKernel", entryKernel);
builder->get_widget("entryIT", entryIT);
builder->get_widget("entryOT", entryOT);
builder->get_widget("entryIPT", entryIPT);
builder->get_widget("entryOTT", entryOTT);
builder->get_widget("boxColor", boxColor);
builder->get_widget("boxWidgetAll", boxWidgetAll);
@ -295,24 +329,70 @@ void MainWindow::event(){
treeViewOTTModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_OTT));
}
void MainWindow::save_global_local_cfg(){
void MainWindow::save_global_local_cfg() {
if (flag_save_global == false) {
flag_save_all = true;
}
else if (flag_save_local == false) {
flag_save_all = true;
}
else{
info_status_app("boxInfoMessOK");
lblWarning->set_text(gettext("Nothing to save!"));
}
info_warning_error(4);
}
void MainWindow::save_global_cfg(){
void MainWindow::save_global_cfg() {
if (flag_save_global == false) {
flag_save_global = true;
}
else{
info_status_app("boxInfoMessOK");
lblWarning->set_text(gettext("Nothing to save!"));
}
info_warning_error(3);
}
void MainWindow::save_local_cfg(){
void MainWindow::save_local_cfg() {
if (flag_save_local == false) {
flag_save_local = true;
}
else{
info_status_app("boxInfoMessOK");
lblWarning->set_text(gettext("Nothing to save!"));
}
info_warning_error(2);
}
void MainWindow::download_globl_cfg(){
void MainWindow::download_globl_cfg() {
entryKernel->set_text("");
entryOTT->set_text("");
entryIPT->set_text("");
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
flag_load = true;
info_warning_error(1);
}
void MainWindow::download_local_cfg(){
void MainWindow::download_local_cfg() {
entryKernel->set_text("");
entryOTT->set_text("");
entryIPT->set_text("");
flag_load = false;
flag_save_local = true;
flag_save_global = true;
flag_save_all = true;
info_warning_error(0);
}

@ -67,8 +67,8 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::CheckButton *chbLoadVariantSelectionTimer;
Gtk::CheckButton *chbLastSelectionWillBecome;
Gtk::Entry *entryKernel;
Gtk::Entry *entryIT;
Gtk::Entry *entryOT;
Gtk::Entry *entryIPT;
Gtk::Entry *entryOTT;
Gtk::Box *boxColor;
Gtk::AboutDialog *aboutWindows;
Gtk::MenuItem *btnAbout;
@ -100,7 +100,21 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::TreeModel::Row row_kernel;
Gtk::TreeModel::Row row_IPT;
Gtk::TreeModel::Row row_OTT;
std::map <string, string> cmd_selection_global;
std::map <string, string> map_cmd_selection_kernel;
std::map <string, string> map_cmd_selection_IPT;
std::map <string, string> map_cmd_selection_OTT;
std::map <string, string> map_global_cmd_selection_kernel;
std::map <string, string> map_global_cmd_selection_IPT;
std::map <string, string> map_global_cmd_selection_OTT;
std::map <string, string> map_local_cmd_selection_kernel;
std::map <string, string> map_local_cmd_selection_IPT;
std::map <string, string> map_local_cmd_selection_OTT;
bool flag_load = false;
bool flag_save_all = false;
bool flag_save_global = false;
bool flag_save_local = false;
int width;
int heigh;
int screen_width;
@ -140,10 +154,11 @@ class MainWindow : public Gtk::ApplicationWindow {
void info_warning_error(int mess);
int check_root();
void fill_in_view();
string dynamic_update_entry(std::map<string, string> &map_view, std::map<string, string> &map_global_view, std::map<string, string> &map_local_view) ;
void item_selected_kernel(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&);
void item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&);
void item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&);
void template_item_selected(const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store);
void template_item_selected(std::map<string, string> &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store);
};
class SettingsPlug : public Gtk::Plug{

@ -2,6 +2,12 @@
text-shadow: 2px 2px @theme_bg_color;
color: @theme_text_color;
}
.boxInfoMessError{
background-color: #ea9999;
}
.boxInfoMessOK{
background-color: #f3f0ac;
}
.bannerbackground {
background-color: #404040;
}

@ -475,7 +475,7 @@ specified priority</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="height-request">100</property>
<property name="height-request">140</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
@ -590,7 +590,7 @@ specified priority</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="height-request">100</property>
<property name="height-request">140</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
@ -639,7 +639,7 @@ specified priority</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entryIT">
<object class="GtkEntry" id="entryIPT">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-left">5</property>
@ -704,7 +704,7 @@ specified priority</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="height-request">100</property>
<property name="height-request">140</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
@ -753,7 +753,7 @@ specified priority</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entryOT">
<object class="GtkEntry" id="entryOTT">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-left">5</property>

@ -169,6 +169,9 @@ msgstr "intel_idle.max_cstate=4 (Устраняет мерцание диспл
msgid "Command line parameters:"
msgstr "Параметры командной строки:"
msgid "Nothing to save!"
msgstr "Нечего сохранять!"
msgid "serial (Serial terminal)"
msgstr "serial (Последовательный терминал)"
@ -244,6 +247,9 @@ msgstr "Успешно записана глобальная конфигура
msgid "Local configuration successfully written"
msgstr "Успешно записана локальная конфигурация"
msgid "Successfully saved local and global configuration"
msgstr "Успешно записаны локальная и глобальная конфигурация"
msgid "The program must be run as root"
msgstr "Программа должна быть запущена с правами \nсуперпользователя!"

Loading…
Cancel
Save