更新代码
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
#include "appdata.h"
|
||||
#include "quihelper.h"
|
||||
|
||||
QString AppData::Version = "V20220316";
|
||||
QString AppData::TitleFlag = "(QQ: 517216493 WX: feiyangqingyun)";
|
||||
|
||||
int AppData::RowHeight = 25;
|
||||
int AppData::RightWidth = 180;
|
||||
int AppData::FormWidth = 1200;
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
class AppData
|
||||
{
|
||||
public:
|
||||
static QString Version; //版本号
|
||||
static QString TitleFlag; //标题标识
|
||||
|
||||
static int RowHeight; //行高
|
||||
static int RightWidth; //右侧宽度
|
||||
static int FormWidth; //窗体宽度
|
||||
|
||||
@@ -17,6 +17,8 @@ CONFIG += warn_off
|
||||
CONFIG += resources_big
|
||||
#开启后会将打印信息用控制台输出
|
||||
#CONFIG += console
|
||||
#开启后不会生成空的 debug release 目录
|
||||
#CONFIG -= debug_and_release
|
||||
|
||||
#引入全志H3芯片依赖
|
||||
include ($$PWD/h3.pri)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "quihelper.h"
|
||||
#include "qnetworkinterface.h"
|
||||
#include "qnetworkproxy.h"
|
||||
|
||||
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
|
||||
int QUIHelper::getScreenIndex()
|
||||
@@ -116,11 +117,13 @@ QString QUIHelper::appPath()
|
||||
static QString path;
|
||||
if (path.isEmpty()) {
|
||||
#ifdef Q_OS_ANDROID
|
||||
//path = QString("/sdcard/Android/%1").arg(appName());
|
||||
path = QString("/storage/emulated/0/%1").arg(appName());
|
||||
//默认安卓根目录
|
||||
path = "/storage/emulated/0";
|
||||
//带上程序名称作为目录 前面加个0方便排序
|
||||
path = path + "/0" + appName();
|
||||
#else
|
||||
path = qApp->applicationDirPath();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
return path;
|
||||
@@ -430,6 +433,8 @@ void QUIHelper::initAll(bool utf8, bool style, int fontSize)
|
||||
QUIHelper::setTranslator(":/qm/widgets.qm");
|
||||
QUIHelper::setTranslator(":/qm/qt_zh_CN.qm");
|
||||
QUIHelper::setTranslator(":/qm/designer_zh_CN.qm");
|
||||
//设置不使用本地系统环境代理配置
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
||||
}
|
||||
|
||||
void QUIHelper::initMain(bool on)
|
||||
@@ -679,7 +684,7 @@ QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key)
|
||||
}
|
||||
|
||||
int count = result.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
result[i] = QChar(result.at(i).toLatin1() ^ key);
|
||||
}
|
||||
return result;
|
||||
@@ -689,7 +694,7 @@ uchar QUIHelper::getOrCode(const QByteArray &data)
|
||||
{
|
||||
int len = data.length();
|
||||
uchar result = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
result ^= data.at(i);
|
||||
}
|
||||
|
||||
@@ -700,7 +705,7 @@ uchar QUIHelper::getCheckCode(const QByteArray &data)
|
||||
{
|
||||
int len = data.length();
|
||||
uchar temp = 0;
|
||||
for (uchar i = 0; i < len; i++) {
|
||||
for (uchar i = 0; i < len; ++i) {
|
||||
temp += data.at(i);
|
||||
}
|
||||
|
||||
@@ -758,7 +763,7 @@ void QUIHelper::openFile(const QString &fileName, const QString &msg)
|
||||
if (!QFile(fileName).exists()) {
|
||||
return;
|
||||
}
|
||||
if (QUIHelper::showMessageBoxQuestion(msg + "成功!确定现在就打开吗?") == QMessageBox::Yes) {
|
||||
if (QUIHelper::showMessageBoxQuestion(msg + "成功, 确定现在就打开吗?") == QMessageBox::Yes) {
|
||||
QString url = QString("file:///%1").arg(fileName);
|
||||
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
|
||||
}
|
||||
@@ -801,3 +806,13 @@ bool QUIHelper::checkIniFile(const QString &iniFile)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString QUIHelper::cutString(const QString &text, int len, int left, int right, const QString &mid)
|
||||
{
|
||||
//如果是文件名则取文件名的前字符+末尾字符+去掉拓展名
|
||||
QString result = text.split(".").first();
|
||||
if (result.length() > len) {
|
||||
result = QString("%1%2%3").arg(result.left(left)).arg(mid).arg(result.right(right));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ public:
|
||||
static void setCode(bool utf8 = true);
|
||||
//设置翻译文件
|
||||
static void setTranslator(const QString &qmFile);
|
||||
//一次性设置所有
|
||||
static void initAll(bool utf8 = true, bool style = true, int fontSize = 13);
|
||||
|
||||
//一次性设置所有包括编码样式字体等
|
||||
static void initAll(bool utf8 = true, bool style = true, int fontSize = 13);
|
||||
//初始化main函数最前面执行的一段代码
|
||||
static void initMain(bool on = true);
|
||||
|
||||
@@ -122,6 +122,9 @@ public:
|
||||
|
||||
//检查ini配置文件
|
||||
static bool checkIniFile(const QString &iniFile);
|
||||
|
||||
//首尾截断字符串显示
|
||||
static QString cutString(const QString &text, int len, int left, int right, const QString &mid = "...");
|
||||
};
|
||||
|
||||
#endif // QUIHELPER2_H
|
||||
|
||||
@@ -4,15 +4,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//设置不应用操作系统设置比如字体
|
||||
QApplication::setDesktopSettingsAware(false);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
QApplication::setAttribute(Qt::AA_Use96Dpi);
|
||||
#endif
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
#endif
|
||||
|
||||
QUIHelper::initMain();
|
||||
QApplication a(argc, argv);
|
||||
AppInit::Instance()->start();
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ void frmMain::initLeftMain()
|
||||
btnsMain << ui->tbtnMain1 << ui->tbtnMain2 << ui->tbtnMain3;
|
||||
|
||||
int count = btnsMain.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QToolButton *btn = (QToolButton *)btnsMain.at(i);
|
||||
btn->setCheckable(true);
|
||||
btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
@@ -175,7 +175,7 @@ void frmMain::initLeftConfig()
|
||||
btnsConfig << ui->tbtnConfig1 << ui->tbtnConfig2 << ui->tbtnConfig3 << ui->tbtnConfig4 << ui->tbtnConfig5 << ui->tbtnConfig6;
|
||||
|
||||
int count = btnsConfig.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QToolButton *btn = (QToolButton *)btnsConfig.at(i);
|
||||
btn->setCheckable(true);
|
||||
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
@@ -200,7 +200,7 @@ void frmMain::leftMainClick()
|
||||
QString name = b->text();
|
||||
|
||||
int count = btnsMain.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QAbstractButton *btn = btnsMain.at(i);
|
||||
btn->setChecked(btn == b);
|
||||
}
|
||||
@@ -214,7 +214,7 @@ void frmMain::leftConfigClick()
|
||||
QString name = b->text();
|
||||
|
||||
int count = btnsConfig.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QAbstractButton *btn = btnsConfig.at(i);
|
||||
btn->setChecked(btn == b);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//设置不应用操作系统设置比如字体
|
||||
QApplication::setDesktopSettingsAware(false);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
QApplication::setAttribute(Qt::AA_Use96Dpi);
|
||||
#endif
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
#endif
|
||||
QUIHelper::initMain();
|
||||
QApplication a(argc, argv);
|
||||
AppInit::Instance()->start();
|
||||
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//设置不应用操作系统设置比如字体
|
||||
QApplication::setDesktopSettingsAware(false);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
QApplication::setAttribute(Qt::AA_Use96Dpi);
|
||||
#endif
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
#endif
|
||||
QUIHelper::initMain();
|
||||
QApplication a(argc, argv);
|
||||
AppInit::Instance()->start();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ void frmMain::initForm()
|
||||
names << "访客登记" << "记录查询" << "证件扫描" << "信息打印" << "系统设置" << "系统重启";
|
||||
|
||||
QList<QToolButton *> btns = this->findChildren<QToolButton *>();
|
||||
for (int i = 0; i < btns.count(); i++) {
|
||||
for (int i = 0; i < btns.count(); ++i) {
|
||||
QToolButton *btn = btns.at(i);
|
||||
btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
btn->setIconSize(QSize(iconWidth, iconHeight));
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//设置不应用操作系统设置比如字体
|
||||
QApplication::setDesktopSettingsAware(false);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
QApplication::setAttribute(Qt::AA_Use96Dpi);
|
||||
#endif
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
#endif
|
||||
QUIHelper::initMain();
|
||||
QApplication a(argc, argv);
|
||||
AppInit::Instance()->start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user