标题颜色随主题变化

This commit is contained in:
kangshuning 2021-12-21 11:09:35 +08:00
parent 9108664ee8
commit d869664426
5 changed files with 24 additions and 14 deletions

View File

@ -173,9 +173,9 @@ void NetConnect::initComponent() {
ui->availableLayout->setSpacing(SPACING);
ui->horizontalLayout->setContentsMargins(TOP_MARGINS);
connect(wiredSwitch, &SwitchButton::disabledClick, this, [=]() {
showDesktopNotify(tr("No ethernet device avaliable"));
});
// connect(wiredSwitch, &SwitchButton::disabledClick, this, [=]() {
// showDesktopNotify(tr("No ethernet device avaliable"));
// });
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);

View File

@ -188,9 +188,9 @@ void WlanConnect::initComponent() {
ui->verticalLayout_3->setContentsMargins(NO_MARGINS);
ui->availableLayout->setSpacing(SPACING);
connect(m_wifiSwitch, &SwitchButton::disabledClick, this, [=]() {
showDesktopNotify(tr("No wireless network card detected"));
});
// connect(m_wifiSwitch, &SwitchButton::disabledClick, this, [=]() {
// showDesktopNotify(tr("No wireless network card detected"));
// });
//开关
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {

View File

@ -118,7 +118,7 @@ private:
void initWindowTheme();
void resetWindowTheme();
void showControlCenter();
double m_transparency=0.0; //透明度
double m_transparency=1.0; //透明度
QGSettings * m_transGsettings; //透明度配置文件
int currentIconIndex=0;
QList<QIcon> loadIcons;

View File

@ -2,10 +2,12 @@
#include <qsettings.h>
#include <QDBusInterface>
#include <QLabel>
#include <QApplication>
TabPage::TabPage(QWidget *parent) : QWidget(parent)
{
initUI();
connect(qApp, &QApplication::paletteChanged, this, &TabPage::onPaletteChanged);
}
TabPage::~TabPage()
@ -43,13 +45,7 @@ void TabPage::initUI()
m_deviceLabel->setText(tr("Current Device"));
m_deviceComboBox = new QComboBox(m_deviceFrame);
m_deviceComboBox->setFixedWidth(DEVICE_COMBOBOX_WIDTH);
if (m_deviceComboBox->view()) {
QPalette view_pal = m_deviceComboBox->view()->palette();
QColor view_color = m_deviceComboBox->palette().color(QPalette::Active, QPalette::Button);
view_pal.setColor(QPalette::Base, view_color);
m_deviceComboBox->setPalette(view_pal);
m_deviceComboBox->view()->setPalette(view_pal);
}
m_tipsLabel = new QLabel(m_deviceFrame);
m_tipsLabel->setText(tr("Devices Closed!"));
m_deviceLayout->addWidget(m_deviceLabel);
@ -121,11 +117,24 @@ void TabPage::initUI()
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
m_inactivatedNetListArea->setPalette(pal);
onPaletteChanged();
}
void TabPage::onPaletteChanged()
{
QPalette labPal = m_activatedNetLabel->palette();
QColor color = labPal.color(QPalette::PlaceholderText);
labPal.setColor(QPalette::WindowText, color);
m_activatedNetLabel->setPalette(labPal);
m_inactivatedNetLabel->setPalette(labPal);
if (m_deviceComboBox->view()) {
QPalette view_pal = m_deviceComboBox->view()->palette();
QColor view_color = m_deviceComboBox->palette().color(QPalette::Active, QPalette::Button);
view_pal.setColor(QPalette::Base, view_color);
m_deviceComboBox->setPalette(view_pal);
m_deviceComboBox->view()->setPalette(view_pal);
}
}
void TabPage::showDesktopNotify(const QString &message)

View File

@ -102,6 +102,7 @@ protected:
public slots:
virtual void onDeviceComboxIndexChanged(int currentIndex) = 0;
void onPaletteChanged();
};