diff --git a/ui/iconhelper/frmiconhelper.cpp b/ui/iconhelper/frmiconhelper.cpp index 11e5de0..0c488d1 100644 --- a/ui/iconhelper/frmiconhelper.cpp +++ b/ui/iconhelper/frmiconhelper.cpp @@ -28,8 +28,10 @@ bool frmIconHelper::eventFilter(QObject *watched, QEvent *event) QLabel *lab = (QLabel *)watched; if (lab != 0) { //由于有图形字体的范围值冲突需要手动切换索引 - if (ui->rbtnFontWeather->isChecked()) { + if (ui->rbtnFontAwesome6->isChecked()) { IconHelper::iconFontIndex = 2; + } else if (ui->rbtnFontWeather->isChecked()) { + IconHelper::iconFontIndex = 3; } else { IconHelper::iconFontIndex = -1; } @@ -54,6 +56,8 @@ bool frmIconHelper::eventFilter(QObject *watched, QEvent *event) QFont font = IconHelper::getIconFontAwesome(); if (ui->rbtnFontAliBaBa->isChecked()) { font = IconHelper::getIconFontAliBaBa(); + } else if (ui->rbtnFontAwesome6->isChecked()) { + font = IconHelper::getIconFontAwesome6(); } else if (ui->rbtnFontWeather->isChecked()) { font = IconHelper::getIconFontWeather(); } @@ -99,9 +103,10 @@ void frmIconHelper::initForm() ui->btnImage->setIcon(QIcon(pix)); //关联单选框切换 - connect(ui->rbtnFontAliBaBa, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); - connect(ui->rbtnFontAwesome, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); - connect(ui->rbtnFontWeather, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + QList rbtns = ui->widgetRight->findChildren(); + foreach (QRadioButton *rbtn, rbtns) { + connect(rbtn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + } ui->tabWidget->setCurrentIndex(0); } @@ -121,11 +126,16 @@ void frmIconHelper::initPanel() start = 0xe500; end = 0xea5d; iconFont = IconHelper::getIconFontAliBaBa(); + } else if (ui->rbtnFontAwesome6->isChecked()) { + start = 0xe000; + end = 0xf8ff; + iconFont = IconHelper::getIconFontAwesome6(); + IconHelper::iconFontIndex = 2; } else if (ui->rbtnFontWeather->isChecked()) { start = 0xe900; end = 0xe9cf; iconFont = IconHelper::getIconFontWeather(); - IconHelper::iconFontIndex = 2; + IconHelper::iconFontIndex = 3; } //设置字体大小 @@ -134,11 +144,15 @@ void frmIconHelper::initPanel() //加载图形字体面板 QStringList list; for (int icon = start; icon <= end; icon++) { - //阿里巴巴图形字体中间有一段是空的,可以自行屏蔽下面这段代码查看这段空的值对应的文字 + //中间有一段是空的,可以自行屏蔽下面这段代码查看这段空的值对应的文字 if (ui->rbtnFontAliBaBa->isChecked()) { if (icon >= 0xe76c && icon <= 0xe8f8) { continue; } + } else if (ui->rbtnFontAwesome6->isChecked()) { + if (icon >= 0xe33d && icon <= 0xefff) { + continue; + } } QString tip = "0x" + QString::number(icon, 16); diff --git a/ui/iconhelper/frmiconhelper.ui b/ui/iconhelper/frmiconhelper.ui index b55afa7..4fbf880 100644 --- a/ui/iconhelper/frmiconhelper.ui +++ b/ui/iconhelper/frmiconhelper.ui @@ -743,7 +743,7 @@ - + 130 @@ -773,6 +773,13 @@ + + + + FontAwesome6 + + + diff --git a/ui/iconhelper/iconhelper.cpp b/ui/iconhelper/iconhelper.cpp index 26c85e2..fdbc86a 100644 --- a/ui/iconhelper/iconhelper.cpp +++ b/ui/iconhelper/iconhelper.cpp @@ -2,6 +2,7 @@ IconHelper *IconHelper::iconFontAliBaBa = 0; IconHelper *IconHelper::iconFontAwesome = 0; +IconHelper *IconHelper::iconFontAwesome6 = 0; IconHelper *IconHelper::iconFontWeather = 0; int IconHelper::iconFontIndex = -1; @@ -16,6 +17,9 @@ void IconHelper::initFont() if (iconFontAwesome == 0) { iconFontAwesome = new IconHelper(":/font/fontawesome-webfont.ttf", "FontAwesome"); } + if (iconFontAwesome6 == 0) { + iconFontAwesome6 = new IconHelper(":/font/fa-regular-400.ttf", "Font Awesome 6 Pro Regular"); + } if (iconFontWeather == 0) { iconFontWeather = new IconHelper(":/font/pe-icon-set-weather.ttf", "pe-icon-set-weather"); } @@ -34,6 +38,12 @@ QFont IconHelper::getIconFontAwesome() return iconFontAwesome->getIconFont(); } +QFont IconHelper::getIconFontAwesome6() +{ + initFont(); + return iconFontAwesome6->getIconFont(); +} + QFont IconHelper::getIconFontWeather() { initFont(); @@ -48,6 +58,7 @@ IconHelper *IconHelper::getIconHelper(int icon) //没指定则自动根据不同的字体的值选择对应的类 //由于部分值范围冲突所以可以指定索引来取 //fontawesome 0xf000-0xf2e0 + //fontawesome6 0xe000-0xe33d 0xf000-0xf8ff //iconfont 0xe501-0xe793 0xe8d5-0xea5d //weather 0xe900-0xe9cf @@ -61,6 +72,8 @@ IconHelper *IconHelper::getIconHelper(int icon) } else if (iconFontIndex == 1) { iconHelper = iconFontAwesome; } else if (iconFontIndex == 2) { + iconHelper = iconFontAwesome6; + } else if (iconFontIndex == 3) { iconHelper = iconFontWeather; } diff --git a/ui/iconhelper/iconhelper.h b/ui/iconhelper/iconhelper.h index eb8e850..09a6341 100644 --- a/ui/iconhelper/iconhelper.h +++ b/ui/iconhelper/iconhelper.h @@ -94,6 +94,8 @@ public: static IconHelper *iconFontAliBaBa; //FontAwesome图形字体类 static IconHelper *iconFontAwesome; + //FontAwesome6图形字体类 + static IconHelper *iconFontAwesome6; //天气图形字体类 static IconHelper *iconFontWeather; //图形字体索引 @@ -105,6 +107,7 @@ public: //获取图形字体 static QFont getIconFontAliBaBa(); static QFont getIconFontAwesome(); + static QFont getIconFontAwesome6(); static QFont getIconFontWeather(); //根据值获取图形字体类