Merge branch 'dbus-interface' of http://gitlab2.kylin.com/kylin-desktop/kylin-nm into optimize-notification
This commit is contained in:
commit
8e58fd7a82
|
@ -25,6 +25,8 @@
|
|||
#define EMPTY_SSID "EMPTY_SSID"
|
||||
#define LOG_FLAG "[WlanListItem]"
|
||||
#define WAIT_US 10*1000
|
||||
#define ENABLE_BUTTON_COLOR qApp->palette().highlight().color()
|
||||
#define UNABLE_BUTTON_COLOR qApp->palette().button().color()
|
||||
|
||||
WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isApMode, QWidget *parent)
|
||||
: WlanListItem(wirelessNetItem, device, parent)
|
||||
|
@ -45,6 +47,7 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q
|
|||
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
|
||||
connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered);
|
||||
connect(qApp, &QApplication::paletteChanged, this, &WlanListItem::setConnectButtonState);
|
||||
|
||||
m_wirelessConnectOperation = new KyWirelessConnectOperation(this);
|
||||
m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||
|
@ -513,6 +516,7 @@ void WlanListItem::onPwdEditorTextChanged()
|
|||
} else {
|
||||
m_connectButton->setEnabled(true);
|
||||
}
|
||||
setConnectButtonState();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -611,4 +615,15 @@ void WlanListItem::forgetPwd()
|
|||
}
|
||||
}
|
||||
|
||||
void WlanListItem::setConnectButtonState()
|
||||
{
|
||||
QPalette btnPal;
|
||||
if (m_connectButton->isEnabled()) {
|
||||
btnPal.setColor(QPalette::Button, ENABLE_BUTTON_COLOR);
|
||||
m_connectButton->setPalette(btnPal);
|
||||
} else {
|
||||
btnPal.setColor(QPalette::Button, UNABLE_BUTTON_COLOR);
|
||||
m_connectButton->setPalette(btnPal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ private slots:
|
|||
void onConnectButtonClicked();
|
||||
void onMenuTriggered(QAction *action);
|
||||
void onEnterpriseWlanDialogClose(bool isShow);
|
||||
void setConnectButtonState();
|
||||
};
|
||||
|
||||
#endif // WLANLISTITEM_H
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#define BUTTON_SIZE 36,36
|
||||
|
||||
QColor mixColor(const QColor &c1, const QColor &c2, qreal bias);
|
||||
|
||||
InfoButton::InfoButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
this->setFixedSize(BUTTON_SIZE);
|
||||
|
@ -56,26 +58,6 @@ void InfoButton::onPaletteChanged()
|
|||
this->repaint();
|
||||
}
|
||||
|
||||
QColor InfoButton::mixColor(const QColor &c1, const QColor &c2, qreal bias)
|
||||
{
|
||||
if (bias <= 0.0) {
|
||||
return c1;
|
||||
}
|
||||
if (bias >= 1.0) {
|
||||
return c2;
|
||||
}
|
||||
if (qIsNaN(bias)) {
|
||||
return c1;
|
||||
}
|
||||
|
||||
qreal r = mixQreal(c1.redF(), c2.redF(), bias);
|
||||
qreal g = mixQreal(c1.greenF(), c2.greenF(), bias);
|
||||
qreal b = mixQreal(c1.blueF(), c2.blueF(), bias);
|
||||
qreal a = mixQreal(c1.alphaF(), c2.alphaF(), bias);
|
||||
|
||||
return QColor::fromRgbF(r, g, b, a);
|
||||
}
|
||||
|
||||
void InfoButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
|
|
|
@ -39,12 +39,6 @@ protected:
|
|||
private:
|
||||
void initUI();
|
||||
|
||||
static inline qreal mixQreal(qreal a, qreal b, qreal bias)
|
||||
{
|
||||
return a + (b - a) * bias;
|
||||
}
|
||||
QColor mixColor(const QColor &c1, const QColor &c2, qreal bias);
|
||||
|
||||
private:
|
||||
QColor m_backgroundColor;
|
||||
QColor m_foregroundColor;
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#define FOREGROUND_COLOR_PRESS_INACTIVE_DARK QColor(70,70,70,255)
|
||||
#define FOREGROUND_COLOR_NORMAL_ACTIVE QColor(55,144,250,255)
|
||||
#define FOREGROUND_COLOR_PRESS_ACTIVE QColor(36,109,212,255)
|
||||
#define COLOR_BRIGHT_TEXT qApp->palette().brightText().color()
|
||||
#define COLOR_HIGH_LIGHT qApp->palette().highlight().color()
|
||||
|
||||
QColor mixColor(const QColor &c1, const QColor &c2, qreal bias);
|
||||
|
||||
RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
|
@ -159,9 +163,10 @@ void RadioItemButton::paintEvent(QPaintEvent *event)
|
|||
void RadioItemButton::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_isActivated) {
|
||||
m_backgroundColor = qApp->palette().highlight().color();
|
||||
// m_backgroundColor = qApp->palette().highlight().color();
|
||||
m_backgroundColor = mixColor(COLOR_HIGH_LIGHT, COLOR_BRIGHT_TEXT, 0.2);
|
||||
} else {
|
||||
m_backgroundColor = qApp->palette().brightText().color();
|
||||
m_backgroundColor = COLOR_BRIGHT_TEXT;
|
||||
m_backgroundColor.setAlphaF(0.21);
|
||||
}
|
||||
this->update();
|
||||
|
@ -171,10 +176,10 @@ void RadioItemButton::mousePressEvent(QMouseEvent *event)
|
|||
void RadioItemButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_isActivated) {
|
||||
m_backgroundColor = qApp->palette().highlight().color();
|
||||
m_backgroundColor = COLOR_HIGH_LIGHT;
|
||||
} else {
|
||||
m_backgroundColor = qApp->palette().brightText().color();
|
||||
m_backgroundColor.setAlphaF(0.18);
|
||||
m_backgroundColor = COLOR_BRIGHT_TEXT;
|
||||
m_backgroundColor.setAlphaF(0.12);
|
||||
}
|
||||
this->update();
|
||||
return QPushButton::mouseReleaseEvent(event);
|
||||
|
@ -183,10 +188,10 @@ void RadioItemButton::mouseReleaseEvent(QMouseEvent *event)
|
|||
void RadioItemButton::enterEvent(QEvent *event)
|
||||
{
|
||||
if (m_isActivated) {
|
||||
m_backgroundColor = qApp->palette().highlight().color();
|
||||
m_backgroundColor = COLOR_HIGH_LIGHT;
|
||||
} else {
|
||||
m_backgroundColor = qApp->palette().brightText().color();
|
||||
m_backgroundColor.setAlphaF(0.32);
|
||||
m_backgroundColor = COLOR_BRIGHT_TEXT;
|
||||
m_backgroundColor.setAlphaF(0.15);
|
||||
}
|
||||
this->update();
|
||||
return QPushButton::enterEvent(event);
|
||||
|
@ -195,10 +200,10 @@ void RadioItemButton::enterEvent(QEvent *event)
|
|||
void RadioItemButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
if (m_isActivated) {
|
||||
m_backgroundColor = qApp->palette().highlight().color();
|
||||
m_backgroundColor = COLOR_HIGH_LIGHT;
|
||||
} else {
|
||||
m_backgroundColor = qApp->palette().brightText().color();
|
||||
m_backgroundColor.setAlphaF(0.18);
|
||||
m_backgroundColor = COLOR_BRIGHT_TEXT;
|
||||
m_backgroundColor.setAlphaF(0.12);
|
||||
}
|
||||
this->update();
|
||||
return QPushButton::leaveEvent(event);
|
||||
|
@ -207,10 +212,10 @@ void RadioItemButton::leaveEvent(QEvent *event)
|
|||
void RadioItemButton::refreshButtonIcon()
|
||||
{
|
||||
if (m_isActivated) {
|
||||
m_backgroundColor = qApp->palette().highlight().color();
|
||||
m_backgroundColor = COLOR_HIGH_LIGHT;
|
||||
m_iconLabel->setPixmap(loadSvg(m_pixmap, PixmapColor::WHITE));
|
||||
} else {
|
||||
m_backgroundColor = qApp->palette().brightText().color();
|
||||
m_backgroundColor = COLOR_BRIGHT_TEXT;
|
||||
m_backgroundColor.setAlphaF(0.18);
|
||||
if (qApp->palette().base().color().red() > MIDDLE_COLOR) {
|
||||
m_iconLabel->setPixmap(m_pixmap);
|
||||
|
|
Loading…
Reference in New Issue