bug#100020图标底色

This commit is contained in:
kangshuning 2021-12-28 15:24:44 +08:00
parent 4cfc5f6b33
commit fb882eedd5
5 changed files with 51 additions and 18 deletions

View File

@ -39,7 +39,7 @@ LanListItem::LanListItem(const KyConnectItem *lanConnectItem,
LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
{
m_isActive = false;
m_netButton->setButtonIcon(QIcon::fromTheme("network-offline-symbolic"));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
setIcon(false);
const QString str=tr("Not connected");
m_nameLabel->setText(str);

View File

@ -36,12 +36,13 @@ WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid;
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic"));
m_netButton->setDefaultPixmap();
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-offline-symbolic"));
m_netButton->setActive(false);
// m_netButton->setDefaultPixmap();
const QString name = tr("Not connected");
setExpanded(false);
this->setName(name);
this->m_netButton->setEnabled(false);
// this->m_netButton->setEnabled(false);
this->m_infoButton->hide();
}

View File

@ -171,7 +171,7 @@ void MainWindow::paintWithTrans()
tabPal.setColor(QPalette::Base, color);
QColor inactiveColor = qApp->palette().window().color();
inactiveColor.setAlphaF(0.75 *m_transparency);
inactiveColor.setAlphaF(0.86 *m_transparency);
tabPal.setColor(QPalette::Window, inactiveColor);
m_centralWidget->tabBar()->setPalette(tabPal);
@ -184,8 +184,8 @@ void MainWindow::initUI()
{
m_centralWidget = new QTabWidget(this);
this->setCentralWidget(m_centralWidget);
m_centralWidget->tabBar()->setFixedWidth(this->width());
m_centralWidget->tabBar()->setStyleSheet("QTabBar::tab{min-height:40px}");
m_centralWidget->tabBar()->setFixedWidth(this->width()+1);
// m_centralWidget->tabBar()->setStyleSheet("QTabBar::tab{min-height:40px}");
m_lanWidget = new LanPage(m_centralWidget);
m_wlanWidget = new WlanPage(m_centralWidget);
connect(this, &MainWindow::mainWindowVisibleChanged, m_wlanWidget, &WlanPage::onMainWindowVisibleChanged);
@ -204,6 +204,7 @@ void MainWindow::initUI()
m_tabBarLayout->addWidget(m_wlanLabel);
m_centralWidget->tabBar()->setLayout(m_tabBarLayout);
connect(m_centralWidget, &QTabWidget::currentChanged, m_wlanWidget, &WlanPage::onWlanPageVisibleChanged);
m_centralWidget->setAttribute(Qt::WA_TranslucentBackground, true);
paintWithTrans();
}

View File

@ -139,35 +139,63 @@ void RadioItemButton::paintEvent(QPaintEvent *event)
void RadioItemButton::mousePressEvent(QMouseEvent *event)
{
m_backgroundColor = m_isActivated? FOREGROUND_COLOR_PRESS_ACTIVE :
(qApp->palette().base().color().red() > MIDDLE_COLOR ?
FOREGROUND_COLOR_PRESS_INACTIVE_LIGHT :
FOREGROUND_COLOR_PRESS_INACTIVE_DARK);
if (m_isActivated) {
m_backgroundColor = qApp->palette().highlight().color();
} else {
m_backgroundColor = qApp->palette().brightText().color();
m_backgroundColor.setAlphaF(0.21);
}
this->repaint();
return QPushButton::mousePressEvent(event);
}
void RadioItemButton::mouseReleaseEvent(QMouseEvent *event)
{
m_backgroundColor = m_isActivated? FOREGROUND_COLOR_NORMAL_ACTIVE :
(qApp->palette().base().color().red() > MIDDLE_COLOR ?
FOREGROUND_COLOR_NORMAL_INACTIVE_LIGHT :
FOREGROUND_COLOR_NORMAL_INACTIVE_DARK);
if (m_isActivated) {
m_backgroundColor = qApp->palette().highlight().color();
} else {
m_backgroundColor = qApp->palette().brightText().color();
m_backgroundColor.setAlphaF(0.18);
}
this->repaint();
return QPushButton::mouseReleaseEvent(event);
}
void RadioItemButton::enterEvent(QEvent *event)
{
if (m_isActivated) {
m_backgroundColor = qApp->palette().highlight().color();
} else {
m_backgroundColor = qApp->palette().brightText().color();
m_backgroundColor.setAlphaF(0.32);
}
this->repaint();
return QPushButton::enterEvent(event);
}
void RadioItemButton::leaveEvent(QEvent *event)
{
if (m_isActivated) {
m_backgroundColor = qApp->palette().highlight().color();
} else {
m_backgroundColor = qApp->palette().brightText().color();
m_backgroundColor.setAlphaF(0.18);
}
this->repaint();
return QPushButton::leaveEvent(event);
}
void RadioItemButton::refreshButtonIcon()
{
if (m_isActivated) {
m_backgroundColor = FOREGROUND_COLOR_NORMAL_ACTIVE;
m_backgroundColor = qApp->palette().highlight().color();
m_iconLabel->setPixmap(loadSvg(m_pixmap, PixmapColor::WHITE));
} else {
m_backgroundColor = qApp->palette().brightText().color();
m_backgroundColor.setAlphaF(0.18);
if (qApp->palette().base().color().red() > MIDDLE_COLOR) {
m_backgroundColor = FOREGROUND_COLOR_NORMAL_INACTIVE_LIGHT;
m_iconLabel->setPixmap(m_pixmap);
} else {
m_backgroundColor = FOREGROUND_COLOR_NORMAL_INACTIVE_DARK;
m_iconLabel->setPixmap(loadSvg(m_pixmap, PixmapColor::WHITE));
}
}

View File

@ -37,6 +37,8 @@ protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
bool m_isActivated = false;
@ -45,6 +47,7 @@ private:
QVariantAnimation * m_animation = nullptr;
QPixmap m_pixmap;
QIcon m_icon;
void refreshButtonIcon();