From df0d0af3eee9106f1c89eaad9a5f96ba601b8772 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Feb 2023 09:26:10 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B1=D0=B0=D0=B3=D0=B8=20=D1=81=20=D0=B3?= =?UTF-8?q?=D0=B0=D0=BB=D0=BA=D0=BE=D0=B9=20dhcp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 89b2d19..ac46b29 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -383,7 +383,7 @@ void MainWindow::event_entry_cbDhcp(){ txtNtpServer->set_text(""); } string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - if ((str_dhcp!="") && (str_dhcp!="(null)") && (str_dhcp.find("default")==std::string::npos)){ + if ((str_dhcp.find("(null)")==std::string::npos) && (str_dhcp.find("default")==std::string::npos)){ str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length()); str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n")); if (str_dhcp!="dhcp" && str_dhcp!="(null)"){ @@ -450,9 +450,11 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - if ((str_dhcp!="") && (str_dhcp!="(null)")){ - cbxSynchronizeNtpGlob->set_active(1); - this->set_ntp_toggle_glob(); + cout << str_dhcp << endl; + if (str_dhcp.find("(null)")==std::string::npos){ + + cbxSynchronizeNtpGlob->set_active(true); + //this->set_ntp_toggle_glob(); str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length()); str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n")); if (str_dhcp=="dhcp"){ @@ -482,9 +484,10 @@ void MainWindow::enry_dhcp_mess(){ } } else{ - cbxSynchronizeNtpGlob->set_active(0); - cbDhcp->set_sensitive(0); - txtNtpServer->set_sensitive(0); + cout << 2222 << endl; + cbxSynchronizeNtpGlob->set_active(false); + cbDhcp->set_sensitive(false); + txtNtpServer->set_sensitive(false); } } @@ -602,14 +605,16 @@ void MainWindow::set_ntp_toggle_glob(){ if (flag==false){ system("/usr/bin/ubconfig remove network NTPSERVERS"); cbDhcp->set_sensitive(false); + txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); + } else{ cbDhcp->set_sensitive(true); - int activ_index = cbDhcp->get_active_row_number(); - if (activ_index==2){ - txtNtpServer->set_sensitive(true); - } + system("/usr/bin/ubconfig set network NTPSERVERS=dhcp"); + cbDhcp->set_active(1); + txtNtpServer->set_text(""); + txtNtpServer->set_sensitive(false); } }