Merge branch '2309-0721' into 'yhkylin/v101'
bug 173999 133746 被移出主题黑名单后 修改托盘网络弹窗色板逻辑 See merge request kylinos-src/kylin-nm!228
This commit is contained in:
commit
c5d757d832
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
#include "listitem.h"
|
||||
#include <QDebug>
|
||||
#include "themepalette.h"
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
|
@ -28,8 +29,8 @@
|
|||
#define FRAME_WIDTH 404
|
||||
#define INFO_ICON_WIDTH 16
|
||||
#define INFO_ICON_HEIGHT 16
|
||||
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
|
||||
#define DARK_HOVER_COLOR QColor(15,15,15,255)
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
|
@ -39,6 +40,7 @@ ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
|||
initConnection();
|
||||
connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged);
|
||||
// m_itemFrame->installEventFilter(this);
|
||||
onPaletteChanged();
|
||||
}
|
||||
|
||||
ListItem::~ListItem()
|
||||
|
@ -144,8 +146,22 @@ void ListItem::initConnection()
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,10 @@ public:
|
|||
private:
|
||||
void initUI();
|
||||
void initConnection();
|
||||
void onPaletteChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void onNetButtonClicked() = 0;
|
||||
void onPaletteChanged();
|
||||
virtual void onMenuTriggered(QAction *action)=0;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
SinglePage::SinglePage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setThemePalette();
|
||||
initUI();
|
||||
initWindowProperties();
|
||||
initTransparency();
|
||||
|
@ -65,6 +66,7 @@ void SinglePage::initUI()
|
|||
m_listFrame->setLayout(m_listLayout);
|
||||
m_listWidget = new QListWidget(m_listFrame);
|
||||
m_listLayout->addWidget(m_listWidget);
|
||||
m_listWidget->setProperty("needTranslucent", true);
|
||||
|
||||
m_setDivider = new Divider(this);
|
||||
|
||||
|
@ -152,7 +154,7 @@ void SinglePage::paintEvent(QPaintEvent *event) {
|
|||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::transparent);
|
||||
QColor col = qApp->palette().window().color();
|
||||
QColor col = this->palette().window().color();
|
||||
|
||||
QPainterPath rectPath;
|
||||
|
||||
|
@ -186,15 +188,34 @@ void SinglePage::onTransChanged()
|
|||
void SinglePage::onThemeChanged(const QString &key)
|
||||
{
|
||||
if (key == COLOR_THEME) {
|
||||
setThemePalette();
|
||||
paintWithTrans();
|
||||
Q_EMIT qApp->paletteChanged(qApp->palette());
|
||||
} else if ("themeColor" == key) {
|
||||
setThemePalette();
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePage::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);
|
||||
}
|
||||
}
|
||||
pal.setColor(QPalette::Background, pal.base().color());
|
||||
this->setPalette(pal);
|
||||
}
|
||||
|
||||
void SinglePage::paintWithTrans()
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
QColor color = qApp->palette().base().color();
|
||||
QColor color = this->palette().base().color();
|
||||
color.setAlphaF(m_transparency);
|
||||
pal.setColor(QPalette::Window, color);
|
||||
this->setPalette(pal);
|
||||
|
@ -207,5 +228,3 @@ void SinglePage::keyPressEvent(QKeyEvent *event)
|
|||
}
|
||||
return QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ Q_SIGNALS:
|
|||
private Q_SLOTS:
|
||||
void onTransChanged();
|
||||
void onThemeChanged(const QString &key);
|
||||
void setThemePalette();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QApplication>
|
||||
|
||||
#include "../netdetails/coninfo.h"
|
||||
#include "themepalette.h"
|
||||
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
@ -31,30 +32,31 @@ Divider::Divider(bool useLightPal, QWidget * parent)
|
|||
QFrame(parent)
|
||||
{
|
||||
this->setFixedHeight(1);
|
||||
initPalette();
|
||||
connect(qApp, &QApplication::paletteChanged, this ,&Divider::onPaletteChanged);
|
||||
onPaletteChanged();
|
||||
}
|
||||
|
||||
void Divider::onPaletteChanged()
|
||||
void Divider::initPalette()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id) && m_useLightPal) {
|
||||
styleGsettings = new QGSettings(style_id);
|
||||
const QByteArray styleId(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(styleId)) {
|
||||
styleGsettings = new QGSettings(styleId, QByteArray(), this);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = lightPalette(this);
|
||||
pal = themePalette(true, this);
|
||||
}
|
||||
}
|
||||
this->setPalette(pal);
|
||||
}
|
||||
|
||||
void Divider::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
m_color = pal.color(QPalette::BrightText);
|
||||
m_color.setAlphaF(0.08);
|
||||
|
||||
if (styleGsettings != nullptr) {
|
||||
delete styleGsettings;
|
||||
styleGsettings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Divider::paintEvent(QPaintEvent * e)
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
private:
|
||||
bool m_useLightPal;
|
||||
QColor m_color;
|
||||
void initPalette();
|
||||
private Q_SLOTS:
|
||||
void onPaletteChanged();
|
||||
protected:
|
||||
|
|
|
@ -22,20 +22,22 @@
|
|||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QApplication>
|
||||
#include <QGSettings>
|
||||
#include "themepalette.h"
|
||||
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ICON_SIZE 16,16
|
||||
#define BACKGROUND_COLOR QColor(0,0,0,0)
|
||||
#define FOREGROUND_COLOR_NORMAL qApp->palette().text().color()
|
||||
//#define FOREGROUND_COLOR_HOVER QColor(55,144,250,255)
|
||||
//#define FOREGROUND_COLOR_PRESS QColor(36,109,212,255)
|
||||
#define FOREGROUND_COLOR_BRIGHTTEXT qApp->palette().brightText().color()
|
||||
#define FOREGROUND_COLOR_HIGHLIGHT qApp->palette().highlight().color()
|
||||
#define FOREGROUND_COLOR_NORMAL this->palette().text().color()
|
||||
#define FOREGROUND_COLOR_BRIGHTTEXT this->palette().brightText().color()
|
||||
#define FOREGROUND_COLOR_HIGHLIGHT this->palette().highlight().color()
|
||||
#define OUTER_PATH 8,10,16,16
|
||||
#define INNER_PATH 9,11,14,14
|
||||
#define TEXT_POS 14,7,16,16,0
|
||||
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
QColor mixColor(const QColor &c1, const QColor &c2, qreal bias);
|
||||
|
||||
|
@ -44,6 +46,17 @@ InfoButton::InfoButton(QWidget *parent) : QPushButton(parent)
|
|||
this->setFixedSize(BUTTON_SIZE);
|
||||
initUI();
|
||||
connect(qApp, &QApplication::paletteChanged, this, &InfoButton::onPaletteChanged);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void InfoButton::initUI()
|
||||
|
@ -55,6 +68,18 @@ void InfoButton::initUI()
|
|||
|
||||
void InfoButton::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray styleId(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(styleId)) {
|
||||
styleGsettings = new QGSettings(styleId, QByteArray(), this);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = themePalette(true, this);
|
||||
}
|
||||
}
|
||||
this->setPalette(pal);
|
||||
|
||||
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
|
||||
this->repaint();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <QFontMetrics>
|
||||
#include <QGSettings>
|
||||
|
||||
#define FOREGROUND_COLOR_NORMAL qApp->palette().text().color()
|
||||
#define FOREGROUND_COLOR_NORMAL this->palette().text().color()
|
||||
|
||||
static inline qreal mixQreal(qreal a, qreal b, qreal bias)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QLabel>
|
||||
#include "themepalette.h"
|
||||
|
||||
class FixLabel : public QLabel
|
||||
{
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
#include <QDebug>
|
||||
#include "themepalette.h"
|
||||
|
||||
#define FLASH_SPEED 100
|
||||
#define TIMEOUT_TIMER 90*1000
|
||||
#define BUTTON_SIZE 36,36
|
||||
|
@ -35,9 +37,10 @@
|
|||
#define FOREGROUND_COLOR_PRESS_INACTIVE_DARK QColor(70,70,70,255)
|
||||
#define FOREGROUND_COLOR_NORMAL_ACTIVE QColor(55,144,250,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()
|
||||
#define COLOR_BRIGHT_TEXT this->palette().brightText().color()
|
||||
#define COLOR_HIGH_LIGHT this->palette().highlight().color()
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
QColor mixColor(const QColor &c1, const QColor &c2, qreal bias);
|
||||
|
||||
|
@ -61,6 +64,7 @@ RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent)
|
|||
}
|
||||
});
|
||||
}
|
||||
onPaletteChanged();
|
||||
|
||||
//JXJ_TODO loading动画
|
||||
connect(this, &RadioItemButton::requestStartLoading, this, &RadioItemButton::onLoadingStarted);
|
||||
|
@ -140,6 +144,18 @@ void RadioItemButton::onLoadingStopped()
|
|||
|
||||
void RadioItemButton::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray styleId(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(styleId)) {
|
||||
styleGsettings = new QGSettings(styleId, QByteArray(), this);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = themePalette(true, this);
|
||||
}
|
||||
}
|
||||
this->setPalette(pal);
|
||||
|
||||
refreshButtonIcon();
|
||||
}
|
||||
|
||||
|
@ -233,7 +249,7 @@ void RadioItemButton::refreshButtonIcon()
|
|||
} else {
|
||||
m_backgroundColor = COLOR_BRIGHT_TEXT;
|
||||
m_backgroundColor.setAlphaF(0.12);
|
||||
if (qApp->palette().base().color().red() > MIDDLE_COLOR) {
|
||||
if (this->palette().base().color().red() > MIDDLE_COLOR) {
|
||||
m_iconLabel->setPixmap(m_pixmap);
|
||||
} else {
|
||||
m_iconLabel->setPixmap(loadSvg(m_pixmap, PixmapColor::WHITE));
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
#ifndef THEMEPALETTE_H
|
||||
#define THEMEPALETTE_H
|
||||
|
||||
#include <QPalette>
|
||||
#include <QApplication>
|
||||
|
||||
static QPalette themePalette(bool isDark, QWidget *widget)
|
||||
{
|
||||
QPalette palette = qApp->palette();
|
||||
|
||||
//ukui-light palette UKUI3.1
|
||||
QColor windowText_at(38, 38, 38),
|
||||
windowText_iat(0, 0, 0, 255 * 0.55),
|
||||
windowText_dis(0, 0, 0, 255 * 0.3),
|
||||
button_at(230, 230, 230),
|
||||
button_iat(230, 230, 230),
|
||||
button_dis(233, 233, 233),
|
||||
light_at(255, 255, 255),
|
||||
light_iat(255, 255, 255),
|
||||
light_dis(242, 242, 242),
|
||||
midlight_at(218, 218, 218),
|
||||
midlight_iat(218, 218, 218),
|
||||
midlight_dis(230, 230, 230),
|
||||
dark_at(77, 77, 77),
|
||||
dark_iat(77, 77, 77),
|
||||
dark_dis(64, 64, 64),
|
||||
mid_at(115, 115, 115),
|
||||
mid_iat(115, 115, 115),
|
||||
mid_dis(102, 102, 102),
|
||||
text_at(38, 38, 38),
|
||||
text_iat(38, 38, 38),
|
||||
text_dis(0, 0, 0, 255 * 0.3),
|
||||
brightText_at(0, 0, 0),
|
||||
brightText_iat(0, 0, 0),
|
||||
brightText_dis(0, 0, 0),
|
||||
buttonText_at(38, 38, 38),
|
||||
buttonText_iat(38, 38, 38),
|
||||
buttonText_dis(179, 179, 179),
|
||||
base_at(255, 255, 255),
|
||||
base_iat(245, 245, 245),
|
||||
base_dis(237, 237, 237),
|
||||
window_at(245, 245, 245),
|
||||
window_iat(237, 237, 237),
|
||||
window_dis(230, 230, 230),
|
||||
shadow_at(0, 0, 0, 255 * 0.16),
|
||||
shadow_iat(0, 0, 0, 255 * 0.16),
|
||||
shadow_dis(0, 0, 0, 255 * 0.21),
|
||||
highLight_at(55, 144, 250),
|
||||
highLight_iat(55, 144, 250),
|
||||
highLight_dis(233, 233, 233),
|
||||
highLightText_at(255, 255, 255),
|
||||
highLightText_iat(255, 255, 255),
|
||||
highLightText_dis(179, 179, 179),
|
||||
link_at(55, 144, 250),
|
||||
link_iat(55, 144, 250),
|
||||
link_dis(55, 144, 250),
|
||||
linkVisited_at(114, 46, 209),
|
||||
linkVisited_iat(114, 46, 209),
|
||||
linkVisited_dis(114, 46, 209),
|
||||
alternateBase_at(245, 245, 245),
|
||||
alternateBase_iat(245, 245, 245),
|
||||
alternateBase_dis(245, 245, 245),
|
||||
noRale_at(240, 240, 240),
|
||||
noRole_iat(240, 240, 240),
|
||||
noRole_dis(217, 217, 217),
|
||||
toolTipBase_at(255, 255, 255),
|
||||
toolTipBase_iat(255, 255, 255),
|
||||
toolTipBase_dis(255, 255, 255),
|
||||
toolTipText_at(38, 38, 38),
|
||||
toolTipText_iat(38, 38, 38),
|
||||
toolTipText_dis(38, 38, 38),
|
||||
placeholderText_at(0, 0, 0, 255 * 0.35),
|
||||
placeholderText_iat(0, 0, 0, 255 * 0.35),
|
||||
placeholderText_dis(0, 0, 0, 255 * 0.3);
|
||||
|
||||
//ukui-dark
|
||||
if (isDark) {
|
||||
windowText_at.setRgb(217, 217, 217);
|
||||
windowText_iat.setRgb(255, 255, 255, 255 * 0.55);
|
||||
windowText_dis.setRgb(255, 255, 255, 255 * 0.3);
|
||||
button_at.setRgb(55, 55, 59);
|
||||
button_iat.setRgb(55, 55, 59);
|
||||
button_dis.setRgb(46, 46, 46);
|
||||
light_at.setRgb(255, 255, 255);
|
||||
light_iat.setRgb(255, 255, 255);
|
||||
light_dis.setRgb(242, 242, 242);
|
||||
midlight_at.setRgb(95, 95, 98);
|
||||
midlight_iat.setRgb(95, 95, 98);
|
||||
midlight_dis.setRgb(79, 79, 82);
|
||||
dark_at.setRgb(38, 38, 38);
|
||||
dark_iat.setRgb(38, 38, 38);
|
||||
dark_dis.setRgb(26, 26, 26);
|
||||
mid_at.setRgb(115, 115, 115);
|
||||
mid_iat.setRgb(115, 115, 115);
|
||||
mid_dis.setRgb(102, 102, 102);
|
||||
text_at.setRgb(217, 217, 217);
|
||||
text_iat.setRgb(217, 217, 217);
|
||||
text_dis.setRgb(255, 255, 255, 255 * 0.3);
|
||||
brightText_at.setRgb(255, 255, 255);
|
||||
brightText_iat.setRgb(255, 255, 255);
|
||||
brightText_dis.setRgb(255, 255, 255);
|
||||
buttonText_at.setRgb(217, 217, 217);
|
||||
buttonText_iat.setRgb(217, 217, 217);
|
||||
buttonText_dis.setRgb(76, 76, 79);
|
||||
base_at.setRgb(29, 29, 29);
|
||||
base_iat.setRgb(28, 28, 28);
|
||||
base_dis.setRgb(36, 36, 36);
|
||||
window_at.setRgb(35, 36, 38);
|
||||
window_iat.setRgb(26, 26, 26);
|
||||
window_dis.setRgb(18, 18, 18);
|
||||
shadow_at.setRgb(0, 0, 0, 255 * 0.16);
|
||||
shadow_iat.setRgb(0, 0, 0, 255 * 0.16);
|
||||
shadow_dis.setRgb(0, 0, 0, 255 * 0.21);
|
||||
highLight_at.setRgb(55, 144, 250);
|
||||
highLight_iat.setRgb(55, 144, 250);
|
||||
highLight_dis.setRgb(46, 46, 46);
|
||||
highLightText_at.setRgb(255, 255, 255);
|
||||
highLightText_iat.setRgb(255, 255, 255);
|
||||
highLightText_dis.setRgb(77, 77, 77);
|
||||
link_at.setRgb(55, 144, 250);
|
||||
link_iat.setRgb(55, 144, 250);
|
||||
link_dis.setRgb(55, 144, 250);
|
||||
linkVisited_at.setRgb(114, 46, 209);
|
||||
linkVisited_iat.setRgb(114, 46, 209);
|
||||
linkVisited_dis.setRgb(114, 46, 209);
|
||||
alternateBase_at.setRgb(38, 38, 38);
|
||||
alternateBase_iat.setRgb(38, 38, 38);
|
||||
alternateBase_dis.setRgb(38, 38, 38);
|
||||
noRale_at.setRgb(51, 51, 51);
|
||||
noRole_iat.setRgb(51, 51, 51);
|
||||
noRole_dis.setRgb(60, 60, 60);
|
||||
toolTipBase_at.setRgb(38, 38, 38);
|
||||
toolTipBase_iat.setRgb(38, 38, 38);
|
||||
toolTipBase_dis.setRgb(38, 38, 38);
|
||||
toolTipText_at.setRgb(217, 217, 217);
|
||||
toolTipText_iat.setRgb(217, 217, 217);
|
||||
toolTipText_dis.setRgb(217, 217, 217);
|
||||
placeholderText_at.setRgb(255, 255, 255, 255 * 0.35);
|
||||
placeholderText_iat.setRgb(255, 255, 255, 255 * 0.35);
|
||||
placeholderText_dis.setRgb(255, 255, 255, 255 * 0.3);
|
||||
}
|
||||
palette.setColor(QPalette::Active, QPalette::WindowText, windowText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::WindowText, windowText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::WindowText, windowText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Button, button_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Button, button_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Button, button_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Light, light_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Light, light_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Light, light_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Midlight, midlight_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Midlight, midlight_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Midlight, midlight_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Dark, dark_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Dark, dark_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Dark, dark_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Mid, mid_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Mid, mid_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Mid, mid_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Text, text_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Text, text_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Text, text_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::BrightText, brightText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::BrightText, brightText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::BrightText, brightText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::ButtonText, buttonText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ButtonText, buttonText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Base, base_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Base, base_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Base, base_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Window, window_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Window, window_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Window, window_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Shadow, shadow_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::HighlightedText, highLightText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::AlternateBase, alternateBase_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::AlternateBase, alternateBase_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::AlternateBase, alternateBase_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::NoRole, noRale_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::NoRole, noRole_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::NoRole, noRole_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::ToolTipBase, toolTipBase_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::ToolTipBase, toolTipBase_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, toolTipBase_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::ToolTipText, toolTipText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::ToolTipText, toolTipText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ToolTipText, toolTipText_dis);
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
|
||||
palette.setColor(QPalette::Active, QPalette::PlaceholderText, placeholderText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::PlaceholderText, placeholderText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, placeholderText_dis);
|
||||
#endif
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
#endif // THEMEPALETTE_H
|
|
@ -7,7 +7,8 @@ HEADERS += \
|
|||
$$PWD/loadingdiv.h \
|
||||
$$PWD/radioitembutton.h \
|
||||
$$PWD/switchbutton.h \
|
||||
$$PWD/kylable.h
|
||||
$$PWD/kylable.h \
|
||||
$$PWD/themepalette.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
|
|
Loading…
Reference in New Issue