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