From 3ccad670cf50eef753a6bc9a2b9864a2ae892439 Mon Sep 17 00:00:00 2001 From: kangshuning Date: Wed, 29 Dec 2021 16:09:49 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=BC=80=E5=85=B3=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=B8=89=E6=80=81&&bug#100740?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/tab-pages/lanpage.cpp | 28 +++++++++++++---- src/frontend/tab-pages/wlanpage.cpp | 24 ++++++++++++--- src/frontend/tools/switchbutton.cpp | 48 +++++++++++++++++++++++------ src/frontend/tools/switchbutton.h | 4 +++ 4 files changed, 85 insertions(+), 19 deletions(-) diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index dccd21f0..7b5f4c93 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -413,9 +413,14 @@ void LanPage::constructConnectionArea() delete p_deactiveConnectionItem; p_deactiveConnectionItem = nullptr; + } } - + if (m_inactivatedLanListWidget->count() < 4) { + m_inactivatedLanListWidget->setFixedWidth(383); + } else { + m_inactivatedLanListWidget->setFixedWidth(400); + } return; } @@ -457,7 +462,9 @@ bool LanPage::removeConnectionItem(QMap &connectMap, p_listWidgetItem = nullptr; iter = connectMap.erase(iter); - + if (m_inactivatedLanListWidget->count() < 4) { + m_inactivatedLanListWidget->setFixedWidth(383); + } return true; } } @@ -478,6 +485,7 @@ void LanPage::onRemoveConnection(QString path) //删除时后端会 if (m_activeConnectionMap.count() <= 0) { addEmptyConnectItem(m_activeConnectionMap, m_activatedLanListWidget); } + return; } } @@ -507,7 +515,9 @@ void LanPage::onAddConnection(QString uuid) //新增一个有线 delete p_newItem; p_newItem = nullptr; - + if (m_inactivatedLanListWidget->count() >= 4) { + m_inactivatedLanListWidget->setFixedWidth(400); + } return; } @@ -750,6 +760,7 @@ void LanPage::initUI() m_activatedLanListWidget->setFrameShape(QFrame::Shape::NoFrame); m_activatedLanListWidget->setSpacing(LAN_LIST_SPACING); m_activatedLanListWidget->setFixedHeight(ITEM_HEIGHT); //active区域固定高度,只显示一个条目 + m_activatedLanListWidget->setFixedWidth(383); m_activatedLanListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_activatedNetLayout->addWidget(m_activatedLanListWidget); @@ -805,7 +816,6 @@ QListWidgetItem *LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listW p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable)); p_listWidgetItem->setSizeHint(QSize(listWidget->width(), ITEM_HEIGHT)); listWidget->addItem(p_listWidgetItem); - LanListItem *p_lanItem = nullptr; if (itemData != nullptr) { p_lanItem = new LanListItem(itemData, m_currentDeviceName); @@ -817,7 +827,6 @@ QListWidgetItem *LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listW } listWidget->setItemWidget(p_listWidgetItem, p_lanItem); - return p_listWidgetItem; } @@ -828,7 +837,6 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem) } deleteConnectionMapItem(m_inactiveConnectionMap, m_inactivatedLanListWidget, p_newItem->m_connectUuid); - if (p_newItem->m_ifaceName == m_currentDeviceName) { qDebug()<<"[LanPage]update active connection item"<m_connectName; deleteConnectionMapItem(m_activeConnectionMap, m_activatedLanListWidget, EMPTY_CONNECT_UUID); @@ -836,6 +844,9 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem) m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); this->showDesktopNotify(tr("LAN Connected Successfully")); } + if (m_inactivatedLanListWidget->count() < 4) { + m_inactivatedLanListWidget->setFixedWidth(383); + } return; } @@ -857,6 +868,11 @@ void LanPage::updateConnectionArea(KyConnectItem *p_newItem) m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); this->showDesktopNotify(tr("LAN Disconnected Successfully")); } + if (m_inactivatedLanListWidget->count() < 4) { + m_inactivatedLanListWidget->setFixedWidth(383); + } else { + m_inactivatedLanListWidget->setFixedWidth(400); + } return; } diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index e3faa347..63069cd7 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -79,6 +79,7 @@ void WlanPage::initWlanUI() m_activatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS); m_activatedNetListWidget->setSpacing(NET_LIST_SPACING); m_activatedNetListWidget->setFixedHeight(NORMAL_HEIGHT); + m_activatedNetListWidget->setFixedWidth(383); m_activatedNetListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_activatedNetLayout->addWidget(m_activatedNetListWidget); @@ -382,6 +383,9 @@ void WlanPage::deleteWirelessItemFormMap(QMap &wirele delete p_listWidgetItem; p_listWidgetItem = nullptr; + if (m_inactivatedNetListWidget->count() < 4) { + m_inactivatedNetListWidget->setFixedWidth(383); + } return; } @@ -457,7 +461,11 @@ void WlanPage::constructWirelessNetArea() qDebug() << "[WlanPage] Stopped loading wireless net list! time=" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz"); - + if (m_inactivatedNetListWidget->count() < 4) { + m_inactivatedNetListWidget->setFixedWidth(383); + } else { + m_inactivatedNetListWidget->setFixedWidth(400); + } return; } @@ -507,7 +515,9 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated); addWlanMoreItem(); - + if (m_inactivatedNetListWidget->count() >= 4) { + m_inactivatedNetListWidget->setFixedWidth(400); + } return; } @@ -826,7 +836,9 @@ void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName) m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem); m_activatedNetListWidget->setFixedHeight(p_listWidgetItem->sizeHint().height()); - + if (m_inactivatedNetListWidget->count() < 4) { + m_inactivatedNetListWidget->setFixedWidth(383); + } return; } @@ -857,7 +869,11 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName // 更新‘更多’条目,以保证其处于listwidget的最底部 addWlanMoreItem(); - + if (m_inactivatedNetListWidget->count() < 4) { + m_inactivatedNetListWidget->setFixedWidth(383); + } else { + m_inactivatedNetListWidget->setFixedWidth(400); + } return; } diff --git a/src/frontend/tools/switchbutton.cpp b/src/frontend/tools/switchbutton.cpp index 0f121829..8806557e 100644 --- a/src/frontend/tools/switchbutton.cpp +++ b/src/frontend/tools/switchbutton.cpp @@ -18,10 +18,18 @@ #include "switchbutton.h" #define SWITCH_WIDTH 48 #define SWITCH_HEIGHT 24 +#define COLOR_ACTIVE QColor(55,144,250,255) +#define COLOR_INACTIVE QColor(55,55,55,255) +#define COLOR_ACTIVE_HOVER QColor(95,166,251,255) +#define COLOR_INACTIVE_HOVER QColor(95,95,95,255) +#define COLOR_ACTIVE_PRESS QColor(65,150,250,255) +#define COLOR_INACTIVE_PRESS QColor(65,65,65,255) +#define COLOR_UNABLE QColor(76,76,79,255) SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent) { - + m_colorActive = COLOR_ACTIVE; + m_colorInactive = COLOR_INACTIVE; setFixedSize(SWITCH_WIDTH,SWITCH_HEIGHT); m_fWidth = (float)width(); m_fHeight = (float)height(); @@ -34,7 +42,6 @@ SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent) else { m_fCurrentValue = 4; } - connect(m_cTimer, SIGNAL(timeout()), this, SLOT(startAnimation())); @@ -49,7 +56,6 @@ void SwitchButton::setSwitchStatus(bool check) { } else { m_bIsOn = 0; } - emit this->switchStatusChanged(); m_cTimer->start(); //开始播放动画 @@ -106,6 +112,30 @@ void SwitchButton::mousePressEvent(QMouseEvent *event) { return QWidget::mousePressEvent(event); } +void SwitchButton::enterEvent(QEvent *event) +{ + if (m_enabled && m_bIsOn) { + m_colorActive = COLOR_ACTIVE_HOVER; + } + else if (m_enabled && !m_bIsOn) { + m_colorInactive = COLOR_INACTIVE_HOVER; + } + this->update(); + return QWidget::enterEvent(event); +} + +void SwitchButton::leaveEvent(QEvent *event) +{ + if (m_enabled && m_bIsOn) { + m_colorActive = COLOR_ACTIVE; + } + else if (m_enabled && !m_bIsOn) { + m_colorInactive = COLOR_INACTIVE; + } + this->update(); + return QWidget::leaveEvent(event); +} + /* 绘制滑动按钮主体 */ void SwitchButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event); @@ -113,28 +143,28 @@ void SwitchButton::paintEvent(QPaintEvent *event) { painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setRenderHint(QPainter::Antialiasing); //抗锯齿效果 painter.setPen(Qt::NoPen); - QColor colorActive(61,107,229); - QColor colorInactive(190,190,190); - colorInactive.setAlphaF(0.12); if(m_bIsOn && m_enabled) { painter.save(); - painter.setBrush(colorActive); + painter.setBrush(m_colorActive); QRectF active_rect = QRectF(0,0,m_fWidth,m_fHeight); painter.drawRoundedRect(active_rect, 0.5 * m_fHeight, 0.5 * m_fHeight); //画开启状态 } else { painter.save(); - painter.setBrush(colorInactive); + painter.setBrush(m_colorInactive); QRectF inactive_rect = QRectF(0 ,0,m_fWidth,m_fHeight); painter.drawRoundedRect(inactive_rect, 0.5 * m_fHeight, 0.5 * m_fHeight); //画关闭状态 } painter.restore(); painter.save(); if (!m_enabled) { - painter.setBrush(Qt::darkGray); + painter.setBrush(COLOR_UNABLE); +// QRectF enableRect = QRectF(30, 10, 8, 4); +// painter.drawRoundedRect(enableRect, 2, 2); } else { painter.setBrush(Qt::white); } painter.drawEllipse(m_fCurrentValue,4, 16, 16); + painter.restore(); } diff --git a/src/frontend/tools/switchbutton.h b/src/frontend/tools/switchbutton.h index 1662c310..55d985c8 100644 --- a/src/frontend/tools/switchbutton.h +++ b/src/frontend/tools/switchbutton.h @@ -34,6 +34,8 @@ public: bool getEnabled(); private: + QColor m_colorActive; + QColor m_colorInactive; int m_bIsOn = 1; QTimer *m_cTimer; float m_fWidth; @@ -41,6 +43,8 @@ private: float m_fCurrentValue; void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent *event); + void enterEvent(QEvent *event); + void leaveEvent(QEvent *event); bool m_enabled = true; Q_SIGNALS: From ca88d224dd0643231c1d7f1c5d7e10c03df458fe Mon Sep 17 00:00:00 2001 From: kangshuning Date: Wed, 29 Dec 2021 16:48:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4tabbar=E5=88=86=E5=89=B2?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/mainwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index 415206e6..66bfad43 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -203,8 +203,9 @@ void MainWindow::initUI() m_tabBarLayout->addWidget(m_lanLabel); m_tabBarLayout->addWidget(m_wlanLabel); m_centralWidget->tabBar()->setLayout(m_tabBarLayout); + m_centralWidget->tabBar()->setProperty("useTabbarSeparateLine", false); // 去掉中间的分割线 + m_centralWidget->setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明 解决切换黑屏问题 connect(m_centralWidget, &QTabWidget::currentChanged, m_wlanWidget, &WlanPage::onWlanPageVisibleChanged); - m_centralWidget->setAttribute(Qt::WA_TranslucentBackground, true); paintWithTrans(); } From 5c65f628609e46ed9699cf36e6253d8bc7e633be Mon Sep 17 00:00:00 2001 From: kangshuning Date: Thu, 30 Dec 2021 09:34:35 +0800 Subject: [PATCH 3/4] use define --- src/frontend/tab-pages/lanpage.cpp | 26 +++++++++++++------------- src/frontend/tab-pages/tabpage.h | 4 ++++ src/frontend/tab-pages/wlanpage.cpp | 26 +++++++++++++------------- src/frontend/tools/switchbutton.cpp | 3 +-- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 7b5f4c93..27799a92 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -416,10 +416,10 @@ void LanPage::constructConnectionArea() } } - if (m_inactivatedLanListWidget->count() < 4) { - m_inactivatedLanListWidget->setFixedWidth(383); + if (m_inactivatedLanListWidget->count() < MAX_ITEMS) { + m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); } else { - m_inactivatedLanListWidget->setFixedWidth(400); + m_inactivatedLanListWidget->setFixedWidth(MAX_WIDTH); } return; } @@ -462,8 +462,8 @@ bool LanPage::removeConnectionItem(QMap &connectMap, p_listWidgetItem = nullptr; iter = connectMap.erase(iter); - if (m_inactivatedLanListWidget->count() < 4) { - m_inactivatedLanListWidget->setFixedWidth(383); + if (m_inactivatedLanListWidget->count() < MAX_ITEMS) { + m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); } return true; } @@ -515,8 +515,8 @@ void LanPage::onAddConnection(QString uuid) //新增一个有线 delete p_newItem; p_newItem = nullptr; - if (m_inactivatedLanListWidget->count() >= 4) { - m_inactivatedLanListWidget->setFixedWidth(400); + if (m_inactivatedLanListWidget->count() >= MAX_ITEMS) { + m_inactivatedLanListWidget->setFixedWidth(MAX_WIDTH); } return; } @@ -760,7 +760,7 @@ void LanPage::initUI() m_activatedLanListWidget->setFrameShape(QFrame::Shape::NoFrame); m_activatedLanListWidget->setSpacing(LAN_LIST_SPACING); m_activatedLanListWidget->setFixedHeight(ITEM_HEIGHT); //active区域固定高度,只显示一个条目 - m_activatedLanListWidget->setFixedWidth(383); + m_activatedLanListWidget->setFixedWidth(MIN_WIDTH); m_activatedLanListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_activatedNetLayout->addWidget(m_activatedLanListWidget); @@ -844,8 +844,8 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem) m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); this->showDesktopNotify(tr("LAN Connected Successfully")); } - if (m_inactivatedLanListWidget->count() < 4) { - m_inactivatedLanListWidget->setFixedWidth(383); + if (m_inactivatedLanListWidget->count() < MAX_ITEMS) { + m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); } return; @@ -868,10 +868,10 @@ void LanPage::updateConnectionArea(KyConnectItem *p_newItem) m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); this->showDesktopNotify(tr("LAN Disconnected Successfully")); } - if (m_inactivatedLanListWidget->count() < 4) { - m_inactivatedLanListWidget->setFixedWidth(383); + if (m_inactivatedLanListWidget->count() < MAX_ITEMS) { + m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); } else { - m_inactivatedLanListWidget->setFixedWidth(400); + m_inactivatedLanListWidget->setFixedWidth(MAX_WIDTH); } return; diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index ee3b54d9..7be11d55 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -33,6 +33,10 @@ #define INACTIVE_AREA_MIN_HEIGHT 170 #define ACTIVE_AREA_MAX_HEIGHT 92 +#define MAX_ITEMS 4 +#define MAX_WIDTH 400 +#define MIN_WIDTH 383 + #define SCROLL_STEP 4 enum KyDeviceType diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 63069cd7..e9be8ef1 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -79,7 +79,7 @@ void WlanPage::initWlanUI() m_activatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS); m_activatedNetListWidget->setSpacing(NET_LIST_SPACING); m_activatedNetListWidget->setFixedHeight(NORMAL_HEIGHT); - m_activatedNetListWidget->setFixedWidth(383); + m_activatedNetListWidget->setFixedWidth(MIN_WIDTH); m_activatedNetListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_activatedNetLayout->addWidget(m_activatedNetListWidget); @@ -383,8 +383,8 @@ void WlanPage::deleteWirelessItemFormMap(QMap &wirele delete p_listWidgetItem; p_listWidgetItem = nullptr; - if (m_inactivatedNetListWidget->count() < 4) { - m_inactivatedNetListWidget->setFixedWidth(383); + if (m_inactivatedNetListWidget->count() < MAX_ITEMS) { + m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH); } return; } @@ -461,10 +461,10 @@ void WlanPage::constructWirelessNetArea() qDebug() << "[WlanPage] Stopped loading wireless net list! time=" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz"); - if (m_inactivatedNetListWidget->count() < 4) { - m_inactivatedNetListWidget->setFixedWidth(383); + if (m_inactivatedNetListWidget->count() < MAX_ITEMS) { + m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH); } else { - m_inactivatedNetListWidget->setFixedWidth(400); + m_inactivatedNetListWidget->setFixedWidth(MAX_WIDTH); } return; } @@ -515,8 +515,8 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated); addWlanMoreItem(); - if (m_inactivatedNetListWidget->count() >= 4) { - m_inactivatedNetListWidget->setFixedWidth(400); + if (m_inactivatedNetListWidget->count() >= MAX_ITEMS) { + m_inactivatedNetListWidget->setFixedWidth(MAX_WIDTH); } return; } @@ -836,8 +836,8 @@ void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName) m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem); m_activatedNetListWidget->setFixedHeight(p_listWidgetItem->sizeHint().height()); - if (m_inactivatedNetListWidget->count() < 4) { - m_inactivatedNetListWidget->setFixedWidth(383); + if (m_inactivatedNetListWidget->count() < MAX_ITEMS) { + m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH); } return; } @@ -869,10 +869,10 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName // 更新‘更多’条目,以保证其处于listwidget的最底部 addWlanMoreItem(); - if (m_inactivatedNetListWidget->count() < 4) { - m_inactivatedNetListWidget->setFixedWidth(383); + if (m_inactivatedNetListWidget->count() < MAX_ITEMS) { + m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH); } else { - m_inactivatedNetListWidget->setFixedWidth(400); + m_inactivatedNetListWidget->setFixedWidth(MAX_WIDTH); } return; } diff --git a/src/frontend/tools/switchbutton.cpp b/src/frontend/tools/switchbutton.cpp index 8806557e..532ea7db 100644 --- a/src/frontend/tools/switchbutton.cpp +++ b/src/frontend/tools/switchbutton.cpp @@ -128,8 +128,7 @@ void SwitchButton::leaveEvent(QEvent *event) { if (m_enabled && m_bIsOn) { m_colorActive = COLOR_ACTIVE; - } - else if (m_enabled && !m_bIsOn) { + } else if (m_enabled && !m_bIsOn) { m_colorInactive = COLOR_INACTIVE; } this->update(); From 6cc2e731eb029a00461cfbc71599229ae700f0b1 Mon Sep 17 00:00:00 2001 From: kangshuning Date: Thu, 30 Dec 2021 10:04:47 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/tools/switchbutton.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/frontend/tools/switchbutton.cpp b/src/frontend/tools/switchbutton.cpp index 532ea7db..430443c6 100644 --- a/src/frontend/tools/switchbutton.cpp +++ b/src/frontend/tools/switchbutton.cpp @@ -116,11 +116,12 @@ void SwitchButton::enterEvent(QEvent *event) { if (m_enabled && m_bIsOn) { m_colorActive = COLOR_ACTIVE_HOVER; - } - else if (m_enabled && !m_bIsOn) { + } else if (m_enabled && !m_bIsOn) { m_colorInactive = COLOR_INACTIVE_HOVER; } + this->update(); + return QWidget::enterEvent(event); } @@ -131,7 +132,9 @@ void SwitchButton::leaveEvent(QEvent *event) } else if (m_enabled && !m_bIsOn) { m_colorInactive = COLOR_INACTIVE; } + this->update(); + return QWidget::leaveEvent(event); }