托盘网络移出主题黑名单后 修改色板显示逻辑 bug 133746
This commit is contained in:
parent
5f11a64d8c
commit
3c0d0b28d3
|
@ -81,11 +81,17 @@ void EnterpriseWlanDialog::closeEvent(QCloseEvent *event)
|
|||
|
||||
void EnterpriseWlanDialog::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
// QPalette pal = qApp->palette();
|
||||
// QPainter painter(this);
|
||||
// painter.setBrush(pal.color(QPalette::Base));
|
||||
// painter.drawRect(this->rect());
|
||||
// painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
|
||||
QPalette pal = qApp->palette();
|
||||
QPainter painter(this);
|
||||
QColor color;
|
||||
if (this->isActiveWindow()) {
|
||||
color = pal.color(QPalette::Base);
|
||||
} else {
|
||||
color = pal.color(QPalette::Background);
|
||||
}
|
||||
painter.setBrush(color);
|
||||
painter.drawRect(this->rect());
|
||||
painter.fillRect(rect(), QBrush(color));
|
||||
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
@ -131,11 +137,7 @@ void EnterpriseWlanDialog::initUI()
|
|||
m_enterWlanScrollArea->setFixedWidth(SCROAREA_WIDTH);
|
||||
m_enterWlanScrollArea->setWidget(m_centerWidget);
|
||||
m_enterWlanScrollArea->setWidgetResizable(true);
|
||||
|
||||
QPalette pal = m_enterWlanScrollArea->palette();
|
||||
pal.setBrush(QPalette::Base, QColor(0,0,0,0));
|
||||
m_enterWlanScrollArea->setPalette(pal);
|
||||
m_enterWlanScrollArea->setWidgetResizable(true);
|
||||
m_enterWlanScrollArea->setBackgroundRole(QPalette::Base);
|
||||
|
||||
m_bottomDivider = new Divider(this);
|
||||
|
||||
|
@ -159,7 +161,7 @@ void EnterpriseWlanDialog::initUI()
|
|||
this->setFixedSize(MAIN_SIZE_EXPAND);
|
||||
this->setWindowTitle(m_wirelessNetItem.m_NetSsid);
|
||||
initConnections();
|
||||
onPaletteChanged();
|
||||
// onPaletteChanged();
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::centerToScreen()
|
||||
|
@ -183,6 +185,7 @@ void EnterpriseWlanDialog::initConnections()
|
|||
m_connectBtn->setEnabled(status);
|
||||
});
|
||||
|
||||
#if 0
|
||||
connect(qApp, &QApplication::paletteChanged, this, &EnterpriseWlanDialog::onPaletteChanged);
|
||||
|
||||
const QByteArray id(THEME_SCHAME);
|
||||
|
@ -194,8 +197,9 @@ void EnterpriseWlanDialog::initConnections()
|
|||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void EnterpriseWlanDialog::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
|
@ -219,6 +223,7 @@ void EnterpriseWlanDialog::onPaletteChanged()
|
|||
styleGsettings = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void EnterpriseWlanDialog::initData()
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
private Q_SLOTS:
|
||||
void onBtnConnectClicked();
|
||||
void onEapTypeChanged(const KyEapMethodType &type);
|
||||
void onPaletteChanged();
|
||||
//void onPaletteChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void enterpriseWlanDialogClose(bool);
|
||||
|
|
|
@ -118,6 +118,16 @@ ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
|||
initConnection();
|
||||
connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged);
|
||||
// m_itemFrame->installEventFilter(this);
|
||||
const QByteArray id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(id)) {
|
||||
QGSettings * styleGsettings = new QGSettings(id, QByteArray(), this);
|
||||
connect(styleGsettings, &QGSettings::changed, this, [=](QString key){
|
||||
if ("themeColor" == key) {
|
||||
onPaletteChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
onPaletteChanged();
|
||||
}
|
||||
|
||||
ListItem::~ListItem()
|
||||
|
@ -314,6 +324,23 @@ void ListItem::onPaletteChanged()
|
|||
// QPalette pal = qApp->palette();
|
||||
// pal.setColor(QPalette::Window, qApp->palette().base().color());
|
||||
// this->setPalette(pal);
|
||||
QPalette pal = qApp->palette();
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
styleGsettings = new QGSettings(style_id, QByteArray(), this);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = themePalette(true, this);
|
||||
}
|
||||
}
|
||||
this->setPalette(pal);
|
||||
|
||||
if (m_menu != nullptr) {
|
||||
pal.setColor(QPalette::Base, pal.color(QPalette::Base));
|
||||
pal.setColor(QPalette::Text, pal.color(QPalette::Text));
|
||||
m_menu->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#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()
|
||||
#define NAMELABLE_MAX_WIDTH_HOVER 176
|
||||
#define NAMELABLE_MAX_WIDTH_ACTIVATED 142
|
||||
#define NAMELABLE_MAX_WIDTH_DEACTIVATED 276
|
||||
|
@ -259,12 +257,11 @@ void WlanListItem::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
void WlanListItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
if (m_pwdLineEdit != nullptr) {
|
||||
pal.setColor(QPalette::Base, pal.color(QPalette::Base));
|
||||
m_pwdLineEdit->setPalette(pal);
|
||||
}
|
||||
|
||||
// QPalette pal = qApp->palette();
|
||||
// if (m_pwdLineEdit != nullptr) {
|
||||
// pal.setColor(QPalette::Base, pal.color(QPalette::Base));
|
||||
// m_pwdLineEdit->setPalette(pal);
|
||||
// }
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
|
@ -276,7 +273,7 @@ void WlanListItem::initWlanUI()
|
|||
this->setName(m_wirelessNetItem.m_NetSsid);
|
||||
//刷新左侧按钮图标
|
||||
refreshIcon(false);
|
||||
|
||||
this->onPaletteChanged();
|
||||
#define PWD_AREA_HEIGHT 36
|
||||
#define CONNECT_BUTTON_WIDTH 96
|
||||
#define FRAME_CONTENT_MARGINS 56,0,16,4
|
||||
|
@ -295,7 +292,7 @@ void WlanListItem::initWlanUI()
|
|||
m_pwdLineEdit = new KPasswordEdit(m_pwdFrame);
|
||||
m_pwdLineEdit->setFixedWidth(LINEEDIT_WIDTH);
|
||||
m_pwdLineEdit->setProperty("needTranslucent", true);
|
||||
m_pwdLineEdit->setUseCustomPalette(true);
|
||||
// m_pwdLineEdit->setUseCustomPalette(true);
|
||||
m_pwdLineEdit->setClearButtonEnabled(false); //禁用ClearBtn按钮
|
||||
m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); //打开输入法
|
||||
// m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
|
||||
|
|
|
@ -260,7 +260,7 @@ void MainWindow::onTransChanged()
|
|||
void MainWindow::paintWithTrans()
|
||||
{
|
||||
QPalette pal = m_centralWidget->palette();
|
||||
QColor color = qApp->palette().base().color();
|
||||
QColor color = this->palette().base().color();
|
||||
color.setAlphaF(m_transparency);
|
||||
pal.setColor(QPalette::Base, color);
|
||||
m_centralWidget->setPalette(pal);
|
||||
|
@ -268,7 +268,7 @@ void MainWindow::paintWithTrans()
|
|||
QPalette tabPal = m_centralWidget->tabBar()->palette();
|
||||
tabPal.setColor(QPalette::Base, color);
|
||||
|
||||
QColor inactiveColor = qApp->palette().window().color();
|
||||
QColor inactiveColor = this->palette().window().color();
|
||||
inactiveColor.setAlphaF(0.86 *m_transparency);
|
||||
tabPal.setColor(QPalette::Window, inactiveColor);
|
||||
|
||||
|
@ -280,6 +280,7 @@ void MainWindow::paintWithTrans()
|
|||
*/
|
||||
void MainWindow::initUI()
|
||||
{
|
||||
setThemePalette();
|
||||
m_centralWidget = new QTabWidget(this);
|
||||
this->setCentralWidget(m_centralWidget);
|
||||
m_centralWidget->tabBar()->setFixedWidth(this->width()+1);
|
||||
|
@ -593,6 +594,21 @@ void MainWindow::assembleTrayIconTooltip(QMap<QString, QString> &map, QString &t
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::setThemePalette()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
styleGsettings = new QGSettings(style_id, QByteArray(), this);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = themePalette(true, this);
|
||||
}
|
||||
}
|
||||
this->setPalette(pal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::onTrayIconActivated 点击托盘图标的槽函数
|
||||
*/
|
||||
|
@ -627,8 +643,11 @@ void MainWindow::onThemeChanged(const QString &key)
|
|||
if (key == COLOR_THEME) {
|
||||
qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__;
|
||||
// resetWindowTheme();
|
||||
setThemePalette();
|
||||
paintWithTrans();
|
||||
Q_EMIT qApp->paletteChanged(qApp->palette());
|
||||
} else if ("themeColor" == key) {
|
||||
setThemePalette();
|
||||
} else {
|
||||
qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
|
|
@ -163,6 +163,8 @@ private:
|
|||
void showByWaylandHelper();
|
||||
void setCentralWidgetType(IconActiveType iconStatus);
|
||||
void assembleTrayIconTooltip(QMap<QString, QString> &map, QString &tip);
|
||||
void setThemePalette();
|
||||
|
||||
double m_transparency=1.0; //透明度
|
||||
QGSettings * m_transGsettings; //透明度配置文件
|
||||
int currentIconIndex=0;
|
||||
|
|
|
@ -151,7 +151,7 @@ void JoinHiddenWiFiPage::initUI()
|
|||
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
|
||||
this->setFixedWidth(WINDOW_WIDTH);
|
||||
this->setFixedHeight(MIN_WINDOW_HEIGHT);
|
||||
onPaletteChanged();
|
||||
// onPaletteChanged();
|
||||
}
|
||||
|
||||
void JoinHiddenWiFiPage::initComponent()
|
||||
|
@ -171,6 +171,7 @@ void JoinHiddenWiFiPage::initComponent()
|
|||
});
|
||||
connect(m_nameEdit, &LineEdit::textChanged, this, &JoinHiddenWiFiPage::setJoinBtnEnable);
|
||||
|
||||
#if 0
|
||||
connect(qApp, &QApplication::paletteChanged, this, &JoinHiddenWiFiPage::onPaletteChanged);
|
||||
|
||||
const QByteArray id(THEME_SCHAME);
|
||||
|
@ -182,6 +183,7 @@ void JoinHiddenWiFiPage::initComponent()
|
|||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void JoinHiddenWiFiPage::setJoinBtnEnable()
|
||||
|
@ -256,7 +258,7 @@ void JoinHiddenWiFiPage::onEapTypeChanged(const KyEapMethodType &type)
|
|||
this->setFixedHeight(EAPMIN_WINDOW_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void JoinHiddenWiFiPage::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
|
@ -279,4 +281,4 @@ void JoinHiddenWiFiPage::onPaletteChanged()
|
|||
styleGsettings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -85,7 +85,7 @@ private Q_SLOTS:
|
|||
void onBtnShowListClicked();
|
||||
void onSecuTypeChanged(const KySecuType &type);
|
||||
void onEapTypeChanged(const KyEapMethodType &type);
|
||||
void onPaletteChanged();
|
||||
//void onPaletteChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void hiddenWiFiPageClose(QString);
|
||||
|
|
|
@ -197,7 +197,10 @@ NetDetail::~NetDetail()
|
|||
void NetDetail::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
pal.setColor(QPalette::Background, pal.base().color());
|
||||
this->setPalette(pal);
|
||||
|
||||
#if 0
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
|
@ -216,6 +219,7 @@ void NetDetail::onPaletteChanged()
|
|||
setFramePalette(securityPage, pal);
|
||||
setFramePalette(createNetPage, pal);
|
||||
QToolTip::setPalette(pal);
|
||||
#endif
|
||||
|
||||
QPalette listwidget_pal(detailPage->m_listWidget->palette());
|
||||
listwidget_pal.setColor(QPalette::Base, pal.base().color());
|
||||
|
@ -223,10 +227,12 @@ void NetDetail::onPaletteChanged()
|
|||
detailPage->m_listWidget->setAlternatingRowColors(true);
|
||||
detailPage->m_listWidget->setPalette(listwidget_pal);
|
||||
|
||||
#if 0
|
||||
if (styleGsettings != nullptr) {
|
||||
delete styleGsettings;
|
||||
styleGsettings = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void NetDetail::currentRowChangeSlot(int row)
|
||||
|
|
|
@ -161,14 +161,14 @@ void TabPage::initUI()
|
|||
void TabPage::onPaletteChanged()
|
||||
{
|
||||
QPalette labPal = m_activatedNetLabel->palette();
|
||||
QColor color = qApp->palette().color(QPalette::PlaceholderText);
|
||||
QColor color = this->palette().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 = qApp->palette().color(QPalette::Active, QPalette::Button);
|
||||
QColor view_color = this->palette().color(QPalette::Active, QPalette::Button);
|
||||
view_pal.setColor(QPalette::Base, view_color);
|
||||
m_deviceComboBox->setPalette(view_pal);
|
||||
m_deviceComboBox->view()->setPalette(view_pal);
|
||||
|
|
Loading…
Reference in New Issue