From e9bcc1790b791877e6276d6c4e677c9054ddec41 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 12:34:57 +0600 Subject: [PATCH 1/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D1=91=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 1 - ubl-settings-datetime.glade | 45 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index d251243..646b6de 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -477,7 +477,6 @@ void MainWindow::get_calendar(){ } void MainWindow::calendar_show(){ - cout << 2222 << endl; if (year==0){ time_t now = time(0); tm *ltm = localtime(&now); diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 52dac69..ccf56b9 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -169,28 +169,6 @@ - - 240 - 185 - False - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False Настройки даты и времени @@ -1003,6 +981,29 @@ Format: DD.MM.YYYY + + 240 + 185 + False + btnChooseDate + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + False -- 2.35.1 From 331f665eec3fe998d73546521ea9d338c234dedb Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 12:38:52 +0600 Subject: [PATCH 2/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D1=91=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 1 - ubl-settings-datetime.glade | 45 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index d251243..646b6de 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -477,7 +477,6 @@ void MainWindow::get_calendar(){ } void MainWindow::calendar_show(){ - cout << 2222 << endl; if (year==0){ time_t now = time(0); tm *ltm = localtime(&now); diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 52dac69..ccf56b9 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -169,28 +169,6 @@ - - 240 - 185 - False - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False Настройки даты и времени @@ -1003,6 +981,29 @@ Format: DD.MM.YYYY + + 240 + 185 + False + btnChooseDate + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + False -- 2.35.1 From 8e2a8dd95a070171663423a7a432d73a0404276b Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 09:59:19 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=80=D0=B5=D0=B3=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 2 +- source/ubl-settings-datetime.cc | 155 +++++++++++++++++++------------- source/ubl-settings-datetime.h | 8 +- 3 files changed, 99 insertions(+), 66 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e4e1133..a7ed26f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -13,7 +13,7 @@ find_package(ICU REQUIRED COMPONENTS uc dt in io) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection") + -fstack-clash-protection -fcf-protection -g ") set(SOURCE_FILES main.cc diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 646b6de..a3e7edf 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -28,7 +28,6 @@ #include #include "unicode/utypes.h" #include "unicode/utext.h" - #include #include #include @@ -553,7 +552,7 @@ void MainWindow::get_config(){ this->update_hour_minute(); this->update_calendar(); this->enry_dhcp_mess(); - string cmd = "/usr/bin/ubconfig --source global get clock ZONE"; + string cmd = "/usr/bin/ubconfig --default --source global get clock ZONE"; struct Result obj_result = this->wrapper_call(cmd); if (obj_result.error==0){ auto arr_reg_zone_glob = this->split_region_zone(obj_result.response); @@ -561,14 +560,14 @@ void MainWindow::get_config(){ this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1],cbRegionGlob,cbZoneGlob); } else{ - this->append_region_zone("Africa","Abidjan", cbRegion, cbZone); + this->append_region_zone("","",cbRegionGlob,cbZoneGlob); } } else { - this->append_region_zone("Africa","Abidjan",cbRegionGlob,cbZoneGlob); + this->append_region_zone("","",cbRegionGlob,cbZoneGlob); } - cmd = "/usr/bin/ubconfig --source system get clock ZONE"; + cmd = "/usr/bin/ubconfig --default --source system get clock ZONE"; struct Result obj_result_1 = this->wrapper_call(cmd); if (obj_result_1.error==0){ auto arr_reg_zone = this->split_region_zone(obj_result_1.response); @@ -576,12 +575,13 @@ void MainWindow::get_config(){ this->append_region_zone(arr_reg_zone[0],arr_reg_zone[1], cbRegion, cbZone); } else{ - this->append_region_zone("Africa","Abidjan", cbRegion, cbZone); + this->append_region_zone("","",cbRegion,cbZone); } } else { - this->append_region_zone("Africa","Abidjan", cbRegion, cbZone); + this->append_region_zone("","",cbRegion,cbZone); } + } array MainWindow::split_region_zone(string read_reg_zon_cfg){ @@ -677,14 +677,34 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex str_region_glob=region; int index = 0; Glib::ustring reg_local = ""; - for (const auto &text : array_region) { - reg_local = text; - reg_local = string(_(reg_local.c_str())); - tmpCbReg->append(Glib::ustring(reg_local)); - if (text == region){ - tmpCbReg->set_active_text(reg_local); + int size_vec = array_region_local.size(); + if (size_vec==0){ + for (auto& [key, value]: time_reg_map){ + array_region_local.push_back(string(_(key.c_str()))); + array_region.push_back(key); + index+=1; + } + } + // Cортировка пузырьком + if (size_vec==0){ + for (int i = 0; i < size_vec; i++) { + for (int j = 0; j < size_vec-1; j++) { + if (array_region_local[j] > array_region_local[j + 1]) { + auto b = array_region_local[j]; + array_region_local[j] = array_region_local[j + 1]; + array_region_local[j + 1] = b; + b = array_region[j]; + array_region[j] = array_region[j + 1]; + array_region[j + 1] = b; + } + } + } + } + for (string ® : array_region_local){ + tmpCbReg->append(Glib::ustring(reg)); + if (reg == string(_(region.c_str()))){ + tmpCbReg->set_active_text(reg); } - index+=1; } index = 0; string zone_mixing = ""; @@ -692,14 +712,25 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex string zone_offest = ""; path_reg_zone=region+"/"+zone; zone_offest = this->zone_file_read(path_reg_zone) + _(zone.c_str()); - for (string &_str_zone : time_reg_map_local.at(region)){ - tmpCbZone->append(_str_zone); - if (_str_zone!=""){ - if (zone_offest == _str_zone){ - tmpCbZone->set_active(index); + if (region==""){ + tmpCbZone->append(" "); + tmpCbZone->set_active(0); + return; + } + if (time_reg_map_local.find(region) == time_reg_map_local.end()){ + tmpCbZone->append(" "); + tmpCbZone->set_active(0); + } + else{ + for (string &_str_zone : time_reg_map_local.at(region)){ + tmpCbZone->append(_str_zone); + if (_str_zone!=""){ + if (zone_offest == _str_zone){ + tmpCbZone->set_active(index); + } } - } - index+=1; + index+=1; + } } } @@ -866,11 +897,10 @@ void MainWindow::read_file(){ if (fs::is_directory(path_dir)){ if (key_reg!="Pacific"){ if (key_reg!="posix"){ - if (key_reg!="Etc"){ + //if (key_reg!="Etc"){ if (key_reg!="right"){ vector zone; vector zone_local; - //zone.push_back(""); for (const auto & entry_zone : fs::directory_iterator(path_dir)){ std::ifstream in1(entry_zone.path()); // окрываем файл для чтения if (in1.is_open()){ @@ -887,7 +917,7 @@ void MainWindow::read_file(){ this->sort_zone(&zone_local, &zone); time_reg_map.insert({key_reg, zone}); time_reg_map_local.insert({key_reg, zone_local}); - }}}} + }}} } } in.close(); @@ -900,46 +930,47 @@ void MainWindow::sort_zone(vector *time_reg_map_local,vector *ti string str_j_1 = ""; int j_i_1; int size_vec = time_reg_map_local->size(); - for (int i = 0; i < size_vec; i++) { - for (int j = 0; j < size_vec-1; j++) { + for (int i = 1; i < size_vec; i++) { + for (int j = 1; j < size_vec-1; j++) { str_j=(*time_reg_map_local)[j]; - str_j = str_j.substr(5,str_j.find(")")-5); - if (str_j[1]=='0'){ - str_j.replace(1,1,"0"); - } - - if (str_j.find("+") != std::string::npos){ - str_j.replace(0,1,"+"); - j_i = stoi(str_j); - } - else{ - str_j.replace(0,1,"-"); - j_i = stoi(str_j); - j_i=-j_i; - } - str_j_1=(*time_reg_map_local)[j+1]; - str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5); - if (str_j_1[1]=='0'){ - str_j_1.replace(1,1,"0"); - } - if (str_j_1.find("+") != std::string::npos){ - str_j_1.replace(0,1,"+"); - j_i_1 = stoi(str_j_1); - } - else{ - str_j_1.replace(0,1,"-"); - j_i_1 = stoi(str_j_1); - j_i_1 = -j_i_1; - } - if (j_i > j_i_1) { - string b = (*time_reg_map_local)[j]; - (*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1]; - (*time_reg_map_local)[j + 1] = b; + if (str_j!=" "){ + str_j = str_j.substr(5,str_j.find(")")-5); + if (str_j[1]=='0'){ + str_j.replace(1,1,"0"); + } + + if (str_j.find("+") != std::string::npos){ + str_j.replace(0,1,"+"); + j_i = stoi(str_j); + } + else{ + str_j.replace(0,1,"-"); + j_i = stoi(str_j); + j_i=-j_i; + } + str_j_1=(*time_reg_map_local)[j+1]; + str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5); + if (str_j_1[1]=='0'){ + str_j_1.replace(1,1,"0"); + } + if (str_j_1.find("+") != std::string::npos){ + str_j_1.replace(0,1,"+"); + j_i_1 = stoi(str_j_1); + } + else{ + str_j_1.replace(0,1,"-"); + j_i_1 = stoi(str_j_1); + j_i_1 = -j_i_1; + } + if (j_i > j_i_1) { + string b = (*time_reg_map_local)[j]; + (*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1]; + (*time_reg_map_local)[j + 1] = b; - b = (*time_reg_map)[j]; - (*time_reg_map)[j] = (*time_reg_map)[j + 1]; - (*time_reg_map)[j + 1] = b; - } + b = (*time_reg_map)[j]; + (*time_reg_map)[j] = (*time_reg_map)[j + 1]; + (*time_reg_map)[j + 1] = b; + } } } } } diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index a3266cc..4a5ef20 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -99,12 +99,14 @@ class MainWindow : public Gtk::ApplicationWindow { Type response; int error; }; - string array_region[14]={ - "Africa", + vector array_region_local; + vector array_region;/*={ "America", "Antarctica", "Arctic", "Asia", + "Africa", + "Etc", "Atlantic", "Australia", "Brazil", @@ -113,7 +115,7 @@ class MainWindow : public Gtk::ApplicationWindow { "Europe", "Indian", "Mexico", - "US"}; + "US"};*/ public: MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); MainWindow(Glib::RefPtr const& builder); -- 2.35.1 From 3095b62e04ca779560b84023dd41df18787f64b4 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 16:26:39 +0600 Subject: [PATCH 4/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D1=80=D0=B5=D0=B3=D0=B8=D0=BE=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2,=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D0=BE=D1=87=D0=BD=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 47 +++++++++++---------------------- source/ubl-settings-datetime.h | 17 +----------- 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index a3e7edf..20fdde2 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -1,36 +1,18 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include #include -#include +#include +#include #include -#include +#include #include -#include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "unicode/utypes.h" -#include "unicode/utext.h" #include #include -#include #include "ubl-settings-datetime.h" using namespace std; @@ -687,16 +669,17 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex } // Cортировка пузырьком if (size_vec==0){ + size_vec = array_region_local.size(); for (int i = 0; i < size_vec; i++) { for (int j = 0; j < size_vec-1; j++) { - if (array_region_local[j] > array_region_local[j + 1]) { - auto b = array_region_local[j]; - array_region_local[j] = array_region_local[j + 1]; - array_region_local[j + 1] = b; - b = array_region[j]; - array_region[j] = array_region[j + 1]; - array_region[j + 1] = b; - } + if (array_region_local[j] > array_region_local[j + 1]) { + auto b = array_region_local[j]; + array_region_local[j] = array_region_local[j + 1]; + array_region_local[j + 1] = b; + b = array_region[j]; + array_region[j] = array_region[j + 1]; + array_region[j + 1] = b; + } } } } diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index 4a5ef20..c1572ab 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -100,22 +100,7 @@ class MainWindow : public Gtk::ApplicationWindow { int error; }; vector array_region_local; - vector array_region;/*={ - "America", - "Antarctica", - "Arctic", - "Asia", - "Africa", - "Etc", - "Atlantic", - "Australia", - "Brazil", - "Canada", - "Chile", - "Europe", - "Indian", - "Mexico", - "US"};*/ + vector array_region; public: MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); MainWindow(Glib::RefPtr const& builder); -- 2.35.1 From 2735f1a7301985e25d78908a601b1acdad02f8ee Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 16:40:40 +0600 Subject: [PATCH 5/5] fix and update repo --- source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a7ed26f..27292b0 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -13,7 +13,7 @@ find_package(ICU REQUIRED COMPONENTS uc dt in io) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection -g ") + -fstack-clash-protection -fcf-protection ") set(SOURCE_FILES main.cc -- 2.35.1