diff --git a/src/lockwidget.cpp b/src/lockwidget.cpp index daef32c..15ed1a1 100644 --- a/src/lockwidget.cpp +++ b/src/lockwidget.cpp @@ -60,6 +60,8 @@ #define KEY_PRIMARY_COLOR "primaryColor" #define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins" #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_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%);} \ @@ -98,9 +100,6 @@ LockWidget::LockWidget(QWidget *parent) // connect(this, &LockWidget::capsLockChanged, // authDialog, &AuthDialog::onCapsLockChanged); -// connect(m_kylinNM, &KylinNM::onConnectChanged, this,[=](){ -// updateNetIcon(m_kylinNM->getConnectStatus()); -// }); curFontSize = configuration->getFontSize(); this->installEventFilter(this); initUI(); @@ -191,25 +190,6 @@ bool LockWidget::eventFilter(QObject *obj, QEvent *event) //qDebug()<<"````````````````````````````````````````````"<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; } @@ -262,7 +242,7 @@ void LockWidget::key_enter_release(int key) case NETWORKBTN: if(!m_kylinNM || !(m_kylinNM && m_kylinNM->isVisible())) showNetManager(true); - btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); + widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); authDialog->setFocusin(REMOVE); break; case KEYBOARDBTN: @@ -559,19 +539,19 @@ void LockWidget::setBottomBtnSheet() case BATTERYBTN: ui->btnBatteryStatus->setStyleSheet(ON_TAB_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->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); break; case SWITCHBTN: ui->btnSwitchUser->setStyleSheet(ON_TAB_SHEET); - btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); + widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); break; case NETWORKBTN: - btnNetworkManager->setStyleSheet(ON_TAB_SHEET); + widgetNetworkManager->setStyleSheet(ON_TAB_SHEET_WIDGET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); @@ -581,19 +561,19 @@ void LockWidget::setBottomBtnSheet() ui->btnKeyboard->setStyleSheet(ON_TAB_SHEET); ui->btnPowerManager->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); break; case POWERBTN: ui->btnPowerManager->setStyleSheet(ON_TAB_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->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); break; default: ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); + widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); @@ -601,7 +581,7 @@ void LockWidget::setBottomBtnSheet() } } else { ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - btnNetworkManager->setStyleSheet(ON_NORMAL_SHEET); + widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); @@ -796,21 +776,15 @@ void LockWidget::initUI() ,this,&LockWidget::showPowerManager); -// QtConcurrent::run([=](){ -// updateNetIcon(getNetStatus()); -// }); - btnNetworkManager = new KyNetworkIcon(this); - btnNetworkManager->setStyleSheet("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::pressed {background-color: rgba(255,255,255,40%);}\ - QPushButton::checked {background-color: rgba(255, 255, 255, 40%);}"); + widgetNetworkManager = new QWidget(this); + widgetNetworkManager->setObjectName("widgetNetworkManager"); + widgetNetworkManager->setFixedSize(48,48); + btnNetworkManager = new KyNetworkIcon(widgetNetworkManager); btnNetworkManager->setCheckable(true); btnNetworkManager->setFixedSize(48,48); btnNetworkManager->setIconSize(QSize(24,24)); 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->setCursor(Qt::PointingHandCursor); @@ -1087,7 +1061,8 @@ void LockWidget::showWarning(QVector &wlist, int typ sureWidget->setFocus(); ui->widgetTime->hide(); ui->btnPowerManager->hide(); - btnNetworkManager->hide(); + //btnNetworkManager->hide(); + widgetNetworkManager->hide(); ui->btnSwitchUser->hide(); ui->btnKeyboard->hide(); ui->btnBatteryStatus->hide(); @@ -1109,7 +1084,8 @@ void LockWidget::switchToSureDialog(int type) sureWidget->setFocus(); ui->widgetTime->hide(); ui->btnPowerManager->hide(); - btnNetworkManager->hide(); + widgetNetworkManager->hide(); + //btnNetworkManager->hide(); ui->btnSwitchUser->hide(); ui->btnKeyboard->hide(); ui->btnBatteryStatus->hide(); @@ -1123,7 +1099,8 @@ void LockWidget::hideSureDialog() powermanager->show(); ui->widgetTime->show(); ui->btnPowerManager->show(); - btnNetworkManager->show(); + widgetNetworkManager->show(); + //btnNetworkManager->show(); ui->btnSwitchUser->show(); ui->btnKeyboard->show(); ui->btnBatteryStatus->show(); @@ -1142,7 +1119,8 @@ void LockWidget::confirmClicked() authDialog->show(); ui->widgetTime->show(); ui->btnPowerManager->show(); - btnNetworkManager->show(); + widgetNetworkManager->show(); + //btnNetworkManager->show(); ui->btnSwitchUser->show(); ui->btnKeyboard->show(); ui->btnBatteryStatus->show(); @@ -1335,27 +1313,6 @@ int LockWidget::getNetStatus() 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() { m_kylinNM = new QWidget(this); @@ -1665,8 +1622,8 @@ void LockWidget::resizeEvent(QResizeEvent *event) ui->btnKeyboard->move(width() - x, height() - y); } - x = x + btnNetworkManager->width()+16; - btnNetworkManager->move(width() - x, height() - y); + x = x + widgetNetworkManager->width()+16; + widgetNetworkManager->move(width() - x, height() - y); if(!ui->btnSwitchUser->isHidden()) { x = x + ui->btnSwitchUser->width()+16; @@ -1878,7 +1835,7 @@ bool LockWidget::exitSubWidget() setCheckedSheet(NETWORKBTN, false); at_plugins = false; if(tabAt == BOTTMBTN && horAT == NETWORKBTN) - btnNetworkManager->setStyleSheet(ON_TAB_SHEET); + widgetNetworkManager->setStyleSheet(ON_TAB_SHEET_WIDGET); allExited = false; } else if(vKeyboard && vKeyboard->isVisible()) { vKeyboard->hide(); diff --git a/src/lockwidget.h b/src/lockwidget.h index 0291240..da89db0 100644 --- a/src/lockwidget.h +++ b/src/lockwidget.h @@ -105,7 +105,6 @@ private: void initUI(); void initUserMenu(); void setVirkeyboardPos(); - void updateNetIcon(int status); bool getLoadStatus(const QString &name); int getNetStatus(); void key_OB_release(int key); @@ -186,6 +185,7 @@ private: int powermanagerType; int nowAt = -1; int loginedNum = 0; + QWidget *widgetNetworkManager = nullptr; QPushButton *btnNetworkManager = nullptr; bool m_isStartupMode = false; bool is_switchBtn = true;