托盘VPN深浅主题下修改为深色 bug 173999
This commit is contained in:
parent
1e614eb144
commit
5f11a64d8c
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue