File indexing completed on 2025-01-26 05:24:12
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2021 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef KASTEN_ICONLABEL_HPP 0010 #define KASTEN_ICONLABEL_HPP 0011 0012 // Qt 0013 #include <QLabel> 0014 #include <QIcon> 0015 0016 namespace Kasten { 0017 0018 // TODO: fix QLabel to support icons, or rewrite to directly paint the icon ourselves 0019 // still fails to update on icon theme change 0020 class IconLabel : public QLabel 0021 { 0022 Q_OBJECT 0023 0024 public: 0025 explicit IconLabel(QWidget* parent = nullptr); 0026 0027 void setIcon(const QIcon& icon); 0028 0029 protected: 0030 void changeEvent(QEvent* event) override; 0031 0032 private: 0033 void updatePixmap(); 0034 void updateSize(); 0035 QSize iconSize() const; 0036 0037 private: 0038 QIcon mIcon; 0039 }; 0040 0041 } 0042 0043 #endif