更新文档

master
feiyangqingyun 2023-03-20 15:04:23 +08:00
parent de79df1314
commit 64bb823ba9
38 changed files with 183 additions and 125 deletions

View File

@ -11,7 +11,9 @@ Battery::Battery(QWidget *parent) : QWidget(parent)
maxValue = 100; maxValue = 100;
value = 0; value = 0;
alarmValue = 30; alarmValue = 30;
step = 0.5;
animation = true;
animationStep = 0.5;
borderWidth = 5; borderWidth = 5;
borderRadius = 8; borderRadius = 8;
@ -91,7 +93,7 @@ void Battery::drawBg(QPainter *painter)
} }
int margin = qMin(width(), height()) / 20; int margin = qMin(width(), height()) / 20;
double unit = (batteryRect.width() - (margin * 2)) / 100; double unit = (batteryRect.width() - (margin * 2)) / (maxValue - minValue);
double width = currentValue * unit; double width = currentValue * unit;
QPointF topLeft(batteryRect.topLeft().x() + margin, batteryRect.topLeft().y() + margin); QPointF topLeft(batteryRect.topLeft().x() + margin, batteryRect.topLeft().y() + margin);
QPointF bottomRight(width + margin + borderWidth, batteryRect.bottomRight().y() - margin); QPointF bottomRight(width + margin + borderWidth, batteryRect.bottomRight().y() - margin);
@ -126,13 +128,13 @@ void Battery::drawHead(QPainter *painter)
void Battery::updateValue() void Battery::updateValue()
{ {
if (isForward) { if (isForward) {
currentValue -= step; currentValue -= animationStep;
if (currentValue <= value) { if (currentValue <= value) {
currentValue = value; currentValue = value;
timer->stop(); timer->stop();
} }
} else { } else {
currentValue += step; currentValue += animationStep;
if (currentValue >= value) { if (currentValue >= value) {
currentValue = value; currentValue = value;
timer->stop(); timer->stop();
@ -162,9 +164,14 @@ double Battery::getAlarmValue() const
return this->alarmValue; return this->alarmValue;
} }
double Battery::getStep() const bool Battery::getAnimation() const
{ {
return this->step; return this->animation;
}
double Battery::getAnimationStep() const
{
return this->animationStep;
} }
int Battery::getBorderWidth() const int Battery::getBorderWidth() const
@ -288,10 +295,14 @@ void Battery::setValue(double value)
} }
this->value = value; this->value = value;
this->update();
emit valueChanged(value); emit valueChanged(value);
timer->stop(); if (animation) {
timer->start(); timer->stop();
timer->start();
} else {
this->currentValue = value;
this->update();
}
} }
void Battery::setValue(int value) void Battery::setValue(int value)
@ -312,17 +323,20 @@ void Battery::setAlarmValue(int alarmValue)
setAlarmValue((double)alarmValue); setAlarmValue((double)alarmValue);
} }
void Battery::setStep(double step) void Battery::setAnimation(bool animation)
{ {
if (this->step != step) { if (this->animation != animation) {
this->step = step; this->animation = animation;
this->update(); this->update();
} }
} }
void Battery::setStep(int step) void Battery::setAnimationStep(double animationStep)
{ {
setStep((double)step); if (this->animationStep != animationStep) {
this->animationStep = animationStep;
this->update();
}
} }
void Battery::setBorderWidth(int borderWidth) void Battery::setBorderWidth(int borderWidth)

View File

@ -27,7 +27,9 @@ class Battery : public QWidget
Q_PROPERTY(double value READ getValue WRITE setValue) Q_PROPERTY(double value READ getValue WRITE setValue)
Q_PROPERTY(double alarmValue READ getAlarmValue WRITE setAlarmValue) Q_PROPERTY(double alarmValue READ getAlarmValue WRITE setAlarmValue)
Q_PROPERTY(double step READ getStep WRITE setStep) Q_PROPERTY(bool animation READ getAnimation WRITE setAnimation)
Q_PROPERTY(double animationStep READ getAnimationStep WRITE setAnimationStep)
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth) Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
Q_PROPERTY(int borderRadius READ getBorderRadius WRITE setBorderRadius) Q_PROPERTY(int borderRadius READ getBorderRadius WRITE setBorderRadius)
Q_PROPERTY(int bgRadius READ getBgRadius WRITE setBgRadius) Q_PROPERTY(int bgRadius READ getBgRadius WRITE setBgRadius)
@ -61,7 +63,9 @@ private:
double value; //目标电量 double value; //目标电量
double alarmValue; //电池电量警戒值 double alarmValue; //电池电量警戒值
double step; //每次移动的步长 bool animation; //是否启用动画显示
double animationStep; //动画显示时步长
int borderWidth; //边框粗细 int borderWidth; //边框粗细
int borderRadius; //边框圆角角度 int borderRadius; //边框圆角角度
int bgRadius; //背景进度圆角角度 int bgRadius; //背景进度圆角角度
@ -87,7 +91,9 @@ public:
double getValue() const; double getValue() const;
double getAlarmValue() const; double getAlarmValue() const;
double getStep() const; bool getAnimation() const;
double getAnimationStep() const;
int getBorderWidth() const; int getBorderWidth() const;
int getBorderRadius() const; int getBorderRadius() const;
int getBgRadius() const; int getBgRadius() const;
@ -122,9 +128,10 @@ public Q_SLOTS:
void setAlarmValue(double alarmValue); void setAlarmValue(double alarmValue);
void setAlarmValue(int alarmValue); void setAlarmValue(int alarmValue);
//设置步长 //设置是否启用动画显示
void setStep(double step); void setAnimation(bool animation);
void setStep(int step); //设置动画显示的步长
void setAnimationStep(double animationStep);
//设置边框粗细 //设置边框粗细
void setBorderWidth(int borderWidth); void setBorderWidth(int borderWidth);

View File

@ -218,7 +218,7 @@ void DeviceSizeTable::checkSize(const QString &result, const QString &name)
QStringList list = result.split(" "); QStringList list = result.split(" ");
int index = 0; int index = 0;
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.count(); ++i) {
QString s = list.at(i).trimmed(); QString s = list.at(i).trimmed();
if (s.isEmpty()) { if (s.isEmpty()) {
continue; continue;

View File

@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) { if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile); int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId); QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.size() == 0) { if (listName.count() == 0) {
qDebug() << QString("load %1 error").arg(fontName); qDebug() << QString("load %1 error").arg(fontName);
} }
} }
@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor) void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{ {
int btnCount = btns.size(); int btnCount = btns.count();
int iconCount = icons.size(); int iconCount = icons.count();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) { if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return; return;
} }
@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的 //可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) { for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.size(); j++) { for (int j = 0; j < this->btns.count(); j++) {
if (this->btns.at(j) == btns.at(i)) { if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this); this->btns.at(j)->removeEventFilter(this);

View File

@ -114,7 +114,7 @@ SaveLog::SaveLog(QObject *parent) : QObject(parent)
//默认取应用程序可执行文件名称 //默认取应用程序可执行文件名称
QString str = qApp->applicationFilePath(); QString str = qApp->applicationFilePath();
QStringList list = str.split("/"); QStringList list = str.split("/");
name = list.at(list.size() - 1).split(".").at(0); name = list.at(list.count() - 1).split(".").at(0);
fileName = ""; fileName = "";
//默认所有类型都输出 //默认所有类型都输出

View File

@ -28,7 +28,7 @@ SaveRunTime::SaveRunTime(QObject *parent) : QObject(parent)
path = qApp->applicationDirPath(); path = qApp->applicationDirPath();
QString str = qApp->applicationFilePath(); QString str = qApp->applicationFilePath();
QStringList list = str.split("/"); QStringList list = str.split("/");
name = list.at(list.size() - 1).split(".").at(0); name = list.at(list.count() - 1).split(".").at(0);
saveInterval = 1 * 60 * 1000; saveInterval = 1 * 60 * 1000;
startTime = QDateTime::currentDateTime(); startTime = QDateTime::currentDateTime();
@ -187,7 +187,7 @@ void SaveRunTime::saveLog()
//重新清空文件 //重新清空文件
file.resize(0); file.resize(0);
//如果行数小于2则返回 //如果行数小于2则返回
if (content.size() < 2) { if (content.count() < 2) {
file.close(); file.close();
return; return;
} }
@ -206,7 +206,7 @@ void SaveRunTime::saveLog()
lastLine = list.join("\t"); lastLine = list.join("\t");
//重新替换最后一行并写入新的数据 //重新替换最后一行并写入新的数据
content[content.size() - 1] = lastLine; content[content.count() - 1] = lastLine;
QTextStream stream(&file); QTextStream stream(&file);
stream << content.join("") << "\n"; stream << content.join("") << "\n";

View File

@ -4,7 +4,7 @@
QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points) QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
{ {
QPainterPath path; QPainterPath path;
int len = points.size(); int len = points.count();
if (len < 2) { if (len < 2) {
return path; return path;
} }
@ -24,13 +24,13 @@ QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points) QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points)
{ {
//采用Qt原生方法不做任何处理 //采用Qt原生方法不做任何处理
int size = points.size(); int count = points.count();
if (size == 0) { if (count == 0) {
return QPainterPath(); return QPainterPath();
} }
QPainterPath path(points.at(0)); QPainterPath path(points.at(0));
for (int i = 0; i < size - 1; ++i) { for (int i = 0; i < count - 1; ++i) {
//控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半 //控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半
//第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标 //第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标
//第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标 //第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标
@ -68,7 +68,7 @@ void SmoothCurve::calculateControlPoints(const QVector<QPointF> &datas,
QVector<QPointF> *firstControlPoints, QVector<QPointF> *firstControlPoints,
QVector<QPointF> *secondControlPoints) QVector<QPointF> *secondControlPoints)
{ {
int n = datas.size() - 1; int n = datas.count() - 1;
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
firstControlPoints->append(QPointF()); firstControlPoints->append(QPointF());
secondControlPoints->append(QPointF()); secondControlPoints->append(QPointF());

View File

@ -250,7 +250,7 @@ void ZhToPY::loadPY(const QString &fileName)
QString ZhToPY::zhToPY(const QString &chinese) QString ZhToPY::zhToPY(const QString &chinese)
{ {
if (listPY.size() == 0) { if (listPY.count() == 0) {
return ""; return "";
} }

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

View File

@ -2,6 +2,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11 greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11
#lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11 #lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
#将当前目录加入到头文件路径
INCLUDEPATH += $$PWD
DEFINES += qcustomplot DEFINES += qcustomplot
#引入平滑曲线类 #引入平滑曲线类

View File

@ -4,7 +4,7 @@
QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points) QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
{ {
QPainterPath path; QPainterPath path;
int len = points.size(); int len = points.count();
if (len < 2) { if (len < 2) {
return path; return path;
} }
@ -24,13 +24,13 @@ QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points) QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points)
{ {
//采用Qt原生方法不做任何处理 //采用Qt原生方法不做任何处理
int size = points.size(); int count = points.count();
if (size == 0) { if (count == 0) {
return QPainterPath(); return QPainterPath();
} }
QPainterPath path(points.at(0)); QPainterPath path(points.at(0));
for (int i = 0; i < size - 1; ++i) { for (int i = 0; i < count - 1; ++i) {
//控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半 //控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半
//第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标 //第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标
//第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标 //第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标
@ -68,7 +68,7 @@ void SmoothCurve::calculateControlPoints(const QVector<QPointF> &datas,
QVector<QPointF> *firstControlPoints, QVector<QPointF> *firstControlPoints,
QVector<QPointF> *secondControlPoints) QVector<QPointF> *secondControlPoints)
{ {
int n = datas.size() - 1; int n = datas.count() - 1;
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
firstControlPoints->append(QPointF()); firstControlPoints->append(QPointF());
secondControlPoints->append(QPointF()); secondControlPoints->append(QPointF());

View File

@ -1145,15 +1145,15 @@ void QCPLayer::drawToPaintBuffer()
if (painter->isActive()) { if (painter->isActive()) {
draw(painter); draw(painter);
} else { } else {
qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter"; //qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter";
} }
delete painter; delete painter;
mPaintBuffer.data()->donePainting(); mPaintBuffer.data()->donePainting();
} else { } else {
qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter"; //qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter";
} }
} else { } else {
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer"; //qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
} }
} }

View File

@ -1173,15 +1173,15 @@ void QCPLayer::drawToPaintBuffer()
if (painter->isActive()) { if (painter->isActive()) {
draw(painter); draw(painter);
} else { } else {
qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter"; //qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter";
} }
delete painter; delete painter;
pb->donePainting(); pb->donePainting();
} else { } else {
qDebug() << Q_FUNC_INFO << "paint buffer returned nullptr painter"; //qDebug() << Q_FUNC_INFO << "paint buffer returned nullptr painter";
} }
} else { } else {
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer"; //qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
} }
} }

View File

@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) { if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile); int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId); QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.size() == 0) { if (listName.count() == 0) {
qDebug() << QString("load %1 error").arg(fontName); qDebug() << QString("load %1 error").arg(fontName);
} }
} }
@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor) void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{ {
int btnCount = btns.size(); int btnCount = btns.count();
int iconCount = icons.size(); int iconCount = icons.count();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) { if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return; return;
} }
@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的 //可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) { for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.size(); j++) { for (int j = 0; j < this->btns.count(); j++) {
if (this->btns.at(j) == btns.at(i)) { if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this); this->btns.at(j)->removeEventFilter(this);

Binary file not shown.

View File

@ -2,6 +2,8 @@ QT += network
greaterThan(QT_MAJOR_VERSION, 4) { greaterThan(QT_MAJOR_VERSION, 4) {
lessThan(QT_MAJOR_VERSION, 6) { lessThan(QT_MAJOR_VERSION, 6) {
android {QT += androidextras} android {QT += androidextras}
} else {
QT += core-private
}} }}
#指定编译产生的文件分门别类放到对应目录 #指定编译产生的文件分门别类放到对应目录

View File

@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) { if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile); int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId); QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.size() == 0) { if (listName.count() == 0) {
qDebug() << QString("load %1 error").arg(fontName); qDebug() << QString("load %1 error").arg(fontName);
} }
} }
@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor) void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{ {
int btnCount = btns.size(); int btnCount = btns.count();
int iconCount = icons.size(); int iconCount = icons.count();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) { if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return; return;
} }
@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的 //可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) { for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.size(); j++) { for (int j = 0; j < this->btns.count(); j++) {
if (this->btns.at(j) == btns.at(i)) { if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this); this->btns.at(j)->removeEventFilter(this);

View File

@ -9,7 +9,7 @@ int QUIHelper::getScreenIndex()
//需要对多个屏幕进行处理 //需要对多个屏幕进行处理
int screenIndex = 0; int screenIndex = 0;
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
int screenCount = qApp->screens().count(); int screenCount = qApp->screens().size();
#else #else
int screenCount = qApp->desktop()->screenCount(); int screenCount = qApp->desktop()->screenCount();
#endif #endif
@ -136,10 +136,11 @@ QString QUIHelper::appName()
static QString name; static QString name;
if (name.isEmpty()) { if (name.isEmpty()) {
name = qApp->applicationFilePath(); name = qApp->applicationFilePath();
//下面的方法主要为了过滤安卓的路径 lib程序名_armeabi-v7a //下面的方法主要为了过滤安卓的路径 lib程序名_armeabi-v7a/lib程序名_arm64-v8a
QStringList list = name.split("/"); QStringList list = name.split("/");
name = list.at(list.count() - 1).split(".").at(0); name = list.at(list.size() - 1).split(".").at(0);
name.replace("_armeabi-v7a", ""); name.replace("_armeabi-v7a", "");
name.replace("_arm64-v8a", "");
} }
return name; return name;
@ -165,7 +166,7 @@ QString QUIHelper::appPath()
QStringList QUIHelper::getLocalIPs() QStringList QUIHelper::getLocalIPs()
{ {
static QStringList ips; static QStringList ips;
if (ips.count() == 0) { if (ips.size() == 0) {
#ifdef Q_OS_WASM #ifdef Q_OS_WASM
ips << "127.0.0.1"; ips << "127.0.0.1";
#else #else
@ -206,7 +207,7 @@ QList<QColor> QUIHelper::colors = QList<QColor>();
QList<QColor> QUIHelper::getColorList() QList<QColor> QUIHelper::getColorList()
{ {
//备用颜色集合 可以自行添加 //备用颜色集合 可以自行添加
if (colors.count() == 0) { if (colors.size() == 0) {
colors << QColor(0, 176, 180) << QColor(0, 113, 193) << QColor(255, 192, 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(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(214, 77, 84) << QColor(71, 164, 233) << QColor(34, 163, 169);
@ -230,7 +231,7 @@ QStringList QUIHelper::getColorNames()
QColor QUIHelper::getRandColor() QColor QUIHelper::getRandColor()
{ {
QList<QColor> colors = getColorList(); QList<QColor> colors = getColorList();
int index = getRandValue(0, colors.count(), true); int index = getRandValue(0, colors.size(), true);
return colors.at(index); return colors.at(index);
} }
@ -380,7 +381,7 @@ QFont QUIHelper::addFont(const QString &fontFile, const QString &fontName)
if (!fontDb.families().contains(fontName)) { if (!fontDb.families().contains(fontName)) {
int fontId = fontDb.addApplicationFont(fontFile); int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId); QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.count() == 0) { if (listName.size() == 0) {
qDebug() << QString("load %1 error").arg(fontName); qDebug() << QString("load %1 error").arg(fontName);
} }
} }
@ -458,9 +459,11 @@ void QUIHelper::setTranslator(const QString &qmFile)
} }
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
//Qt6中将相关类移到了core模块而且名字变了
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) #if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
#include <QtAndroidExtras> #include <QtAndroidExtras>
#else
//Qt6中将相关类移到了core模块而且名字变了
#include <QtCore/private/qandroidextras_p.h>
#endif #endif
#endif #endif
@ -476,6 +479,11 @@ bool QUIHelper::checkPermission(const QString &permission)
return false; return false;
} }
} }
#else
QFuture<QtAndroidPrivate::PermissionResult> result = QtAndroidPrivate::requestPermission(permission);
if (result.resultAt(0) == QtAndroidPrivate::PermissionResult::Denied) {
return false;
}
#endif #endif
#endif #endif
return true; return true;
@ -544,6 +552,26 @@ void QUIHelper::initMain(bool desktopSettingsAware, bool useOpenGLES)
#endif #endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
//win上获取显卡是否被禁用(禁用则必须启用OpenGLES)
#ifdef Q_OS_WIN
QProcess p;
QStringList args;
args << "path" << "win32_VideoController" << "get" << "name,Status";
p.start("wmic", args);
p.waitForFinished(1000);
QString result = QString::fromLocal8Bit(p.readAllStandardOutput());
result.replace("\r", "");
result.replace("\n", "");
result = result.simplified();
result = result.trimmed();
//Name Status Intel(R) UHD Graphics 630 OK
//Name Status Intel(R) UHD Graphics 630 Error
//QStringList list = result.split(" ");
if (result.contains("Error")) {
useOpenGLES = true;
}
#endif
//设置opengl模式 AA_UseDesktopOpenGL(默认) AA_UseOpenGLES AA_UseSoftwareOpenGL //设置opengl模式 AA_UseDesktopOpenGL(默认) AA_UseOpenGLES AA_UseSoftwareOpenGL
//在一些很旧的设备上或者对opengl支持很低的设备上需要使用AA_UseOpenGLES表示禁用硬件加速 //在一些很旧的设备上或者对opengl支持很低的设备上需要使用AA_UseOpenGLES表示禁用硬件加速
//如果开启的是AA_UseOpenGLES则无法使用硬件加速比如ffmpeg的dxva2 //如果开启的是AA_UseOpenGLES则无法使用硬件加速比如ffmpeg的dxva2
@ -619,41 +647,41 @@ void QUIHelper::setFramelessForm(QWidget *widgetMain, bool tool, bool top, bool
} }
} }
int QUIHelper::showMessageBox(const QString &info, int type, int closeSec, bool exec) int QUIHelper::showMessageBox(const QString &text, int type, int closeSec, bool exec)
{ {
int result = 0; int result = 0;
if (type == 0) { if (type == 0) {
showMessageBoxInfo(info, closeSec, exec); showMessageBoxInfo(text, closeSec, exec);
} else if (type == 1) { } else if (type == 1) {
showMessageBoxError(info, closeSec, exec); showMessageBoxError(text, closeSec, exec);
} else if (type == 2) { } else if (type == 2) {
result = showMessageBoxQuestion(info); result = showMessageBoxQuestion(text);
} }
return result; return result;
} }
void QUIHelper::showMessageBoxInfo(const QString &info, int closeSec, bool exec) void QUIHelper::showMessageBoxInfo(const QString &text, int closeSec, bool exec)
{ {
QMessageBox box(QMessageBox::Information, "提示", info); QMessageBox box(QMessageBox::Information, "提示", text);
box.setStandardButtons(QMessageBox::Yes); box.setStandardButtons(QMessageBox::Yes);
box.setButtonText(QMessageBox::Yes, QString("确 定")); box.setButtonText(QMessageBox::Yes, QString("确 定"));
box.exec(); box.exec();
//QMessageBox::information(0, "提示", info, QMessageBox::Yes); //QMessageBox::information(0, "提示", info, QMessageBox::Yes);
} }
void QUIHelper::showMessageBoxError(const QString &info, int closeSec, bool exec) void QUIHelper::showMessageBoxError(const QString &text, int closeSec, bool exec)
{ {
QMessageBox box(QMessageBox::Critical, "错误", info); QMessageBox box(QMessageBox::Critical, "错误", text);
box.setStandardButtons(QMessageBox::Yes); box.setStandardButtons(QMessageBox::Yes);
box.setButtonText(QMessageBox::Yes, QString("确 定")); box.setButtonText(QMessageBox::Yes, QString("确 定"));
box.exec(); box.exec();
//QMessageBox::critical(0, "错误", info, QMessageBox::Yes); //QMessageBox::critical(0, "错误", info, QMessageBox::Yes);
} }
int QUIHelper::showMessageBoxQuestion(const QString &info) int QUIHelper::showMessageBoxQuestion(const QString &text)
{ {
QMessageBox box(QMessageBox::Question, "询问", info); QMessageBox box(QMessageBox::Question, "询问", text);
box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
box.setButtonText(QMessageBox::Yes, QString("确 定")); box.setButtonText(QMessageBox::Yes, QString("确 定"));
box.setButtonText(QMessageBox::No, QString("取 消")); box.setButtonText(QMessageBox::No, QString("取 消"));
@ -770,8 +798,8 @@ QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key)
result = result.mid(8, result.length() - 9); result = result.mid(8, result.length() - 9);
} }
int count = result.count(); int size = result.size();
for (int i = 0; i < count; ++i) { for (int i = 0; i < size; ++i) {
result[i] = QChar(result.at(i).toLatin1() ^ key); result[i] = QChar(result.at(i).toLatin1() ^ key);
} }
return result; return result;
@ -873,7 +901,7 @@ bool QUIHelper::checkIniFile(const QString &iniFile)
line.replace("\n", ""); line.replace("\n", "");
QStringList list = line.split("="); QStringList list = line.split("=");
if (list.count() == 2) { if (list.size() == 2) {
QString key = list.at(0); QString key = list.at(0);
QString value = list.at(1); QString value = list.at(1);
if (value.isEmpty()) { if (value.isEmpty()) {

View File

@ -88,13 +88,13 @@ public:
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);
//弹出框 //弹出框
static int showMessageBox(const QString &info, int type = 0, int closeSec = 0, bool exec = false); static int showMessageBox(const QString &text, int type = 0, int closeSec = 0, bool exec = false);
//弹出消息框 //弹出消息框
static void showMessageBoxInfo(const QString &info, int closeSec = 0, bool exec = false); static void showMessageBoxInfo(const QString &text, int closeSec = 0, bool exec = false);
//弹出错误框 //弹出错误框
static void showMessageBoxError(const QString &info, int closeSec = 0, bool exec = false); static void showMessageBoxError(const QString &text, int closeSec = 0, bool exec = false);
//弹出询问框 //弹出询问框
static int showMessageBoxQuestion(const QString &info); static int showMessageBoxQuestion(const QString &text);
//为什么还要自定义对话框因为可控宽高和汉化对应文本等 //为什么还要自定义对话框因为可控宽高和汉化对应文本等
//初始化对话框文本 //初始化对话框文本

View File

@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) { if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile); int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId); QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.size() == 0) { if (listName.count() == 0) {
qDebug() << QString("load %1 error").arg(fontName); qDebug() << QString("load %1 error").arg(fontName);
} }
} }
@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor) void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{ {
int btnCount = btns.size(); int btnCount = btns.count();
int iconCount = icons.size(); int iconCount = icons.count();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) { if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return; return;
} }
@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的 //可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) { for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.size(); j++) { for (int j = 0; j < this->btns.count(); j++) {
if (this->btns.at(j) == btns.at(i)) { if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this); this->btns.at(j)->removeEventFilter(this);

View File

@ -37,7 +37,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//超过一个子元素则添加子菜单 //超过一个子元素则添加子菜单
QMenu *menuSub; QMenu *menuSub;
if (flags.size() > 1) { if (flags.count() > 1) {
menuSub = menu->addMenu(name); menuSub = menu->addMenu(name);
} else { } else {
menuSub = menu; menuSub = menu;
@ -50,7 +50,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//对应菜单文本 //对应菜单文本
QString text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end); QString text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end);
if (flags.size() == 1) { if (flags.count() == 1) {
text = name; text = name;
} }
@ -76,7 +76,7 @@ void VideoBox::setLayout(QGridLayout *gridLayout)
void VideoBox::setWidgets(QWidgetList widgets) void VideoBox::setWidgets(QWidgetList widgets)
{ {
this->widgets = widgets; this->widgets = widgets;
this->videoCount = widgets.size(); this->videoCount = widgets.count();
} }
void VideoBox::setMenuFlag(const QString &menuFlag) void VideoBox::setMenuFlag(const QString &menuFlag)
@ -97,7 +97,7 @@ void VideoBox::setTypes(const QMap<int, QStringList> &types)
void VideoBox::initMenu(QMenu *menu, const QList<bool> &enable) void VideoBox::initMenu(QMenu *menu, const QList<bool> &enable)
{ {
//通过菜单是否可见设置每个菜单可见与否 //通过菜单是否可见设置每个菜单可见与否
if (enable.size() < 9) { if (enable.count() < 9) {
return; return;
} }
@ -255,7 +255,7 @@ void VideoBox::change_video_custom(int index, int type)
void VideoBox::change_video_6(const QList<int> &indexs) void VideoBox::change_video_6(const QList<int> &indexs)
{ {
//过滤防止索引越界 //过滤防止索引越界
if (indexs.size() < 6) { if (indexs.count() < 6) {
return; return;
} }
@ -277,7 +277,7 @@ void VideoBox::change_video_6(const QList<int> &indexs)
void VideoBox::change_video_8(const QList<int> &indexs) void VideoBox::change_video_8(const QList<int> &indexs)
{ {
//过滤防止索引越界 //过滤防止索引越界
if (indexs.size() < 8) { if (indexs.count() < 8) {
return; return;
} }
@ -301,7 +301,7 @@ void VideoBox::change_video_8(const QList<int> &indexs)
void VideoBox::change_video_13(const QList<int> &indexs) void VideoBox::change_video_13(const QList<int> &indexs)
{ {
//过滤防止索引越界 //过滤防止索引越界
if (indexs.size() < 13) { if (indexs.count() < 13) {
return; return;
} }

View File

@ -37,7 +37,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//超过一个子元素则添加子菜单 //超过一个子元素则添加子菜单
QMenu *menuSub; QMenu *menuSub;
if (flags.size() > 1) { if (flags.count() > 1) {
menuSub = menu->addMenu(name); menuSub = menu->addMenu(name);
} else { } else {
menuSub = menu; menuSub = menu;
@ -50,7 +50,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//对应菜单文本 //对应菜单文本
QString text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end); QString text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end);
if (flags.size() == 1) { if (flags.count() == 1) {
text = name; text = name;
} }
@ -76,7 +76,7 @@ void VideoBox::setLayout(QGridLayout *gridLayout)
void VideoBox::setWidgets(QWidgetList widgets) void VideoBox::setWidgets(QWidgetList widgets)
{ {
this->widgets = widgets; this->widgets = widgets;
this->videoCount = widgets.size(); this->videoCount = widgets.count();
} }
void VideoBox::setMenuFlag(const QString &menuFlag) void VideoBox::setMenuFlag(const QString &menuFlag)
@ -97,7 +97,7 @@ void VideoBox::setTypes(const QMap<int, QStringList> &types)
void VideoBox::initMenu(QMenu *menu, const QList<bool> &enable) void VideoBox::initMenu(QMenu *menu, const QList<bool> &enable)
{ {
//通过菜单是否可见设置每个菜单可见与否 //通过菜单是否可见设置每个菜单可见与否
if (enable.size() < 9) { if (enable.count() < 9) {
return; return;
} }
@ -255,7 +255,7 @@ void VideoBox::change_video_custom(int index, int type)
void VideoBox::change_video_6(const QList<int> &indexs) void VideoBox::change_video_6(const QList<int> &indexs)
{ {
//过滤防止索引越界 //过滤防止索引越界
if (indexs.size() < 6) { if (indexs.count() < 6) {
return; return;
} }
@ -277,7 +277,7 @@ void VideoBox::change_video_6(const QList<int> &indexs)
void VideoBox::change_video_8(const QList<int> &indexs) void VideoBox::change_video_8(const QList<int> &indexs)
{ {
//过滤防止索引越界 //过滤防止索引越界
if (indexs.size() < 8) { if (indexs.count() < 8) {
return; return;
} }
@ -301,7 +301,7 @@ void VideoBox::change_video_8(const QList<int> &indexs)
void VideoBox::change_video_13(const QList<int> &indexs) void VideoBox::change_video_13(const QList<int> &indexs)
{ {
//过滤防止索引越界 //过滤防止索引越界
if (indexs.size() < 13) { if (indexs.count() < 13) {
return; return;
} }

View File

@ -109,7 +109,7 @@ void VideoWindow::initFlowPanel()
if (!fontDb.families().contains("iconfont")) { if (!fontDb.families().contains("iconfont")) {
int fontId = fontDb.addApplicationFont(":/font/iconfont.ttf"); int fontId = fontDb.addApplicationFont(":/font/iconfont.ttf");
QStringList fontName = fontDb.applicationFontFamilies(fontId); QStringList fontName = fontDb.applicationFontFamilies(fontId);
if (fontName.size() == 0) { if (fontName.count() == 0) {
qDebug() << "load iconfont.ttf error"; qDebug() << "load iconfont.ttf error";
} }
} }
@ -124,7 +124,7 @@ void VideoWindow::initFlowPanel()
#endif #endif
//循环添加顶部按钮 //循环添加顶部按钮
for (int i = 0; i < btns.size(); ++i) { for (int i = 0; i < btns.count(); ++i) {
QPushButton *btn = new QPushButton; QPushButton *btn = new QPushButton;
//绑定按钮单击事件,用来发出信号通知 //绑定按钮单击事件,用来发出信号通知
connect(btn, SIGNAL(clicked(bool)), this, SLOT(btnClicked())); connect(btn, SIGNAL(clicked(bool)), this, SLOT(btnClicked()));

View File

@ -17,7 +17,7 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) : QWidget(parent)
if (!fontDb.families().contains("FontAwesome")) { if (!fontDb.families().contains("FontAwesome")) {
int fontId = fontDb.addApplicationFont(":/font/fontawesome-webfont.ttf"); int fontId = fontDb.addApplicationFont(":/font/fontawesome-webfont.ttf");
QStringList fontName = fontDb.applicationFontFamilies(fontId); QStringList fontName = fontDb.applicationFontFamilies(fontId);
if (fontName.size() == 0) { if (fontName.count() == 0) {
qDebug() << "load fontawesome-webfont.ttf error"; qDebug() << "load fontawesome-webfont.ttf error";
} }
} }