新增SpkIconButton为主题和按钮工作减负

This commit is contained in:
RigoLigoRLC
2021-12-05 18:09:31 +08:00
parent 2e04d05b34
commit cefd309097
12 changed files with 171 additions and 18 deletions

30
inc/spkiconbutton.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef SPKICONBUTTON_H
#define SPKICONBUTTON_H
#include <QPushButton>
#include "spkui_general.h"
class SpkIconButton : public QPushButton
{
Q_OBJECT
public:
SpkIconButton(QWidget *parent = nullptr);
~SpkIconButton() {};
void SetIcon(QIcon, QSize);
void SetIcon(QPixmap);
void SetIconSize(QSize);
protected:
void paintEvent(QPaintEvent *) override;
private:
static enum { Dark, Light } sCurrentTheme;
QPixmap mPmapPaintedIcon;
QSize mPmapSize;
static constexpr int IconMargin = 8; // shall we make it changable?
};
#endif // SPKICONBUTTON_H