fix(wayland):Fixed an issue where the network icon on the lock screen is gray

Description:修复锁屏界面网络图标显示灰色的问题

Log: issue I73TLX
This commit is contained in:
liuyuanpeng 2023-05-31 15:47:09 +00:00
parent 7fa253233a
commit cfe2038a26
2 changed files with 26 additions and 69 deletions

View File

@ -60,6 +60,8 @@
#define KEY_PRIMARY_COLOR "primaryColor" #define KEY_PRIMARY_COLOR "primaryColor"
#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins" #define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins"
#define CONFIG_FILE "/etc/lightdm/ukui-greeter.conf" #define CONFIG_FILE "/etc/lightdm/ukui-greeter.conf"
#define ON_TAB_SHEET_WIDGET "#widgetNetworkManager{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}"
#define ON_NORMAL_SHEET_WIDGET "#widgetNetworkManager{text-align:center;color: rgba(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;}"
#define ON_TAB_SHEET "QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}" #define ON_TAB_SHEET "QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}"
#define ON_NORMAL_SHEET "QPushButton{text-align:center;color: rgba(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;} \ #define ON_NORMAL_SHEET "QPushButton{text-align:center;color: rgba(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;} \
QPushButton::hover{background-color: rgba(255,255,255,15%);} \ QPushButton::hover{background-color: rgba(255,255,255,15%);} \
@ -98,9 +100,6 @@ LockWidget::LockWidget(QWidget *parent)
// connect(this, &LockWidget::capsLockChanged, // connect(this, &LockWidget::capsLockChanged,
// authDialog, &AuthDialog::onCapsLockChanged); // authDialog, &AuthDialog::onCapsLockChanged);
// connect(m_kylinNM, &KylinNM::onConnectChanged, this,[=](){
// updateNetIcon(m_kylinNM->getConnectStatus());
// });
curFontSize = configuration->getFontSize(); curFontSize = configuration->getFontSize();
this->installEventFilter(this); this->installEventFilter(this);
initUI(); initUI();
@ -191,25 +190,6 @@ bool LockWidget::eventFilter(QObject *obj, QEvent *event)
//qDebug()<<"````````````````````````````````````````````"<<event->type(); //qDebug()<<"````````````````````````````````````````````"<<event->type();
} }
} }
/*
if(event->type() == QEvent::WindowActivate){
if(!isNetFinished){
isNetFinished = true;
QTimer::singleShot(1000, this, [=](){
loadNetPlugin();
// m_kylinNM = new KylinNM(this);
// m_kylinNM->installEventFilter(this);
// connect(m_kylinNM, &KylinNM::onConnectChanged, this,[=](){
// updateNetIcon(m_kylinNM->getConnectStatus());
// });
// m_kylinNM->hide();
// QtConcurrent::run([=](){
// updateNetIcon(getNetStatus());
// });
});
}
}
*/
return false; return false;
} }
@ -262,7 +242,7 @@ void LockWidget::key_enter_release(int key)
case NETWORKBTN: case NETWORKBTN:
if(!m_kylinNM || !(m_kylinNM && m_kylinNM->isVisible())) if(!m_kylinNM || !(m_kylinNM && m_kylinNM->isVisible()))
showNetManager(true); showNetManager(true);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
authDialog->setFocusin(REMOVE); authDialog->setFocusin(REMOVE);
break; break;
case KEYBOARDBTN: case KEYBOARDBTN:
@ -559,19 +539,19 @@ void LockWidget::setBottomBtnSheet()
case BATTERYBTN: case BATTERYBTN:
ui->btnBatteryStatus->setStyleSheet(ON_TAB_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_TAB_SHEET);
ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET);
ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET);
break; break;
case SWITCHBTN: case SWITCHBTN:
ui->btnSwitchUser->setStyleSheet(ON_TAB_SHEET); ui->btnSwitchUser->setStyleSheet(ON_TAB_SHEET);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET);
ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET);
ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET);
break; break;
case NETWORKBTN: case NETWORKBTN:
btnNetworkManager->setStyleSheet(ON_TAB_SHEET); widgetNetworkManager->setStyleSheet(ON_TAB_SHEET_WIDGET);
ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET);
ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET);
ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET);
@ -581,19 +561,19 @@ void LockWidget::setBottomBtnSheet()
ui->btnKeyboard->setStyleSheet(ON_TAB_SHEET); ui->btnKeyboard->setStyleSheet(ON_TAB_SHEET);
ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET);
ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET);
break; break;
case POWERBTN: case POWERBTN:
ui->btnPowerManager->setStyleSheet(ON_TAB_SHEET); ui->btnPowerManager->setStyleSheet(ON_TAB_SHEET);
ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET);
ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET);
break; break;
default: default:
ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET);
ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET);
ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET);
@ -601,7 +581,7 @@ void LockWidget::setBottomBtnSheet()
} }
} else { } else {
ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET);
btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET);
ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET);
ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET);
ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET);
@ -796,21 +776,15 @@ void LockWidget::initUI()
,this,&LockWidget::showPowerManager); ,this,&LockWidget::showPowerManager);
// QtConcurrent::run([=](){
// updateNetIcon(getNetStatus());
// });
btnNetworkManager = new KyNetworkIcon(this); widgetNetworkManager = new QWidget(this);
btnNetworkManager->setStyleSheet("QPushButton{text-align:center;color: rgba(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;} \ widgetNetworkManager->setObjectName("widgetNetworkManager");
QPushButton::hover{background-color: rgba(255,255,255,15%);} \ widgetNetworkManager->setFixedSize(48,48);
QPushButton::pressed {background-color: rgba(255,255,255,40%);}\ btnNetworkManager = new KyNetworkIcon(widgetNetworkManager);
QPushButton::checked {background-color: rgba(255, 255, 255, 40%);}");
btnNetworkManager->setCheckable(true); btnNetworkManager->setCheckable(true);
btnNetworkManager->setFixedSize(48,48); btnNetworkManager->setFixedSize(48,48);
btnNetworkManager->setIconSize(QSize(24,24)); btnNetworkManager->setIconSize(QSize(24,24));
btnNetworkManager->setFocusPolicy(Qt::NoFocus); btnNetworkManager->setFocusPolicy(Qt::NoFocus);
// ui->btnNetworkManager->setStyleSheet("QPushButton:Hover{border-radius:24px;background-color:rgba(255, 255, 255, 0.15);}"
// "QPushButton:Pressed{border-radius:24px;background-color:rgba(255, 255, 255, 0.05);}");
btnNetworkManager->installEventFilter(this); btnNetworkManager->installEventFilter(this);
btnNetworkManager->setCursor(Qt::PointingHandCursor); btnNetworkManager->setCursor(Qt::PointingHandCursor);
@ -1087,7 +1061,8 @@ void LockWidget::showWarning(QVector<InhibitInfo::InhibitorInfo> &wlist, int typ
sureWidget->setFocus(); sureWidget->setFocus();
ui->widgetTime->hide(); ui->widgetTime->hide();
ui->btnPowerManager->hide(); ui->btnPowerManager->hide();
btnNetworkManager->hide(); //btnNetworkManager->hide();
widgetNetworkManager->hide();
ui->btnSwitchUser->hide(); ui->btnSwitchUser->hide();
ui->btnKeyboard->hide(); ui->btnKeyboard->hide();
ui->btnBatteryStatus->hide(); ui->btnBatteryStatus->hide();
@ -1109,7 +1084,8 @@ void LockWidget::switchToSureDialog(int type)
sureWidget->setFocus(); sureWidget->setFocus();
ui->widgetTime->hide(); ui->widgetTime->hide();
ui->btnPowerManager->hide(); ui->btnPowerManager->hide();
btnNetworkManager->hide(); widgetNetworkManager->hide();
//btnNetworkManager->hide();
ui->btnSwitchUser->hide(); ui->btnSwitchUser->hide();
ui->btnKeyboard->hide(); ui->btnKeyboard->hide();
ui->btnBatteryStatus->hide(); ui->btnBatteryStatus->hide();
@ -1123,7 +1099,8 @@ void LockWidget::hideSureDialog()
powermanager->show(); powermanager->show();
ui->widgetTime->show(); ui->widgetTime->show();
ui->btnPowerManager->show(); ui->btnPowerManager->show();
btnNetworkManager->show(); widgetNetworkManager->show();
//btnNetworkManager->show();
ui->btnSwitchUser->show(); ui->btnSwitchUser->show();
ui->btnKeyboard->show(); ui->btnKeyboard->show();
ui->btnBatteryStatus->show(); ui->btnBatteryStatus->show();
@ -1142,7 +1119,8 @@ void LockWidget::confirmClicked()
authDialog->show(); authDialog->show();
ui->widgetTime->show(); ui->widgetTime->show();
ui->btnPowerManager->show(); ui->btnPowerManager->show();
btnNetworkManager->show(); widgetNetworkManager->show();
//btnNetworkManager->show();
ui->btnSwitchUser->show(); ui->btnSwitchUser->show();
ui->btnKeyboard->show(); ui->btnKeyboard->show();
ui->btnBatteryStatus->show(); ui->btnBatteryStatus->show();
@ -1335,27 +1313,6 @@ int LockWidget::getNetStatus()
return ret; return ret;
} }
void LockWidget::updateNetIcon(int status)
{
switch(status) {
case 0:
//有线
btnNetworkManager->setIcon(QIcon(":/image/assets/intel/icon-wired.png"));
break;
case 1:
//无线
btnNetworkManager->setIcon(QIcon(":/image/assets/intel/icon-wifi.png"));
break;
case 2:
//有线+无线
btnNetworkManager->setIcon(QIcon(":/image/assets/intel/icon-wired.png"));
break;
default:
//无连接
btnNetworkManager->setIcon(QIcon(":/image/assets/intel/icon-no-signal.png"));
}
}
void LockWidget::loadNetPlugin() void LockWidget::loadNetPlugin()
{ {
m_kylinNM = new QWidget(this); m_kylinNM = new QWidget(this);
@ -1665,8 +1622,8 @@ void LockWidget::resizeEvent(QResizeEvent *event)
ui->btnKeyboard->move(width() - x, height() - y); ui->btnKeyboard->move(width() - x, height() - y);
} }
x = x + btnNetworkManager->width()+16; x = x + widgetNetworkManager->width()+16;
btnNetworkManager->move(width() - x, height() - y); widgetNetworkManager->move(width() - x, height() - y);
if(!ui->btnSwitchUser->isHidden()) { if(!ui->btnSwitchUser->isHidden()) {
x = x + ui->btnSwitchUser->width()+16; x = x + ui->btnSwitchUser->width()+16;
@ -1878,7 +1835,7 @@ bool LockWidget::exitSubWidget()
setCheckedSheet(NETWORKBTN, false); setCheckedSheet(NETWORKBTN, false);
at_plugins = false; at_plugins = false;
if(tabAt == BOTTMBTN && horAT == NETWORKBTN) if(tabAt == BOTTMBTN && horAT == NETWORKBTN)
btnNetworkManager->setStyleSheet(ON_TAB_SHEET); widgetNetworkManager->setStyleSheet(ON_TAB_SHEET_WIDGET);
allExited = false; allExited = false;
} else if(vKeyboard && vKeyboard->isVisible()) { } else if(vKeyboard && vKeyboard->isVisible()) {
vKeyboard->hide(); vKeyboard->hide();

View File

@ -105,7 +105,6 @@ private:
void initUI(); void initUI();
void initUserMenu(); void initUserMenu();
void setVirkeyboardPos(); void setVirkeyboardPos();
void updateNetIcon(int status);
bool getLoadStatus(const QString &name); bool getLoadStatus(const QString &name);
int getNetStatus(); int getNetStatus();
void key_OB_release(int key); void key_OB_release(int key);
@ -186,6 +185,7 @@ private:
int powermanagerType; int powermanagerType;
int nowAt = -1; int nowAt = -1;
int loginedNum = 0; int loginedNum = 0;
QWidget *widgetNetworkManager = nullptr;
QPushButton *btnNetworkManager = nullptr; QPushButton *btnNetworkManager = nullptr;
bool m_isStartupMode = false; bool m_isStartupMode = false;
bool is_switchBtn = true; bool is_switchBtn = true;