@ -22,6 +22,16 @@
|
|||||||||||||
#include <string>
|
#include <string>
|
||||||||||||
#include <sstream>
|
#include <sstream>
|
||||||||||||
#include <vector>
|
#include <vector>
|
||||||||||||
|
#include <unicode/unistr.h>
|
||||||||||||
|
#include <unicode/ustdio.h>
|
||||||||||||
|
#include <unicode/uloc.h>
|
||||||||||||
|
#include <unicode/uldnames.h>
|
||||||||||||
|
#include "unicode/utypes.h"
|
||||||||||||
|
#include "unicode/utext.h"
|
||||||||||||
|
|
||||||||||||
|
#include <unicode/timezone.h>
|
||||||||||||
|
#include <unicode/timezone.h>
|
||||||||||||
|
|
|||||||||||||
|
#include <unicode/calendar.h>
|
||||||||||||
#include "ubl-settings-datetime.h"
|
#include "ubl-settings-datetime.h"
|
||||||||||||
using namespace std;
|
using namespace std;
|
||||||||||||
|
|
||||||||||||
@ -104,39 +114,39 @@ void MainWindow::settings(){
|
|||||||||||||
|
|
||||||||||||
int MainWindow::check_root(){
|
int MainWindow::check_root(){
|
||||||||||||
if (geteuid()!=0){
|
if (geteuid()!=0){
|
||||||||||||
lblMessageSudo->set_text(gettext("The program must be run with \nsuperuser privileges!"));
|
lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!"));
|
||||||||||||
mess_sudo->show();
|
mess_sudo->show();
|
||||||||||||
return 1;
|
return 1;
|
||||||||||||
}
|
}
|
||||||||||||
return 0;
|
return 0;
|
||||||||||||
}
|
}
|
||||||||||||
void MainWindow::lacalization(){
|
void MainWindow::lacalization(){
|
||||||||||||
txtDate->set_tooltip_text(gettext("Date of\nFormat: DD.MM.YYYY"));
|
txtDate->set_tooltip_text(_("Date of\nFormat: DD.MM.YYYY"));
|
||||||||||||
lblSynchronizebChkGLob->set_text(gettext("Synchronize via NTP"));
|
lblSynchronizebChkGLob->set_text(_("Synchronize via NTP"));
|
||||||||||||
cbDhcp->append(gettext("By default"));
|
cbDhcp->append(_("By default"));
|
||||||||||||
|
asmeron
commented 3 years ago
Review
Исправить! |
|||||||||||||
cbDhcp->append(gettext("DHCP"));
|
cbDhcp->append(_("DHCP"));
|
||||||||||||
cbDhcp->append(gettext("Manually"));
|
cbDhcp->append(_("Manually"));
|
||||||||||||
|
asmeron
commented 3 years ago
Review
Исправить! |
|||||||||||||
lblDateTimeSetting->set_text(gettext("Local Configuration"));
|
lblDateTimeSetting->set_text(_("Local Configuration"));
|
||||||||||||
lblHead->set_text(gettext("Settings the date and time"));
|
lblHead->set_text(_("Settings the date and time"));
|
||||||||||||
lblTime->set_text(gettext("Time"));
|
lblTime->set_text(_("Time"));
|
||||||||||||
lblData->set_text(gettext("Date"));
|
lblData->set_text(_("Date"));
|
||||||||||||
lblTimeZone->set_text(gettext("Time zone"));
|
lblTimeZone->set_text(_("Time zone"));
|
||||||||||||
lblReg->set_text(gettext("Region"));
|
lblReg->set_text(_("Region"));
|
||||||||||||
lblZone->set_text(gettext("Zone"));
|
lblZone->set_text(_("Zone"));
|
||||||||||||
lblRegGlob->set_text(gettext("Region"));
|
lblRegGlob->set_text(_("Region"));
|
||||||||||||
lblZone1Glob->set_text(gettext("Zone"));
|
lblZone1Glob->set_text(_("Zone"));
|
||||||||||||
lblTimeZoneGlob->set_text(gettext("Time zone"));
|
lblTimeZoneGlob->set_text(_("Time zone"));
|
||||||||||||
lblSynchronizeBtn->set_text(gettext("Sync by"));
|
lblSynchronizeBtn->set_text(_("Sync by"));
|
||||||||||||
lblDateTimeSettingGlob->set_text(gettext("Global customization"));
|
lblDateTimeSettingGlob->set_text(_("Global customization"));
|
||||||||||||
this->set_title(gettext("ubl-settings-datetime"));
|
this->set_title(_("ubl-settings-datetime"));
|
||||||||||||
windowsNnpClose->set_title(gettext("Warning!"));
|
windowsNnpClose->set_title(_("Warning!"));
|
||||||||||||
mess_sudo->set_title(gettext("Warning!"));
|
mess_sudo->set_title(_("Warning!"));
|
||||||||||||
mess_dchp->set_title(gettext("Warning!"));
|
mess_dchp->set_title(_("Warning!"));
|
||||||||||||
lblTimeBios->set_text(gettext("Synchronize hardware time"));
|
lblTimeBios->set_text(_("Synchronize hardware time"));
|
||||||||||||
lblBanerStopNtp->set_text(gettext("Active service detected\nAutomatic time and date synchronization service detected"));
|
lblBanerStopNtp->set_text(_("Active service detected\nAutomatic time and date synchronization service detected"));
|
||||||||||||
lblNtpStop->set_text(gettext("Stop the synchronization service"));
|
lblNtpStop->set_text(_("Stop the synchronization service"));
|
||||||||||||
lblNtpClose->set_text(gettext("Close"));
|
lblNtpClose->set_text(_("Close"));
|
||||||||||||
//_lblSynchronizebChk->set_text(gettext("Synchronize via NTP"));
|
//_lblSynchronizebChk->set_text(_("Synchronize via NTP"));
|
||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
void MainWindow::flag_block_gui(){
|
void MainWindow::flag_block_gui(){
|
||||||||||||
@ -280,28 +290,14 @@ void MainWindow::wind_close_ntp(){
|
|||||||||||||
|
|
||||||||||||
void MainWindow::stop_ntp(){
|
void MainWindow::stop_ntp(){
|
||||||||||||
windowsNnpClose->hide();
|
windowsNnpClose->hide();
|
||||||||||||
/*
|
string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; "
|
||||||||||||
// string cmd = "systemd-timesyncd [[ systemctl --quiet is-active systemd-timesyncd &>/dev/null ]] && systemctl stop systemd-timesyncd";
|
"SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
|
||||||||||||
|
"SEL_SERVICE=\"ntpdate\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
|
||||||||||||
string cmd = "sudo systemctl stop systemd-timesyncd; " ;
|
"SEL_SERVICE=\"chronyd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
|
||||||||||||
cmd += "sudo systemctl stop ntp.service; sudo systemctl stop ntpdate.service; ";
|
"SEL_SERVICE=\"openntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ntpd; "
|
||||||||||||
cmd += "sudo systemctl stop chronyd; sudo service ntpd stop; sudo systemctl stop ptp4l; ";
|
"SEL_SERVICE=\"ptp4l\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
|
||||||||||||
cmd += "sudo systemctl stop openntpd.service; sudo timedatectl set-ntp false";
|
"SEL_SERVICE=\"phc2sys\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE} ";
|
||||||||||||
cmd += "sudo systemctl stop phc2sys";
|
|
||||||||||||
*/
|
|
||||||||||||
string cmd = "";
|
|
||||||||||||
string response = "";
|
|
||||||||||||
string array_servis[8] = {"systemd-timesyncd", "chronyd", "ntp.service", "ntpdate.service",
|
|
||||||||||||
"ntpd", "ptp4l", "openntpd.service", "phc2sys"};
|
|
||||||||||||
for (string &name_serive: array_servis){
|
|
||||||||||||
cmd = "sudo systemctl status " + name_serive + " | grep \"Active: active\"";
|
|
||||||||||||
response = this->call(cmd.c_str());
|
|
||||||||||||
if (response.length()!=0){
|
|
||||||||||||
cmd = "sudo systemctl stop " + name_serive;
|
|
||||||||||||
this->call(cmd.c_str());
|
|
||||||||||||
}
|
|
||||||||||||
}
|
|
||||||||||||
|
|
||||||||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||||||||
this->update_time_date();
|
this->update_time_date();
|
||||||||||||
|
|
||||||||||||
@ -319,7 +315,7 @@ void MainWindow::gui_mess_close(){
|
|||||||||||||
bool MainWindow::focus_ntp(GdkEventFocus* event){
|
bool MainWindow::focus_ntp(GdkEventFocus* event){
|
||||||||||||
if (event!=NULL){}
|
if (event!=NULL){}
|
||||||||||||
if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){
|
if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){
|
||||||||||||
lblMessage->set_text(gettext("Enter DHCP!"));
|
lblMessage->set_text(_("Enter DHCP!"));
|
||||||||||||
mess_dchp->show();
|
mess_dchp->show();
|
||||||||||||
}
|
}
|
||||||||||||
else{
|
else{
|
||||||||||||
@ -334,7 +330,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|||||||||||||
void MainWindow::event_entry_cbDhcp(){
|
void MainWindow::event_entry_cbDhcp(){
|
||||||||||||
Glib::ustring str_dhcp = cbDhcp->get_active_text();
|
Glib::ustring str_dhcp = cbDhcp->get_active_text();
|
||||||||||||
int activ_index = cbDhcp->get_active_row_number();
|
int activ_index = cbDhcp->get_active_row_number();
|
||||||||||||
cout << activ_index << endl;
|
|
||||||||||||
if (str_dhcp.length()!=0){
|
if (str_dhcp.length()!=0){
|
||||||||||||
if (activ_index==0){
|
if (activ_index==0){
|
||||||||||||
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
|
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
|
||||||||||||
@ -442,7 +437,7 @@ void MainWindow::enry_dhcp_mess(){
|
|||||||||||||
}
|
}
|
||||||||||||
else{
|
else{
|
||||||||||||
if (str_dhcp==""){
|
if (str_dhcp==""){
|
||||||||||||
lblMessage->set_text(gettext("Enter DHCP!"));
|
lblMessage->set_text(_("Enter DHCP!"));
|
||||||||||||
mess_dchp->show();
|
mess_dchp->show();
|
||||||||||||
}
|
}
|
||||||||||||
else if (str_dhcp=="(null)"){
|
else if (str_dhcp=="(null)"){
|
||||||||||||
@ -479,6 +474,7 @@ void MainWindow::get_config(){
|
|||||||||||||
str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
|
str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
|
||||||||||||
string str_zone_check = "";
|
string str_zone_check = "";
|
||||||||||||
this->append_region_zone(str_filling_reg,str_filling_zon);
|
this->append_region_zone(str_filling_reg,str_filling_zon);
|
||||||||||||
|
//this->append_region_zone("Africa","Abidjan");
|
||||||||||||
}
|
}
|
||||||||||||
else {
|
else {
|
||||||||||||
this->append_region_zone("Africa","Abidjan");
|
this->append_region_zone("Africa","Abidjan");
|
||||||||||||
@ -486,15 +482,30 @@ void MainWindow::get_config(){
|
|||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
void MainWindow::enter_zone(){
|
void MainWindow::enter_zone(){
|
||||||||||||
Glib::ustring zone_text = cbZone->get_active_text();
|
int activ_index_reg = cbRegion->get_active_row_number();
|
||||||||||||
Glib::ustring reg_text = cbRegion->get_active_text();
|
string reg_text=array_region[activ_index_reg];
|
||||||||||||
if(!(zone_text.empty()) && !(reg_text.empty())){
|
int activ_index = cbZone->get_active_row_number();
|
||||||||||||
str_zone=zone_text.substr(zone_text.find(") ")+2,zone_text.length());
|
string zone_text = "";
|
||||||||||||
str_region=reg_text;
|
if(!(reg_text.empty())){
|
||||||||||||
string cmd = "rm -f /etc/localtime";
|
int index=0;
|
||||||||||||
system(cmd.c_str());
|
for (const auto &zone :time_reg_map.at(reg_text)){
|
||||||||||||
string cmd1 = "ln -s /usr/share/zoneinfo/" + str_region + "/" + str_zone+" /etc/localtime";
|
if (index==activ_index){
|
||||||||||||
system(cmd1.c_str());
|
zone_text=zone;
|
||||||||||||
|
}
|
||||||||||||
|
index+=1;
|
||||||||||||
|
}
|
||||||||||||
|
if (!(zone_text.empty())){
|
||||||||||||
|
str_zone=zone_text;
|
||||||||||||
|
str_region=reg_text;
|
||||||||||||
|
string cmd = "rm -f /etc/localtime";
|
||||||||||||
|
system(cmd.c_str());
|
||||||||||||
|
string cmd1 = "ln -s /usr/share/zoneinfo/" + str_region + "/" + str_zone+" /etc/localtime";
|
||||||||||||
|
system(cmd1.c_str());
|
||||||||||||
|
}
|
||||||||||||
|
else{
|
||||||||||||
|
str_zone="";
|
||||||||||||
|
str_region="";
|
||||||||||||
|
}
|
||||||||||||
}
|
}
|
||||||||||||
else{
|
else{
|
||||||||||||
str_zone="";
|
str_zone="";
|
||||||||||||
@ -512,16 +523,31 @@ void MainWindow::parse_text_date(){
|
|||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
void MainWindow::enter_zone_glob(){
|
void MainWindow::enter_zone_glob(){
|
||||||||||||
Glib::ustring zone_text = cbZoneGlob->get_active_text();
|
int activ_index_reg = cbRegionGlob->get_active_row_number();
|
||||||||||||
Glib::ustring reg_text = cbRegionGlob->get_active_text();
|
string reg_text=array_region[activ_index_reg];
|
||||||||||||
if(!(zone_text.empty()) && !(reg_text.empty())){
|
int activ_index = cbZoneGlob->get_active_row_number();
|
||||||||||||
|
string zone_text="";
|
||||||||||||
|
if(!(reg_text.empty())){
|
||||||||||||
|
int index=0;
|
||||||||||||
|
for (const auto &zone :time_reg_map.at(reg_text)){
|
||||||||||||
|
if (index==activ_index){
|
||||||||||||
|
zone_text=zone;
|
||||||||||||
|
}
|
||||||||||||
|
index+=1;
|
||||||||||||
|
}
|
||||||||||||
|
if (!(zone_text.empty())){
|
||||||||||||
//str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length());
|
//str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length());
|
||||||||||||
string cmd = "/usr/bin/ubconfig set clock ZONE=" +reg_text +"/" + zone_text;
|
string cmd = "/usr/bin/ubconfig set clock ZONE=" +reg_text +"/" + zone_text;
|
||||||||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||||||||
|
}
|
||||||||||||
|
else{
|
||||||||||||
|
str_zoneGlob="";
|
||||||||||||
|
str_region_glob="";
|
||||||||||||
|
}
|
||||||||||||
}
|
}
|
||||||||||||
else{
|
else{
|
||||||||||||
str_zoneGlob="";
|
str_zoneGlob="";
|
||||||||||||
str_region_glob="";
|
str_region_glob="";
|
||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
@ -540,22 +566,33 @@ void MainWindow::set_ntp_toggle_glob(){
|
|||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
void MainWindow::append_region_zone(string region, string zone){
|
void MainWindow::append_region_zone(string region, string zone){
|
||||||||||||
|
str_region=region;
|
||||||||||||
|
str_region_glob=region;
|
||||||||||||
int index = 0;
|
int index = 0;
|
||||||||||||
for ( const auto &text : time_reg_map ) {
|
Glib::ustring reg_local = "";
|
||||||||||||
cbRegion->append(text.first);
|
for (const auto &text : array_region) {
|
||||||||||||
cbRegionGlob->append(text.first);
|
reg_local = text;
|
||||||||||||
if (text.first == region){
|
reg_local = string(_(reg_local.c_str()));
|
||||||||||||
cbRegionGlob->set_active(index);
|
cbRegion->append(Glib::ustring(reg_local));
|
||||||||||||
cbRegion->set_active(index);
|
cbRegionGlob->append(Glib::ustring(reg_local));
|
||||||||||||
|
if (text == region){
|
||||||||||||
|
cbRegionGlob->set_active_text(reg_local);
|
||||||||||||
|
cbRegion->set_active_text(reg_local);
|
||||||||||||
}
|
}
|
||||||||||||
index+=1;
|
index+=1;
|
||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
index = 0;
|
index = 0;
|
||||||||||||
for (const auto &_str_zone : time_reg_map.at(region)){
|
string zone_mixing = "";
|
||||||||||||
cbZone->append(_str_zone);
|
string path_reg_zone = "";
|
||||||||||||
cbZoneGlob->append(_str_zone);
|
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)){
|
||||||||||||
|
cbZone->append(zone_mixing);
|
||||||||||||
|
cbZoneGlob->append(zone_mixing);
|
||||||||||||
if (_str_zone!=""){
|
if (_str_zone!=""){
|
||||||||||||
if (_str_zone == zone){
|
if (zone_offest == _str_zone){
|
||||||||||||
cbZone->set_active(index);
|
cbZone->set_active(index);
|
||||||||||||
cbZoneGlob->set_active(index);
|
cbZoneGlob->set_active(index);
|
||||||||||||
}
|
}
|
||||||||||||
@ -585,25 +622,33 @@ string MainWindow::call(string cmd){
|
|||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
void MainWindow::append_zone(){
|
void MainWindow::append_zone(){
|
||||||||||||
Glib::ustring text = cbRegion->get_active_text();
|
//int length_zone = time_reg_map.at(str_region).size();
|
||||||||||||
cbZone->remove_all();
|
cbZone->remove_all();
|
||||||||||||
if(!(text.empty())){
|
int index = cbRegion->get_active_row_number();
|
||||||||||||
str_region = text;
|
string str_region = array_region[index];
|
||||||||||||
for (const auto &_str_zone : time_reg_map.at(str_region)){
|
string zone_mixing="";
|
||||||||||||
cbZone->append(_str_zone);
|
string path_dir="";
|
||||||||||||
|
if(str_region.length()!=0){
|
||||||||||||
|
for (const auto &_str_zone : time_reg_map_local.at(str_region)){
|
||||||||||||
|
cbZone->append(Glib::ustring(_str_zone));
|
||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
|
cbZone->set_active(0);
|
||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
void MainWindow::append_zone_glob(){
|
void MainWindow::append_zone_glob(){
|
||||||||||||
Glib::ustring text = cbRegionGlob->get_active_text();
|
|
||||||||||||
cbZoneGlob->remove_all();
|
cbZoneGlob->remove_all();
|
||||||||||||
if(!(text.empty())){
|
int index = cbRegionGlob->get_active_row_number();
|
||||||||||||
str_region_glob = text;
|
string str_region_glob = array_region[index];
|
||||||||||||
for (const auto &_str_zone : time_reg_map.at(str_region_glob)){
|
string zone_mixing="";
|
||||||||||||
cbZoneGlob->append(_str_zone);
|
string path_dir="";
|
||||||||||||
|
|
||||||||||||
|
if(str_region_glob.length()!=0){
|
||||||||||||
|
for (const auto &_str_zone : time_reg_map_local.at(str_region_glob)){
|
||||||||||||
|
cbZoneGlob->append(Glib::ustring(_str_zone));
|
||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
|
cbZoneGlob->set_active(0);
|
||||||||||||
}
|
}
|
||||||||||||
void MainWindow::wrapper_update_time_date(){
|
void MainWindow::wrapper_update_time_date(){
|
||||||||||||
string cmd = "pidof systemd-timesyncd ntpd chronyd";
|
string cmd = "pidof systemd-timesyncd ntpd chronyd";
|
||||||||||||
@ -681,7 +726,7 @@ void MainWindow::post_entry_data(){
|
|||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
else{
|
else{
|
||||||||||||
lblMessage->set_text(gettext("Incorrect date format"));
|
lblMessage->set_text(_("Incorrect date format"));
|
||||||||||||
mess_dchp->show();
|
mess_dchp->show();
|
||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
@ -720,6 +765,8 @@ void MainWindow::update_calendar(){
|
|||||||||||||
|
|
||||||||||||
void MainWindow::read_file(){
|
void MainWindow::read_file(){
|
||||||||||||
std::string line;
|
std::string line;
|
||||||||||||
|
string key_zone_local = "";
|
||||||||||||
|
string path_reg_zone = "";
|
||||||||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||||||||
for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){
|
for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){
|
||||||||||||
std::ifstream in(entry.path()); // окрываем файл для чтения
|
std::ifstream in(entry.path()); // окрываем файл для чтения
|
||||||||||||
@ -732,20 +779,24 @@ void MainWindow::read_file(){
|
|||||||||||||
if (key_reg!="Etc"){
|
if (key_reg!="Etc"){
|
||||||||||||
if (key_reg!="right"){
|
if (key_reg!="right"){
|
||||||||||||
vector<string> zone;
|
vector<string> zone;
|
||||||||||||
zone.push_back("");
|
vector<string> zone_local;
|
||||||||||||
|
//zone.push_back("");
|
||||||||||||
for (const auto & entry_zone : fs::directory_iterator(path_dir)){
|
for (const auto & entry_zone : fs::directory_iterator(path_dir)){
|
||||||||||||
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
|
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
|
||||||||||||
if (in1.is_open()){
|
if (in1.is_open()){
|
||||||||||||
string key_zone = entry_zone.path().filename().string();
|
string key_zone = entry_zone.path().filename().string();
|
||||||||||||
if (key_zone.length()!=0 || key_zone!=" "){
|
if (key_zone.length()!=0 || key_zone!=" "){
|
||||||||||||
zone.push_back(string(gettext(key_zone.c_str())));
|
zone.push_back(key_zone);
|
||||||||||||
|
path_reg_zone=key_reg + "/" + key_zone;
|
||||||||||||
|
key_zone_local = this->zone_file_read(path_reg_zone) +_(key_zone.c_str());
|
||||||||||||
|
zone_local.push_back(key_zone_local);
|
||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
in1.close();
|
in1.close();
|
||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
key_reg = string(gettext(key_reg.c_str()));
|
time_reg_map.insert({key_reg, zone});
|
||||||||||||
time_reg_map.insert({key_reg, zone});
|
time_reg_map_local.insert({key_reg, zone_local});
|
||||||||||||
}}}}
|
}}}}
|
||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
@ -753,6 +804,43 @@ void MainWindow::read_file(){
|
|||||||||||||
}
|
}
|
||||||||||||
}
|
}
|
||||||||||||
|
|
||||||||||||
|
string MainWindow::zone_file_read(string zone){
|
||||||||||||
|
|
||||||||||||
|
if (zone.length()==1){
|
||||||||||||
|
return "";
|
||||||||||||
|
}
|
||||||||||||
|
UErrorCode success = U_ZERO_ERROR;
|
||||||||||||
|
UDate curDate;
|
||||||||||||
|
int32_t stdOffset,dstOffset;
|
||||||||||||
|
U_ICU_NAMESPACE::TimeZone *tzWest = U_ICU_NAMESPACE::TimeZone::createTimeZone(zone.c_str());
|
||||||||||||
|
U_ICU_NAMESPACE::Calendar* calendar = U_ICU_NAMESPACE::Calendar::createInstance(success);
|
||||||||||||
|
curDate = calendar->getNow();
|
||||||||||||
|
tzWest->getOffset(curDate,true,stdOffset,dstOffset,success);
|
||||||||||||
|
int offset = stdOffset/(1000*60*60);
|
||||||||||||
|
string str_utc = "";
|
||||||||||||
|
if (offset>=0){
|
||||||||||||
|
if (offset<=9){
|
||||||||||||
|
str_utc = "(UTC +0" + to_string(offset) + ") ";
|
||||||||||||
|
}
|
||||||||||||
|
else{
|
||||||||||||
|
str_utc = "(UTC +" + to_string(offset) + ") ";
|
||||||||||||
|
}
|
||||||||||||
|
|
||||||||||||
|
}
|
||||||||||||
|
else{
|
||||||||||||
|
if (offset>=-9){
|
||||||||||||
|
offset*=-1;
|
||||||||||||
|
str_utc = "(UTC -0" + to_string(offset) + ") ";
|
||||||||||||
|
}
|
||||||||||||
|
else{
|
||||||||||||
|
str_utc = "(UTC " + to_string(offset) + ") ";
|
||||||||||||
|
}
|
||||||||||||
|
}
|
||||||||||||
|
delete calendar;
|
||||||||||||
|
delete tzWest;
|
||||||||||||
|
return str_utc;
|
||||||||||||
|
}
|
||||||||||||
|
|
||||||||||||
vector<std::string> MainWindow::split(const std::string &s, char delim){
|
vector<std::string> MainWindow::split(const std::string &s, char delim){
|
||||||||||||
std::stringstream ss(s);
|
std::stringstream ss(s);
|
||||||||||||
std::string item;
|
std::string item;
|
||||||||||||
|
|||||||||||||
@ -1,26 +1,16 @@
|
|||||||||||||
#ifndef UBL_SETTINGS_DATETIME_H
|
#ifndef UBL_SETTINGS_DATETIME_H
|
||||||||||||
#define UBL_SETTINGS_DATETIME_H
|
#define UBL_SETTINGS_DATETIME_H
|
||||||||||||
#include <gtkmm/window.h>
|
#include <gtkmm/window.h>
|
||||||||||||
#include <stddef.h>
|
|
||||||||||||
#include <cstddef>
|
|
||||||||||||
#include <cstdlib>
|
|
||||||||||||
#include <iostream>
|
#include <iostream>
|
||||||||||||
#include <memory>
|
|
||||||||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||||||||
#include <ostream>
|
|
||||||||||||
#include <string>
|
#include <string>
|
||||||||||||
#include <ctime>
|
|
||||||||||||
#include <vector>
|
#include <vector>
|
||||||||||||
#include <map>
|
#include <map>
|
||||||||||||
#include <fstream>
|
|
||||||||||||
#include <filesystem>
|
|
||||||||||||
#include <glibmm/i18n.h>
|
#include <glibmm/i18n.h>
|
||||||||||||
#include <stdio.h>
|
|
||||||||||||
#include <gtkmm/plug.h>
|
#include <gtkmm/plug.h>
|
||||||||||||
#include <gtkmm/stock.h>
|
#include <gtkmm/stock.h>
|
||||||||||||
#include <unistd.h>
|
|
||||||||||||
#include <sys/types.h>
|
|
||||||||||||
#include <stdio.h>
|
|
||||||||||||
using namespace std;
|
using namespace std;
|
||||||||||||
|
|
||||||||||||
extern string path_app;
|
extern string path_app;
|
||||||||||||
@ -81,6 +71,7 @@ class MainWindow : public Gtk::ApplicationWindow {
|
|||||||||||||
void stop_ntp();
|
void stop_ntp();
|
||||||||||||
void wind_close_ntp();
|
void wind_close_ntp();
|
||||||||||||
void wrapper_update_time_date();
|
void wrapper_update_time_date();
|
||||||||||||
|
string zone_file_read(string zone);
|
||||||||||||
string str_remove(std::string& source, const std::string to_remove);
|
string str_remove(std::string& source, const std::string to_remove);
|
||||||||||||
vector<std::string> split(const std::string &s, char delim);
|
vector<std::string> split(const std::string &s, char delim);
|
||||||||||||
private:
|
private:
|
||||||||||||
@ -130,6 +121,7 @@ class MainWindow : public Gtk::ApplicationWindow {
|
|||||||||||||
Gtk::Entry *txtNtpServer;
|
Gtk::Entry *txtNtpServer;
|
||||||||||||
Gtk::Entry *txtDate;
|
Gtk::Entry *txtDate;
|
||||||||||||
std::map <string, vector<string>> time_reg_map;
|
std::map <string, vector<string>> time_reg_map;
|
||||||||||||
|
std::map <string, vector<string>> time_reg_map_local;
|
||||||||||||
unsigned int year=0;
|
unsigned int year=0;
|
||||||||||||
unsigned int month=0;
|
unsigned int month=0;
|
||||||||||||
unsigned int day=0;
|
unsigned int day=0;
|
||||||||||||
@ -141,7 +133,21 @@ class MainWindow : public Gtk::ApplicationWindow {
|
|||||||||||||
string strtxtNtpServer;
|
string strtxtNtpServer;
|
||||||||||||
string str_zone="";
|
string str_zone="";
|
||||||||||||
string str_zoneGlob;
|
string str_zoneGlob;
|
||||||||||||
|
string array_region[14]={
|
||||||||||||
|
asmeron
commented 3 years ago
Review
Для чего массив тут нужен, когда эта информация в системе присутствует !! |
|||||||||||||
|
"Africa",
|
||||||||||||
|
"America",
|
||||||||||||
|
"Antarctica",
|
||||||||||||
|
"Arctic",
|
||||||||||||
|
"Asia",
|
||||||||||||
|
"Atlantic",
|
||||||||||||
|
"Australia",
|
||||||||||||
|
"Brazil",
|
||||||||||||
|
"Canada",
|
||||||||||||
|
"Chile",
|
||||||||||||
|
"Europe",
|
||||||||||||
|
"Indian",
|
||||||||||||
|
"Mexico",
|
||||||||||||
|
"US"};
|
||||||||||||
};
|
};
|
||||||||||||
|
|
||||||||||||
class SettingsPlug : public Gtk::Plug
|
class SettingsPlug : public Gtk::Plug
|
||||||||||||
|
|||||||||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue
Дубликат?