流程图标深浅主题时背景色及字体颜色优化
This commit is contained in:
parent
4379273e99
commit
bd91179b4b
|
@ -47,10 +47,23 @@
|
|||
|
||||
#define PID_STRING_LEN 1024
|
||||
|
||||
// 蓝色
|
||||
#define COLOR_BLUE "#3790FA"
|
||||
// 蓝黑
|
||||
#define COLOR_BLUE_DARK "#3B4251"
|
||||
// 浅灰
|
||||
#define COLOR_LIGHT_DARK "#F4F4F4"
|
||||
// 灰色
|
||||
#define COLOR_GRAY "#CCCCCC"
|
||||
// 深灰
|
||||
#define COLOR_DARK_GRAY "#393A3E"
|
||||
// 黑灰
|
||||
#define COLOR_BLACK_GRAY "#2D2E32"
|
||||
// 字体灰色
|
||||
#define COLOR_DISABLE_GRAY "#737373"
|
||||
// 黄色
|
||||
#define COLOR_YELLOW "#F8A34C"
|
||||
// 浅蓝
|
||||
#define COLOR_LIGHT_BLUE "#DDEBFF"
|
||||
|
||||
#define END_LINE "\n"
|
||||
|
|
|
@ -10,7 +10,8 @@ CircleLable::CircleLable(const QString& text, QWidget* parent /*= nullptr*/, int
|
|||
m_text(text),
|
||||
m_textColor(Qt::white)
|
||||
{
|
||||
this->setFixedSize(QSize(size, size));
|
||||
m_oldTextColor = m_textColor;
|
||||
setFixedSize(QSize(size, size));
|
||||
setBackgroundColor(backgroundColor);
|
||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
if (!m_bAutoTheme) {
|
||||
|
@ -56,13 +57,25 @@ void CircleLable::paintEvent(QPaintEvent *event)
|
|||
Q_UNUSED(event)
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
// 如果使用的是默认的灰色,则转换为调色板中的按钮背景色
|
||||
if (m_backgroundColor == QColor(0xCC, 0xCC, 0xCC)) {
|
||||
QColor background = this->palette().color(QPalette::Button);
|
||||
painter.setBrush(QBrush(background));
|
||||
// 深浅主题切换
|
||||
if (g_GSettingWrapper.isDarkTheme()) {
|
||||
if (m_backgroundColor == QColor(COLOR_GRAY)) {
|
||||
m_backgroundColor = QColor(COLOR_BLACK_GRAY);
|
||||
m_textColor = QColor(COLOR_DISABLE_GRAY);
|
||||
} else if (m_backgroundColor == QColor(COLOR_LIGHT_DARK)) {
|
||||
m_backgroundColor = QColor(COLOR_DARK_GRAY);
|
||||
m_textColor = QColor(COLOR_DISABLE_GRAY);
|
||||
}
|
||||
} else {
|
||||
painter.setBrush(QBrush(m_backgroundColor));
|
||||
if (m_backgroundColor == QColor(COLOR_BLACK_GRAY)) {
|
||||
m_backgroundColor = QColor(COLOR_GRAY);
|
||||
m_textColor = m_oldTextColor;
|
||||
} else if (m_backgroundColor == QColor(COLOR_DARK_GRAY)) {
|
||||
m_backgroundColor = QColor(COLOR_LIGHT_DARK);
|
||||
m_textColor = m_oldTextColor;
|
||||
}
|
||||
}
|
||||
painter.setBrush(QBrush(m_backgroundColor));
|
||||
painter.setPen(Qt::NoPen);
|
||||
QRect rect = this->rect();
|
||||
// 也可用QPainterPath 绘制代替 painter.drawRoundedRect(rect, 15, 15); { QPainterPath painterPath; painterPath.addRoundedRect(rect, 15, 15); p.drawPath(painterPath); }
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
#include <QLabel>
|
||||
#include <QPaintEvent>
|
||||
#include <QColor>
|
||||
#include "../../common/mydefine.h"
|
||||
|
||||
class CircleLable : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CircleLable(const QString& text, QWidget* parent = nullptr, int size = 24, QColor backgroundColor = QColor(0xCC, 0xCC, 0xCC));
|
||||
CircleLable(const QString& text, QWidget* parent = nullptr, int size = 24, QColor backgroundColor = QColor(COLOR_GRAY));
|
||||
virtual ~CircleLable();
|
||||
void setText(const QString& text) {
|
||||
m_text = text;
|
||||
|
@ -17,6 +18,7 @@ public:
|
|||
}
|
||||
void setTextColor(QColor color) {
|
||||
m_textColor = color;
|
||||
m_oldTextColor = m_textColor;
|
||||
repaint();
|
||||
}
|
||||
void setBackgroundColor(QColor backgroundColor);
|
||||
|
@ -27,6 +29,7 @@ protected:
|
|||
private:
|
||||
QString m_text;
|
||||
QColor m_textColor;
|
||||
QColor m_oldTextColor;
|
||||
QColor m_backgroundColor;
|
||||
// 是否自动跟随主题
|
||||
bool m_bAutoTheme;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include "linelabel.h"
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include "../globalbackupinfo.h"
|
||||
#include "../gsettingswrapper.h"
|
||||
|
||||
#define LOCAL_COLOR_DARK_GRAY "#2D2E32"
|
||||
|
||||
LineLabel::LineLabel(QWidget* parent /*= nullptr*/, QColor color /*= QColor(0xCC, 0xCC, 0xCC)*/) :
|
||||
QLabel(parent),
|
||||
|
@ -18,15 +22,24 @@ void LineLabel::paintEvent(QPaintEvent *event)
|
|||
Q_UNUSED(event)
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
// 如果使用的是默认的灰色,则转换为调色板中的按钮背景色
|
||||
if (m_color == QColor(0xCC, 0xCC, 0xCC)) {
|
||||
QColor background = this->palette().color(QPalette::Button);
|
||||
painter.setPen(background);
|
||||
painter.save();
|
||||
// 深浅主题切换
|
||||
if (g_GSettingWrapper.isDarkTheme()) {
|
||||
if (m_color == QColor(COLOR_GRAY)) {
|
||||
m_color = QColor(LOCAL_COLOR_DARK_GRAY);
|
||||
}
|
||||
} else {
|
||||
painter.setPen(m_color);
|
||||
if (m_color == QColor(LOCAL_COLOR_DARK_GRAY)) {
|
||||
m_color = QColor(COLOR_GRAY);
|
||||
}
|
||||
}
|
||||
QPen pen = painter.pen();
|
||||
pen.setColor(m_color);
|
||||
pen.setWidth(2);
|
||||
painter.setPen(pen);
|
||||
QRect rect = this->rect();
|
||||
painter.drawLine(0, rect.height()/2, rect.width(), rect.height()/2);
|
||||
|
||||
painter.restore();
|
||||
QLabel::paintEvent(event);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QLabel>
|
||||
#include <QSize>
|
||||
#include <QColor>
|
||||
#include "../../common/mydefine.h"
|
||||
|
||||
/**
|
||||
* @brief 目前仅支持横线
|
||||
|
@ -12,7 +13,7 @@ class LineLabel : public QLabel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LineLabel(QWidget* parent = nullptr, QColor color = QColor(0xCC, 0xCC, 0xCC));
|
||||
LineLabel(QWidget* parent = nullptr, QColor color = QColor(COLOR_GRAY));
|
||||
virtual ~LineLabel();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QIcon>
|
||||
#include <QApplication>
|
||||
#include "circlelabel.h"
|
||||
|
||||
MyIconLabel::MyIconLabel(QWidget *parent /*= nullptr*/) :
|
||||
QLabel(parent)
|
||||
|
@ -13,6 +12,7 @@ MyIconLabel::MyIconLabel(QWidget *parent /*= nullptr*/) :
|
|||
// const QString greySheetStyle = "min-width: 36px; min-height: 36px;max-width:36px; max-height: 36px;border-radius: 18px; background:#F4F4F4";
|
||||
// m_iconLabel->setStyleSheet(greySheetStyle);
|
||||
m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
m_iconLabel->setBackgroundColor(QColor(COLOR_LIGHT_DARK));
|
||||
|
||||
m_textLabel = new QLabel(this);
|
||||
QSizePolicy textLabelPolicy = m_textLabel->sizePolicy();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MYICONLABEL_H
|
||||
#define MYICONLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include "circlelabel.h"
|
||||
|
||||
class MyIconLabel : public QLabel
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public slots:
|
|||
// void changePalette(bool checked);
|
||||
|
||||
private:
|
||||
QLabel *m_iconLabel;
|
||||
CircleLable *m_iconLabel;
|
||||
QLabel *m_textLabel;
|
||||
QString m_themeIconName;
|
||||
QString m_defaultIconName;
|
||||
|
|
|
@ -191,7 +191,7 @@ void DataBackup::initFirstWidget()
|
|||
backupPointManage->setFlat(true);
|
||||
backupPointManage->setProperty("useButtonPalette", true);
|
||||
QPalette pal(backupPointManage->palette());
|
||||
pal.setColor(QPalette::ButtonText, QColor(COLOR_BLUE));
|
||||
pal.setColor(QPalette::ButtonText, this->palette().link().color());
|
||||
pal.setColor(QPalette::Button, this->palette().base().color());
|
||||
backupPointManage->setPalette(pal);
|
||||
bottomHBoxLayout->addWidget(backupPointManage);
|
||||
|
@ -207,13 +207,13 @@ void DataBackup::initFirstWidget()
|
|||
ManageBackupPointList backupManager(first, ManageBackupPointList::DATA);
|
||||
backupManager.exec();
|
||||
});
|
||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
Q_UNUSED(isDark)
|
||||
// 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。
|
||||
QPalette pal(backupPointManage->palette());
|
||||
pal.setColor(QPalette::Button, this->palette().base().color());
|
||||
backupPointManage->setPalette(pal);
|
||||
});
|
||||
// connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
// Q_UNUSED(isDark)
|
||||
// // 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。
|
||||
// QPalette pal(backupPointManage->palette());
|
||||
// pal.setColor(QPalette::Button, this->palette().base().color());
|
||||
// backupPointManage->setPalette(pal);
|
||||
// });
|
||||
|
||||
addWidget(first);
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ void SystemBackup::initFirstWidget()
|
|||
backupPointManage->setFlat(true);
|
||||
backupPointManage->setProperty("useButtonPalette", true);
|
||||
QPalette pal(backupPointManage->palette());
|
||||
pal.setColor(QPalette::ButtonText, QColor(COLOR_BLUE));
|
||||
pal.setColor(QPalette::ButtonText, this->palette().link().color());
|
||||
pal.setColor(QPalette::Button, this->palette().base().color());
|
||||
backupPointManage->setPalette(pal);
|
||||
bottomHBoxLayout->addWidget(backupPointManage);
|
||||
|
@ -157,13 +157,13 @@ void SystemBackup::initFirstWidget()
|
|||
ManageBackupPointList backupManager(first, ManageBackupPointList::SYSTEM);
|
||||
backupManager.exec();
|
||||
});
|
||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
Q_UNUSED(isDark)
|
||||
// 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。
|
||||
QPalette pal(backupPointManage->palette());
|
||||
pal.setColor(QPalette::Button, this->palette().base().color());
|
||||
backupPointManage->setPalette(pal);
|
||||
});
|
||||
// connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
// Q_UNUSED(isDark)
|
||||
// // 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。
|
||||
// QPalette pal(backupPointManage->palette());
|
||||
// pal.setColor(QPalette::Button, this->palette().base().color());
|
||||
// backupPointManage->setPalette(pal);
|
||||
// });
|
||||
|
||||
addWidget(first);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue