-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetting_widget.cpp
More file actions
99 lines (68 loc) · 2.4 KB
/
Copy pathsetting_widget.cpp
File metadata and controls
99 lines (68 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "setting/setting_widget.h"
Setting_Widget::Setting_Widget(WelcomeWidget *widget)
{
this->welcomewidget = widget;
welcome_ui = this->welcomewidget->ui;
connect(welcome_ui->pb_update,SIGNAL(clicked()),this,SLOT(on_pb_update_clicked())); //建立信号槽
connect(welcome_ui->pb_time_update,SIGNAL(clicked()),this,SLOT(on_pb_time_update_clicked())); //建立信号槽
}
Setting_Widget::~Setting_Widget()
{
}
void Setting_Widget::on_pb_update_clicked()
{
//qDebug() << "on_pb_update_clicked()";
Update_Dialog *update_dialog = new Update_Dialog();
update_dialog->exec();
delete update_dialog;
}
void Setting_Widget::on_pb_time_update_clicked()
{
//welcome_ui->label_time->setText(trUtf8("正在进行时间同步..."));
QProcess proc;
proc.execute("ntpdate 202.112.29.82");
if(proc.waitForFinished(30000))
{
qDebug() << "time update timeout";
proc.close();
QMessageBox::information(new Update_Dialog(), "INFORMATION", tr("<font color='white'>连接服务器超时</font>"));
}
else
{
if(proc.exitStatus() == QProcess::CrashExit)
{
qDebug() << "time update fail";
proc.close();
QMessageBox::information(new Update_Dialog(), "INFORMATION", tr("<font color='white'>时间同步失败</font>"));
}
else
{
qDebug() << "time update success";
proc.start("hwclock --systohc");
QMessageBox::information(new Update_Dialog(), "INFORMATION", tr("<font color='white'>时间同步成功</font>"));
if(proc.waitForFinished())
{
proc.close();
}
else
{
if(proc.exitStatus() == QProcess::CrashExit)
{
proc.close();
}
else
{
}
}
}
}
proc.close();
// connect(&proc,SIGNAL(finished(int, QProcess::ExitStatus)),this,SLOT(slot_time_update_finished(int, QProcess::ExitStatus))); //建立信号槽
}
void Setting_Widget::slot_time_update_finished(int exit_code, QProcess::ExitStatus exit_status)
{
qDebug() << exit_code << exit_status;
//QMessageBox::information(this, "INFORMATION", tr("<font color='white'>时间同步成功</font>"));
QProcess proc;
proc.startDetached("hwclock --systohc");
}