125640 【设计】【UKUI攻关】【备份还原】系统备份、数据备份界面的管理备份文字主题高亮不变化

This commit is contained in:
zhaominyong 2022-06-27 11:19:34 +08:00
parent e90cf2a31a
commit c8984cb3ef
15 changed files with 64 additions and 15 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -75,7 +75,13 @@ void CircleLable::paintEvent(QPaintEvent *event)
m_textColor = m_oldTextColor; m_textColor = m_oldTextColor;
} }
} }
// 如果设置的是蓝色,则使用调色板里的高亮色
if (m_backgroundColor == QColor(COLOR_BLUE)) {
painter.setBrush(QBrush(this->palette().highlight().color()));
} else {
painter.setBrush(QBrush(m_backgroundColor)); painter.setBrush(QBrush(m_backgroundColor));
}
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
QRect rect = this->rect(); QRect rect = this->rect();
// 也可用QPainterPath 绘制代替 painter.drawRoundedRect(rect, 15, 15); { QPainterPath painterPath; painterPath.addRoundedRect(rect, 15, 15); p.drawPath(painterPath); } // 也可用QPainterPath 绘制代替 painter.drawRoundedRect(rect, 15, 15); { QPainterPath painterPath; painterPath.addRoundedRect(rect, 15, 15); p.drawPath(painterPath); }

View File

@ -34,7 +34,12 @@ void LineLabel::paintEvent(QPaintEvent *event)
} }
} }
QPen pen = painter.pen(); QPen pen = painter.pen();
// 如果设置的是蓝色,则使用调色板里的高亮色
if (m_color == QColor(COLOR_BLUE)) {
pen.setColor(this->palette().highlight().color());
} else {
pen.setColor(m_color); pen.setColor(m_color);
}
pen.setWidth(2); pen.setWidth(2);
painter.setPen(pen); painter.setPen(pen);
QRect rect = this->rect(); QRect rect = this->rect();

View File

@ -3,6 +3,7 @@
#include <QFont> #include <QFont>
#include <QFontMetrics> #include <QFontMetrics>
#include <QPainter> #include <QPainter>
#include "../../common/mydefine.h"
#include "../globalbackupinfo.h" #include "../globalbackupinfo.h"
#include "../gsettingswrapper.h" #include "../gsettingswrapper.h"
@ -125,9 +126,21 @@ void MyLabel::setFontColor(QColor color)
} else { } else {
m_bAutoTheme = true; m_bAutoTheme = true;
} }
m_fontColor = color;
QPalette palette = this->palette(); QPalette palette = this->palette();
if (m_fontColor == QColor(COLOR_BLUE)) {
palette.setColor(QPalette::WindowText, palette.highlight().color());
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::themeColorChanged, this, [=]() {
// 强调色更换,高亮等颜色已经改变,所以要重新加载图标。
QPalette pal(this->palette());
pal.setColor(QPalette::WindowText, this->palette().highlight().color());
this->setPalette(pal);
});
} else {
palette.setColor(QPalette::WindowText, color); palette.setColor(QPalette::WindowText, color);
}
this->setPalette(palette); this->setPalette(palette);
} }

View File

@ -3,6 +3,7 @@
#include <QLabel> #include <QLabel>
#include <QRect> #include <QRect>
#include <QColor>
class MyLabel : public QLabel class MyLabel : public QLabel
{ {
@ -32,6 +33,7 @@ private:
bool m_isOriginal = false; bool m_isOriginal = false;
bool m_needResize = false; bool m_needResize = false;
QRect m_rect; QRect m_rect;
QColor m_fontColor;
// 背景及字体颜色是否自动跟随主题 // 背景及字体颜色是否自动跟随主题
bool m_bAutoTheme; bool m_bAutoTheme;

View File

@ -33,7 +33,6 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
else else
p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE))); p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE)));
p.drawEllipse(outRect); p.drawEllipse(outRect);
p.setBrush(QBrush(QColor(COLOR_BLUE)));
//画遮罩 //画遮罩
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
@ -45,7 +44,8 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
//画圆弧 //画圆弧
pen.setCapStyle(Qt::RoundCap); pen.setCapStyle(Qt::RoundCap);
pen.setColor(QColor(COLOR_BLUE)); // pen.setColor(QColor(COLOR_BLUE));
pen.setColor(this->palette().highlight().color());
qreal penWidth = 5; qreal penWidth = 5;
pen.setWidthF(penWidth); pen.setWidthF(penWidth);
p.setPen(pen); p.setPen(pen);
@ -57,15 +57,15 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
p.save(); p.save();
QPainterPath path; QPainterPath path;
path.moveTo(inRect.center()); path.moveTo(inRect.center());
path.arcTo(QRectF(5 + penWidth/2 , 5 + penWidth/2, side - 10 - penWidth, side - 10 - penWidth), 90, -m_rotateAngle); path.arcTo(QRectF(5 + penWidth/2 , 5 + penWidth/2, side - 10 - penWidth, side - 10 - penWidth), 90, -1 * m_rotateAngle);
QPointF currentPosition = path.currentPosition(); QPointF currentPosition = path.currentPosition();
QColor color(QColor(COLOR_BLUE)); QColor color(this->palette().highlight().color());
color.setAlphaF(0.5); color.setAlphaF(0.5);
p.setPen(color); p.setPen(color);
p.setBrush(QBrush(QColor(Qt::white))); p.setBrush(QBrush(QColor(Qt::white)));
p.drawEllipse(currentPosition, 6, 6); p.drawEllipse(currentPosition, 6, 6);
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(QBrush(QColor(COLOR_BLUE))); p.setBrush(QBrush(this->palette().highlight().color()));
p.drawEllipse(currentPosition, 3.5, 3.5); p.drawEllipse(currentPosition, 3.5, 3.5);
p.restore(); p.restore();
@ -74,7 +74,7 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
f.setBold(true); f.setBold(true);
f.setPixelSize(25); f.setPixelSize(25);
p.setFont(f); p.setFont(f);
p.setPen(QColor(COLOR_BLUE)); p.setPen(this->palette().highlight().color());
p.drawText(inRect, Qt::AlignCenter, valueStr); p.drawText(inRect, Qt::AlignCenter, valueStr);
p.restore(); p.restore();

View File

@ -25,6 +25,9 @@ signals:
// 字体(家族或大小)变化 // 字体(家族或大小)变化
void fontChanged(int fontSize); void fontChanged(int fontSize);
// 强调色变化
void themeColorChanged();
}; };
#endif // GLOBALSIGNALS_H #endif // GLOBALSIGNALS_H

View File

@ -43,6 +43,9 @@ GSettingsWrapper::GSettingsWrapper(token)
// 字体大小或字体类型发生变化 // 字体大小或字体类型发生变化
int fontSize = m_pGsettingThemeData->get("system-font-size").toInt(); int fontSize = m_pGsettingThemeData->get("system-font-size").toInt();
emit GlobelBackupInfo::inst().getGlobalSignals()->fontChanged(fontSize); emit GlobelBackupInfo::inst().getGlobalSignals()->fontChanged(fontSize);
} else if (key == COLOR_QT_KEY) {
// 强调色变化
emit GlobelBackupInfo::inst().getGlobalSignals()->themeIconChanged();
} }
}); });
} }

View File

@ -19,6 +19,7 @@ class QWidget;
#define STYLE_NAME_VALUE_WHITE "ukui-white" #define STYLE_NAME_VALUE_WHITE "ukui-white"
#define ICON_THEME_NAME "iconThemeName" #define ICON_THEME_NAME "iconThemeName"
#define TRANSPARENCY_NAME "transparency" #define TRANSPARENCY_NAME "transparency"
#define COLOR_QT_KEY "theme-color"
// 颜色 // 颜色
// 浅灰 // 浅灰

View File

@ -34,9 +34,9 @@ MainDialog::MainDialog(QWidget *parent)
// 使得窗口无边框 // 使得窗口无边框
// w.setWindowFlag(Qt::FramelessWindowHint); // w.setWindowFlag(Qt::FramelessWindowHint);
// 指示窗口管理器模糊给定窗口后面指定区域的背景(毛玻璃化背景) // 指示窗口管理器模糊给定窗口后面指定区域的背景(毛玻璃化背景)
KWindowEffects::enableBlurBehind(this->winId(), true); // KWindowEffects::enableBlurBehind(this->winId(), true);
// 或使用设置毛玻璃属性的方式实现毛玻璃背景(两者都行,可使用其一) // 或使用设置毛玻璃属性的方式实现毛玻璃背景(两者都行,可使用其一)
// this->setProperty("useSystemStyleBlur", true); this->setProperty("useSystemStyleBlur", true);
this->setAutoFillBackground(true); this->setAutoFillBackground(true);
// 添加窗管协议 // 添加窗管协议

View File

@ -202,7 +202,7 @@ void DataBackup::initFirstWidget()
backupPointManage->setFlat(true); backupPointManage->setFlat(true);
backupPointManage->setProperty("useButtonPalette", true); backupPointManage->setProperty("useButtonPalette", true);
QPalette pal(backupPointManage->palette()); QPalette pal(backupPointManage->palette());
pal.setColor(QPalette::ButtonText, this->palette().link().color()); pal.setColor(QPalette::ButtonText, this->palette().highlight().color());
pal.setColor(QPalette::Button, this->palette().base().color()); pal.setColor(QPalette::Button, this->palette().base().color());
backupPointManage->setPalette(pal); backupPointManage->setPalette(pal);
bottomHBoxLayout->addWidget(backupPointManage); bottomHBoxLayout->addWidget(backupPointManage);
@ -223,6 +223,14 @@ void DataBackup::initFirstWidget()
Q_UNUSED(isDark) Q_UNUSED(isDark)
// 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。 // 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。
QPalette pal(backupPointManage->palette()); QPalette pal(backupPointManage->palette());
pal.setColor(QPalette::ButtonText, this->palette().highlight().color());
pal.setColor(QPalette::Button, this->palette().base().color());
backupPointManage->setPalette(pal);
});
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::themeColorChanged, this, [=]() {
// 强调色更换,高亮等颜色已经改变,所以要重新加载图标。
QPalette pal(backupPointManage->palette());
pal.setColor(QPalette::ButtonText, this->palette().highlight().color());
pal.setColor(QPalette::Button, this->palette().base().color()); pal.setColor(QPalette::Button, this->palette().base().color());
backupPointManage->setPalette(pal); backupPointManage->setPalette(pal);
}); });

View File

@ -119,8 +119,8 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
} }
//hide factory backup //hide factory backup
if (backupPoint.m_uuid == FACTORY_BACKUP_UUID) // if (backupPoint.m_uuid == FACTORY_BACKUP_UUID)
continue; // continue;
//udisk unique //udisk unique
if (backupPoint.m_path.startsWith(preDevPath)) { if (backupPoint.m_path.startsWith(preDevPath)) {

View File

@ -170,6 +170,14 @@ void SystemBackup::initFirstWidget()
Q_UNUSED(isDark) Q_UNUSED(isDark)
// 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。 // 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。
QPalette pal(backupPointManage->palette()); QPalette pal(backupPointManage->palette());
pal.setColor(QPalette::ButtonText, this->palette().highlight().color());
pal.setColor(QPalette::Button, this->palette().base().color());
backupPointManage->setPalette(pal);
});
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::themeColorChanged, this, [=]() {
// 强调色更换,高亮等颜色已经改变,所以要重新加载图标。
QPalette pal(backupPointManage->palette());
pal.setColor(QPalette::ButtonText, this->palette().highlight().color());
pal.setColor(QPalette::Button, this->palette().base().color()); pal.setColor(QPalette::Button, this->palette().base().color());
backupPointManage->setPalette(pal); backupPointManage->setPalette(pal);
}); });

View File

@ -37,7 +37,7 @@
<message> <message>
<location filename="component/backuplistwidget.cpp" line="103"/> <location filename="component/backuplistwidget.cpp" line="103"/>
<source>File drag and drop area</source> <source>File drag and drop area</source>
<translation></translation> <translation></translation>
</message> </message>
</context> </context>
<context> <context>