From 890c97d2f4bb5029861f8d56ae170fecfcb3c457 Mon Sep 17 00:00:00 2001 From: chenlelin Date: Sun, 11 Oct 2020 15:02:18 +0800 Subject: [PATCH] Fix bug unable to fit ukui light theme --- debian/control | 1 + kylin-nm.pro | 2 +- nmqrc.qrc | 1 + res/x/control.svg | 15 ++ src/confform.cpp | 75 ++++---- src/kylin-dbus-interface.cpp | 9 + src/kylin-dbus-interface.h | 1 + src/mainwindow.cpp | 222 ++++++++++++++++++------ src/mainwindow.h | 6 + src/mainwindow.ui | 76 ++++---- src/oneconnform.cpp | 51 +++--- src/oneconnform.ui | 2 +- src/onelancform.cpp | 31 ++-- src/onelancform.ui | 6 +- src/switchbutton.cpp | 4 +- wireless-security/dlgconnhidwifi.cpp | 43 +++-- wireless-security/dlgconnhidwifiwpa.cpp | 47 ++--- wireless-security/kylinheadfile.cpp | 2 +- 18 files changed, 387 insertions(+), 207 deletions(-) create mode 100644 res/x/control.svg diff --git a/debian/control b/debian/control index fdebab42..d2e11f86 100644 --- a/debian/control +++ b/debian/control @@ -14,6 +14,7 @@ Build-Depends: debhelper-compat (= 12), libgsettings-qt-dev, libkf5windowsystem-dev, libx11-dev, + libqt5svg5-dev, Standards-Version: 4.5.0 Rules-Requires-Root: no Homepage: https://github.com/ukui/kylin-nm diff --git a/kylin-nm.pro b/kylin-nm.pro index 7074ea17..0c40dec3 100644 --- a/kylin-nm.pro +++ b/kylin-nm.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui x11extras dbus KWindowSystem +QT += core gui x11extras dbus KWindowSystem svg greaterThan(QT_MAJOR_VERSION, 4): QT += widgets diff --git a/nmqrc.qrc b/nmqrc.qrc index b3a79529..f3f09270 100644 --- a/nmqrc.qrc +++ b/nmqrc.qrc @@ -78,5 +78,6 @@ res/s/conning-s/11.png res/s/conning-s/12.png res/x/setup.png + res/x/control.svg diff --git a/res/x/control.svg b/res/x/control.svg new file mode 100644 index 00000000..a64182b7 --- /dev/null +++ b/res/x/control.svg @@ -0,0 +1,15 @@ + + + + +画板 1 + + + diff --git a/src/confform.cpp b/src/confform.cpp index 831b24f1..39affb7d 100644 --- a/src/confform.cpp +++ b/src/confform.cpp @@ -48,13 +48,13 @@ ConfForm::ConfForm(QWidget *parent) : path.addRoundedRect(rect, 6, 6); setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - this->setStyleSheet("QWidget{border-radius:6px;border:none;}"); - KylinDBus mkylindbus; - double trans = mkylindbus.getTransparentData(); - QString strTrans; - strTrans = QString::number(trans, 10, 2); - QString sty = "#centralWidget{border:1px solid rgba(255,255,255,0.05);border-radius:6px;background:rgba(19,19,20," + strTrans + ");}"; - ui->centralWidget->setStyleSheet(sty); +// this->setStyleSheet("QWidget{border-radius:6px;border:none;}"); +// KylinDBus mkylindbus; +// double trans = mkylindbus.getTransparentData(); +// QString strTrans; +// strTrans = QString::number(trans, 10, 2); +// QString sty = "#centralWidget{border:1px solid rgba(255,255,255,0.05);border-radius:6px;background:rgba(19,19,20," + strTrans + ");}"; +// ui->centralWidget->setStyleSheet(sty); labelQss = "QLabel{border:0px;color:rgba(255,255,255,0.97);background-color:transparent;}"; cbxQss = "QComboBox{padding-left:20px;font-size:13px;color:rgba(255,255,255,0.91);" @@ -71,35 +71,35 @@ ConfForm::ConfForm(QWidget *parent) : btnOnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"; - lineQss = "background:rgba(255,255,255,0.08);"; + lineQss = "background:rgba(156,156,156,0.1);"; // ui->centralWidget->setStyleSheet("#centralWidget{border:1px solid #297a97;background-color:#ffffff;}"); ui->wdHead->setStyleSheet("#wdHead{border:none}"); ui->wgManual->setStyleSheet("#wgManual{border:none}"); ui->wdBottom->setStyleSheet("#wdBottom{border:none}"); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbName->setStyleSheet(labelQss); - ui->lbTxt1->setStyleSheet(labelQss); - ui->lbTxt2->setStyleSheet(labelQss); - ui->lbTxt3->setStyleSheet(labelQss); - ui->lbTxt4->setStyleSheet(labelQss); - ui->lbTxt5->setStyleSheet(labelQss); - ui->lbTxt6->setStyleSheet(labelQss); +// ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); +// ui->lbName->setStyleSheet(labelQss); +// ui->lbTxt1->setStyleSheet(labelQss); +// ui->lbTxt2->setStyleSheet(labelQss); +// ui->lbTxt3->setStyleSheet(labelQss); +// ui->lbTxt4->setStyleSheet(labelQss); +// ui->lbTxt5->setStyleSheet(labelQss); +// ui->lbTxt6->setStyleSheet(labelQss); - ui->cbType->setStyleSheet(cbxQss); - ui->cbType->setView(new QListView()); - ui->cbMask->setStyleSheet(cbxQss); - ui->cbMask->setView(new QListView()); +// ui->cbType->setStyleSheet(cbxQss); +// ui->cbType->setView(new QListView()); +// ui->cbMask->setStyleSheet(cbxQss); +// ui->cbMask->setView(new QListView()); - ui->leName->setStyleSheet(leQss); - ui->leAddr->setStyleSheet(leQss); - ui->leGateway->setStyleSheet(leQss); - ui->leDns->setStyleSheet(leQss); - ui->leDns2->setStyleSheet(leQss); +// ui->leName->setStyleSheet(leQss); +// ui->leAddr->setStyleSheet(leQss); +// ui->leGateway->setStyleSheet(leQss); +// ui->leDns->setStyleSheet(leQss); +// ui->leDns2->setStyleSheet(leQss); - ui->btnCancel->setStyleSheet(btnOffQss); - ui->btnOk->setStyleSheet(btnOnQss); - ui->btnCreate->setStyleSheet(btnOnQss); +// ui->btnCancel->setStyleSheet(btnOffQss); +// ui->btnOk->setStyleSheet(btnOnQss); +// ui->btnCreate->setStyleSheet(btnOnQss); ui->lineUp->setStyleSheet(lineQss); ui->lineDown->setStyleSheet(lineQss); ui->lineUp->hide(); @@ -337,10 +337,10 @@ void ConfForm::cbTypeChanged(int index) this->resize(432, 510); } if (index == 3) { - ui->btnOk->setStyleSheet(btnOffQss); +// ui->btnOk->setStyleSheet(btnOffQss); ui->btnOk->setEnabled(false); - ui->btnCreate->setStyleSheet(btnOffQss); +// ui->btnCreate->setStyleSheet(btnOffQss); ui->btnCreate->setEnabled(false); ui->leName->setEnabled(true); @@ -413,10 +413,10 @@ void ConfForm::setEnableOfBtn() } } - ui->btnOk->setStyleSheet(btnOnQss); +// ui->btnOk->setStyleSheet(btnOnQss); ui->btnOk->setEnabled(true); - ui->btnCreate->setStyleSheet(btnOnQss); +// ui->btnCreate->setStyleSheet(btnOnQss); ui->btnCreate->setEnabled(true); } @@ -435,10 +435,10 @@ bool ConfForm::getTextEditState(QString text) //设置创建或保存按钮不可点击 void ConfForm::setBtnEnableFalse() { - ui->btnOk->setStyleSheet(btnOffQss); +// ui->btnOk->setStyleSheet(btnOffQss); ui->btnOk->setEnabled(false); - ui->btnCreate->setStyleSheet(btnOffQss); +// ui->btnCreate->setStyleSheet(btnOffQss); ui->btnCreate->setEnabled(false); } @@ -448,5 +448,12 @@ void ConfForm::paintEvent(QPaintEvent *event) opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + + QRect rect = this->rect(); + p.setRenderHint(QPainter::Antialiasing); // 反锯齿; + p.setBrush(opt.palette.color(QPalette::Base)); + //p.setOpacity(1); + p.setPen(Qt::NoPen); + p.drawRoundedRect(rect, 6, 6); QWidget::paintEvent(event); } diff --git a/src/kylin-dbus-interface.cpp b/src/kylin-dbus-interface.cpp index 6ade345d..bf61195d 100644 --- a/src/kylin-dbus-interface.cpp +++ b/src/kylin-dbus-interface.cpp @@ -974,3 +974,12 @@ double KylinDBus::getTransparentData() return 0.7; } } + +//使用GSetting获取当前系统主题样式 +void KylinDBus::getUkuiStyleState() +{ +// if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { +// QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); +// connect(gsetting,&QGSettings::changed,this,&SideBarWidget::themeModeChangeSlot); +// } +} diff --git a/src/kylin-dbus-interface.h b/src/kylin-dbus-interface.h index 182986b3..6dda6964 100644 --- a/src/kylin-dbus-interface.h +++ b/src/kylin-dbus-interface.h @@ -57,6 +57,7 @@ public: void initTaskbarGsetting(); int getTaskbarHeight(); int getTaskbarPos(); + void getUkuiStyleState(); void getWifiSwitchState(); bool getSwitchStatus(QString key); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 451601ad..098f809f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -53,9 +53,9 @@ MainWindow::MainWindow(QWidget *parent) : path.addRoundedRect(rect, 6, 6); setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - this->setStyleSheet("QWidget{border:none;border-radius:6px;}"); + //this->setStyleSheet("QWidget{border:none;border-radius:6px;}"); - ui->centralWidget->setStyleSheet("#centralWidget{border:none;border-radius:6px;background:rgba(19,19,20,0.7);}"); + //ui->centralWidget->setStyleSheet("#centralWidget{border:none;border-radius:6px;background:rgba(19,19,20,0.5);}"); editQssString(); //编辑部分控件QSS createTopLanUI(); //创建顶部有线网item @@ -205,11 +205,11 @@ void MainWindow::editQssString() btnOnQss = "QLabel{min-width: 37px; min-height: 37px;max-width:37px; max-height: 37px;border-radius: 4px; background-color:rgba(61,107,229,1)}"; btnBgOffQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 10px; background-color:rgba(255,255,255,0.2)}"; btnBgOnQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 10px; background-color:rgba(61,107,229,1);}"; - btnBgHoverQss = "QLabel{border-radius: 4px; background-color:rgba(255,255,255,0.12)}"; + btnBgHoverQss = "QLabel{border-radius: 4px; background-color:rgba(156,156,156,0.3)}"; btnBgLeaveQss = "QLabel{border-radius: 4px; background-color:rgba(255,255,255,0)}"; leftBtnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.12);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.12);}"; + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(156,156,156,0.3);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(156,156,156,0.3);}"; funcBtnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(107,142,235,0.97);font-size:14px;}" "QPushButton:Hover{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(151,175,241,0.97);font-size:14px;}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(61,107,229,0.97);font-size:14px;}"; @@ -225,7 +225,7 @@ void MainWindow::createTopLanUI() lbTopLanList->setText(tr("Ethernet Networks"));//"可用网络列表" lbTopLanList->resize(W_MIDDLE_WORD, H_MIDDLE_WORD); lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); - lbTopLanList->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.97);}"); +// lbTopLanList->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.97);}"); lbTopLanList->show(); /*新建有线网按钮*/ btnCreateNet = new QPushButton(topLanListWidget); @@ -248,7 +248,7 @@ void MainWindow::createTopWifiUI() lbTopWifiList->setText(tr("Wifi Networks"));//"可用网络列表" lbTopWifiList->resize(W_MIDDLE_WORD, H_MIDDLE_WORD); lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); - lbTopWifiList->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.97);}"); +// lbTopWifiList->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.97);}"); lbTopWifiList->show(); /*新建有线网按钮*/ btnAddNet = new QPushButton(topWifiListWidget); @@ -283,7 +283,8 @@ void MainWindow::createOtherUI() lbNoItemTip = new QLabel(ui->centralWidget); lbNoItemTip->resize(W_NO_ITEM_TIP, H_NO_ITEM_TIP); lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2); - lbNoItemTip->setStyleSheet("QLabel{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);}"); +// lbNoItemTip->setStyleSheet("QLabel{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);}"); + lbNoItemTip->setStyleSheet("QLabel{border:none;background:transparent;}"); lbNoItemTip->setText(tr("No usable network in the list"));//列表暂无可连接网络 lbNoItemTip->setAlignment(Qt::AlignCenter); lbNoItemTip->hide(); @@ -308,7 +309,7 @@ void MainWindow::createListAreaUI() lbLanList = new QLabel(lanListWidget); lbWifiList = new QLabel(wifiListWidget); - ui->lbNetwork->setStyleSheet("QLabel{font-size:20px;color:rgba(255,255,255,0.97);}"); +// ui->lbNetwork->setStyleSheet("QLabel{font-size:20px;color:rgba(255,255,255,0.97);}"); ui->lbNetwork->show(); topLanListWidget->setStyleSheet("QWidget{border:none;}"); @@ -317,19 +318,19 @@ void MainWindow::createListAreaUI() topWifiListWidget->setStyleSheet("QWidget{border:none;}"); topWifiListWidget->setStyleSheet("background-color:transparent;"); - lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); - lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); +// lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); +// lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); lbLoadUp->setText("0KB/s"); lbLoadDown->setText("0KB/s."); this->on_setNetSpeed(); scrollAreal->setStyleSheet("QScrollArea{border:none;}"); scrollAreal->viewport()->setStyleSheet("background-color:transparent;"); - //scrollAreal->verticalScrollBar()->setStyleSheet(scrollBarQss); + //scrollAreal->verticalScrollBar()->setStyleSheet(scrollBarQss);//// scrollAreaw->setStyleSheet("QScrollArea{border:none;}"); scrollAreaw->viewport()->setStyleSheet("background-color:transparent;"); - //scrollAreaw->verticalScrollBar()->setStyleSheet(scrollBarQss); + //scrollAreaw->verticalScrollBar()->setStyleSheet(scrollBarQss);//// } void MainWindow::createLeftAreaUI() @@ -340,13 +341,32 @@ void MainWindow::createLeftAreaUI() QString txtEthernet(tr("Ethernet")); ui->btnNetList->setToolTip(txtEthernet); ui->lbNetListBG->setStyleSheet(btnOffQss); - ui->lbNetListImg->setStyleSheet("QLabel{background-image:url(:/res/x/net-list-bg.svg);}"); + //ui->lbNetListImg->setStyleSheet("QLabel{background-image:url(:/res/x/net-list-bg.svg);}"); + //ui->btnNetListImg->setStyleSheet("QPushButton{background:transparent;}"); + //设置PushButton背景透明 + QPalette paletteLan = ui->btnNetListImg->palette(); + paletteLan.setColor(QPalette::Highlight, Qt::transparent); + paletteLan.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0))); + ui->btnNetListImg->setPalette(paletteLan); + //添加PushButton的svg图片 + ui->btnNetListImg->setIcon(QIcon(":/res/x/net-list-bg.svg")); + ui->btnNetListImg->setProperty("useIconHighlightEffect", true); + ui->btnNetListImg->setProperty("iconHighlightEffectMode", true); ui->btnWifiList->setFocusPolicy(Qt::NoFocus); QString txtWifi(tr("Wifi")); ui->btnWifiList->setToolTip(txtWifi); ui->lbWifiListBG->setStyleSheet(btnOffQss); - ui->lbWifiListImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-list-bg.svg);}"); + //ui->lbWifiListImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-list-bg.svg);}"); + //设置PushButton背景透明 + QPalette paletteWifi = ui->btnWifiListImg->palette(); + paletteWifi.setColor(QPalette::Highlight, Qt::transparent); + paletteWifi.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0))); + ui->btnWifiListImg->setPalette(paletteWifi); + //添加PushButton的svg图片 + ui->btnWifiListImg->setIcon(QIcon(":/res/x/wifi-list-bg.svg")); + ui->btnWifiListImg->setProperty("useIconHighlightEffect", true); + ui->btnWifiListImg->setProperty("iconHighlightEffectMode", true); ui->btnNet->hide(); @@ -376,9 +396,16 @@ void MainWindow::createLeftAreaUI() ui->btnAdvConf->setFocusPolicy(Qt::NoFocus); QString txtAdvanced(tr("Advanced")); ui->btnAdvConf->setToolTip(txtAdvanced); - //ui->lbBtnConfImg->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}"); - ui->btnConfImg->setStyleSheet("QPushButton{background-image:url(:/res/x/setup.png);}"); - //ui->btnConfImg->setIcon(QIcon::fromTheme("settings-app-symbolic.svg", QIcon(":/res/x/setup.png")) ); + //ui->lbBtnConfImg->setStyleSheet("QLabel{background-image:url(:/res/x/control.svg);}"); + //设置PushButton背景透明 + QPalette paletteConf = ui->btnConfImg->palette(); + paletteConf.setColor(QPalette::Highlight, Qt::transparent); + paletteConf.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0))); + ui->btnConfImg->setPalette(paletteConf); + //添加PushButton的svg图片 + ui->btnConfImg->setIcon(QIcon(":/res/x/control.svg")); + ui->btnConfImg->setProperty("useIconHighlightEffect", true); + ui->btnConfImg->setProperty("iconHighlightEffectMode", true); } // 初始化有线网列表 @@ -429,15 +456,15 @@ void MainWindow::initNetwork() syslog(LOG_DEBUG, "current network state: wired state =%d, wifi state =%d", iface->lstate, iface->wstate); qDebug()<<"==="; - //ui->lbBtnNetBG->setStyleSheet(btnOnQss); + //ui->lbBtnNetBG->setStyleSheet(btnOnQss);//// if (iface->wstate == 0 || iface->wstate == 1) { - // ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); + // ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);//// + //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);//// btnWireless->setSwitchStatus(true); } else { btnWireless->setSwitchStatus(false); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);//// + //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);//// } // 初始化网络列表 @@ -604,11 +631,11 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) handleIconClicked(); if (this->isHidden()) { - double trans = objKyDBus->getTransparentData(); - QString strTrans; - strTrans = QString::number(trans, 10, 2); - QString sty = "#centralWidget{background:rgba(19,19,20," + strTrans + ");}"; - ui->centralWidget->setStyleSheet(sty); +// double trans = objKyDBus->getTransparentData(); +// QString strTrans; +// strTrans = QString::number(trans, 10, 2); +// QString sty = "#centralWidget{background:rgba(19,19,20," + strTrans + ");}"; +// ui->centralWidget->setStyleSheet(sty); this->showNormal(); if (is_btnNetList_clicked == 1) { @@ -1242,18 +1269,18 @@ void MainWindow::on_btnWifiList_clicked() //ui->lbBtnWifiBG->show(); //ui->lbBtnWifiBall->show(); if (iface->wstate == 0 || iface->wstate == 1) { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);//// + //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);//// btnWireless->setSwitchStatus(true); } else { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);//// + //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);//// btnWireless->setSwitchStatus(false); } if (iface->wstate != 2) { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);//// + //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);//// btnWireless->setSwitchStatus(true); lbTopWifiList->show(); btnAddNet->show(); @@ -1261,8 +1288,8 @@ void MainWindow::on_btnWifiList_clicked() this->startLoading(); this->ksnm->execGetWifiList(); } else { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);//// + //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);//// btnWireless->setSwitchStatus(false); delete topWifiListWidget; //清空top列表 createTopWifiUI(); //创建顶部无线网item @@ -1778,15 +1805,15 @@ void MainWindow::on_btnAdvConf_released() void MainWindow::on_btnFlyMode_clicked() { if (is_fly_mode_on == 0) { - ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-on.svg);}"); - ui->lbFlyBG->setStyleSheet(btnOnQss); +// ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-on.svg);}"); +// ui->lbFlyBG->setStyleSheet(btnOnQss); is_fly_mode_on = 1; onBtnWifiClicked(0); on_btnWifiList_clicked(); } else { - ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}"); - ui->lbFlyBG->setStyleSheet(btnOffQss); +// ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}"); +// ui->lbFlyBG->setStyleSheet(btnOffQss); is_fly_mode_on = 0; } } @@ -2159,13 +2186,13 @@ void MainWindow::enNetDone() BackThread *bt = new BackThread(); mwBandWidth = bt->execChkLanWidth(lname); - ui->lbBtnNetBG->setStyleSheet(btnOnQss); +// ui->lbBtnNetBG->setStyleSheet(btnOnQss); // 打开网络开关时如果Wifi开关是打开的,设置其样式 if (checkWlOn()) { btnWireless->setSwitchStatus(true); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);//// + //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);//// } onBtnNetListClicked(1); @@ -2207,7 +2234,7 @@ void MainWindow::disNetDone() ccf->move(L_VERTICAL_LINE_TO_ITEM, 0); ccf->show(); - ui->lbBtnNetBG->setStyleSheet(btnOffQss); +// ui->lbBtnNetBG->setStyleSheet(btnOffQss); btnWireless->setSwitchStatus(false); @@ -2227,13 +2254,13 @@ void MainWindow::disNetDone() } void MainWindow::launchLanDone() { - ui->lbBtnNetBG->setStyleSheet(btnOnQss); +// ui->lbBtnNetBG->setStyleSheet(btnOnQss); } void MainWindow::enWifiDone() { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);//// + //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);//// is_update_wifi_list = 0; if (is_btnWifiList_clicked) { @@ -2262,8 +2289,8 @@ void MainWindow::disWifiStateKeep() { if (this->is_btnNetList_clicked == 1) { btnWireless->setSwitchStatus(false); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);//// + //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);//// } if (this->is_btnWifiList_clicked== 1) { disWifiDoneChangeUI(); @@ -2304,8 +2331,8 @@ void MainWindow::disWifiDoneChangeUI() } btnWireless->setSwitchStatus(false); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); + //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);//// + //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);//// this->lanListWidget->hide(); this->topLanListWidget->hide(); @@ -2526,3 +2553,96 @@ void MainWindow::connWifiDone(int connFlag) syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected"); } } + +//重新绘制背景色 +void MainWindow::paintEvent(QPaintEvent *event) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + QRect rect = this->rect(); + p.setRenderHint(QPainter::Antialiasing); // 反锯齿; + p.setBrush(opt.palette.color(QPalette::Base)); + //p.setOpacity(1); + p.setPen(Qt::NoPen); + p.drawRoundedRect(rect, 6, 6); + QWidget::paintEvent(event); +} + + +/////////////////////////////////////////////////////////////////////////////// +//控件随主题色置灰或置白 +void MainWindow::setUkuiStyle(QString style) +{ + qDebug() << "zzzzz" << style; +// const auto ratio=devicePixelRatioF(); +// QPixmap pixmap=loadSvg(iconStr,19*ratio); +// if (style == "ukui-light") { +// pixmap=drawSymbolicBlackColoredPixmap(pixmap); +// } else { +// pixmap=drawSymbolicColoredPixmap(pixmap);//反白 +// } +// pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); +// label->setPixmap(pixmap); +} + +QPixmap MainWindow::drawSymbolicColoredPixmap(const QPixmap &source) +{ + QColor gray(128,128,128); + QColor standard (31,32,34); + QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { + for (int y = 0; y < img.height(); y++) { + auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { + if (qAbs(color.red()-gray.red())<20 && qAbs(color.green()-gray.green())<20 && qAbs(color.blue()-gray.blue())<20) { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } else if(qAbs(color.red()-standard.red())<20 && qAbs(color.green()-standard.green())<20 && qAbs(color.blue()-standard.blue())<20) { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } else { + img.setPixelColor(x, y, color); + } + } + } + } + return QPixmap::fromImage(img); +} + +QPixmap MainWindow::drawSymbolicBlackColoredPixmap(const QPixmap &source) +{ + QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { + for (int y = 0; y < img.height(); y++) { + auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { + if (qAbs(color.red())>=200 && qAbs(color.green())>=200 && qAbs(color.blue())>=200) { + color.setRed(56); + color.setGreen(56); + color.setBlue(56); + img.setPixelColor(x, y, color); + } + } + } + } + return QPixmap::fromImage(img); +} + +const QPixmap MainWindow::loadSvg(const QString &fileName, const int size) +{ + QPixmap pixmap(size, size); + QSvgRenderer renderer(fileName); + pixmap.fill(Qt::transparent); + + QPainter painter; + painter.begin(&pixmap); + renderer.render(&painter); + painter.end(); + + return pixmap; +} diff --git a/src/mainwindow.h b/src/mainwindow.h index c783fce0..522cb4d0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -62,6 +62,7 @@ #include #include #include +#include #define W_LEFT_AREA 41 #define W_VERTICAL_LINE 1 //左边竖线宽度 @@ -166,6 +167,7 @@ public slots: void onNetworkDeviceAdded(QDBusObjectPath objPath); void onNetworkDeviceRemoved(QDBusObjectPath objPath); void getLanBandWidth(); + void setUkuiStyle(QString style); void onExternalConnectionChange(QString type); void onExternalLanChange(); @@ -185,6 +187,7 @@ public slots: protected: bool eventFilter(QObject *obj, QEvent *event); + void paintEvent(QPaintEvent *event); private: void checkSingle(); @@ -197,6 +200,9 @@ private: void getLanList(); void getWifiList(); void getInitLanSlist(); + QPixmap drawSymbolicColoredPixmap(const QPixmap &source); + QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); + const QPixmap loadSvg(const QString &fileName, const int size); Ui::MainWindow *ui; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f3803f32..9f80f050 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -170,32 +170,6 @@ - - - - 11 - 20 - 19 - 19 - - - - - - - - - - 11 - 67 - 19 - 19 - - - - - - @@ -258,26 +232,51 @@ - background-color: rgba(255, 255, 255,0.06); + background-color: rgba(156, 156, 156,0.1); Qt::Vertical - + - 11 - 499 - 19 - 19 + 8 + 18 + 24 + 24 + + + + + + + + + + 8 + 65 + 24 + 24 + + + + + + + + + + 8 + 497 + 24 + 24 - btnConfImg lbFlyBG lbHotBG lbFlyImg @@ -285,18 +284,19 @@ lbBtnNetBG btnNet lbBtnWifiBG - btnAdvConf btnHotspot btnFlyMode lbBtnWifiBall lbNetListBG lbWifiListBG - lbWifiListImg - lbNetListImg - btnNetList - btnWifiList lbNetwork vLine + btnNetListImg + btnNetList + btnWifiListImg + btnConfImg + btnWifiList + btnAdvConf diff --git a/src/oneconnform.cpp b/src/oneconnform.cpp index c0e2e6e6..05bd1278 100644 --- a/src/oneconnform.cpp +++ b/src/oneconnform.cpp @@ -50,8 +50,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf ui->lePassword->setEchoMode(QLineEdit::Normal); ui->btnConnPWD->setEnabled(false); - leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.57);font-family:Noto Sans CJK SC;}"; - leQssHigh = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);font-family:Noto Sans CJK SC;}"; + leQssLow = "QLineEdit{border:none;background:transparent;font-family:Noto Sans CJK SC;}"; + leQssHigh = "QLineEdit{border:none;background:transparent;font-family:Noto Sans CJK SC;}"; ui->leInfo_1->setStyleSheet(leQssLow); ui->leInfo_2->setStyleSheet(leQssLow); @@ -60,13 +60,14 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf ui->leInfo_2->setEnabled(false); ui->leInfo_3->setEnabled(false); ui->btnInfo->setStyleSheet("QPushButton{border:none;background:transparent;}"); - ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0);}"); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); - ui->wbg_3->setStyleSheet("#wbg_3{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.91);}"); - ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); - ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;" - "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}"); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(156,156,156,0);}"); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); + ui->wbg_3->setStyleSheet("#wbg_3{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); +// ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.91);}"); +// ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); +// ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;" +// "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}"); + ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;background:rgba(0,0,0,0.2);}"); ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}" "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}" "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}"); @@ -79,9 +80,12 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); - ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); +// ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" +// "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" +// "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(156,156,156,0.2);}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(156,156,156,0.3);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); ui->btnHideConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); @@ -172,14 +176,14 @@ bool OneConnForm::eventFilter(QObject *obj, QEvent *event) if (!this->isTopItem) { if (!this->isSelected) { ui->btnConn->show(); - ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); ui->wbg->show(); } } return true; } else if (event->type() == QEvent::HoverLeave) { ui->btnConn->hide(); - ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0);}"); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(156,156,156,0);}"); ui->wbg->hide(); return true; } @@ -200,10 +204,10 @@ bool OneConnForm::eventFilter(QObject *obj, QEvent *event) void OneConnForm::setAct(bool isAct) { if (isAct) { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); + //ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->show(); } else { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); + //ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->hide(); } isActive = isAct; @@ -283,8 +287,7 @@ void OneConnForm::setSelected(bool isSelected, bool isCurrName) } else { resize(W_ITEM, H_ITEM); ui->lePassword->setText(tr("Input Password..."));//"输入密码..." - ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;" - "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}"); + ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;background:rgba(0,0,0,0.2);}"); ui->lePassword->setEchoMode(QLineEdit::Normal); ui->checkBoxPwd->setChecked(true); @@ -589,7 +592,7 @@ bool OneConnForm::isWifiConfExist(QString netName) void OneConnForm::on_checkBoxPwd_stateChanged(int arg1) { if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); + ui->lePassword->setEchoMode(QLineEdit::Password); } else { ui->lePassword->setEchoMode(QLineEdit::Normal); } @@ -597,17 +600,15 @@ void OneConnForm::on_checkBoxPwd_stateChanged(int arg1) void OneConnForm::on_lePassword_textEdited(const QString &arg1) { - ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;" - "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.91);font-size:14px;}"); + ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;background:rgba(0,0,0,0.2);}"); - if (ui->lePassword->text().size() < 5){ + if (ui->lePassword->text().size() < 5) { ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); ui->btnConnPWD->setEnabled(false); - if (ui->lePassword->text().size() == 0){ - ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;" - "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}"); + if (ui->lePassword->text().size() == 0) { + ui->lePassword->setStyleSheet("QLineEdit{border:1px solid rgba(61,107,229,1);border-radius:4px;background:rgba(0,0,0,0.2);}"); } } else { ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" diff --git a/src/oneconnform.ui b/src/oneconnform.ui index 475cae09..b6fb441d 100644 --- a/src/oneconnform.ui +++ b/src/oneconnform.ui @@ -217,7 +217,7 @@ - background-color: rgba(255, 255, 255,0.05); + background-color: rgba(156, 156, 156,0.1); Qt::Horizontal diff --git a/src/onelancform.cpp b/src/onelancform.cpp index 9876ecea..cf6d46b6 100644 --- a/src/onelancform.cpp +++ b/src/onelancform.cpp @@ -34,27 +34,32 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf ui->lbConned->setAlignment(Qt::AlignLeft); - leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.57);font-family:Noto Sans CJK SC;}"; - leQssHigh = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);font-family:Noto Sans CJK SC;}"; +// leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.57);font-family:Noto Sans CJK SC;}"; +// leQssHigh = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);font-family:Noto Sans CJK SC;}"; + leQssLow = "QLineEdit{border:none;background:transparent;font-family:Noto Sans CJK SC;}"; + leQssHigh = "QLineEdit{border:none;background:transparent;font-family:Noto Sans CJK SC;}"; ui->leInfo_1->setStyleSheet(leQssLow); ui->leInfo_2->setStyleSheet(leQssLow); ui->leInfo_3->setStyleSheet(leQssLow); ui->leInfo_4->setStyleSheet(leQssLow); ui->btnInfo->setStyleSheet("QPushButton{border:none;background:transparent;}"); - ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0);}"); - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.91);}"); - ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0);}"); +// ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.91);}"); +// ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); ui->btnConnSub->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); ui->btnConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); - ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); +// ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" +// "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" +// "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(156,156,156,0.2);}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(156,156,156,0.3);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}"); ui->lbWaitingIcon->setStyleSheet("QLabel{border:0px;background-color:transparent;}"); @@ -127,14 +132,14 @@ bool OneLancForm::eventFilter(QObject *obj, QEvent *event) if (!this->isTopItem) { if (!this->isSelected) { ui->btnConn->show(); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0.1);}"); ui->wbg_2->show(); } } return true; } else if(event->type() == QEvent::HoverLeave) { ui->btnConn->hide(); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0);}"); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(156,156,156,0);}"); ui->wbg_2->hide(); return true; } @@ -147,11 +152,11 @@ bool OneLancForm::eventFilter(QObject *obj, QEvent *event) void OneLancForm::setAct(bool isAct) { if (isAct) { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); + //ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->show(); ui->btnConnSub->hide(); } else { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); + //ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->hide(); ui->btnConnSub->hide(); } diff --git a/src/onelancform.ui b/src/onelancform.ui index c8c13ffd..5e149230 100644 --- a/src/onelancform.ui +++ b/src/onelancform.ui @@ -7,7 +7,7 @@ 0 0 424 - 250 + 60 @@ -115,7 +115,7 @@ 63 86 - 250 + 260 20 @@ -169,7 +169,7 @@ - background-color: rgba(255, 255, 255,0.05); + background-color: rgba(156, 156, 156,0.1); Qt::Horizontal diff --git a/src/switchbutton.cpp b/src/switchbutton.cpp index e3b2dbf7..752f68c7 100644 --- a/src/switchbutton.cpp +++ b/src/switchbutton.cpp @@ -70,8 +70,8 @@ void SwitchButton::paintEvent(QPaintEvent *event) { painter.setRenderHint(QPainter::Antialiasing); //抗锯齿效果 painter.setPen(Qt::NoPen); QColor colorActive(61,107,229); - QColor colorInactive(255,255,255); - colorInactive.setAlphaF(0.12); + QColor colorInactive(190,190,190); + colorInactive.setAlphaF(0.12); if(m_bIsOn) { painter.save(); painter.setBrush(colorActive); diff --git a/wireless-security/dlgconnhidwifi.cpp b/wireless-security/dlgconnhidwifi.cpp index ab13c6ae..b43ef39f 100644 --- a/wireless-security/dlgconnhidwifi.cpp +++ b/wireless-security/dlgconnhidwifi.cpp @@ -47,31 +47,31 @@ DlgConnHidWifi::DlgConnHidWifi(int type, MainWindow *mainWindow, QWidget *parent path.addRoundedRect(rect, 6, 6); setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - KylinDBus mkylindbus; - double trans = mkylindbus.getTransparentData(); - QString strTrans; - strTrans = QString::number(trans, 10, 2); - QString sty = "QWidget{border-radius:6px;background-color:rgba(19,19,20," + strTrans + ");border:1px solid rgba(255, 255, 255, 0.05);}"; - this->setStyleSheet(sty); +// KylinDBus mkylindbus; +// double trans = mkylindbus.getTransparentData(); +// QString strTrans; +// strTrans = QString::number(trans, 10, 2); +// QString sty = "QWidget{border-radius:6px;background-color:rgba(19,19,20," + strTrans + ");border:1px solid rgba(255, 255, 255, 0.05);}"; +// this->setStyleSheet(sty); //this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); MyQss objQss; - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); +// ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); +// ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); +// ui->lbConn->setStyleSheet(objQss.labelQss); +// ui->lbNetName->setStyleSheet(objQss.labelQss); +// ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); +// ui->cbxConn->setStyleSheet(objQss.cbxQss); +// ui->cbxConn->setView(new QListView()); +// ui->leNetName->setStyleSheet(objQss.leQss); +// ui->cbxSecurity->setStyleSheet(objQss.cbxQss); +// ui->cbxSecurity->setView(new QListView()); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); +// ui->btnConnect->setStyleSheet(objQss.btnConnQss); +// ui->btnCancel->setStyleSheet(objQss.btnCancelQss); ui->lineUp->setStyleSheet(objQss.lineQss); ui->lineDown->setStyleSheet(objQss.lineQss); @@ -323,5 +323,12 @@ void DlgConnHidWifi::paintEvent(QPaintEvent *event) opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + + QRect rect = this->rect(); + p.setRenderHint(QPainter::Antialiasing); // 反锯齿; + p.setBrush(opt.palette.color(QPalette::Base)); + //p.setOpacity(1); + p.setPen(Qt::NoPen); + p.drawRoundedRect(rect, 6, 6); QWidget::paintEvent(event); } diff --git a/wireless-security/dlgconnhidwifiwpa.cpp b/wireless-security/dlgconnhidwifiwpa.cpp index bb72caac..ce4f2be2 100644 --- a/wireless-security/dlgconnhidwifiwpa.cpp +++ b/wireless-security/dlgconnhidwifiwpa.cpp @@ -46,34 +46,34 @@ DlgConnHidWifiWpa::DlgConnHidWifiWpa(int type, MainWindow *mainWindow, QWidget * path.addRoundedRect(rect, 6, 6); setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - KylinDBus mkylindbus; - double trans = mkylindbus.getTransparentData(); - QString strTrans; - strTrans = QString::number(trans, 10, 2); - QString sty = "QWidget{border-radius:6px;background-color:rgba(19,19,20," + strTrans + ");border:1px solid rgba(255, 255, 255, 0.05);}"; - this->setStyleSheet(sty); +// KylinDBus mkylindbus; +// double trans = mkylindbus.getTransparentData(); +// QString strTrans; +// strTrans = QString::number(trans, 10, 2); +// QString sty = "QWidget{border-radius:6px;background-color:rgba(19,19,20," + strTrans + ");border:1px solid rgba(255, 255, 255, 0.05);}"; +// this->setStyleSheet(sty); //this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); MyQss objQss; - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); +// ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); +// ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); +// ui->lbConn->setStyleSheet(objQss.labelQss); +// ui->lbNetName->setStyleSheet(objQss.labelQss); +// ui->lbSecurity->setStyleSheet(objQss.labelQss); +// ui->lbPassword->setStyleSheet(objQss.labelQss); - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); +// ui->cbxConn->setStyleSheet(objQss.cbxQss); +// ui->cbxConn->setView(new QListView()); +// ui->leNetName->setStyleSheet(objQss.leQss); +// ui->lePassword->setStyleSheet(objQss.leQss); +// ui->cbxSecurity->setStyleSheet(objQss.cbxQss); +// ui->cbxSecurity->setView(new QListView()); ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); +// ui->btnCancel->setStyleSheet(objQss.btnCancelQss); +// ui->btnConnect->setStyleSheet(objQss.btnConnQss); ui->lineUp->setStyleSheet(objQss.lineQss); ui->lineDown->setStyleSheet(objQss.lineQss); ui->btnCancel->setFocusPolicy(Qt::NoFocus); @@ -353,5 +353,12 @@ void DlgConnHidWifiWpa::paintEvent(QPaintEvent *event) opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + + QRect rect = this->rect(); + p.setRenderHint(QPainter::Antialiasing); // 反锯齿; + p.setBrush(opt.palette.color(QPalette::Base)); + //p.setOpacity(1); + p.setPen(Qt::NoPen); + p.drawRoundedRect(rect, 6, 6); QWidget::paintEvent(event); } diff --git a/wireless-security/kylinheadfile.cpp b/wireless-security/kylinheadfile.cpp index 56ac9622..8b721716 100644 --- a/wireless-security/kylinheadfile.cpp +++ b/wireless-security/kylinheadfile.cpp @@ -40,5 +40,5 @@ MyQss::MyQss() btnConnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"; - lineQss = "background:rgba(255,255,255,0.08);"; + lineQss = "background:rgba(156,156,156,0.1);"; }