更新代码
|
@ -29,8 +29,10 @@ DeviceSizeTable::DeviceSizeTable(QWidget *parent) : QTableWidget(parent)
|
||||||
textColor2 = QColor(255, 255, 255);
|
textColor2 = QColor(255, 255, 255);
|
||||||
textColor3 = QColor(255, 255, 255);
|
textColor3 = QColor(255, 255, 255);
|
||||||
|
|
||||||
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
|
||||||
process = new QProcess(this);
|
process = new QProcess(this);
|
||||||
connect(process, SIGNAL(readyRead()), this, SLOT(readData()));
|
connect(process, SIGNAL(readyRead()), this, SLOT(readData()));
|
||||||
|
#endif
|
||||||
|
|
||||||
this->clear();
|
this->clear();
|
||||||
|
|
||||||
|
@ -118,8 +120,7 @@ void DeviceSizeTable::load()
|
||||||
insertSize(dirName, use, free, all, percent);
|
insertSize(dirName, use, free, all, percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
|
||||||
#else
|
|
||||||
process->start("df", QStringList() << "-h");
|
process->start("df", QStringList() << "-h");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -182,6 +183,7 @@ void DeviceSizeTable::setTextColor3(const QColor &textColor3)
|
||||||
|
|
||||||
void DeviceSizeTable::readData()
|
void DeviceSizeTable::readData()
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
|
||||||
while (!process->atEnd()) {
|
while (!process->atEnd()) {
|
||||||
QString result = QLatin1String(process->readLine());
|
QString result = QLatin1String(process->readLine());
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
|
@ -206,6 +208,7 @@ void DeviceSizeTable::readData()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSizeTable::checkSize(const QString &result, const QString &name)
|
void DeviceSizeTable::checkSize(const QString &result, const QString &name)
|
||||||
|
@ -217,7 +220,7 @@ void DeviceSizeTable::checkSize(const QString &result, const QString &name)
|
||||||
|
|
||||||
for (int i = 0; i < list.count(); ++i) {
|
for (int i = 0; i < list.count(); ++i) {
|
||||||
QString s = list.at(i).trimmed();
|
QString s = list.at(i).trimmed();
|
||||||
if (s == "") {
|
if (s.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,12 @@ IconHelper *IconHelper::getIconHelper(int icon)
|
||||||
//由于部分值范围冲突所以可以指定索引来取
|
//由于部分值范围冲突所以可以指定索引来取
|
||||||
//fontawesome 0xf000-0xf2e0
|
//fontawesome 0xf000-0xf2e0
|
||||||
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
||||||
//iconfont 0xe501-0xe793 0xe8d5-0xea5d
|
//iconfont 0xe501-0xe793 0xe8d5-0xea5d 0xeb00-0xec00
|
||||||
//weather 0xe900-0xe9cf
|
//weather 0xe900-0xe9cf
|
||||||
|
|
||||||
IconHelper *iconHelper = iconFontAwesome;
|
IconHelper *iconHelper = iconFontAwesome;
|
||||||
if (iconFontIndex < 0) {
|
if (iconFontIndex < 0) {
|
||||||
if ((icon > 0xe501 && icon < 0xe793) || (icon > 0xe8d5 && icon < 0xea5d)) {
|
if ((icon >= 0xe501 && icon <= 0xe793) || (icon >= 0xe8d5 && icon <= 0xea5d) || (icon >= 0xeb00 && icon <= 0xec00)) {
|
||||||
iconHelper = iconFontAliBaBa;
|
iconHelper = iconFontAliBaBa;
|
||||||
}
|
}
|
||||||
} else if (iconFontIndex == 0) {
|
} else if (iconFontIndex == 0) {
|
||||||
|
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 167 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 142 KiB |
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 140 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 154 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 190 KiB |
After Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 308 KiB After Width: | Height: | Size: 225 KiB |
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 154 KiB |
After Width: | Height: | Size: 157 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 144 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 207 KiB |
Before Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 151 KiB |
Before Width: | Height: | Size: 287 KiB After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 271 KiB |
Before Width: | Height: | Size: 296 KiB |
Before Width: | Height: | Size: 268 KiB |
|
@ -64,12 +64,12 @@ IconHelper *IconHelper::getIconHelper(int icon)
|
||||||
//由于部分值范围冲突所以可以指定索引来取
|
//由于部分值范围冲突所以可以指定索引来取
|
||||||
//fontawesome 0xf000-0xf2e0
|
//fontawesome 0xf000-0xf2e0
|
||||||
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
||||||
//iconfont 0xe501-0xe793 0xe8d5-0xea5d
|
//iconfont 0xe501-0xe793 0xe8d5-0xea5d 0xeb00-0xec00
|
||||||
//weather 0xe900-0xe9cf
|
//weather 0xe900-0xe9cf
|
||||||
|
|
||||||
IconHelper *iconHelper = iconFontAwesome;
|
IconHelper *iconHelper = iconFontAwesome;
|
||||||
if (iconFontIndex < 0) {
|
if (iconFontIndex < 0) {
|
||||||
if ((icon > 0xe501 && icon < 0xe793) || (icon > 0xe8d5 && icon < 0xea5d)) {
|
if ((icon >= 0xe501 && icon <= 0xe793) || (icon >= 0xe8d5 && icon <= 0xea5d) || (icon >= 0xeb00 && icon <= 0xec00)) {
|
||||||
iconHelper = iconFontAliBaBa;
|
iconHelper = iconFontAliBaBa;
|
||||||
}
|
}
|
||||||
} else if (iconFontIndex == 0) {
|
} else if (iconFontIndex == 0) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "qapplication.h"
|
#include "qapplication.h"
|
||||||
#include "qevent.h"
|
#include "qevent.h"
|
||||||
#include "qwidget.h"
|
#include "qwidget.h"
|
||||||
|
#include "qdebug.h"
|
||||||
|
|
||||||
QScopedPointer<AppInit> AppInit::self;
|
QScopedPointer<AppInit> AppInit::self;
|
||||||
AppInit *AppInit::Instance()
|
AppInit *AppInit::Instance()
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
QT += network
|
QT += network
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||||
|
lessThan(QT_MAJOR_VERSION, 6) {
|
||||||
|
android {QT += androidextras}
|
||||||
|
}}
|
||||||
|
|
||||||
#指定编译产生的文件分门别类放到对应目录
|
#指定编译产生的文件分门别类放到对应目录
|
||||||
MOC_DIR = temp/moc
|
MOC_DIR = temp/moc
|
||||||
RCC_DIR = temp/rcc
|
RCC_DIR = temp/rcc
|
||||||
|
@ -22,20 +27,26 @@ CONFIG += resources_big
|
||||||
|
|
||||||
#引入全志H3芯片依赖
|
#引入全志H3芯片依赖
|
||||||
include ($$PWD/h3.pri)
|
include ($$PWD/h3.pri)
|
||||||
|
#将当前目录加入到头文件路径
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += $$PWD/appdata.h
|
||||||
$$PWD/appdata.h \
|
SOURCES += $$PWD/appdata.cpp
|
||||||
$$PWD/appinit.h \
|
|
||||||
$$PWD/base64helper.h \
|
|
||||||
$$PWD/iconhelper.h \
|
|
||||||
$$PWD/quihelper.h
|
|
||||||
|
|
||||||
SOURCES += \
|
HEADERS += $$PWD/appinit.h
|
||||||
$$PWD/appdata.cpp \
|
SOURCES += $$PWD/appinit.cpp
|
||||||
$$PWD/appinit.cpp \
|
|
||||||
$$PWD/base64helper.cpp \
|
HEADERS += $$PWD/base64helper.h
|
||||||
$$PWD/iconhelper.cpp \
|
SOURCES += $$PWD/base64helper.cpp
|
||||||
$$PWD/quihelper.cpp
|
|
||||||
|
HEADERS += $$PWD/customstyle.h
|
||||||
|
SOURCES += $$PWD/customstyle.cpp
|
||||||
|
|
||||||
|
HEADERS += $$PWD/iconhelper.h
|
||||||
|
SOURCES += $$PWD/iconhelper.cpp
|
||||||
|
|
||||||
|
HEADERS += $$PWD/quihelper.h
|
||||||
|
SOURCES += $$PWD/quihelper.cpp
|
||||||
|
|
||||||
#可以指定不加载对应的资源文件
|
#可以指定不加载对应的资源文件
|
||||||
!contains(DEFINES, no_qrc_image) {
|
!contains(DEFINES, no_qrc_image) {
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include "customstyle.h"
|
||||||
|
#include "qapplication.h"
|
||||||
|
#include "qpalette.h"
|
||||||
|
|
||||||
|
void CustomStyle::initStyle(int fontSize, int radioButtonSize, int checkBoxSize, int sliderHeight)
|
||||||
|
{
|
||||||
|
if (fontSize <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList list;
|
||||||
|
//全局字体
|
||||||
|
list << QString("*{font-size:%1px;}").arg(fontSize);
|
||||||
|
//单选框
|
||||||
|
list << QString("QRadioButton::indicator{width:%1px;height:%1px;}").arg(radioButtonSize);
|
||||||
|
//复选框
|
||||||
|
list << QString("QCheckBox::indicator,QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{width:%1px;height:%1px;}").arg(checkBoxSize);
|
||||||
|
|
||||||
|
//滑块颜色
|
||||||
|
#if 0
|
||||||
|
QString normalColor = "#e3e3e3";
|
||||||
|
QString grooveColor = "#0078d7";
|
||||||
|
QString handleColor = "#FFFFFF";
|
||||||
|
QString borderColor = "#9B9B9B";
|
||||||
|
#else
|
||||||
|
QPalette palette;
|
||||||
|
for (int i = 0; i < 21; ++i) {
|
||||||
|
//qDebug() << i << palette.color((QPalette::ColorRole)i).name();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString normalColor = palette.color(QPalette::Midlight).name();
|
||||||
|
QString grooveColor = palette.color(QPalette::Highlight).name();
|
||||||
|
QString handleColor = palette.color(QPalette::Light).name();
|
||||||
|
QString borderColor = palette.color(QPalette::Shadow).name();
|
||||||
|
#endif
|
||||||
|
int sliderRadius = sliderHeight / 2;
|
||||||
|
int handleWidth = (sliderHeight * 3) / 2 + (sliderHeight / 5);
|
||||||
|
int handleRadius = handleWidth / 2 + 1;
|
||||||
|
int handleOffset = handleRadius / 2;
|
||||||
|
|
||||||
|
//横向滑块
|
||||||
|
list << QString("QSlider::horizontal{min-height:%1px;}").arg(sliderHeight * 2);
|
||||||
|
list << QString("QSlider::groove:horizontal{background:%1;height:%2px;border-radius:%3px;}")
|
||||||
|
.arg(normalColor).arg(sliderHeight).arg(sliderRadius);
|
||||||
|
list << QString("QSlider::add-page:horizontal{background:%1;height:%2px;border-radius:%3px;}")
|
||||||
|
.arg(normalColor).arg(sliderHeight).arg(sliderRadius);
|
||||||
|
list << QString("QSlider::sub-page:horizontal{background:%1;height:%2px;border-radius:%3px;}")
|
||||||
|
.arg(grooveColor).arg(sliderHeight).arg(sliderRadius);
|
||||||
|
list << QString("QSlider::handle:horizontal{border:1px solid %5;width:%2px;margin-top:-%3px;margin-bottom:-%3px;border-radius:%4px;"
|
||||||
|
"background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #FFFFFF,stop:0.8 %1);}")
|
||||||
|
.arg(handleColor).arg(handleWidth).arg(handleOffset).arg(handleRadius).arg(borderColor);
|
||||||
|
|
||||||
|
//垂直滑块
|
||||||
|
list << QString("QSlider::vertical{min-width:%1px;}").arg(sliderHeight * 2);
|
||||||
|
list << QString("QSlider::groove:vertical{background:%1;width:%2px;border-radius:%3px;}")
|
||||||
|
.arg(normalColor).arg(sliderHeight).arg(sliderRadius);
|
||||||
|
list << QString("QSlider::add-page:vertical{background:%1;width:%2px;border-radius:%3px;}")
|
||||||
|
.arg(grooveColor).arg(sliderHeight).arg(sliderRadius);
|
||||||
|
list << QString("QSlider::sub-page:vertical{background:%1;width:%2px;border-radius:%3px;}")
|
||||||
|
.arg(normalColor).arg(sliderHeight).arg(sliderRadius);
|
||||||
|
list << QString("QSlider::handle:vertical{border:1px solid %5;height:%2px;margin-left:-%3px;margin-right:-%3px;border-radius:%4px;"
|
||||||
|
"background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #FFFFFF,stop:0.8 %1);}")
|
||||||
|
.arg(handleColor).arg(handleWidth).arg(handleOffset).arg(handleRadius).arg(borderColor);
|
||||||
|
|
||||||
|
qApp->setStyleSheet(list.join(""));
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef CUSTOMSTYLE_H
|
||||||
|
#define CUSTOMSTYLE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class CustomStyle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//全局样式比如放大选择器
|
||||||
|
static void initStyle(int fontSize = 15, int radioButtonSize = 18, int checkBoxSize = 16, int sliderHeight = 13);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CUSTOMSTYLE_H
|
|
@ -1,6 +1,7 @@
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
|
contains(QT_ARCH, arm) {
|
||||||
contains(DEFINES, arma7) {
|
contains(DEFINES, arma7) {
|
||||||
INCLUDEPATH += /usr/local/openssl-1.0.2m-h3-gcc-4.9.2/include
|
INCLUDEPATH += /usr/local/openssl-1.0.2m-h3-gcc-4.9.2/include
|
||||||
LIBS += -L/usr/local/openssl-1.0.2m-h3-gcc-4.9.2/lib -lssl -lcrypto
|
LIBS += -L/usr/local/openssl-1.0.2m-h3-gcc-4.9.2/lib -lssl -lcrypto
|
||||||
LIBS += -L/usr/local/h3_rootfsv -lXdmcp
|
LIBS += -L/usr/local/h3_rootfsv -lXdmcp
|
||||||
}}
|
}}}
|
||||||
|
|
|
@ -64,12 +64,12 @@ IconHelper *IconHelper::getIconHelper(int icon)
|
||||||
//由于部分值范围冲突所以可以指定索引来取
|
//由于部分值范围冲突所以可以指定索引来取
|
||||||
//fontawesome 0xf000-0xf2e0
|
//fontawesome 0xf000-0xf2e0
|
||||||
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
||||||
//iconfont 0xe501-0xe793 0xe8d5-0xea5d
|
//iconfont 0xe501-0xe793 0xe8d5-0xea5d 0xeb00-0xec00
|
||||||
//weather 0xe900-0xe9cf
|
//weather 0xe900-0xe9cf
|
||||||
|
|
||||||
IconHelper *iconHelper = iconFontAwesome;
|
IconHelper *iconHelper = iconFontAwesome;
|
||||||
if (iconFontIndex < 0) {
|
if (iconFontIndex < 0) {
|
||||||
if ((icon > 0xe501 && icon < 0xe793) || (icon > 0xe8d5 && icon < 0xea5d)) {
|
if ((icon >= 0xe501 && icon <= 0xe793) || (icon >= 0xe8d5 && icon <= 0xea5d) || (icon >= 0xeb00 && icon <= 0xec00)) {
|
||||||
iconHelper = iconFontAliBaBa;
|
iconHelper = iconFontAliBaBa;
|
||||||
}
|
}
|
||||||
} else if (iconFontIndex == 0) {
|
} else if (iconFontIndex == 0) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "qnetworkproxy.h"
|
#include "qnetworkproxy.h"
|
||||||
|
|
||||||
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
|
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
|
||||||
|
|
||||||
int QUIHelper::getScreenIndex()
|
int QUIHelper::getScreenIndex()
|
||||||
{
|
{
|
||||||
//需要对多个屏幕进行处理
|
//需要对多个屏幕进行处理
|
||||||
|
@ -50,6 +51,38 @@ QRect QUIHelper::getScreenRect(bool available)
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal QUIHelper::getScreenRatio(bool devicePixel)
|
||||||
|
{
|
||||||
|
qreal ratio = 1.0;
|
||||||
|
int screenIndex = getScreenIndex();
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||||
|
QScreen *screen = qApp->screens().at(screenIndex);
|
||||||
|
if (devicePixel) {
|
||||||
|
//需要开启 AA_EnableHighDpiScaling 属性才能正常获取
|
||||||
|
ratio = screen->devicePixelRatio() * 100;
|
||||||
|
} else {
|
||||||
|
ratio = screen->logicalDotsPerInch();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
//Qt4不能动态识别缩放更改后的值
|
||||||
|
ratio = qApp->desktop()->screen(screenIndex)->logicalDpiX();
|
||||||
|
#endif
|
||||||
|
return ratio / 96;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect QUIHelper::checkCenterRect(QRect &rect, bool available)
|
||||||
|
{
|
||||||
|
QRect deskRect = QUIHelper::getScreenRect(available);
|
||||||
|
int formWidth = rect.width();
|
||||||
|
int formHeight = rect.height();
|
||||||
|
int deskWidth = deskRect.width();
|
||||||
|
int deskHeight = deskRect.height();
|
||||||
|
int formX = deskWidth / 2 - formWidth / 2 + deskRect.x();
|
||||||
|
int formY = deskHeight / 2 - formHeight / 2;
|
||||||
|
rect = QRect(formX, formY, formWidth, formHeight);
|
||||||
|
return deskRect;
|
||||||
|
}
|
||||||
|
|
||||||
int QUIHelper::deskWidth()
|
int QUIHelper::deskWidth()
|
||||||
{
|
{
|
||||||
return getScreenRect().width();
|
return getScreenRect().width();
|
||||||
|
@ -137,7 +170,7 @@ QStringList QUIHelper::getLocalIPs()
|
||||||
ips << "127.0.0.1";
|
ips << "127.0.0.1";
|
||||||
#else
|
#else
|
||||||
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
|
||||||
foreach (const QNetworkInterface &netInterface, netInterfaces) {
|
foreach (QNetworkInterface netInterface, netInterfaces) {
|
||||||
//移除虚拟机和抓包工具的虚拟网卡
|
//移除虚拟机和抓包工具的虚拟网卡
|
||||||
QString humanReadableName = netInterface.humanReadableName().toLower();
|
QString humanReadableName = netInterface.humanReadableName().toLower();
|
||||||
if (humanReadableName.startsWith("vmware network adapter") || humanReadableName.startsWith("npcap loopback adapter")) {
|
if (humanReadableName.startsWith("vmware network adapter") || humanReadableName.startsWith("npcap loopback adapter")) {
|
||||||
|
@ -276,6 +309,11 @@ QStringList QUIHelper::getRandPoint(int count, float mainLng, float mainLat, flo
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QUIHelper::getRangeValue(int oldMin, int oldMax, int oldValue, int newMin, int newMax)
|
||||||
|
{
|
||||||
|
return (((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin;
|
||||||
|
}
|
||||||
|
|
||||||
QString QUIHelper::getUuid()
|
QString QUIHelper::getUuid()
|
||||||
{
|
{
|
||||||
QString uuid = QUuid::createUuid().toString();
|
QString uuid = QUuid::createUuid().toString();
|
||||||
|
@ -284,19 +322,21 @@ QString QUIHelper::getUuid()
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QUIHelper::newDir(const QString &dirName)
|
void QUIHelper::checkPath(const QString &dirName)
|
||||||
{
|
{
|
||||||
QString strDir = dirName;
|
//相对路径需要补全完整路径
|
||||||
|
QString path = dirName;
|
||||||
//如果路径中包含斜杠字符则说明是绝对路径
|
if (path.startsWith("./")) {
|
||||||
//linux系统路径字符带有 / windows系统 路径字符带有 :/
|
path.replace(".", "");
|
||||||
if (!strDir.startsWith("/") && !strDir.contains(":/")) {
|
path = QUIHelper::appPath() + path;
|
||||||
strDir = QString("%1/%2").arg(QUIHelper::appPath()).arg(strDir);
|
} else if (!path.startsWith("/") && !path.contains(":/")) {
|
||||||
|
path = QUIHelper::appPath() + "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir dir(strDir);
|
//目录不存在则新建
|
||||||
|
QDir dir(path);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.mkpath(strDir);
|
dir.mkpath(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,30 +457,74 @@ void QUIHelper::setTranslator(const QString &qmFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
//Qt6中将相关类移到了core模块而且名字变了
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
||||||
|
#include <QtAndroidExtras>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool QUIHelper::checkPermission(const QString &permission)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
||||||
|
QtAndroid::PermissionResult result = QtAndroid::checkPermission(permission);
|
||||||
|
if (result == QtAndroid::PermissionResult::Denied) {
|
||||||
|
QtAndroid::requestPermissionsSync(QStringList() << permission);
|
||||||
|
result = QtAndroid::checkPermission(permission);
|
||||||
|
if (result == QtAndroid::PermissionResult::Denied) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QUIHelper::initAndroidPermission()
|
||||||
|
{
|
||||||
|
//可以把所有要动态申请的权限都写在这里
|
||||||
|
checkPermission("android.permission.CALL_PHONE");
|
||||||
|
checkPermission("android.permission.SEND_SMS");
|
||||||
|
checkPermission("android.permission.CAMERA");
|
||||||
|
checkPermission("android.permission.READ_EXTERNAL_STORAGE");
|
||||||
|
checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
|
||||||
|
|
||||||
|
checkPermission("android.permission.ACCESS_COARSE_LOCATION");
|
||||||
|
checkPermission("android.permission.BLUETOOTH");
|
||||||
|
checkPermission("android.permission.BLUETOOTH_SCAN");
|
||||||
|
checkPermission("android.permission.BLUETOOTH_CONNECT");
|
||||||
|
checkPermission("android.permission.BLUETOOTH_ADVERTISE");
|
||||||
|
}
|
||||||
|
|
||||||
void QUIHelper::initAll(bool utf8, bool style, int fontSize)
|
void QUIHelper::initAll(bool utf8, bool style, int fontSize)
|
||||||
{
|
{
|
||||||
|
//初始化安卓权限
|
||||||
|
QUIHelper::initAndroidPermission();
|
||||||
//初始化随机数种子
|
//初始化随机数种子
|
||||||
QUIHelper::initRand();
|
QUIHelper::initRand();
|
||||||
//设置编码
|
//设置编码
|
||||||
QUIHelper::setCode(utf8);
|
QUIHelper::setCode(utf8);
|
||||||
|
//设置字体
|
||||||
|
QUIHelper::setFont(fontSize);
|
||||||
//设置样式风格
|
//设置样式风格
|
||||||
if (style) {
|
if (style) {
|
||||||
QUIHelper::setStyle();
|
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");
|
||||||
|
|
||||||
//设置不使用本地系统环境代理配置
|
//设置不使用本地系统环境代理配置
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QUIHelper::initMain(bool on)
|
void QUIHelper::initMain(bool desktopSettingsAware, bool useOpenGLES)
|
||||||
{
|
{
|
||||||
//设置是否应用操作系统设置比如字体
|
//设置是否应用操作系统设置比如字体
|
||||||
QApplication::setDesktopSettingsAware(on);
|
QApplication::setDesktopSettingsAware(desktopSettingsAware);
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
|
||||||
|
@ -463,14 +547,17 @@ void QUIHelper::initMain(bool on)
|
||||||
//设置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
|
||||||
//QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
if (useOpenGLES) {
|
||||||
|
QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||||
|
}
|
||||||
|
|
||||||
//设置opengl共享上下文
|
//设置opengl共享上下文
|
||||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<int> QUIHelper::msgTypes = QVector<int>() << 0 << 1 << 2 << 3 << 4;
|
QVector<int> QUIHelper::msgTypes = QVector<int>() << 0 << 1 << 2 << 3 << 4;
|
||||||
QVector<QString> QUIHelper::msgKeys = QVector<QString>() << "发送" << "接收" << "解析" << "错误" << "提示";
|
QVector<QString> QUIHelper::msgKeys = QVector<QString>() << QString::fromUtf8("发送") << QString::fromUtf8("接收") << QString::fromUtf8("解析") << QString::fromUtf8("错误") << QString::fromUtf8("提示");
|
||||||
QVector<QColor> QUIHelper::msgColors = QVector<QColor>() << QColor("#3BA372") << QColor("#EE6668") << QColor("#9861B4") << QColor("#FA8359") << QColor("#22A3A9");
|
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 ¤tCount, bool clear, bool pause)
|
QString QUIHelper::appendMsg(QTextEdit *textEdit, int type, const QString &data, int maxCount, int ¤tCount, bool clear, bool pause)
|
||||||
{
|
{
|
||||||
|
@ -690,10 +777,10 @@ QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar QUIHelper::getOrCode(const QByteArray &data)
|
quint8 QUIHelper::getOrCode(const QByteArray &data)
|
||||||
{
|
{
|
||||||
int len = data.length();
|
int len = data.length();
|
||||||
uchar result = 0;
|
quint8 result = 0;
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
result ^= data.at(i);
|
result ^= data.at(i);
|
||||||
}
|
}
|
||||||
|
@ -701,11 +788,11 @@ uchar QUIHelper::getOrCode(const QByteArray &data)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar QUIHelper::getCheckCode(const QByteArray &data)
|
quint8 QUIHelper::getCheckCode(const QByteArray &data)
|
||||||
{
|
{
|
||||||
int len = data.length();
|
int len = data.length();
|
||||||
uchar temp = 0;
|
quint8 temp = 0;
|
||||||
for (uchar i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
temp += data.at(i);
|
temp += data.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,12 +894,85 @@ bool QUIHelper::checkIniFile(const QString &iniFile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QUIHelper::cutString(const QString &text, int len, int left, int right, const QString &mid)
|
QString QUIHelper::cutString(const QString &text, int len, int left, int right, bool file, const QString &mid)
|
||||||
{
|
{
|
||||||
//如果是文件名则取文件名的前字符+末尾字符+去掉拓展名
|
//如果指定了字符串分割则表示是文件名需要去掉拓展名
|
||||||
QString result = text.split(".").first();
|
QString result = text;
|
||||||
|
if (file && result.contains(".")) {
|
||||||
|
int index = result.lastIndexOf(".");
|
||||||
|
result = result.mid(0, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
//最终字符串格式为 前缀字符...后缀字符
|
||||||
if (result.length() > len) {
|
if (result.length() > len) {
|
||||||
result = QString("%1%2%3").arg(result.left(left)).arg(mid).arg(result.right(right));
|
result = QString("%1%2%3").arg(result.left(left)).arg(mid).arg(result.right(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect QUIHelper::getCenterRect(const QSize &imageSize, const QRect &widgetRect, int borderWidth, int scaleMode)
|
||||||
|
{
|
||||||
|
QSize newSize = imageSize;
|
||||||
|
QSize widgetSize = widgetRect.size() - QSize(borderWidth * 1, borderWidth * 1);
|
||||||
|
|
||||||
|
if (scaleMode == 0) {
|
||||||
|
if (newSize.width() > widgetSize.width() || newSize.height() > widgetSize.height()) {
|
||||||
|
newSize.scale(widgetSize, Qt::KeepAspectRatio);
|
||||||
|
}
|
||||||
|
} else if (scaleMode == 1) {
|
||||||
|
newSize.scale(widgetSize, Qt::KeepAspectRatio);
|
||||||
|
} else {
|
||||||
|
newSize = widgetSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = widgetRect.center().x() - newSize.width() / 2;
|
||||||
|
int y = widgetRect.center().y() - newSize.height() / 2;
|
||||||
|
//不是2的倍数需要偏移1像素
|
||||||
|
x += (x % 2 == 0 ? 1 : 0);
|
||||||
|
y += (y % 2 == 0 ? 1 : 0);
|
||||||
|
return QRect(x, y, newSize.width(), newSize.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QUIHelper::getScaledImage(QImage &image, const QSize &widgetSize, int scaleMode, bool fast)
|
||||||
|
{
|
||||||
|
Qt::TransformationMode mode = fast ? Qt::FastTransformation : Qt::SmoothTransformation;
|
||||||
|
if (scaleMode == 0) {
|
||||||
|
if (image.width() > widgetSize.width() || image.height() > widgetSize.height()) {
|
||||||
|
image = image.scaled(widgetSize, Qt::KeepAspectRatio, mode);
|
||||||
|
}
|
||||||
|
} else if (scaleMode == 1) {
|
||||||
|
image = image.scaled(widgetSize, Qt::KeepAspectRatio, mode);
|
||||||
|
} else {
|
||||||
|
image = image.scaled(widgetSize, Qt::IgnoreAspectRatio, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QUIHelper::getTimeString(qint64 time)
|
||||||
|
{
|
||||||
|
time = time / 1000;
|
||||||
|
QString min = QString("%1").arg(time / 60, 2, 10, QChar('0'));
|
||||||
|
QString sec = QString("%2").arg(time % 60, 2, 10, QChar('0'));
|
||||||
|
return QString("%1:%2").arg(min).arg(sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QUIHelper::getTimeString(QElapsedTimer timer)
|
||||||
|
{
|
||||||
|
return QString::number((float)timer.elapsed() / 1000, 'f', 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QUIHelper::getSizeString(quint64 size)
|
||||||
|
{
|
||||||
|
float num = size;
|
||||||
|
QStringList list;
|
||||||
|
list << "KB" << "MB" << "GB" << "TB";
|
||||||
|
|
||||||
|
QString unit("bytes");
|
||||||
|
QStringListIterator i(list);
|
||||||
|
while (num >= 1024.0 && i.hasNext()) {
|
||||||
|
unit = i.next();
|
||||||
|
num /= 1024.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("%1 %2").arg(QString::number(num, 'f', 2)).arg(unit);
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,12 @@
|
||||||
class QUIHelper
|
class QUIHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//获取当前鼠标所在屏幕索引+尺寸
|
//获取当前鼠标所在屏幕索引/区域尺寸/缩放系数
|
||||||
static int getScreenIndex();
|
static int getScreenIndex();
|
||||||
static QRect getScreenRect(bool available = true);
|
static QRect getScreenRect(bool available = true);
|
||||||
|
static qreal getScreenRatio(bool devicePixel = false);
|
||||||
|
//矫正当前鼠标所在屏幕居中尺寸
|
||||||
|
static QRect checkCenterRect(QRect &rect, bool available = true);
|
||||||
|
|
||||||
//获取桌面宽度高度+居中显示
|
//获取桌面宽度高度+居中显示
|
||||||
static int deskWidth();
|
static int deskWidth();
|
||||||
|
@ -43,11 +46,13 @@ public:
|
||||||
static double getRandValue(int min, int max, bool contansMin = false, bool contansMax = false);
|
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);
|
static QStringList getRandPoint(int count, float mainLng, float mainLat, float dotLng, float dotLat);
|
||||||
|
//根据旧的范围值和值计算新的范围值对应的值
|
||||||
|
static int getRangeValue(int oldMin, int oldMax, int oldValue, int newMin, int newMax);
|
||||||
|
|
||||||
//获取uuid
|
//获取uuid
|
||||||
static QString getUuid();
|
static QString getUuid();
|
||||||
//可执行文件目录下新建目录
|
//校验目录
|
||||||
static void newDir(const QString &dirName);
|
static void checkPath(const QString &dirName);
|
||||||
//延时
|
//延时
|
||||||
static void sleep(int msec);
|
static void sleep(int msec);
|
||||||
|
|
||||||
|
@ -61,10 +66,15 @@ public:
|
||||||
//设置翻译文件
|
//设置翻译文件
|
||||||
static void setTranslator(const QString &qmFile);
|
static void setTranslator(const QString &qmFile);
|
||||||
|
|
||||||
|
//动态设置权限
|
||||||
|
static bool checkPermission(const QString &permission);
|
||||||
|
//申请安卓权限
|
||||||
|
static void initAndroidPermission();
|
||||||
|
|
||||||
//一次性设置所有包括编码样式字体等
|
//一次性设置所有包括编码样式字体等
|
||||||
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函数最前面执行的一段代码
|
//初始化main函数最前面执行的一段代码
|
||||||
static void initMain(bool on = true);
|
static void initMain(bool desktopSettingsAware = true, bool useOpenGLES = false);
|
||||||
|
|
||||||
//插入消息
|
//插入消息
|
||||||
static QVector<int> msgTypes;
|
static QVector<int> msgTypes;
|
||||||
|
@ -109,9 +119,9 @@ public:
|
||||||
//异或加密-只支持字符,如果是中文需要将其转换base64编码
|
//异或加密-只支持字符,如果是中文需要将其转换base64编码
|
||||||
static QString getXorEncryptDecrypt(const QString &value, char key);
|
static QString getXorEncryptDecrypt(const QString &value, char key);
|
||||||
//异或校验
|
//异或校验
|
||||||
static uchar getOrCode(const QByteArray &data);
|
static quint8 getOrCode(const QByteArray &data);
|
||||||
//计算校验码
|
//计算校验码
|
||||||
static uchar getCheckCode(const QByteArray &data);
|
static quint8 getCheckCode(const QByteArray &data);
|
||||||
|
|
||||||
//初始化表格
|
//初始化表格
|
||||||
static void initTableView(QTableView *tableView, int rowHeight = 25,
|
static void initTableView(QTableView *tableView, int rowHeight = 25,
|
||||||
|
@ -124,7 +134,19 @@ public:
|
||||||
static bool checkIniFile(const QString &iniFile);
|
static bool checkIniFile(const QString &iniFile);
|
||||||
|
|
||||||
//首尾截断字符串显示
|
//首尾截断字符串显示
|
||||||
static QString cutString(const QString &text, int len, int left, int right, const QString &mid = "...");
|
static QString cutString(const QString &text, int len, int left, int right, bool file, const QString &mid = "...");
|
||||||
|
|
||||||
|
//传入图片尺寸和窗体区域及边框大小返回居中区域(scaleMode: 0-自动调整 1-等比缩放 2-拉伸填充)
|
||||||
|
static QRect getCenterRect(const QSize &imageSize, const QRect &widgetRect, int borderWidth = 2, int scaleMode = 0);
|
||||||
|
//传入图片尺寸和窗体尺寸及缩放策略返回合适尺寸(scaleMode: 0-自动调整 1-等比缩放 2-拉伸填充)
|
||||||
|
static void getScaledImage(QImage &image, const QSize &widgetSize, int scaleMode = 0, bool fast = true);
|
||||||
|
|
||||||
|
//毫秒数转时间 00:00
|
||||||
|
static QString getTimeString(qint64 time);
|
||||||
|
//用时时间转秒数
|
||||||
|
static QString getTimeString(QElapsedTimer timer);
|
||||||
|
//文件大小转 KB MB GB TB
|
||||||
|
static QString getSizeString(quint64 size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUIHELPER2_H
|
#endif // QUIHELPER2_H
|
||||||
|
|
|
@ -125,7 +125,7 @@ void frmIconHelper::initPanel()
|
||||||
|
|
||||||
if (ui->rbtnFontAliBaBa->isChecked()) {
|
if (ui->rbtnFontAliBaBa->isChecked()) {
|
||||||
start = 0xe500;
|
start = 0xe500;
|
||||||
end = 0xea5d;
|
end = 0xec00;
|
||||||
iconFont = IconHelper::getIconFontAliBaBa();
|
iconFont = IconHelper::getIconFontAliBaBa();
|
||||||
} else if (ui->rbtnFontAwesome6->isChecked()) {
|
} else if (ui->rbtnFontAwesome6->isChecked()) {
|
||||||
start = 0xe000;
|
start = 0xe000;
|
||||||
|
@ -197,7 +197,7 @@ bool frmIconHelper::checkIcon(int icon)
|
||||||
|
|
||||||
//过滤不存在的图形字体
|
//过滤不存在的图形字体
|
||||||
//对该图片逐个扫描像素点,都是空白则意味着当前图形字体不存在
|
//对该图片逐个扫描像素点,都是空白则意味着当前图形字体不存在
|
||||||
for (int i = 0; i < height; i++) {
|
for (int i = 0; i < height; ++i) {
|
||||||
uchar *lineByte = img.scanLine(i);
|
uchar *lineByte = img.scanLine(i);
|
||||||
for (int j = 0; j < width; j++) {
|
for (int j = 0; j < width; j++) {
|
||||||
uchar tp = lineByte[j];
|
uchar tp = lineByte[j];
|
||||||
|
|
|
@ -64,12 +64,12 @@ IconHelper *IconHelper::getIconHelper(int icon)
|
||||||
//由于部分值范围冲突所以可以指定索引来取
|
//由于部分值范围冲突所以可以指定索引来取
|
||||||
//fontawesome 0xf000-0xf2e0
|
//fontawesome 0xf000-0xf2e0
|
||||||
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
//fontawesome6 0xe000-0xe33d 0xf000-0xf8ff
|
||||||
//iconfont 0xe501-0xe793 0xe8d5-0xea5d
|
//iconfont 0xe501-0xe793 0xe8d5-0xea5d 0xeb00-0xec00
|
||||||
//weather 0xe900-0xe9cf
|
//weather 0xe900-0xe9cf
|
||||||
|
|
||||||
IconHelper *iconHelper = iconFontAwesome;
|
IconHelper *iconHelper = iconFontAwesome;
|
||||||
if (iconFontIndex < 0) {
|
if (iconFontIndex < 0) {
|
||||||
if ((icon > 0xe501 && icon < 0xe793) || (icon > 0xe8d5 && icon < 0xea5d)) {
|
if ((icon >= 0xe501 && icon <= 0xe793) || (icon >= 0xe8d5 && icon <= 0xea5d) || (icon >= 0xeb00 && icon <= 0xec00)) {
|
||||||
iconHelper = iconFontAliBaBa;
|
iconHelper = iconFontAliBaBa;
|
||||||
}
|
}
|
||||||
} else if (iconFontIndex == 0) {
|
} else if (iconFontIndex == 0) {
|
||||||
|
|