diff --git a/control/navbutton/iconhelper.cpp b/control/navbutton/iconhelper.cpp index 26c85e2..d12c99b 100644 --- a/control/navbutton/iconhelper.cpp +++ b/control/navbutton/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,12 +17,20 @@ 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"); } } } +void IconHelper::setIconFontIndex(int index) +{ + iconFontIndex = index; +} + QFont IconHelper::getIconFontAliBaBa() { initFont(); @@ -34,6 +43,12 @@ QFont IconHelper::getIconFontAwesome() return iconFontAwesome->getIconFont(); } +QFont IconHelper::getIconFontAwesome6() +{ + initFont(); + return iconFontAwesome6->getIconFont(); +} + QFont IconHelper::getIconFontWeather() { initFont(); @@ -48,6 +63,7 @@ IconHelper *IconHelper::getIconHelper(int icon) //没指定则自动根据不同的字体的值选择对应的类 //由于部分值范围冲突所以可以指定索引来取 //fontawesome 0xf000-0xf2e0 + //fontawesome6 0xe000-0xe33d 0xf000-0xf8ff //iconfont 0xe501-0xe793 0xe8d5-0xea5d //weather 0xe900-0xe9cf @@ -61,6 +77,8 @@ IconHelper *IconHelper::getIconHelper(int icon) } else if (iconFontIndex == 1) { iconHelper = iconFontAwesome; } else if (iconFontIndex == 2) { + iconHelper = iconFontAwesome6; + } else if (iconFontIndex == 3) { iconHelper = iconFontWeather; } @@ -115,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) { diff --git a/control/navbutton/iconhelper.h b/control/navbutton/iconhelper.h index eb8e850..4a3b5d9 100644 --- a/control/navbutton/iconhelper.h +++ b/control/navbutton/iconhelper.h @@ -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,21 +102,16 @@ public: } }; - //阿里巴巴图形字体类 - static IconHelper *iconFontAliBaBa; - //FontAwesome图形字体类 - static IconHelper *iconFontAwesome; - //天气图形字体类 - static IconHelper *iconFontWeather; - //图形字体索引 - static int iconFontIndex; //初始化图形字体 static void initFont(); + //设置引用图形字体文件索引 + static void setIconFontIndex(int index); //获取图形字体 static QFont getIconFontAliBaBa(); static QFont getIconFontAwesome(); + static QFont getIconFontAwesome6(); static QFont getIconFontWeather(); //根据值获取图形字体类 diff --git a/third/qcustomplotdemo/frmcustom/iconhelper.cpp b/third/qcustomplotdemo/frmcustom/iconhelper.cpp index 26c85e2..d12c99b 100644 --- a/third/qcustomplotdemo/frmcustom/iconhelper.cpp +++ b/third/qcustomplotdemo/frmcustom/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,12 +17,20 @@ 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"); } } } +void IconHelper::setIconFontIndex(int index) +{ + iconFontIndex = index; +} + QFont IconHelper::getIconFontAliBaBa() { initFont(); @@ -34,6 +43,12 @@ QFont IconHelper::getIconFontAwesome() return iconFontAwesome->getIconFont(); } +QFont IconHelper::getIconFontAwesome6() +{ + initFont(); + return iconFontAwesome6->getIconFont(); +} + QFont IconHelper::getIconFontWeather() { initFont(); @@ -48,6 +63,7 @@ IconHelper *IconHelper::getIconHelper(int icon) //没指定则自动根据不同的字体的值选择对应的类 //由于部分值范围冲突所以可以指定索引来取 //fontawesome 0xf000-0xf2e0 + //fontawesome6 0xe000-0xe33d 0xf000-0xf8ff //iconfont 0xe501-0xe793 0xe8d5-0xea5d //weather 0xe900-0xe9cf @@ -61,6 +77,8 @@ IconHelper *IconHelper::getIconHelper(int icon) } else if (iconFontIndex == 1) { iconHelper = iconFontAwesome; } else if (iconFontIndex == 2) { + iconHelper = iconFontAwesome6; + } else if (iconFontIndex == 3) { iconHelper = iconFontWeather; } @@ -115,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) { diff --git a/third/qcustomplotdemo/frmcustom/iconhelper.h b/third/qcustomplotdemo/frmcustom/iconhelper.h index eb8e850..4a3b5d9 100644 --- a/third/qcustomplotdemo/frmcustom/iconhelper.h +++ b/third/qcustomplotdemo/frmcustom/iconhelper.h @@ -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,21 +102,16 @@ public: } }; - //阿里巴巴图形字体类 - static IconHelper *iconFontAliBaBa; - //FontAwesome图形字体类 - static IconHelper *iconFontAwesome; - //天气图形字体类 - static IconHelper *iconFontWeather; - //图形字体索引 - static int iconFontIndex; //初始化图形字体 static void initFont(); + //设置引用图形字体文件索引 + static void setIconFontIndex(int index); //获取图形字体 static QFont getIconFontAliBaBa(); static QFont getIconFontAwesome(); + static QFont getIconFontAwesome6(); static QFont getIconFontWeather(); //根据值获取图形字体类 diff --git a/tool/moneytool/widget.cpp b/tool/moneytool/widget.cpp index 2194eea..e86d453 100644 --- a/tool/moneytool/widget.cpp +++ b/tool/moneytool/widget.cpp @@ -47,5 +47,21 @@ void Widget::on_btnOk_clicked() } //计算下来3年期定期存款30年总金额翻2番到最初本金3倍 100W本金3年期自动续期30年=321W - ui->txtMoneyAll->setText(QString::number(moneyAll)); + QString value = QString::number(moneyAll); + ui->txtMoneyAll->setText(value); + + //拷贝到其他地方 + if (ui->rbtn1->isChecked()) { + ui->txtValue1->setText(value); + } else { + ui->txtValue2->setText(value); + } + + //计算两种存款方式的差额 比如1年期存3年和3年期存3年 + QString value1 = ui->txtValue1->text().trimmed(); + QString value2 = ui->txtValue2->text().trimmed(); + if (!value1.isEmpty() && !value2.isEmpty()) { + int value = qAbs(value1.toInt() - value2.toInt()); + ui->txtValue->setText(QString::number(value)); + } } diff --git a/tool/moneytool/widget.ui b/tool/moneytool/widget.ui index 9fe738a..7689c28 100644 --- a/tool/moneytool/widget.ui +++ b/tool/moneytool/widget.ui @@ -13,138 +13,228 @@ 存款计算器 - - - - 10 - 10 - 431 - 86 - - - - - - - 年限 + + + + + + 600 + 16777215 + + + + + 0 - - - - - - 本金 + + 0 - - - - - - 0.04125 + + 0 - - - - - - 1000000 + + 0 - - - - - - 利率 - - - - - - - 期限 - - - - - - - 方式 - - - - - - - 1 - - - - 单利 - + + - - - 复利 - + + + + 期限 + + - - - - - - 1 - - - - 1年 - + + + + 利率 + + - - - 3年 - + + + + 1 + + + + 单利 + + + + + 复利 + + + - - - 5年 - + + - - - - - - 30 - - - - - - - - - - 总计 - - - - - - - - 0 - 0 - - - - 计算 - - - - - + + + + 1000000 + + + + + + + + 0 + 0 + + + + 计算 + + + + + + + + + + 本金 + + + + + + + 1 + + + + 1年 + + + + + 3年 + + + + + 5年 + + + + + + + + 年限 + + + + + + + 方式 + + + + + + + 总计2 + + + + + + + + + + 0.04125 + + + + + + + 总计1 + + + true + + + + + + + 总计 + + + + + + + 总计差额 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 30 + + + + + + + + + + Qt::Horizontal + + + + 19 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 489 + + + + + + + txtMoneyCurrent + txtRate + cboxYear + txtYears + cboxType + txtMoneyAll + btnOk + rbtn1 + txtValue1 + rbtn2 + txtValue2 + txtValue + diff --git a/ui/core_common/iconhelper.cpp b/ui/core_common/iconhelper.cpp index 26c85e2..d12c99b 100644 --- a/ui/core_common/iconhelper.cpp +++ b/ui/core_common/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,12 +17,20 @@ 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"); } } } +void IconHelper::setIconFontIndex(int index) +{ + iconFontIndex = index; +} + QFont IconHelper::getIconFontAliBaBa() { initFont(); @@ -34,6 +43,12 @@ QFont IconHelper::getIconFontAwesome() return iconFontAwesome->getIconFont(); } +QFont IconHelper::getIconFontAwesome6() +{ + initFont(); + return iconFontAwesome6->getIconFont(); +} + QFont IconHelper::getIconFontWeather() { initFont(); @@ -48,6 +63,7 @@ IconHelper *IconHelper::getIconHelper(int icon) //没指定则自动根据不同的字体的值选择对应的类 //由于部分值范围冲突所以可以指定索引来取 //fontawesome 0xf000-0xf2e0 + //fontawesome6 0xe000-0xe33d 0xf000-0xf8ff //iconfont 0xe501-0xe793 0xe8d5-0xea5d //weather 0xe900-0xe9cf @@ -61,6 +77,8 @@ IconHelper *IconHelper::getIconHelper(int icon) } else if (iconFontIndex == 1) { iconHelper = iconFontAwesome; } else if (iconFontIndex == 2) { + iconHelper = iconFontAwesome6; + } else if (iconFontIndex == 3) { iconHelper = iconFontWeather; } @@ -115,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) { diff --git a/ui/core_common/iconhelper.h b/ui/core_common/iconhelper.h index eb8e850..4a3b5d9 100644 --- a/ui/core_common/iconhelper.h +++ b/ui/core_common/iconhelper.h @@ -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,21 +102,16 @@ public: } }; - //阿里巴巴图形字体类 - static IconHelper *iconFontAliBaBa; - //FontAwesome图形字体类 - static IconHelper *iconFontAwesome; - //天气图形字体类 - static IconHelper *iconFontWeather; - //图形字体索引 - static int iconFontIndex; //初始化图形字体 static void initFont(); + //设置引用图形字体文件索引 + static void setIconFontIndex(int index); //获取图形字体 static QFont getIconFontAliBaBa(); static QFont getIconFontAwesome(); + static QFont getIconFontAwesome6(); static QFont getIconFontWeather(); //根据值获取图形字体类 diff --git a/ui/iconhelper/font/fa-regular-400.ttf b/ui/iconhelper/font/fa-regular-400.ttf new file mode 100644 index 0000000..4eeca8d Binary files /dev/null and b/ui/iconhelper/font/fa-regular-400.ttf differ diff --git a/ui/iconhelper/frmiconhelper.cpp b/ui/iconhelper/frmiconhelper.cpp index c9c8246..654073f 100644 --- a/ui/iconhelper/frmiconhelper.cpp +++ b/ui/iconhelper/frmiconhelper.cpp @@ -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); } //设置字体大小 diff --git a/ui/iconhelper/iconhelper.cpp b/ui/iconhelper/iconhelper.cpp index fdbc86a..d12c99b 100644 --- a/ui/iconhelper/iconhelper.cpp +++ b/ui/iconhelper/iconhelper.cpp @@ -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) { diff --git a/ui/iconhelper/iconhelper.h b/ui/iconhelper/iconhelper.h index 09a6341..4a3b5d9 100644 --- a/ui/iconhelper/iconhelper.h +++ b/ui/iconhelper/iconhelper.h @@ -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(); diff --git a/ui/iconhelper/main.qrc b/ui/iconhelper/main.qrc index 9f303b2..6a90706 100644 --- a/ui/iconhelper/main.qrc +++ b/ui/iconhelper/main.qrc @@ -3,5 +3,6 @@ font/fontawesome-webfont.ttf font/iconfont.ttf font/pe-icon-set-weather.ttf + font/fa-regular-400.ttf