更新监控系统说明书

This commit is contained in:
feiyangqingyun
2022-04-11 21:08:42 +08:00
parent c016193e1d
commit 9af9e1e355
10 changed files with 517 additions and 130 deletions

View File

@@ -46,7 +46,11 @@ NavButton::NavButton(QWidget *parent) : QPushButton(parent)
setText("导航按钮"); setText("导航按钮");
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
void NavButton::enterEvent(QEnterEvent *)
#else
void NavButton::enterEvent(QEvent *) void NavButton::enterEvent(QEvent *)
#endif
{ {
hover = true; hover = true;
this->update(); this->update();

View File

@@ -92,7 +92,11 @@ public:
explicit NavButton(QWidget *parent = 0); explicit NavButton(QWidget *parent = 0);
protected: protected:
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
void enterEvent(QEnterEvent *);
#else
void enterEvent(QEvent *); void enterEvent(QEvent *);
#endif
void leaveEvent(QEvent *); void leaveEvent(QEvent *);
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void drawBg(QPainter *painter); void drawBg(QPainter *painter);

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

View File

@@ -1,22 +1,22 @@
#include "appdata.h" #include "appdata.h"
#include "quihelper.h" #include "quihelper.h"
QString AppData::Version = "V20211105"; QString AppData::Version = "V20220316";
QString AppData::TitleFlag = "(QQ: 517216493 WX: feiyangqingyun)"; QString AppData::TitleFlag = "(QQ: 517216493 WX: feiyangqingyun)";
int AppData::RowHeight = 25; int AppData::RowHeight = 25;
int AppData::RightWidth = 180; int AppData::RightWidth = 180;
int AppData::FormWidth = 950; int AppData::FormWidth = 1200;
int AppData::FormHeight = 650; int AppData::FormHeight = 750;
void AppData::checkRatio() void AppData::checkRatio()
{ {
//根据分辨率设定宽高 //根据分辨率设定宽高
int width = QUIHelper::deskWidth(); int width = QUIHelper::deskWidth();
if (width > 1440) { if (width >= 1440) {
RowHeight = RowHeight < 25 ? 25 : RowHeight; RowHeight = RowHeight < 25 ? 25 : RowHeight;
RightWidth = RightWidth < 220 ? 220 : RightWidth; RightWidth = RightWidth < 220 ? 220 : RightWidth;
FormWidth = FormWidth < 1250 ? 1250 : FormWidth; FormWidth = FormWidth < 1200 ? 1200 : FormWidth;
FormHeight = FormHeight < 850 ? 850 : FormHeight; FormHeight = FormHeight < 800 ? 800 : FormHeight;
} }
} }

View File

@@ -1,3 +1,4 @@
QT += network
#指定编译产生的文件分门别类放到对应目录 #指定编译产生的文件分门别类放到对应目录
MOC_DIR = temp/moc MOC_DIR = temp/moc
RCC_DIR = temp/rcc RCC_DIR = temp/rcc
@@ -34,6 +35,15 @@ SOURCES += \
$$PWD/iconhelper.cpp \ $$PWD/iconhelper.cpp \
$$PWD/quihelper.cpp $$PWD/quihelper.cpp
RESOURCES += $$PWD/qrc/qm.qrc #可以指定不加载对应的资源文件
RESOURCES += $$PWD/qrc/font.qrc !contains(DEFINES, no_qrc_image) {
RESOURCES += $$PWD/qrc/image.qrc RESOURCES += $$PWD/qrc/image.qrc
}
!contains(DEFINES, no_qrc_qm) {
RESOURCES += $$PWD/qrc/qm.qrc
}
!contains(DEFINES, no_qrc_font) {
RESOURCES += $$PWD/qrc/font.qrc
}

View File

@@ -1,5 +1,7 @@
#include "quihelper.h" #include "quihelper.h"
#include "qnetworkinterface.h"
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
int QUIHelper::getScreenIndex() int QUIHelper::getScreenIndex()
{ {
//需要对多个屏幕进行处理 //需要对多个屏幕进行处理
@@ -57,6 +59,11 @@ int QUIHelper::deskHeight()
return getScreenRect().height(); return getScreenRect().height();
} }
QSize QUIHelper::deskSize()
{
return getScreenRect().size();
}
QWidget *QUIHelper::centerBaseForm = 0; QWidget *QUIHelper::centerBaseForm = 0;
void QUIHelper::setFormInCenter(QWidget *form) void QUIHelper::setFormInCenter(QWidget *form)
{ {
@@ -77,6 +84,18 @@ void QUIHelper::setFormInCenter(QWidget *form)
form->move(movePoint); form->move(movePoint);
} }
void QUIHelper::showForm(QWidget *form)
{
setFormInCenter(form);
form->show();
//判断宽高是否超过了屏幕分辨率,超过了则最大化显示
//qDebug() << TIMEMS << form->size() << deskSize();
if (form->width() + 20 > deskWidth() || form->height() + 50 > deskHeight()) {
QMetaObject::invokeMethod(form, "showMaximized", Qt::QueuedConnection);
}
}
QString QUIHelper::appName() QString QUIHelper::appName()
{ {
//没有必要每次都获取,只有当变量为空时才去获取一次 //没有必要每次都获取,只有当变量为空时才去获取一次
@@ -86,6 +105,7 @@ QString QUIHelper::appName()
//下面的方法主要为了过滤安卓的路径 lib程序名_armeabi-v7a //下面的方法主要为了过滤安卓的路径 lib程序名_armeabi-v7a
QStringList list = name.split("/"); QStringList list = name.split("/");
name = list.at(list.count() - 1).split(".").at(0); name = list.at(list.count() - 1).split(".").at(0);
name.replace("_armeabi-v7a", "");
} }
return name; return name;
@@ -93,12 +113,164 @@ QString QUIHelper::appName()
QString QUIHelper::appPath() QString QUIHelper::appPath()
{ {
static QString path;
if (path.isEmpty()) {
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
//return QString("/sdcard/Android/%1").arg(appName()); //path = QString("/sdcard/Android/%1").arg(appName());
return QString("/storage/emulated/0/%1").arg(appName()); path = QString("/storage/emulated/0/%1").arg(appName());
#else #else
return qApp->applicationDirPath(); path = qApp->applicationDirPath();
#endif #endif
}
return path;
}
QStringList QUIHelper::getLocalIPs()
{
static QStringList ips;
if (ips.count() == 0) {
#ifdef Q_OS_WASM
ips << "127.0.0.1";
#else
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
foreach (const QNetworkInterface &netInterface, netInterfaces) {
//移除虚拟机和抓包工具的虚拟网卡
QString humanReadableName = netInterface.humanReadableName().toLower();
if (humanReadableName.startsWith("vmware network adapter") || humanReadableName.startsWith("npcap loopback adapter")) {
continue;
}
//过滤当前网络接口
bool flag = (netInterface.flags() == (QNetworkInterface::IsUp | QNetworkInterface::IsRunning | QNetworkInterface::CanBroadcast | QNetworkInterface::CanMulticast));
if (!flag) {
continue;
}
QList<QNetworkAddressEntry> addrs = netInterface.addressEntries();
foreach (QNetworkAddressEntry addr, addrs) {
//只取出IPV4的地址
if (addr.ip().protocol() != QAbstractSocket::IPv4Protocol) {
continue;
}
QString ip4 = addr.ip().toString();
if (ip4 != "127.0.0.1") {
ips << ip4;
}
}
}
#endif
}
return ips;
}
QList<QColor> QUIHelper::colors = QList<QColor>();
QList<QColor> QUIHelper::getColorList()
{
//备用颜色集合 可以自行添加
if (colors.count() == 0) {
colors << QColor(0, 176, 180) << QColor(0, 113, 193) << QColor(255, 192, 0);
colors << QColor(72, 103, 149) << QColor(185, 87, 86) << QColor(0, 177, 125);
colors << QColor(214, 77, 84) << QColor(71, 164, 233) << QColor(34, 163, 169);
colors << QColor(59, 123, 156) << QColor(162, 121, 197) << QColor(72, 202, 245);
colors << QColor(0, 150, 121) << QColor(111, 9, 176) << QColor(250, 170, 20);
}
return colors;
}
QStringList QUIHelper::getColorNames()
{
QList<QColor> colors = getColorList();
QStringList colorNames;
foreach (QColor color, colors) {
colorNames << color.name();
}
return colorNames;
}
QColor QUIHelper::getRandColor()
{
QList<QColor> colors = getColorList();
int index = getRandValue(0, colors.count(), true);
return colors.at(index);
}
void QUIHelper::initRand()
{
//初始化随机数种子
QTime t = QTime::currentTime();
srand(t.msec() + t.second() * 1000);
}
float QUIHelper::getRandFloat(float min, float max)
{
double diff = fabs(max - min);
double value = (double)(rand() % 100) / 100;
value = min + value * diff;
return value;
}
double QUIHelper::getRandValue(int min, int max, bool contansMin, bool contansMax)
{
int value;
#if (QT_VERSION <= QT_VERSION_CHECK(5,10,0))
//通用公式 a是起始值,n是整数的范围
//int value = a + rand() % n;
if (contansMin) {
if (contansMax) {
value = min + 0 + (rand() % (max - min + 1));
} else {
value = min + 0 + (rand() % (max - min + 0));
}
} else {
if (contansMax) {
value = min + 1 + (rand() % (max - min + 0));
} else {
value = min + 1 + (rand() % (max - min - 1));
}
}
#else
if (contansMin) {
if (contansMax) {
value = QRandomGenerator::global()->bounded(min + 0, max + 1);
} else {
value = QRandomGenerator::global()->bounded(min + 0, max + 0);
}
} else {
if (contansMax) {
value = QRandomGenerator::global()->bounded(min + 1, max + 1);
} else {
value = QRandomGenerator::global()->bounded(min + 1, max + 0);
}
}
#endif
return value;
}
QStringList QUIHelper::getRandPoint(int count, float mainLng, float mainLat, float dotLng, float dotLat)
{
//随机生成点坐标
QStringList points;
for (int i = 0; i < count; ++i) {
//0.00881415 0.000442928
#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0))
float lngx = QRandomGenerator::global()->bounded(dotLng);
float latx = QRandomGenerator::global()->bounded(dotLat);
#else
float lngx = getRandFloat(dotLng / 10, dotLng);
float latx = getRandFloat(dotLat / 10, dotLat);
#endif
//需要先用精度转换成字符串
QString lng2 = QString::number(mainLng + lngx, 'f', 8);
QString lat2 = QString::number(mainLat + latx, 'f', 8);
QString point = QString("%1,%2").arg(lng2).arg(lat2);
points << point;
}
return points;
} }
QString QUIHelper::getUuid() QString QUIHelper::getUuid()
@@ -109,13 +281,6 @@ QString QUIHelper::getUuid()
return uuid; return uuid;
} }
void QUIHelper::initRand()
{
//初始化随机数种子
QTime t = QTime::currentTime();
srand(t.msec() + t.second() * 1000);
}
void QUIHelper::newDir(const QString &dirName) void QUIHelper::newDir(const QString &dirName)
{ {
QString strDir = dirName; QString strDir = dirName;
@@ -151,30 +316,69 @@ void QUIHelper::sleep(int msec)
void QUIHelper::setStyle() void QUIHelper::setStyle()
{ {
//打印下所有内置风格的名字 //打印下所有内置风格的名字
qDebug() << "Qt内置的样式" << QStyleFactory::keys(); qDebug() << TIMEMS << "QStyleFactory::keys" << QStyleFactory::keys();
//设置内置风格
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
qApp->setStyle(QStyleFactory::create("Fusion")); qApp->setStyle(QStyleFactory::create("Fusion"));
#else #else
qApp->setStyle(QStyleFactory::create("Cleanlooks")); qApp->setStyle(QStyleFactory::create("Cleanlooks"));
#endif #endif
//qApp->setPalette(QPalette("#FFFFFF"));
//设置指定颜色
QPalette palette;
palette.setBrush(QPalette::Window, QColor("#F0F0F0"));
qApp->setPalette(palette);
}
QFont QUIHelper::addFont(const QString &fontFile, const QString &fontName)
{
//判断图形字体是否存在,不存在则加入
QFontDatabase fontDb;
if (!fontDb.families().contains(fontName)) {
int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.count() == 0) {
qDebug() << QString("load %1 error").arg(fontName);
}
}
//再次判断是否包含字体名称防止加载失败
QFont font;
if (fontDb.families().contains(fontName)) {
font = QFont(fontName);
#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0))
font.setHintingPreference(QFont::PreferNoHinting);
#endif
}
return font;
} }
void QUIHelper::setFont(int fontSize) void QUIHelper::setFont(int fontSize)
{ {
QFont font; #ifdef rk3399
font.setFamily("MicroSoft Yahei"); return;
#ifdef Q_OS_ANDROID #endif
font.setPixelSize(15); //安卓套件在有些手机上默认字体不好看需要主动设置字体
#elif __arm__ //网页套件需要主动加载中文字体才能正常显示中文
font.setPixelSize(25); #if (defined Q_OS_ANDROID) || (defined Q_OS_WASM)
#else QString fontFile = ":/font/DroidSansFallback.ttf";
font.setPixelSize(fontSize); QString fontName = "Droid Sans Fallback";
qApp->setFont(addFont(fontFile, fontName));
return;
#endif #endif
#ifndef rk3399 #ifdef __arm__
qApp->setFont(font); fontSize = 25;
#endif #endif
#ifdef Q_OS_ANDROID
fontSize = 15;
#endif
QFont font;
font.setFamily("MicroSoft Yahei");
font.setPixelSize(fontSize);
qApp->setFont(font);
} }
void QUIHelper::setCode(bool utf8) void QUIHelper::setCode(bool utf8)
@@ -205,26 +409,99 @@ void QUIHelper::setTranslator(const QString &qmFile)
} }
QTranslator *translator = new QTranslator(qApp); QTranslator *translator = new QTranslator(qApp);
translator->load(qmFile); if (translator->load(qmFile)) {
qApp->installTranslator(translator); qApp->installTranslator(translator);
}
} }
void QUIHelper::initAll() void QUIHelper::initAll(bool utf8, bool style, int fontSize)
{ {
//初始化随机数种子 //初始化随机数种子
QUIHelper::initRand(); QUIHelper::initRand();
//设置样式风格
QUIHelper::setStyle();
//设置字体
QUIHelper::setFont(13);
//设置编码 //设置编码
QUIHelper::setCode(); QUIHelper::setCode(utf8);
//设置样式风格
if (style) {
QUIHelper::setStyle();
}
//设置字体
QUIHelper::setFont(fontSize);
//设置翻译文件支持多个 //设置翻译文件支持多个
QUIHelper::setTranslator(":/qm/widgets.qm"); QUIHelper::setTranslator(":/qm/widgets.qm");
QUIHelper::setTranslator(":/qm/qt_zh_CN.qm"); QUIHelper::setTranslator(":/qm/qt_zh_CN.qm");
QUIHelper::setTranslator(":/qm/designer_zh_CN.qm"); QUIHelper::setTranslator(":/qm/designer_zh_CN.qm");
} }
void QUIHelper::initMain(bool on)
{
//设置是否应用操作系统设置比如字体
QApplication::setDesktopSettingsAware(on);
#ifdef Q_OS_ANDROID
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
//开启高分屏缩放支持
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#else
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
//不应用任何缩放
QApplication::setAttribute(Qt::AA_Use96Dpi);
#endif
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
//高分屏缩放策略
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
//设置opengl模式 AA_UseDesktopOpenGL(默认) AA_UseOpenGLES AA_UseSoftwareOpenGL
//在一些很旧的设备上或者对opengl支持很低的设备上需要使用AA_UseOpenGLES表示禁用硬件加速
//如果开启的是AA_UseOpenGLES则无法使用硬件加速比如ffmpeg的dxva2
//QApplication::setAttribute(Qt::AA_UseOpenGLES);
//设置opengl共享上下文
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif
}
QVector<int> QUIHelper::msgTypes = QVector<int>() << 0 << 1 << 2 << 3 << 4;
QVector<QString> QUIHelper::msgKeys = QVector<QString>() << "发送" << "接收" << "解析" << "错误" << "提示";
QVector<QColor> QUIHelper::msgColors = QVector<QColor>() << QColor("#3BA372") << QColor("#EE6668") << QColor("#9861B4") << QColor("#FA8359") << QColor("#22A3A9");
QString QUIHelper::appendMsg(QTextEdit *textEdit, int type, const QString &data, int maxCount, int &currentCount, bool clear, bool pause)
{
if (clear) {
textEdit->clear();
currentCount = 0;
return QString();
}
if (pause) {
return QString();
}
if (currentCount >= maxCount) {
textEdit->clear();
currentCount = 0;
}
//不同类型不同颜色显示
QString strType;
int index = msgTypes.indexOf(type);
if (index >= 0) {
strType = msgKeys.at(index);
textEdit->setTextColor(msgColors.at(index));
}
//过滤回车换行符
QString strData = data;
strData.replace("\r", "");
strData.replace("\n", "");
strData = QString("时间[%1] %2: %3").arg(TIMEMS).arg(strType).arg(strData);
textEdit->append(strData);
currentCount++;
return strData;
}
void QUIHelper::setFramelessForm(QWidget *widgetMain, bool tool, bool top, bool menu) void QUIHelper::setFramelessForm(QWidget *widgetMain, bool tool, bool top, bool menu)
{ {
widgetMain->setProperty("form", true); widgetMain->setProperty("form", true);
@@ -292,6 +569,102 @@ int QUIHelper::showMessageBoxQuestion(const QString &info)
//return QMessageBox::question(0, "询问", info, QMessageBox::Yes | QMessageBox::No); //return QMessageBox::question(0, "询问", info, QMessageBox::Yes | QMessageBox::No);
} }
void QUIHelper::initDialog(QFileDialog *dialog, const QString &title, const QString &acceptName,
const QString &dirName, bool native, int width, int height)
{
//设置标题
dialog->setWindowTitle(title);
//设置标签文本
dialog->setLabelText(QFileDialog::Accept, acceptName);
dialog->setLabelText(QFileDialog::Reject, "取消(&C)");
dialog->setLabelText(QFileDialog::LookIn, "查看");
dialog->setLabelText(QFileDialog::FileName, "名称");
dialog->setLabelText(QFileDialog::FileType, "类型");
//设置默认显示目录
if (!dirName.isEmpty()) {
dialog->setDirectory(dirName);
}
//设置对话框宽高
if (width > 0 && height > 0) {
#ifdef Q_OS_ANDROID
bool horizontal = (QUIHelper::deskWidth() > QUIHelper::deskHeight());
if (horizontal) {
width = QUIHelper::deskWidth() / 2;
height = QUIHelper::deskHeight() - 50;
} else {
width = QUIHelper::deskWidth() - 10;
height = QUIHelper::deskHeight() / 2;
}
#endif
dialog->setFixedSize(width, height);
}
//设置是否采用本地对话框
dialog->setOption(QFileDialog::DontUseNativeDialog, !native);
//设置只读可以取消右上角的新建按钮
//dialog->setReadOnly(true);
}
QString QUIHelper::getDialogResult(QFileDialog *dialog)
{
QString result;
if (dialog->exec() == QFileDialog::Accepted) {
result = dialog->selectedFiles().first();
}
return result;
}
QString QUIHelper::getOpenFileName(const QString &filter, const QString &dirName, const QString &fileName,
bool native, int width, int height)
{
QFileDialog dialog;
initDialog(&dialog, "打开文件", "选择(&S)", dirName, native, width, height);
//设置文件类型
if (!filter.isEmpty()) {
dialog.setNameFilter(filter);
}
//设置默认文件名称
dialog.selectFile(fileName);
return getDialogResult(&dialog);
}
QString QUIHelper::getSaveFileName(const QString &filter, const QString &dirName, const QString &fileName,
bool native, int width, int height)
{
QFileDialog dialog;
initDialog(&dialog, "保存文件", "保存(&S)", dirName, native, width, height);
//设置文件类型
if (!filter.isEmpty()) {
dialog.setNameFilter(filter);
}
//设置默认文件名称
dialog.selectFile(fileName);
//设置模态类型允许输入
dialog.setWindowModality(Qt::WindowModal);
//设置置顶显示
dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint);
return getDialogResult(&dialog);
}
QString QUIHelper::getExistingDirectory(const QString &dirName, bool native, int width, int height)
{
QFileDialog dialog;
initDialog(&dialog, "选择目录", "选择(&S)", dirName, native, width, height);
dialog.setOption(QFileDialog::ReadOnly);
//设置只显示目录
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
dialog.setFileMode(QFileDialog::DirectoryOnly);
#endif
dialog.setOption(QFileDialog::ShowDirsOnly);
return getDialogResult(&dialog);
}
QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key) QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key)
{ {
//矫正范围外的数据 //矫正范围外的数据
@@ -299,7 +672,12 @@ QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key)
key = 127; key = 127;
} }
//大概从5.9版本输出的加密密码字符串前面会加上 @String 字符
QString result = value; QString result = value;
if (result.startsWith("@String")) {
result = result.mid(8, result.length() - 9);
}
int count = result.count(); 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); result[i] = QChar(result.at(i).toLatin1() ^ key);
@@ -331,6 +709,8 @@ uchar QUIHelper::getCheckCode(const QByteArray &data)
void QUIHelper::initTableView(QTableView *tableView, int rowHeight, bool headVisible, bool edit, bool stretchLast) void QUIHelper::initTableView(QTableView *tableView, int rowHeight, bool headVisible, bool edit, bool stretchLast)
{ {
//设置弱属性用于应用qss特殊样式
tableView->setProperty("model", true);
//取消自动换行 //取消自动换行
tableView->setWordWrap(false); tableView->setWordWrap(false);
//超出文本不显示省略号 //超出文本不显示省略号
@@ -374,7 +754,8 @@ void QUIHelper::openFile(const QString &fileName, const QString &msg)
#ifdef __arm__ #ifdef __arm__
return; return;
#endif #endif
if (fileName.isEmpty()) { //文件不存在则不用处理
if (!QFile(fileName).exists()) {
return; return;
} }
if (QUIHelper::showMessageBoxQuestion(msg + "成功!确定现在就打开吗?") == QMessageBox::Yes) { if (QUIHelper::showMessageBoxQuestion(msg + "成功!确定现在就打开吗?") == QMessageBox::Yes) {
@@ -401,8 +782,10 @@ bool QUIHelper::checkIniFile(const QString &iniFile)
QStringList list = line.split("="); QStringList list = line.split("=");
if (list.count() == 2) { if (list.count() == 2) {
if (list.at(1) == "") { QString key = list.at(0);
qDebug() << "ini node no value" << list.at(0); QString value = list.at(1);
if (value.isEmpty()) {
qDebug() << TIMEMS << "ini node no value" << key;
ok = false; ok = false;
break; break;
} }

View File

@@ -13,29 +13,66 @@ public:
//获取桌面宽度高度+居中显示 //获取桌面宽度高度+居中显示
static int deskWidth(); static int deskWidth();
static int deskHeight(); static int deskHeight();
static QSize deskSize();
//居中显示窗体 //居中显示窗体
//定义标志位指定是以桌面为参照还是主程序界面为参照 //定义标志位指定是以桌面为参照还是主程序界面为参照
static QWidget *centerBaseForm; static QWidget *centerBaseForm;
static void setFormInCenter(QWidget *form); static void setFormInCenter(QWidget *form);
static void showForm(QWidget *form);
//程序文件名称+当前所在路径 //程序文件名称+当前所在路径
static QString appName(); static QString appName();
static QString appPath(); static QString appPath();
//获取uuid+初始化随机数种子+新建目录+延时 //获取本地网卡IP集合
static QString getUuid(); static QStringList getLocalIPs();
//获取内置颜色集合
static QList<QColor> colors;
static QList<QColor> getColorList();
static QStringList getColorNames();
//随机获取颜色集合中的颜色
static QColor getRandColor();
//初始化随机数种子
static void initRand(); static void initRand();
//获取随机小数
static float getRandFloat(float min, float max);
//获取随机数,指定最小值和最大值
static double getRandValue(int min, int max, bool contansMin = false, bool contansMax = false);
//获取范围值随机经纬度集合
static QStringList getRandPoint(int count, float mainLng, float mainLat, float dotLng, float dotLat);
//获取uuid
static QString getUuid();
//可执行文件目录下新建目录
static void newDir(const QString &dirName); static void newDir(const QString &dirName);
//延时
static void sleep(int msec); static void sleep(int msec);
//设置样式+字体+编码+居中+翻译 //设置Qt自带样式
static void setStyle(); static void setStyle();
//设置字体
static QFont addFont(const QString &fontFile, const QString &fontName);
static void setFont(int fontSize = 12); static void setFont(int fontSize = 12);
//设置编码
static void setCode(bool utf8 = true); static void setCode(bool utf8 = true);
//设置翻译文件
static void setTranslator(const QString &qmFile); static void setTranslator(const QString &qmFile);
//一次性设置所有 //一次性设置所有
static void initAll(); static void initAll(bool utf8 = true, bool style = true, int fontSize = 13);
//初始化main函数最前面执行的一段代码
static void initMain(bool on = true);
//插入消息
static QVector<int> msgTypes;
static QVector<QString> msgKeys;
static QVector<QColor> msgColors;
static QString appendMsg(QTextEdit *textEdit, int type, const QString &data,
int maxCount, int &currentCount,
bool clear = false, bool pause = false);
//设置无边框 //设置无边框
static void setFramelessForm(QWidget *widgetMain, bool tool = false, bool top = false, bool menu = true); static void setFramelessForm(QWidget *widgetMain, bool tool = false, bool top = false, bool menu = true);
@@ -49,6 +86,26 @@ public:
//弹出询问框 //弹出询问框
static int showMessageBoxQuestion(const QString &info); static int showMessageBoxQuestion(const QString &info);
//为什么还要自定义对话框因为可控宽高和汉化对应文本等
//初始化对话框文本
static void initDialog(QFileDialog *dialog, const QString &title, const QString &acceptName,
const QString &dirName, bool native, int width, int height);
//拿到对话框结果
static QString getDialogResult(QFileDialog *dialog);
//选择文件对话框
static QString getOpenFileName(const QString &filter = QString(),
const QString &dirName = QString(),
const QString &fileName = QString(),
bool native = false, int width = 900, int height = 600);
//保存文件对话框
static QString getSaveFileName(const QString &filter = QString(),
const QString &dirName = QString(),
const QString &fileName = QString(),
bool native = false, int width = 900, int height = 600);
//选择目录对话框
static QString getExistingDirectory(const QString &dirName = QString(),
bool native = false, int width = 900, int height = 600);
//异或加密-只支持字符,如果是中文需要将其转换base64编码 //异或加密-只支持字符,如果是中文需要将其转换base64编码
static QString getXorEncryptDecrypt(const QString &value, char key); static QString getXorEncryptDecrypt(const QString &value, char key);
//异或校验 //异或校验

View File

@@ -44,7 +44,11 @@ LunarCalendarItem::LunarCalendarItem(QWidget *parent) : QWidget(parent)
hoverBgColor = QColor(204, 183, 180); hoverBgColor = QColor(204, 183, 180);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
void LunarCalendarItem::enterEvent(QEnterEvent *)
#else
void LunarCalendarItem::enterEvent(QEvent *) void LunarCalendarItem::enterEvent(QEvent *)
#endif
{ {
hover = true; hover = true;
this->update(); this->update();

View File

@@ -62,7 +62,11 @@ public:
explicit LunarCalendarItem(QWidget *parent = 0); explicit LunarCalendarItem(QWidget *parent = 0);
protected: protected:
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
void enterEvent(QEnterEvent *);
#else
void enterEvent(QEvent *); void enterEvent(QEvent *);
#endif
void leaveEvent(QEvent *); void leaveEvent(QEvent *);
void mousePressEvent(QMouseEvent *); void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *);