From 80e2f70953ee000038c1236c2db37dd3172aba83 Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Thu, 30 Jun 2022 11:04:26 +0800 Subject: [PATCH] =?UTF-8?q?126419=20=E3=80=90=E5=A4=87=E4=BB=BD=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E5=B7=A5=E5=85=B7=E3=80=91=E7=95=8C=E9=9D=A2=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=9B=BE=E6=A0=87=E4=B8=8E=E8=AE=BE=E8=AE=A1=E7=A8=BF?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kybackup/component/myiconlabel.cpp | 18 +++++++++++++++--- kybackup/component/myiconlabel.h | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/kybackup/component/myiconlabel.cpp b/kybackup/component/myiconlabel.cpp index 5ec2793..1c80b9e 100755 --- a/kybackup/component/myiconlabel.cpp +++ b/kybackup/component/myiconlabel.cpp @@ -2,11 +2,16 @@ #include #include #include +#include "../globalsignals.h" +#include "../globalbackupinfo.h" +#include "../gsettingswrapper.h" +#include "imageutil.h" MyIconLabel::MyIconLabel(QWidget *parent /*= nullptr*/) : QLabel(parent) { m_iconLabel = new CircleLable("", this, 36); + m_iconSize = 16; // border:1px solid black; // const QString greySheetStyle = "min-width: 36px; min-height: 36px;max-width:36px; max-height: 36px;border-radius: 18px; background:grey"; // const QString greySheetStyle = "min-width: 36px; min-height: 36px;max-width:36px; max-height: 36px;border-radius: 18px; background:#F4F4F4"; @@ -27,18 +32,25 @@ MyIconLabel::MyIconLabel(QWidget *parent /*= nullptr*/) : hLayout->addWidget(m_textLabel); hLayout->addStretch(); setLayout(hLayout); + + connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](){ + this->setThemeIcon(this->m_themeIconName, this->m_defaultIconName, this->m_iconSize); + }); } MyIconLabel::~MyIconLabel() {} -void MyIconLabel::setThemeIcon(const QString &themeIconName, const QString &defaultIconName) +void MyIconLabel::setThemeIcon(const QString &themeIconName, const QString &defaultIconName, int size) { m_themeIconName = themeIconName; m_defaultIconName = defaultIconName; + m_iconSize = size; - QIcon icon = QIcon::fromTheme(themeIconName, QIcon(defaultIconName)); - m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(16, 16)))); + if (g_GSettingWrapper.isDarkTheme()) + m_iconLabel->setPixmap(ImageUtil::loadTheme(this->m_themeIconName, this->m_defaultIconName, "white", m_iconSize)); + else + m_iconLabel->setPixmap(ImageUtil::loadTheme(this->m_themeIconName, this->m_defaultIconName, "default", m_iconSize)); } void MyIconLabel::setDesplayText(const QString &text) diff --git a/kybackup/component/myiconlabel.h b/kybackup/component/myiconlabel.h index 5738f1f..0f24d00 100755 --- a/kybackup/component/myiconlabel.h +++ b/kybackup/component/myiconlabel.h @@ -10,7 +10,7 @@ public: explicit MyIconLabel(QWidget *parent = nullptr); virtual ~MyIconLabel(); - void setThemeIcon(const QString &themeIconName, const QString &defaultIconName = ""); + void setThemeIcon(const QString &themeIconName, const QString &defaultIconName = "", int size = 16); void setDesplayText(const QString &text); @@ -23,6 +23,7 @@ private: QString m_themeIconName; QString m_defaultIconName; QString m_originalText; + int m_iconSize; }; #endif // MYICONLABEL_H