Fix bug command 'nmcli' still exist after forcing to stop wait animation

This commit is contained in:
chenlelin 2020-05-30 19:29:03 +08:00
parent b86a4290be
commit 77b30c8b30
4 changed files with 35 additions and 6 deletions

View File

@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow()
{
trayIcon->deleteLater();
trayIconMenu->deleteLater();
delete ui;
}
@ -527,7 +528,7 @@ void MainWindow::initTimer()
void MainWindow::createTrayIcon()
{
trayIcon = new QSystemTrayIcon(this);
trayIcon = new QSystemTrayIcon();
trayIcon->setToolTip(QString(tr("kylin-nm")));
trayIconMenu = new QMenu();
@ -761,6 +762,12 @@ void MainWindow::stopLoading()
void MainWindow::on_checkOverTime()
{
QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
int status = system(cmd.toUtf8().data());
if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_checkOverTime' failed";
syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'on_checkOverTime' failed");
}
this->stopLoading(); //超时停止等待动画
is_stop_check_net_state = 0;
}
@ -2289,12 +2296,12 @@ void MainWindow::onExternalConnectionChange(QString type)
{
if (!is_stop_check_net_state) {
if (type == "802-3-ethernet" || type == "ethernet") {
qDebug()<<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
qDebug()<<"debug: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
QTimer::singleShot(2*1000, this, SLOT(onExternalLanChange() ));
}
if (type == "802-11-wireless" || type == "wifi") {
qDebug()<<"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
qDebug()<<"debug: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
QTimer::singleShot(4*1000, this, SLOT(onExternalWifiChange() ));
}
}
@ -2307,7 +2314,12 @@ void MainWindow::onExternalLanChange()
void MainWindow::onExternalWifiChange()
{
on_btnWifiList_clicked();
if (is_connect_wifi_failed) {
qDebug()<<"debug: connect wifi failed just now, no need to refresh wifi interface";
is_connect_wifi_failed = 0;
} else {
on_btnWifiList_clicked();
}
}
//终止当前与nmcli有关的进程
@ -2460,6 +2472,7 @@ void MainWindow::connWifiDone(int connFlag)
//if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connWifiDone' failed");}
} else if (connFlag == 1) {
is_stop_check_net_state = 0;
is_connect_wifi_failed = 1;
QString txt(tr("Confirm your Wi-Fi password or usable of wireless card"));
objKyDBus->showDesktopNotify(txt);

View File

@ -150,6 +150,7 @@ public:
int is_wireless_adapter_ready = 1; //主机是否插入无线网卡
int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式
int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态
int is_connect_wifi_failed = 0; //刚才是否连接wifi失败
int is_fly_mode_on = 0; //是否已经打开飞行模式
int is_hot_sopt_on = 0; //是否已经打开热点

View File

@ -714,13 +714,21 @@ void OneConnForm::waitAnimStep()
ui->lbWaitingIcon->setStyleSheet(qpmQss);
this->waitPage --;
if (this->waitPage < 1) {
this->waitPage = TOTAL_PAGE; //循环播放8张图片
}
this->countCurrentTime += FRAME_SPEED;
if (this->countCurrentTime >= LIMIT_TIME) {
QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
int status = system(cmd.toUtf8().data());
if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed";
syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed");
}
this->stopWaiting(); //动画超出时间限制,强制停止动画
mw->is_stop_check_net_state = 0;
}
}

View File

@ -385,14 +385,21 @@ void OneLancForm::waitAnimStep()
ui->lbWaitingIcon->setStyleSheet(qpmQss);
this->waitPage --;
if (this->waitPage < 1) {
this->waitPage = TOTAL_PAGE; //循环播放8张图片
}
this->countCurrentTime += FRAME_SPEED;
if (this->countCurrentTime >= LIMIT_TIME) {
QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
int status = system(cmd.toUtf8().data());
if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed";
syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed");
}
this->stopWaiting(); //动画超出时间限制,强制停止动画
mw->is_stop_check_net_state = 0;
}
}