From ede3f7b0030f436683e96029d35607e00f35db31 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Mon, 27 Mar 2023 12:57:12 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D1=82=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BF=D0=BE=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-bootloader.cc | 122 +++++++++++++++++++++++++----- source/ubl-settings-bootloader.h | 23 +++++- ubl-settings-bootloader.css | 6 ++ ubl-settings-bootloader.glade | 10 +-- ubl-settings-bootloader_ru.po | 6 ++ 5 files changed, 137 insertions(+), 30 deletions(-) diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 68b7e32..7604bf3 100644 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -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 &list_store) { - +void MainWindow::template_item_selected(std::map &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr &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 &map_view, std::map &map_global_view, std::map &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 list_store_m) { std::array, 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); + } diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index f422f84..84f95b4 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -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 cmd_selection_global; + std::map map_cmd_selection_kernel; + std::map map_cmd_selection_IPT; + std::map map_cmd_selection_OTT; + + std::map map_global_cmd_selection_kernel; + std::map map_global_cmd_selection_IPT; + std::map map_global_cmd_selection_OTT; + + std::map map_local_cmd_selection_kernel; + std::map map_local_cmd_selection_IPT; + std::map 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 &map_view, std::map &map_global_view, std::map &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 &list_store); + void template_item_selected(std::map &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr &list_store); }; class SettingsPlug : public Gtk::Plug{ diff --git a/ubl-settings-bootloader.css b/ubl-settings-bootloader.css index b762407..ee3ba98 100644 --- a/ubl-settings-bootloader.css +++ b/ubl-settings-bootloader.css @@ -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; } diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 51737be..6efc9f5 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -475,7 +475,7 @@ specified priority vertical - 100 + 140 True True in @@ -590,7 +590,7 @@ specified priority vertical - 100 + 140 True True in @@ -639,7 +639,7 @@ specified priority - + True True 5 @@ -704,7 +704,7 @@ specified priority vertical - 100 + 140 True True in @@ -753,7 +753,7 @@ specified priority - + True True 5 diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index 84ee3a7..6aaed9d 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -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суперпользователя!"