diff --git a/data/kybackup/kybackup.png b/data/kybackup/kybackup.png index 317c4c4..94df50e 100644 Binary files a/data/kybackup/kybackup.png and b/data/kybackup/kybackup.png differ diff --git a/kybackup/component/circlelabel.cpp b/kybackup/component/circlelabel.cpp index 72282da..9bdce70 100755 --- a/kybackup/component/circlelabel.cpp +++ b/kybackup/component/circlelabel.cpp @@ -75,7 +75,13 @@ void CircleLable::paintEvent(QPaintEvent *event) m_textColor = m_oldTextColor; } } - painter.setBrush(QBrush(m_backgroundColor)); + + // 如果设置的是蓝色,则使用调色板里的高亮色 + if (m_backgroundColor == QColor(COLOR_BLUE)) { + painter.setBrush(QBrush(this->palette().highlight().color())); + } else { + 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); } diff --git a/kybackup/component/linelabel.cpp b/kybackup/component/linelabel.cpp index cd953ea..ea02653 100755 --- a/kybackup/component/linelabel.cpp +++ b/kybackup/component/linelabel.cpp @@ -34,7 +34,12 @@ void LineLabel::paintEvent(QPaintEvent *event) } } QPen pen = painter.pen(); - pen.setColor(m_color); + // 如果设置的是蓝色,则使用调色板里的高亮色 + if (m_color == QColor(COLOR_BLUE)) { + pen.setColor(this->palette().highlight().color()); + } else { + pen.setColor(m_color); + } pen.setWidth(2); painter.setPen(pen); QRect rect = this->rect(); diff --git a/kybackup/component/mylabel.cpp b/kybackup/component/mylabel.cpp index 2f1c95f..b93e101 100755 --- a/kybackup/component/mylabel.cpp +++ b/kybackup/component/mylabel.cpp @@ -3,6 +3,7 @@ #include #include #include +#include "../../common/mydefine.h" #include "../globalbackupinfo.h" #include "../gsettingswrapper.h" @@ -125,9 +126,21 @@ void MyLabel::setFontColor(QColor color) } else { m_bAutoTheme = true; } + m_fontColor = color; QPalette palette = this->palette(); - palette.setColor(QPalette::WindowText, color); + 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); + } this->setPalette(palette); } diff --git a/kybackup/component/mylabel.h b/kybackup/component/mylabel.h index ff6c66f..e7836d1 100755 --- a/kybackup/component/mylabel.h +++ b/kybackup/component/mylabel.h @@ -3,6 +3,7 @@ #include #include +#include class MyLabel : public QLabel { @@ -32,6 +33,7 @@ private: bool m_isOriginal = false; bool m_needResize = false; QRect m_rect; + QColor m_fontColor; // 背景及字体颜色是否自动跟随主题 bool m_bAutoTheme; diff --git a/kybackup/component/ringsprogressbar.cpp b/kybackup/component/ringsprogressbar.cpp index 78d1148..15be50b 100755 --- a/kybackup/component/ringsprogressbar.cpp +++ b/kybackup/component/ringsprogressbar.cpp @@ -33,7 +33,6 @@ void RingsProgressbar::paintEvent(QPaintEvent *) else p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE))); p.drawEllipse(outRect); - p.setBrush(QBrush(QColor(COLOR_BLUE))); //画遮罩 p.setPen(Qt::NoPen); @@ -45,7 +44,8 @@ void RingsProgressbar::paintEvent(QPaintEvent *) //画圆弧 pen.setCapStyle(Qt::RoundCap); - pen.setColor(QColor(COLOR_BLUE)); + // pen.setColor(QColor(COLOR_BLUE)); + pen.setColor(this->palette().highlight().color()); qreal penWidth = 5; pen.setWidthF(penWidth); p.setPen(pen); @@ -57,15 +57,15 @@ void RingsProgressbar::paintEvent(QPaintEvent *) p.save(); QPainterPath path; 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(); - QColor color(QColor(COLOR_BLUE)); + QColor color(this->palette().highlight().color()); color.setAlphaF(0.5); p.setPen(color); p.setBrush(QBrush(QColor(Qt::white))); p.drawEllipse(currentPosition, 6, 6); 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.restore(); @@ -74,7 +74,7 @@ void RingsProgressbar::paintEvent(QPaintEvent *) f.setBold(true); f.setPixelSize(25); p.setFont(f); - p.setPen(QColor(COLOR_BLUE)); + p.setPen(this->palette().highlight().color()); p.drawText(inRect, Qt::AlignCenter, valueStr); p.restore(); diff --git a/kybackup/globalsignals.h b/kybackup/globalsignals.h index a23368c..1857131 100755 --- a/kybackup/globalsignals.h +++ b/kybackup/globalsignals.h @@ -25,6 +25,9 @@ signals: // 字体(家族或大小)变化 void fontChanged(int fontSize); + + // 强调色变化 + void themeColorChanged(); }; #endif // GLOBALSIGNALS_H diff --git a/kybackup/gsettingswrapper.cpp b/kybackup/gsettingswrapper.cpp index 2894280..ae55f2e 100755 --- a/kybackup/gsettingswrapper.cpp +++ b/kybackup/gsettingswrapper.cpp @@ -43,6 +43,9 @@ GSettingsWrapper::GSettingsWrapper(token) // 字体大小或字体类型发生变化 int fontSize = m_pGsettingThemeData->get("system-font-size").toInt(); emit GlobelBackupInfo::inst().getGlobalSignals()->fontChanged(fontSize); + } else if (key == COLOR_QT_KEY) { + // 强调色变化 + emit GlobelBackupInfo::inst().getGlobalSignals()->themeIconChanged(); } }); } diff --git a/kybackup/gsettingswrapper.h b/kybackup/gsettingswrapper.h index bb6c493..7adb8b1 100755 --- a/kybackup/gsettingswrapper.h +++ b/kybackup/gsettingswrapper.h @@ -19,6 +19,7 @@ class QWidget; #define STYLE_NAME_VALUE_WHITE "ukui-white" #define ICON_THEME_NAME "iconThemeName" #define TRANSPARENCY_NAME "transparency" +#define COLOR_QT_KEY "theme-color" // 颜色 // 浅灰 diff --git a/kybackup/maindialog.cpp b/kybackup/maindialog.cpp index acd3c6a..c492b3a 100755 --- a/kybackup/maindialog.cpp +++ b/kybackup/maindialog.cpp @@ -34,9 +34,9 @@ MainDialog::MainDialog(QWidget *parent) // 使得窗口无边框 // 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); // 添加窗管协议 diff --git a/kybackup/module/databackup.cpp b/kybackup/module/databackup.cpp index 1d6749c..4b837cc 100755 --- a/kybackup/module/databackup.cpp +++ b/kybackup/module/databackup.cpp @@ -202,7 +202,7 @@ void DataBackup::initFirstWidget() backupPointManage->setFlat(true); backupPointManage->setProperty("useButtonPalette", true); 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()); backupPointManage->setPalette(pal); bottomHBoxLayout->addWidget(backupPointManage); @@ -223,6 +223,14 @@ void DataBackup::initFirstWidget() Q_UNUSED(isDark) // 深浅主题切换时,因为调色板已经更换,高亮等颜色已经改变,所以要重新加载图标。 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()); backupPointManage->setPalette(pal); }); diff --git a/kybackup/module/managebackuppointlist.cpp b/kybackup/module/managebackuppointlist.cpp index d14b841..064e7dc 100755 --- a/kybackup/module/managebackuppointlist.cpp +++ b/kybackup/module/managebackuppointlist.cpp @@ -119,8 +119,8 @@ void ManageBackupPointList::insertLines(const QListpalette()); + 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()); backupPointManage->setPalette(pal); }); diff --git a/kybackup/qt_zh_CN.ts b/kybackup/qt_zh_CN.ts index 6886040..21ab53f 100755 --- a/kybackup/qt_zh_CN.ts +++ b/kybackup/qt_zh_CN.ts @@ -37,7 +37,7 @@ File drag and drop area - 拖放文件夹识别路径 + 拖放文件或文件夹识别路径 diff --git a/kybackup/resource/language/qt_zh_CN.qm b/kybackup/resource/language/qt_zh_CN.qm index 009b799..d3c1ec6 100644 Binary files a/kybackup/resource/language/qt_zh_CN.qm and b/kybackup/resource/language/qt_zh_CN.qm differ