问题修复
This commit is contained in:
parent
23022b2406
commit
da8f318c1c
|
@ -48,6 +48,7 @@
|
|||
#define PID_STRING_LEN 1024
|
||||
|
||||
#define COLOR_BLUE "#3790FA"
|
||||
#define COLOR_BLUE_DARK "#3B4251"
|
||||
#define COLOR_GRAY "#CCCCCC"
|
||||
#define COLOR_YELLOW "#F8A34C"
|
||||
#define COLOR_LIGHT_BLUE "#DDEBFF"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "component/mypushbutton.h"
|
||||
#include "../common/utils.h"
|
||||
#include "globalbackupinfo.h"
|
||||
#include "gsettingswrapper.h"
|
||||
|
||||
BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLocal) :
|
||||
QDialog(parent),
|
||||
|
@ -21,12 +22,7 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
|
|||
// this->setWindowFlags(this->windowFlags() & ~Qt::WindowMinMaxButtonsHint);
|
||||
|
||||
this->setMinimumSize(QSize(800, 368));
|
||||
|
||||
// 设置背景色
|
||||
this->setAutoFillBackground(true);
|
||||
QPalette palette = this->palette();
|
||||
palette.setColor(QPalette::Window, palette.color(QPalette::Base));
|
||||
this->setPalette(palette);
|
||||
|
||||
// 纵向布局
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
|
@ -87,8 +83,22 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
|
|||
// 表格中的布局
|
||||
// 列表为空时展示图片
|
||||
m_labelEmpty = new QLabel(m_tableWidget);
|
||||
QPixmap pixmap(":/images/empty.png");
|
||||
m_labelEmpty->setPixmap(pixmap);
|
||||
if (g_GSettingWrapper.isDarkTheme()) {
|
||||
QPixmap pixmap(":/images/empty_dark.svg");
|
||||
m_labelEmpty->setPixmap(pixmap);
|
||||
} else {
|
||||
QPixmap pixmap(":/images/empty.svg");
|
||||
m_labelEmpty->setPixmap(pixmap);
|
||||
}
|
||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
if (isDark) {
|
||||
QPixmap pixmap(":/images/empty_dark.svg");
|
||||
m_labelEmpty->setPixmap(pixmap);
|
||||
} else {
|
||||
QPixmap pixmap(":/images/empty.svg");
|
||||
m_labelEmpty->setPixmap(pixmap);
|
||||
}
|
||||
});
|
||||
m_labelEmptyText = new QLabel(tr("No Backup"));
|
||||
m_labelEmptyText->setEnabled(false);
|
||||
m_labelEmpty->setVisible(false);
|
||||
|
@ -190,3 +200,12 @@ QString BackupPointListDialog::text(int row, int column)
|
|||
return "";
|
||||
}
|
||||
|
||||
void BackupPointListDialog::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette palette = this->palette();
|
||||
palette.setColor(QPalette::Window, palette.color(QPalette::Base));
|
||||
this->setPalette(palette);
|
||||
QDialog::paintEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
void setIsOnlyShowLocal(bool onlyShowLocal) { m_onlyShowLocal = onlyShowLocal; }
|
||||
bool isOnlyShowLocal() const { return m_onlyShowLocal; }
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
signals:
|
||||
void udiskChange();
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
CircleLable::CircleLable(const QString& text, QWidget* parent /*= nullptr*/, int size /*= 24*/, QColor backgroundColor /*= QColor(0xCC, 0xCC, 0xCC)*/) :
|
||||
QLabel(parent),
|
||||
m_text(text),
|
||||
m_backgroundColor(backgroundColor),
|
||||
m_bAutoTheme(false)
|
||||
m_textColor(Qt::white)
|
||||
{
|
||||
this->setFixedSize(QSize(size, size));
|
||||
setBackgroundColor(backgroundColor);
|
||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
if (m_bAutoTheme) {
|
||||
if (!m_bAutoTheme) {
|
||||
if (isDark) {
|
||||
this->setBackgroundColor(Qt::white);
|
||||
} else {
|
||||
|
@ -32,19 +32,19 @@ CircleLable::~CircleLable()
|
|||
*/
|
||||
void CircleLable::setBackgroundColor(QColor backgroundColor)
|
||||
{
|
||||
// 只有黑白两色跟随主题
|
||||
// 只有黑白两色不自动跟随主题,需手动设置背景色
|
||||
if (backgroundColor == QColor(Qt::black)) {
|
||||
m_bAutoTheme = true;
|
||||
m_bAutoTheme = false;
|
||||
if (g_GSettingWrapper.isDarkTheme()) {
|
||||
backgroundColor = QColor(Qt::white);
|
||||
}
|
||||
} else if (backgroundColor == QColor(Qt::white)) {
|
||||
m_bAutoTheme = true;
|
||||
m_bAutoTheme = false;
|
||||
if (!g_GSettingWrapper.isDarkTheme()) {
|
||||
backgroundColor = QColor(Qt::black);
|
||||
}
|
||||
} else {
|
||||
m_bAutoTheme = false;
|
||||
m_bAutoTheme = true;
|
||||
}
|
||||
|
||||
m_backgroundColor = backgroundColor;
|
||||
|
@ -63,13 +63,14 @@ void CircleLable::paintEvent(QPaintEvent *event)
|
|||
} else {
|
||||
painter.setBrush(QBrush(m_backgroundColor));
|
||||
}
|
||||
painter.setPen(Qt::white);
|
||||
painter.setPen(Qt::NoPen);
|
||||
QRect rect = this->rect();
|
||||
// 也可用QPainterPath 绘制代替 painter.drawRoundedRect(rect, 15, 15); { QPainterPath painterPath; painterPath.addRoundedRect(rect, 15, 15); p.drawPath(painterPath); }
|
||||
painter.drawRoundedRect(rect, rect.width()/2, rect.width()/2);
|
||||
|
||||
// drawText
|
||||
rect.setHeight(rect.height() - 2);
|
||||
painter.setPen(m_textColor);
|
||||
painter.drawText(rect, Qt::AlignCenter, m_text);
|
||||
|
||||
QLabel::paintEvent(event);
|
||||
|
|
|
@ -11,7 +11,14 @@ class CircleLable : public QLabel
|
|||
public:
|
||||
CircleLable(const QString& text, QWidget* parent = nullptr, int size = 24, QColor backgroundColor = QColor(0xCC, 0xCC, 0xCC));
|
||||
virtual ~CircleLable();
|
||||
void setText(const QString& text) { m_text = text; }
|
||||
void setText(const QString& text) {
|
||||
m_text = text;
|
||||
repaint();
|
||||
}
|
||||
void setTextColor(QColor color) {
|
||||
m_textColor = color;
|
||||
repaint();
|
||||
}
|
||||
void setBackgroundColor(QColor backgroundColor);
|
||||
|
||||
protected:
|
||||
|
@ -19,8 +26,9 @@ protected:
|
|||
|
||||
private:
|
||||
QString m_text;
|
||||
QColor m_textColor;
|
||||
QColor m_backgroundColor;
|
||||
// 是否跟随主题
|
||||
// 是否自动跟随主题
|
||||
bool m_bAutoTheme;
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QFont>
|
||||
|
||||
#include "../../common/mydefine.h"
|
||||
#include "../gsettingswrapper.h"
|
||||
|
||||
RingsProgressbar::RingsProgressbar(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
|
@ -26,7 +27,10 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
|
|||
//画外圆
|
||||
QPen pen = p.pen();
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE)));
|
||||
if (g_GSettingWrapper.isDarkTheme())
|
||||
p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE)));
|
||||
else
|
||||
p.setBrush(QBrush(palette().button().color()));
|
||||
p.drawEllipse(outRect);
|
||||
p.setBrush(QBrush(QColor(COLOR_BLUE)));
|
||||
|
||||
|
@ -38,7 +42,10 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
|
|||
|
||||
//画遮罩
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(palette().window().color());
|
||||
if (g_GSettingWrapper.isDarkTheme())
|
||||
p.setBrush(QBrush(QColor(COLOR_BLUE_DARK)));
|
||||
else
|
||||
p.setBrush(palette().window().color());
|
||||
p.drawEllipse(inRect);
|
||||
|
||||
//画文字
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <QHeaderView>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include "globalbackupinfo.h"
|
||||
#include "gsettingswrapper.h"
|
||||
|
||||
OperationLog::OperationLog(QWidget *parent) :
|
||||
QStackedWidget(parent)
|
||||
|
@ -30,8 +32,22 @@ void OperationLog::initFirstWidget()
|
|||
// 列表为空时展示图片
|
||||
QHBoxLayout *hlayoutLine1 = new QHBoxLayout;
|
||||
QLabel *labelEmptyLogo = new QLabel(this);
|
||||
QPixmap pixmap(":/images/empty.png");
|
||||
labelEmptyLogo->setPixmap(pixmap);
|
||||
if (g_GSettingWrapper.isDarkTheme()) {
|
||||
QPixmap pixmap(":/images/empty_dark.svg");
|
||||
labelEmptyLogo->setPixmap(pixmap);
|
||||
} else {
|
||||
QPixmap pixmap(":/images/empty.svg");
|
||||
labelEmptyLogo->setPixmap(pixmap);
|
||||
}
|
||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
|
||||
if (isDark) {
|
||||
QPixmap pixmap(":/images/empty_dark.svg");
|
||||
labelEmptyLogo->setPixmap(pixmap);
|
||||
} else {
|
||||
QPixmap pixmap(":/images/empty.svg");
|
||||
labelEmptyLogo->setPixmap(pixmap);
|
||||
}
|
||||
});
|
||||
hlayoutLine1->addStretch();
|
||||
hlayoutLine1->addWidget(labelEmptyLogo);
|
||||
hlayoutLine1->addStretch();
|
||||
|
|
Loading…
Reference in New Issue