65 lines
2.6 KiB
C++
65 lines
2.6 KiB
C++
#ifndef ICONHELPER_H
|
|
#define ICONHELPER_H
|
|
|
|
#include <QtCore>
|
|
#include <QtGui>
|
|
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
|
|
#include <QtWidgets>
|
|
#endif
|
|
|
|
//图形字体处理类
|
|
class IconHelper : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static IconHelper *Instance();
|
|
explicit IconHelper(QObject *parent = 0);
|
|
|
|
void setIcon(QLabel *lab, const QChar &str, quint32 size = 12);
|
|
void setIcon(QAbstractButton *btn, const QChar &str, quint32 size = 12);
|
|
QPixmap getPixmap(const QColor &color, const QChar &str, quint32 size = 12,
|
|
quint32 pixWidth = 15, quint32 pixHeight = 15,
|
|
int flags = Qt::AlignCenter);
|
|
|
|
//根据按钮获取该按钮对应的图标
|
|
QPixmap getPixmap(QToolButton *btn, bool normal);
|
|
|
|
//指定导航面板样式,不带图标
|
|
static void setStyle(QWidget *widget, const QString &type = "left", int borderWidth = 3,
|
|
const QString &borderColor = "#029FEA",
|
|
const QString &normalBgColor = "#292F38",
|
|
const QString &darkBgColor = "#1D2025",
|
|
const QString &normalTextColor = "#54626F",
|
|
const QString &darkTextColor = "#FDFDFD");
|
|
|
|
//指定导航面板样式,带图标和效果切换
|
|
void setStyle(QWidget *widget, QList<QToolButton *> btns, QList<int> pixChar,
|
|
quint32 iconSize = 12, quint32 iconWidth = 15, quint32 iconHeight = 15,
|
|
const QString &type = "left", int borderWidth = 3,
|
|
const QString &borderColor = "#029FEA",
|
|
const QString &normalBgColor = "#292F38",
|
|
const QString &darkBgColor = "#1D2025",
|
|
const QString &normalTextColor = "#54626F",
|
|
const QString &darkTextColor = "#FDFDFD");
|
|
|
|
//指定导航按钮样式,带图标和效果切换
|
|
void setStyle(QFrame *frame, QList<QToolButton *> btns, QList<int> pixChar,
|
|
quint32 iconSize = 12, quint32 iconWidth = 15, quint32 iconHeight = 15,
|
|
const QString &normalBgColor = "#2FC5A2",
|
|
const QString &darkBgColor = "#3EA7E9",
|
|
const QString &normalTextColor = "#EEEEEE",
|
|
const QString &darkTextColor = "#FFFFFF");
|
|
|
|
protected:
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
|
|
|
private:
|
|
static QScopedPointer<IconHelper> self;
|
|
QFont iconFont; //图形字体
|
|
QList<QToolButton *> btns; //按钮队列
|
|
QList<QPixmap> pixNormal; //正常图片队列
|
|
QList<QPixmap> pixDark; //加深图片队列
|
|
};
|
|
#endif // ICONHELPER_H
|