mypushbutton自定义控件跟随主题重绘陷入循环,造成备份还原工具占用cpu过高问题修改
This commit is contained in:
parent
00c23c6617
commit
7d8ddfb67a
|
@ -18,13 +18,12 @@ Build-Depends: debhelper (>= 9),
|
|||
libx11-dev,
|
||||
libqt5x11extras5-dev,
|
||||
libgsettings-qt-dev,
|
||||
libqt5svg5-dev,
|
||||
Standards-Version: 3.9.5
|
||||
Homepage: http://kylinos.cn
|
||||
|
||||
Package: yhkylin-backup-tools
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends},${shlibs:Depends},libqt5widgets5,libqt5gui5,libqt5dbus5,libqt5xml5,libqt5core5a,libblkid1,rsync,squashfs-tools, libkysec, libgsettings-qt-dev,libqt5svg5-dev
|
||||
Depends: ${misc:Depends},${shlibs:Depends},libqt5widgets5,libqt5gui5,libqt5dbus5,libqt5xml5,libqt5core5a,libblkid1,rsync,squashfs-tools, libkysec, libgsettings-qt-dev
|
||||
Description: YHkylin backup tools
|
||||
YHkylin backup tools
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QStyleOptionButton>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include "imageutil.h"
|
||||
// #include "imageutil.h"
|
||||
#include "../gsettingswrapper.h"
|
||||
|
||||
MyIconButton::MyIconButton(QWidget *parent) :
|
||||
|
@ -57,27 +57,28 @@ void MyIconButton::changePalette(bool checked)
|
|||
{
|
||||
m_iconButton->setChecked(checked);
|
||||
QPalette pal = m_textLabel->palette();
|
||||
QIcon icon = QIcon::fromTheme(m_themeIconName, QIcon(m_defaultIconName));
|
||||
QPixmap pix;
|
||||
// svg格式的图标会自动跟随主题,不需再手动设置像素颜色
|
||||
// QIcon icon = QIcon::fromTheme(m_themeIconName, QIcon(m_defaultIconName));
|
||||
// QPixmap pix;
|
||||
if (g_GSettingWrapper.isDarkTheme()) {
|
||||
if (checked) {
|
||||
pal.setColor(QPalette::ButtonText, this->palette().highlightedText().color());
|
||||
pix = ImageUtil::loadPixmap(icon, QString("black"));
|
||||
// pix = ImageUtil::loadPixmap(icon, QString("black"));
|
||||
} else {
|
||||
pal.setColor(QPalette::ButtonText, this->palette().windowText().color());
|
||||
pix = ImageUtil::loadPixmap(icon, QString("white"));
|
||||
// pix = ImageUtil::loadPixmap(icon, QString("white"));
|
||||
}
|
||||
} else {
|
||||
if (checked) {
|
||||
pal.setColor(QPalette::ButtonText, this->palette().highlightedText().color());
|
||||
pix = ImageUtil::loadPixmap(icon, QString("white"));
|
||||
// pix = ImageUtil::loadPixmap(icon, QString("white"));
|
||||
} else {
|
||||
pal.setColor(QPalette::ButtonText, this->palette().windowText().color());
|
||||
pix = ImageUtil::loadPixmap(icon, QString("black"));
|
||||
// pix = ImageUtil::loadPixmap(icon, QString("black"));
|
||||
}
|
||||
}
|
||||
m_textLabel->setPalette(pal);
|
||||
m_iconButton->setIcon(pix);
|
||||
//m_iconButton->setIcon(pix);
|
||||
}
|
||||
|
||||
void MyIconButton::paintEvent(QPaintEvent *event)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QIcon>
|
||||
#include <QApplication>
|
||||
#include "imageutil.h"
|
||||
#include "circlelabel.h"
|
||||
|
||||
MyIconLabel::MyIconLabel(QWidget *parent /*= nullptr*/) :
|
||||
|
@ -39,8 +38,7 @@ void MyIconLabel::setThemeIcon(const QString &themeIconName, const QString &defa
|
|||
m_defaultIconName = defaultIconName;
|
||||
|
||||
QIcon icon = QIcon::fromTheme(themeIconName, QIcon(defaultIconName));
|
||||
// m_iconLabel->setPixmap(icon.pixmap(QSize(24,24)));
|
||||
m_iconLabel->setPixmap(ImageUtil::loadPixmap(icon, QString("default")));
|
||||
m_iconLabel->setPixmap(icon.pixmap(QSize(24,24)));
|
||||
}
|
||||
|
||||
void MyIconLabel::setDesplayText(const QString &text)
|
||||
|
@ -56,18 +54,3 @@ void MyIconLabel::setDesplayText(const QString &text)
|
|||
}
|
||||
}
|
||||
|
||||
//void MyIconLabel::changePalette(bool dark)
|
||||
//{
|
||||
// QPalette pal(m_textLabel->palette());
|
||||
// QIcon icon = QIcon::fromTheme(m_themeIconName, QIcon(m_defaultIconName));
|
||||
// QPixmap pix;
|
||||
// if (dark) {
|
||||
// pal.setColor(QPalette::WindowText, pal.color(QPalette::HighlightedText));
|
||||
// pix = ImageUtil::loadPixmap(icon, QString("white"));
|
||||
// } else {
|
||||
// pal.setColor(QPalette::WindowText, this->palette().color(QPalette::WindowText));
|
||||
// pix = ImageUtil::loadPixmap(icon, QString("default"));
|
||||
// }
|
||||
// m_textLabel->setPalette(pal);
|
||||
// m_iconLabel->setPixmap(pix);
|
||||
//}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
QT += core gui svg
|
||||
QT += core gui
|
||||
QT += dbus xml
|
||||
QT += network
|
||||
|
||||
|
@ -42,7 +42,7 @@ HEADERS += \
|
|||
component/circlelabel.h \
|
||||
component/clicklabel.h \
|
||||
component/hoverwidget.h \
|
||||
component/imageutil.h \
|
||||
# component/imageutil.h \
|
||||
component/linelabel.h \
|
||||
component/mycheckbox.h \
|
||||
component/myfileselect.h \
|
||||
|
@ -87,7 +87,7 @@ SOURCES += \
|
|||
component/circlelabel.cpp \
|
||||
component/clicklabel.cpp \
|
||||
component/hoverwidget.cpp \
|
||||
component/imageutil.cpp \
|
||||
# component/imageutil.cpp \
|
||||
component/linelabel.cpp \
|
||||
component/mycheckbox.cpp \
|
||||
component/myfileselect.cpp \
|
||||
|
|
Loading…
Reference in New Issue