更新代码
This commit is contained in:
BIN
ui/iconhelper/font/fa-regular-400.ttf
Normal file
BIN
ui/iconhelper/font/fa-regular-400.ttf
Normal file
Binary file not shown.
@@ -29,11 +29,11 @@ bool frmIconHelper::eventFilter(QObject *watched, QEvent *event)
|
||||
if (lab != 0) {
|
||||
//由于有图形字体的范围值冲突需要手动切换索引
|
||||
if (ui->rbtnFontAwesome6->isChecked()) {
|
||||
IconHelper::iconFontIndex = 2;
|
||||
IconHelper::setIconFontIndex(2);
|
||||
} else if (ui->rbtnFontWeather->isChecked()) {
|
||||
IconHelper::iconFontIndex = 3;
|
||||
IconHelper::setIconFontIndex(3);
|
||||
} else {
|
||||
IconHelper::iconFontIndex = -1;
|
||||
IconHelper::setIconFontIndex(-1);
|
||||
}
|
||||
|
||||
//对应图形字体的16进制值已经赋值给了 toolTip
|
||||
@@ -121,7 +121,8 @@ void frmIconHelper::initPanel()
|
||||
int start = 0xf000;
|
||||
int end = 0xf2e0;
|
||||
QFont iconFont = IconHelper::getIconFontAwesome();
|
||||
IconHelper::iconFontIndex = -1;
|
||||
IconHelper::setIconFontIndex(-1);
|
||||
|
||||
if (ui->rbtnFontAliBaBa->isChecked()) {
|
||||
start = 0xe500;
|
||||
end = 0xea5d;
|
||||
@@ -130,12 +131,12 @@ void frmIconHelper::initPanel()
|
||||
start = 0xe000;
|
||||
end = 0xf8ff;
|
||||
iconFont = IconHelper::getIconFontAwesome6();
|
||||
IconHelper::iconFontIndex = 2;
|
||||
IconHelper::setIconFontIndex(2);
|
||||
} else if (ui->rbtnFontWeather->isChecked()) {
|
||||
start = 0xe900;
|
||||
end = 0xe9cf;
|
||||
iconFont = IconHelper::getIconFontWeather();
|
||||
IconHelper::iconFontIndex = 3;
|
||||
IconHelper::setIconFontIndex(3);
|
||||
}
|
||||
|
||||
//设置字体大小
|
||||
|
||||
@@ -26,6 +26,11 @@ void IconHelper::initFont()
|
||||
}
|
||||
}
|
||||
|
||||
void IconHelper::setIconFontIndex(int index)
|
||||
{
|
||||
iconFontIndex = index;
|
||||
}
|
||||
|
||||
QFont IconHelper::getIconFontAliBaBa()
|
||||
{
|
||||
initFont();
|
||||
@@ -128,7 +133,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
|
||||
{
|
||||
//判断图形字体是否存在,不存在则加入
|
||||
QFontDatabase fontDb;
|
||||
if (!fontDb.families().contains(fontName)) {
|
||||
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
|
||||
int fontId = fontDb.addApplicationFont(fontFile);
|
||||
QStringList listName = fontDb.applicationFontFamilies(fontId);
|
||||
if (listName.count() == 0) {
|
||||
|
||||
@@ -31,6 +31,18 @@ class IconHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
//阿里巴巴图形字体类
|
||||
static IconHelper *iconFontAliBaBa;
|
||||
//FontAwesome图形字体类
|
||||
static IconHelper *iconFontAwesome;
|
||||
//FontAwesome6图形字体类
|
||||
static IconHelper *iconFontAwesome6;
|
||||
//天气图形字体类
|
||||
static IconHelper *iconFontWeather;
|
||||
//图形字体索引
|
||||
static int iconFontIndex;
|
||||
|
||||
public:
|
||||
//样式颜色结构体
|
||||
struct StyleColor {
|
||||
@@ -90,19 +102,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//阿里巴巴图形字体类
|
||||
static IconHelper *iconFontAliBaBa;
|
||||
//FontAwesome图形字体类
|
||||
static IconHelper *iconFontAwesome;
|
||||
//FontAwesome6图形字体类
|
||||
static IconHelper *iconFontAwesome6;
|
||||
//天气图形字体类
|
||||
static IconHelper *iconFontWeather;
|
||||
//图形字体索引
|
||||
static int iconFontIndex;
|
||||
|
||||
//初始化图形字体
|
||||
static void initFont();
|
||||
//设置引用图形字体文件索引
|
||||
static void setIconFontIndex(int index);
|
||||
|
||||
//获取图形字体
|
||||
static QFont getIconFontAliBaBa();
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
<file>font/fontawesome-webfont.ttf</file>
|
||||
<file>font/iconfont.ttf</file>
|
||||
<file>font/pe-icon-set-weather.ttf</file>
|
||||
<file>font/fa-regular-400.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user