Изменение дизайна и новая весрия

pull/55/head
Igor Belitskiy 3 years ago
parent 8e90dd950d
commit c0680032f9

@ -68,8 +68,13 @@ void MainWindow::settings(){
this->flag_block_gui();
this->event();
this->parse_text_date();
btnSaveGlobl->set_sensitive(false);
this->download_local_cfg();
}
else{
btnSaveLocal->set_sensitive(false);
btnSaveGlobl->set_sensitive(false);
btnDownload->set_sensitive(false);
numTimeHrs->set_sensitive(false);
numTimeMin->set_sensitive(false);
lblTime->set_sensitive(false);
@ -87,8 +92,6 @@ void MainWindow::settings(){
lblSynchronizebChkGLob->set_sensitive(false);
cbDhcp->set_sensitive(false);
txtNtpServer->set_sensitive(false);
lblTimeZoneGlob->set_sensitive(false);
lblRegGlob->set_sensitive(false);
lblZone1Glob->set_sensitive(false);
lblDateTimeSetting->set_sensitive(false);
this->event();
@ -104,13 +107,14 @@ int MainWindow::check_root(){
}
return 0;
}
void MainWindow::lacalization(){
lblSave->set_label(_("Save"));
lblDownload->set_label(_("Download"));
btnDownloadGlobal->set_label(_("Download global"));
btnSaveLocal->set_label(_("Save global"));
btnSaveGlobl->set_label(_("Save local"));
btnDownloadlocal->set_label(_("Download local"));
btnSaveLocal->set_label(_("Save local"));
btnSaveGlobl->set_label(_("Save global"));
txtDate->set_tooltip_text(_("Date of\nFormat: DD.MM.YYYY"));
txtNtpServer->set_tooltip_text(_("Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas."));
lblSynchronizebChkGLob->set_text(_("Synchronize via NTP:"));
@ -125,9 +129,6 @@ void MainWindow::lacalization(){
lblTimeZone->set_text(_("Time zone"));
lblReg->set_text(_("Region"));
lblZone->set_text(_("Zone"));
lblRegGlob->set_text(_("Region"));
lblZone1Glob->set_text(_("Zone"));
lblTimeZoneGlob->set_text(_("Time zone"));
lblSynchronizeBtn->set_text(_("Sync by"));
lblDateTimeSettingGlob->set_text(_("Global customization"));
this->set_title(_("ubl-settings-datetime"));
@ -159,8 +160,6 @@ void MainWindow::flag_block_gui(){
if (flag_timezone==true){
cbRegion->set_sensitive(false);
cbZone->set_sensitive(false);
cbRegionGlob->set_sensitive(false);
cbZoneGlob->set_sensitive(false);
//btnChooseDate->set_sensitive(false);
cbDhcp->set_sensitive(false);
}
@ -170,12 +169,6 @@ void MainWindow::flag_block_gui(){
}
if (flag_update==true){
lblDateTimeSettingGlob->set_sensitive(false);
//lblSynchronizebChkGLob->set_sensitive(false);
lblTimeZoneGlob->set_sensitive(false);
lblRegGlob->set_sensitive(false);
cbRegionGlob->set_sensitive(false);
lblZone1Glob->set_sensitive(false);
cbZoneGlob->set_sensitive(false);
txtNtpServer->set_sensitive(false);
cbDhcp->set_sensitive(false);
}
@ -207,9 +200,7 @@ void MainWindow::get_builder(){
builder->get_widget("cbDhcp", cbDhcp);
builder->get_widget("txtDate", txtDate);
builder->get_widget("cbRegion", cbRegion);
builder->get_widget("cbRegionGlob", cbRegionGlob);
builder->get_widget("cbZone", cbZone);
builder->get_widget("cbZoneGlob", cbZoneGlob);
builder->get_widget("txtNtpServer", txtNtpServer);
builder->get_widget("cldrDate", cldrDate);
builder->get_widget("mess_dchp", mess_dchp);
@ -221,9 +212,6 @@ void MainWindow::get_builder(){
builder->get_widget("lblTimeZone",lblTimeZone);
builder->get_widget("lblReg",lblReg);
builder->get_widget("lblZone",lblZone);
builder->get_widget("lblRegGlob",lblRegGlob);
builder->get_widget("lblZone1Glob",lblZone1Glob);
builder->get_widget("lblTimeZoneGlob",lblTimeZoneGlob);
//builder->get_widget("lblSynchronizebChk",_lblSynchronizebChk);
builder->get_widget("lblSynchronizebChkGLob",lblSynchronizebChkGLob);
builder->get_widget("lblSynchronizeBtn",lblSynchronizeBtn);
@ -242,9 +230,11 @@ void MainWindow::get_builder(){
builder->get_widget("btnSaveLocal",btnSaveLocal);
builder->get_widget("btnSaveGlobl",btnSaveGlobl);
builder->get_widget("lblSave",lblSave);
builder->get_widget("btnSave",btnSave);
builder->get_widget("btnDownload",btnDownload);
builder->get_widget("lblDownload",lblDownload);
builder->get_widget("btnDownloadGlobal", btnDownloadGlobal);
builder->get_widget("btnDownloadlocal", btnDownloadlocal);
//builder->get_widget("cbxSynchronizeNtp",cbxSynchronizeNtp);
@ -269,15 +259,40 @@ void MainWindow::event(){
btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show));
cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::event_entry_cbDhcp));
cbRegion->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone));
cbRegionGlob->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone_glob));
cbZone->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::enter_zone));
cbZoneGlob->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::enter_zone_glob));
txtNtpServer->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_ntp));
cldrDate->signal_day_selected_double_click().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
mess_sudo->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::gui_exit_2));
btnNtpWinClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::wind_close_ntp));
btnNtpStop->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::stop_ntp));
btnDownloadGlobal->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::download_globl_cfg));
btnSaveLocal->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::save_local_cfg));
btnSaveGlobl->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::save_global_cfg));
btnDownloadlocal->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::download_local_cfg));
}
void MainWindow::download_globl_cfg(){
this->entry_dhcp_mess();
string cmd = "/usr/bin/ubconfig --default --source global get clock ZONE";
this->fill_in_reg_zone(cmd);
btnSaveGlobl->set_sensitive(true);
}
void MainWindow::download_local_cfg(){
string cmd = "/usr/bin/ubconfig --default --source system get clock ZONE";
this->fill_in_reg_zone(cmd);
}
void MainWindow::save_local_cfg(){
string cmd = "ubconfig --target system set clock ZONE=";
this->enter_zone(cmd);
}
void MainWindow::save_global_cfg(){
string cmd = "/usr/bin/ubconfig --target global set clock ZONE=";
this->enter_zone(cmd);
this->save_Dhcp();
}
void MainWindow::wind_close_ntp(){
windowsNnpClose->hide();
}
@ -309,8 +324,7 @@ void MainWindow::gui_mess_close(){
mess_dchp->hide();
}
bool MainWindow::focus_ntp(GdkEventFocus* event){
if (event!=NULL){}
bool MainWindow::focus_ntp(){
if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){
lblMessage->set_text(_("Enter DHCP!"));
mess_dchp->show();
@ -455,17 +469,18 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd){
}
return obj_result;
}
void MainWindow::event_entry_cbDhcp(){
Glib::ustring str_dhcp = cbDhcp->get_active_text();
string str_dhcp = cbDhcp->get_active_text();
string cmd = "";
int activ_index = cbDhcp->get_active_row_number();
if (str_dhcp.length()!=0){
if (activ_index==0){
if (str_dhcp.length()==0){
cbDhcp->set_active(0);
}
else if (activ_index==0){
txtNtpServer->set_text("");
btnUpdateDateTime->set_sensitive(false);
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
response_cmd=system(cmd.c_str());
txtNtpServer->set_sensitive(false);
cbDhcp->set_active(activ_index);
/*
cmd = "/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT";
struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error==0){
@ -476,22 +491,17 @@ void MainWindow::event_entry_cbDhcp(){
//error = string(_("ERROR")) + "\n" + obj_result.response;
//lblMessage->set_text(error);
//mess_dchp->show();
}
}*/
}
else if (activ_index==1){
btnUpdateDateTime->set_sensitive(false);
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
response_cmd=system(cmd.c_str());
txtNtpServer->set_sensitive(false);
cbDhcp->set_active(activ_index);
txtNtpServer->set_text("");
}
else if (activ_index==2){
btnUpdateDateTime->set_sensitive(false);
txtNtpServer->set_sensitive(true);
if (txtNtpServer->get_text().find("default")!=std::string::npos){
txtNtpServer->set_text("");
}
/*
string cmd = "/usr/bin/ubconfig get network NTPSERVERS";
struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error==0){
@ -509,10 +519,9 @@ void MainWindow::event_entry_cbDhcp(){
lblMessage->set_text(error);
mess_dchp->show();
}
*/
}
else if (activ_index==3){
string cmd = "/usr/bin/ubconfig remove network NTPSERVERS";
response_cmd=system(cmd.c_str());
txtNtpServer->set_text("");
txtNtpServer->set_sensitive(false);
btnUpdateDateTime->set_sensitive(true);
@ -520,10 +529,27 @@ void MainWindow::event_entry_cbDhcp(){
}
}
else{
void MainWindow::save_Dhcp(){
int activ_index = cbDhcp->get_active_row_number();
string str_dhcp = cbDhcp->get_active_text();
string cmd = "";
if (str_dhcp.length()==0){
}
else if (activ_index==0){
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
response_cmd=system(cmd.c_str());
}
else if (activ_index==1){
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
response_cmd=system(cmd.c_str());
cbDhcp->set_active(0);
}
else if (activ_index==2){
this->focus_ntp();
}
else if (activ_index==3){
string cmd = "/usr/bin/ubconfig remove network NTPSERVERS";
response_cmd=system(cmd.c_str());
}
}
@ -575,7 +601,7 @@ void MainWindow::calendar_show(){
popCalendar->show();
}
void MainWindow::enry_dhcp_mess(){
void MainWindow::entry_dhcp_mess(){
string cmd = "/usr/bin/ubconfig get network NTPSERVERS";
struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error==0){
@ -629,27 +655,8 @@ void MainWindow::enry_dhcp_mess(){
}
}
void MainWindow::get_config(){
this->read_file();
this->update_hour_minute();
this->update_calendar();
this->enry_dhcp_mess();
string cmd = "/usr/bin/ubconfig --default --source global get clock ZONE";
struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error==0){
auto arr_reg_zone_glob = this->split_region_zone(obj_result.response);
if (arr_reg_zone_glob[0].length()!=0){
this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1],cbRegionGlob,cbZoneGlob);
}
else{
this->append_region_zone("","",cbRegionGlob,cbZoneGlob);
}
void MainWindow::fill_in_reg_zone(string &cmd){
}
else {
this->append_region_zone("","",cbRegionGlob,cbZoneGlob);
}
cmd = "/usr/bin/ubconfig --default --source system get clock ZONE";
struct Result<string> 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);
@ -663,6 +670,16 @@ void MainWindow::get_config(){
else {
this->append_region_zone("","",cbRegion,cbZone);
}
}
void MainWindow::get_config(){
this->read_file();
this->update_hour_minute();
this->update_calendar();
this->entry_dhcp_mess();
}
@ -684,7 +701,7 @@ array<string, 2> MainWindow::split_region_zone(string read_reg_zon_cfg){
}
void MainWindow::enter_zone(){
void MainWindow::enter_zone(string &cmd){
int activ_index_reg = cbRegion->get_active_row_number();
string reg_text=array_region[activ_index_reg];
int activ_index = cbZone->get_active_row_number();
@ -700,8 +717,7 @@ void MainWindow::enter_zone(){
if (!(zone_text.empty())){
str_zone=zone_text;
str_region=reg_text;
string cmd = "";
cmd = " ubconfig --target system set clock ZONE=" + str_region + "/" + str_zone;
cmd = cmd + str_region + "/" + str_zone;
response_cmd=system(cmd.c_str());
}
else{
@ -724,36 +740,6 @@ void MainWindow::parse_text_date(){
}
}
void MainWindow::enter_zone_glob(){
int activ_index_reg = cbRegionGlob->get_active_row_number();
string reg_text=array_region[activ_index_reg];
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());
string cmd = "/usr/bin/ubconfig --target global set clock ZONE=" +reg_text +"/" + zone_text;
response_cmd=system(cmd.c_str());
}
else{
str_zoneGlob="";
str_region_glob="";
}
}
else{
str_zoneGlob="";
str_region_glob="";
}
}
void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone){
str_region=region;
str_region_glob=region;
@ -789,6 +775,7 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
tmpCbReg->set_active_text(reg);
}
}
tmpCbZone->remove_all();
index = 0;
string zone_mixing = "";
string path_reg_zone = "";
@ -852,23 +839,7 @@ void MainWindow::append_zone(){
cbZone->set_active(0);
}
void MainWindow::append_zone_glob(){
cbZoneGlob->remove_all();
int index = cbRegionGlob->get_active_row_number();
string str_region_glob = array_region[index];
string zone_mixing="";
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::update_time_date(){
//this->enter_zone();
string cmd = "";
if ((year!=0) && (month !=0) && (day !=0)){
string str_month = "";

@ -53,9 +53,7 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::CheckButton *cbxSynchronizeNtpGlob;
Gtk::Box *boxColor;
Gtk::ComboBoxText *cbRegion;
Gtk::ComboBoxText *cbRegionGlob;
Gtk::ComboBoxText *cbZone;
Gtk::ComboBoxText *cbZoneGlob;
Gtk::Window *mess_dchp;
Gtk::Window *mess_sudo;
Gtk::Popover *popCalendar;
@ -69,9 +67,7 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Label *lblTimeZone;
Gtk::Label *lblReg;
Gtk::Label *lblZone;
Gtk::Label *lblRegGlob;
Gtk::Label *lblZone1Glob;
Gtk::Label *lblTimeZoneGlob;
Gtk::Label *lblSynchronizebChk;
Gtk::Label *lblSynchronizebChkGLob;
Gtk::Label *lblSynchronizeBtn;
@ -93,7 +89,9 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Widget *btnDownload;
Gtk::MenuItem *btnSaveLocal;
Gtk::MenuItem *btnSaveGlobl;
Gtk::MenuItem *btnDownloadGlobal;
Gtk::MenuItem *btnDownloadlocal;
std::map <string, vector<string>> time_reg_map;
std::map <string, vector<string>> time_reg_map_local;
unsigned int year=0;
@ -120,6 +118,12 @@ class MainWindow : public Gtk::ApplicationWindow {
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
virtual ~MainWindow() = default;
void fill_in_reg_zone(string &cmd);
void download_globl_cfg();
void save_local_cfg();
void save_global_cfg();
void save_Dhcp();
void download_local_cfg();
void post_entry_data();
void lacalization();
void settings();
@ -128,14 +132,13 @@ class MainWindow : public Gtk::ApplicationWindow {
void get_builder();
void event();
void gui_mess_close();
bool focus_ntp(GdkEventFocus* event);
bool focus_ntp();
void event_entry_cbDhcp();
void get_calendar();
void calendar_show();
void enry_dhcp_mess();
void entry_dhcp_mess();
void get_config();
void enter_zone();
void enter_zone_glob();
void enter_zone(string &cmd);
void set_ntp_toggle();
void append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone);
string call(string cmd);

@ -33,6 +33,14 @@
<property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="btnDownloadlocal">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Download Local</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
<object class="GtkWindow" id="window">
<property name="can-focus">False</property>
@ -692,138 +700,6 @@ Format: DD.MM.YYYY</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">10</property>
<property name="margin-start">5</property>
<property name="margin-end">10</property>
<property name="margin-bottom">6</property>
<property name="label-xalign">0.019999999552965164</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblRegGlob">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-right">5</property>
<property name="margin-start">8</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Region" comments="Region">Region</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbRegionGlob">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblZone1Glob">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">10</property>
<property name="margin-right">5</property>
<property name="margin-start">10</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Zone" comments="Zone">Area</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbZoneGlob">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width-request">5</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">15</property>
<property name="margin-right">5</property>
<property name="margin-start">15</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="lblTimeZoneGlob">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Time Zone</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="label">

@ -1648,6 +1648,9 @@ msgstr "Сохранить локально"
msgid "Download global"
msgstr "Загрузить глобально"
msgid "Download local"
msgstr "Загрузить локально"
msgid "Disabled"
msgstr "Отключено"

Loading…
Cancel
Save