|
|
|
@ -124,6 +124,7 @@ void MainWindow::get_builder(){
|
|
|
|
builder->get_widget("txtNtpServer", _txtNtpServer);
|
|
|
|
builder->get_widget("txtNtpServer", _txtNtpServer);
|
|
|
|
builder->get_widget("cldrDate", _cldrDate);
|
|
|
|
builder->get_widget("cldrDate", _cldrDate);
|
|
|
|
builder->get_widget("mess_dchp", _mess_dchp);
|
|
|
|
builder->get_widget("mess_dchp", _mess_dchp);
|
|
|
|
|
|
|
|
builder->get_widget("lblMessage", _lblMessage);
|
|
|
|
//this->add_CSS();
|
|
|
|
//this->add_CSS();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MainWindow::event(){
|
|
|
|
void MainWindow::event(){
|
|
|
|
@ -431,15 +432,7 @@ void MainWindow::append_zone_glob(){
|
|
|
|
void MainWindow::update_time_date(){
|
|
|
|
void MainWindow::update_time_date(){
|
|
|
|
this->enter_zone();
|
|
|
|
this->enter_zone();
|
|
|
|
bool flag = _cbxSynchronizeNtp->get_active();
|
|
|
|
bool flag = _cbxSynchronizeNtp->get_active();
|
|
|
|
if (flag==false){
|
|
|
|
string cmd = "";
|
|
|
|
hour = _numTimeHrs->get_value_as_int();
|
|
|
|
|
|
|
|
minute = _numTimeMin->get_value_as_int();
|
|
|
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|
|
|
|
string cmd = "date +%T -s \""+
|
|
|
|
|
|
|
|
to_string(hour) + ":" + to_string(minute)
|
|
|
|
|
|
|
|
+ ":" + to_string(ltm->tm_sec) +"\"";
|
|
|
|
|
|
|
|
system(cmd.c_str());
|
|
|
|
|
|
|
|
if ((year!=0) && (month !=0) && (day !=0)){
|
|
|
|
if ((year!=0) && (month !=0) && (day !=0)){
|
|
|
|
string str_month = "";
|
|
|
|
string str_month = "";
|
|
|
|
string str_day = "";
|
|
|
|
string str_day = "";
|
|
|
|
@ -462,6 +455,9 @@ void MainWindow::update_time_date(){
|
|
|
|
cmd = "hwclock --systohc";
|
|
|
|
cmd = "hwclock --systohc";
|
|
|
|
system(cmd.c_str());
|
|
|
|
system(cmd.c_str());
|
|
|
|
_txtDate->set_text(str_day+"." + str_month+"." + to_string(year));
|
|
|
|
_txtDate->set_text(str_day+"." + str_month+"." + to_string(year));
|
|
|
|
|
|
|
|
year=0;
|
|
|
|
|
|
|
|
month=0;
|
|
|
|
|
|
|
|
day=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
string cmd = "";
|
|
|
|
string cmd = "";
|
|
|
|
@ -472,14 +468,30 @@ void MainWindow::update_time_date(){
|
|
|
|
string str_year = data.substr(6,data.length());
|
|
|
|
string str_year = data.substr(6,data.length());
|
|
|
|
cmd = "date +%Y%m%d -s \"" + str_year+
|
|
|
|
cmd = "date +%Y%m%d -s \"" + str_year+
|
|
|
|
str_month+str_day+"\"";
|
|
|
|
str_month+str_day+"\"";
|
|
|
|
|
|
|
|
string str_error_clock = this->call(cmd);
|
|
|
|
|
|
|
|
size_t index = str_error_clock.find("date: ");
|
|
|
|
|
|
|
|
if (index==std::string::npos){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
_lblMessage->set_text("Не верный формат даты");
|
|
|
|
|
|
|
|
_mess_dchp->show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag==false){
|
|
|
|
|
|
|
|
hour = _numTimeHrs->get_value_as_int();
|
|
|
|
|
|
|
|
minute = _numTimeMin->get_value_as_int();
|
|
|
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|
|
|
|
cmd = "date +%T -s \""+
|
|
|
|
|
|
|
|
to_string(hour) + ":" + to_string(minute)
|
|
|
|
|
|
|
|
+ ":" + to_string(ltm->tm_sec) +"\"";
|
|
|
|
system(cmd.c_str());
|
|
|
|
system(cmd.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmd = "hwclock --systohc";
|
|
|
|
cmd = "hwclock --systohc";
|
|
|
|
system(cmd.c_str());
|
|
|
|
system(cmd.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::update_hour_minute(){
|
|
|
|
void MainWindow::update_hour_minute(){
|
|
|
|
time_t now = time(0);
|
|
|
|
time_t now = time(0);
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|