新增网页效果图
parent
44a237e0a9
commit
95ea56d5e7
|
@ -2163,6 +2163,14 @@ void QUIHelper::initRand()
|
||||||
qsrand(t.msec() + t.second() * 1000);
|
qsrand(t.msec() + t.second() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QUIHelper::getUuid()
|
||||||
|
{
|
||||||
|
QString uuid = QUuid::createUuid().toString();
|
||||||
|
uuid = uuid.replace("{", "");
|
||||||
|
uuid = uuid.replace("}", "");
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
void QUIHelper::initDb(const QString &dbName)
|
void QUIHelper::initDb(const QString &dbName)
|
||||||
{
|
{
|
||||||
initFile(QString(":/%1.db").arg(appName()), dbName);
|
initFile(QString(":/%1.db").arg(appName()), dbName);
|
||||||
|
@ -2544,6 +2552,28 @@ void QUIHelper::setCode()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QUIHelper::setFont(const QString &ttfFile, const QString &fontName, int fontSize)
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setFamily(fontName);
|
||||||
|
font.setPixelSize(fontSize);
|
||||||
|
|
||||||
|
//如果存在字体文件则设备字体文件中的字体
|
||||||
|
//安卓版本和网页版本需要字体文件一起打包单独设置字体
|
||||||
|
if (!ttfFile.isEmpty()) {
|
||||||
|
QFontDatabase fontDb;
|
||||||
|
int fontId = fontDb.addApplicationFont(ttfFile);
|
||||||
|
if (fontId != -1) {
|
||||||
|
QStringList androidFont = fontDb.applicationFontFamilies(fontId);
|
||||||
|
if (androidFont.size() != 0) {
|
||||||
|
font.setFamily(androidFont.at(0));
|
||||||
|
font.setPixelSize(fontSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qApp->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
void QUIHelper::sleep(int msec)
|
void QUIHelper::sleep(int msec)
|
||||||
{
|
{
|
||||||
if (msec > 0) {
|
if (msec > 0) {
|
||||||
|
@ -3536,6 +3566,9 @@ QStringList QUIHelper::getLocalIPs()
|
||||||
{
|
{
|
||||||
static QStringList ips;
|
static QStringList ips;
|
||||||
if (ips.count() == 0) {
|
if (ips.count() == 0) {
|
||||||
|
#ifdef emsdk
|
||||||
|
ips << "127.0.0.1";
|
||||||
|
#else
|
||||||
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
|
||||||
foreach (const QNetworkInterface &netInterface, netInterfaces) {
|
foreach (const QNetworkInterface &netInterface, netInterfaces) {
|
||||||
//移除虚拟机和抓包工具的虚拟网卡
|
//移除虚拟机和抓包工具的虚拟网卡
|
||||||
|
@ -3559,6 +3592,7 @@ QStringList QUIHelper::getLocalIPs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return ips;
|
return ips;
|
||||||
|
|
|
@ -593,6 +593,8 @@ public:
|
||||||
|
|
||||||
//初始化随机数种子
|
//初始化随机数种子
|
||||||
static void initRand();
|
static void initRand();
|
||||||
|
//获取uuid
|
||||||
|
static QString getUuid();
|
||||||
|
|
||||||
//初始化数据库
|
//初始化数据库
|
||||||
static void initDb(const QString &dbName);
|
static void initDb(const QString &dbName);
|
||||||
|
@ -641,6 +643,9 @@ public:
|
||||||
static void setTranslator(const QString &qmFile = ":/image/qt_zh_CN.qm");
|
static void setTranslator(const QString &qmFile = ":/image/qt_zh_CN.qm");
|
||||||
//设置编码
|
//设置编码
|
||||||
static void setCode();
|
static void setCode();
|
||||||
|
//设置字体
|
||||||
|
static void setFont(const QString &ttfFile = ":/image/DroidSansFallback.ttf",
|
||||||
|
const QString &fontName = "Microsoft Yahei", int fontSize = 12);
|
||||||
//设置延时
|
//设置延时
|
||||||
static void sleep(int msec);
|
static void sleep(int msec);
|
||||||
//设置系统时间
|
//设置系统时间
|
||||||
|
|
|
@ -2163,6 +2163,14 @@ void QUIHelper::initRand()
|
||||||
qsrand(t.msec() + t.second() * 1000);
|
qsrand(t.msec() + t.second() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QUIHelper::getUuid()
|
||||||
|
{
|
||||||
|
QString uuid = QUuid::createUuid().toString();
|
||||||
|
uuid = uuid.replace("{", "");
|
||||||
|
uuid = uuid.replace("}", "");
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
void QUIHelper::initDb(const QString &dbName)
|
void QUIHelper::initDb(const QString &dbName)
|
||||||
{
|
{
|
||||||
initFile(QString(":/%1.db").arg(appName()), dbName);
|
initFile(QString(":/%1.db").arg(appName()), dbName);
|
||||||
|
@ -2544,6 +2552,28 @@ void QUIHelper::setCode()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QUIHelper::setFont(const QString &ttfFile, const QString &fontName, int fontSize)
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setFamily(fontName);
|
||||||
|
font.setPixelSize(fontSize);
|
||||||
|
|
||||||
|
//如果存在字体文件则设备字体文件中的字体
|
||||||
|
//安卓版本和网页版本需要字体文件一起打包单独设置字体
|
||||||
|
if (!ttfFile.isEmpty()) {
|
||||||
|
QFontDatabase fontDb;
|
||||||
|
int fontId = fontDb.addApplicationFont(ttfFile);
|
||||||
|
if (fontId != -1) {
|
||||||
|
QStringList androidFont = fontDb.applicationFontFamilies(fontId);
|
||||||
|
if (androidFont.size() != 0) {
|
||||||
|
font.setFamily(androidFont.at(0));
|
||||||
|
font.setPixelSize(fontSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qApp->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
void QUIHelper::sleep(int msec)
|
void QUIHelper::sleep(int msec)
|
||||||
{
|
{
|
||||||
if (msec > 0) {
|
if (msec > 0) {
|
||||||
|
@ -3536,6 +3566,9 @@ QStringList QUIHelper::getLocalIPs()
|
||||||
{
|
{
|
||||||
static QStringList ips;
|
static QStringList ips;
|
||||||
if (ips.count() == 0) {
|
if (ips.count() == 0) {
|
||||||
|
#ifdef emsdk
|
||||||
|
ips << "127.0.0.1";
|
||||||
|
#else
|
||||||
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
|
||||||
foreach (const QNetworkInterface &netInterface, netInterfaces) {
|
foreach (const QNetworkInterface &netInterface, netInterfaces) {
|
||||||
//移除虚拟机和抓包工具的虚拟网卡
|
//移除虚拟机和抓包工具的虚拟网卡
|
||||||
|
@ -3559,6 +3592,7 @@ QStringList QUIHelper::getLocalIPs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return ips;
|
return ips;
|
||||||
|
|
|
@ -593,6 +593,8 @@ public:
|
||||||
|
|
||||||
//初始化随机数种子
|
//初始化随机数种子
|
||||||
static void initRand();
|
static void initRand();
|
||||||
|
//获取uuid
|
||||||
|
static QString getUuid();
|
||||||
|
|
||||||
//初始化数据库
|
//初始化数据库
|
||||||
static void initDb(const QString &dbName);
|
static void initDb(const QString &dbName);
|
||||||
|
@ -641,6 +643,9 @@ public:
|
||||||
static void setTranslator(const QString &qmFile = ":/image/qt_zh_CN.qm");
|
static void setTranslator(const QString &qmFile = ":/image/qt_zh_CN.qm");
|
||||||
//设置编码
|
//设置编码
|
||||||
static void setCode();
|
static void setCode();
|
||||||
|
//设置字体
|
||||||
|
static void setFont(const QString &ttfFile = ":/image/DroidSansFallback.ttf",
|
||||||
|
const QString &fontName = "Microsoft Yahei", int fontSize = 12);
|
||||||
//设置延时
|
//设置延时
|
||||||
static void sleep(int msec);
|
static void sleep(int msec);
|
||||||
//设置系统时间
|
//设置系统时间
|
||||||
|
|
|
@ -35,31 +35,7 @@ void frmTcpServer::initForm()
|
||||||
void frmTcpServer::initIP()
|
void frmTcpServer::initIP()
|
||||||
{
|
{
|
||||||
//获取本机所有IP
|
//获取本机所有IP
|
||||||
QStringList ips;
|
QStringList ips = QUIHelper::getLocalIPs();
|
||||||
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) {
|
|
||||||
QList<QNetworkAddressEntry> addrs = netInterface.addressEntries();
|
|
||||||
foreach(QNetworkAddressEntry addr, addrs) {
|
|
||||||
//只取出IPV4的地址
|
|
||||||
if(addr.ip().protocol() == QAbstractSocket::IPv4Protocol) {
|
|
||||||
QString ip4 = addr.ip().toString();
|
|
||||||
if(ip4 != "127.0.0.1") {
|
|
||||||
ips.append(ip4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->cboxListenIP->addItems(ips);
|
ui->cboxListenIP->addItems(ips);
|
||||||
ui->cboxListenIP->addItem("127.0.0.1");
|
ui->cboxListenIP->addItem("127.0.0.1");
|
||||||
}
|
}
|
||||||
|
@ -79,7 +55,7 @@ void frmTcpServer::initConfig()
|
||||||
connect(ui->ckDebug, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
|
connect(ui->ckDebug, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
|
||||||
|
|
||||||
ui->ckAutoSend->setChecked(App::AutoSendTcpServer);
|
ui->ckAutoSend->setChecked(App::AutoSendTcpServer);
|
||||||
connect(ui->ckAutoSend, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
|
connect(ui->ckAutoSend, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
|
||||||
|
|
||||||
ui->cboxInterval->setCurrentIndex(ui->cboxInterval->findText(QString::number(App::IntervalTcpServer)));
|
ui->cboxInterval->setCurrentIndex(ui->cboxInterval->findText(QString::number(App::IntervalTcpServer)));
|
||||||
connect(ui->cboxInterval, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
|
connect(ui->cboxInterval, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
|
||||||
|
@ -102,7 +78,7 @@ void frmTcpServer::saveConfig()
|
||||||
App::HexReceiveTcpServer = ui->ckHexReceive->isChecked();
|
App::HexReceiveTcpServer = ui->ckHexReceive->isChecked();
|
||||||
App::AsciiTcpServer = ui->ckAscii->isChecked();
|
App::AsciiTcpServer = ui->ckAscii->isChecked();
|
||||||
App::DebugTcpServer = ui->ckDebug->isChecked();
|
App::DebugTcpServer = ui->ckDebug->isChecked();
|
||||||
App::AutoSendTcpServer = ui->ckAutoSend->isChecked();
|
App::AutoSendTcpServer = ui->ckAutoSend->isChecked();
|
||||||
App::IntervalTcpServer = ui->cboxInterval->currentText().toInt();
|
App::IntervalTcpServer = ui->cboxInterval->currentText().toInt();
|
||||||
App::TcpListenIP = ui->cboxListenIP->currentText();
|
App::TcpListenIP = ui->cboxListenIP->currentText();
|
||||||
App::TcpListenPort = ui->txtListenPort->text().trimmed().toInt();
|
App::TcpListenPort = ui->txtListenPort->text().trimmed().toInt();
|
||||||
|
|
|
@ -31,31 +31,7 @@ void frmUdpServer::initForm()
|
||||||
void frmUdpServer::initIP()
|
void frmUdpServer::initIP()
|
||||||
{
|
{
|
||||||
//获取本机所有IP
|
//获取本机所有IP
|
||||||
QStringList ips;
|
QStringList ips = QUIHelper::getLocalIPs();
|
||||||
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) {
|
|
||||||
QList<QNetworkAddressEntry> addrs = netInterface.addressEntries();
|
|
||||||
foreach(QNetworkAddressEntry addr, addrs) {
|
|
||||||
//只取出IPV4的地址
|
|
||||||
if(addr.ip().protocol() == QAbstractSocket::IPv4Protocol) {
|
|
||||||
QString ip4 = addr.ip().toString();
|
|
||||||
if(ip4 != "127.0.0.1") {
|
|
||||||
ips.append(ip4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->cboxListenIP->addItems(ips);
|
ui->cboxListenIP->addItems(ips);
|
||||||
ui->cboxListenIP->addItem("127.0.0.1");
|
ui->cboxListenIP->addItem("127.0.0.1");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,11 @@
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setWindowIcon(QIcon(":/main.ico"));
|
a.setWindowIcon(QIcon(":/main.ico"));
|
||||||
|
|
||||||
QFont font;
|
|
||||||
font.setFamily(QUIConfig::FontName);
|
|
||||||
font.setPixelSize(QUIConfig::FontSize);
|
|
||||||
a.setFont(font);
|
|
||||||
|
|
||||||
//设置编码以及加载中文翻译文件
|
//设置编码以及加载中文翻译文件
|
||||||
QUIHelper::setCode();
|
QUIHelper::setCode();
|
||||||
|
QUIHelper::setFont(":/DroidSansFallback.ttf");
|
||||||
QUIHelper::setTranslator(":/qt_zh_CN.qm");
|
QUIHelper::setTranslator(":/qt_zh_CN.qm");
|
||||||
QUIHelper::setTranslator(":/widgets.qm");
|
QUIHelper::setTranslator(":/widgets.qm");
|
||||||
QUIHelper::initRand();
|
QUIHelper::initRand();
|
||||||
|
@ -24,7 +20,7 @@ int main(int argc, char *argv[])
|
||||||
App::readDeviceData();
|
App::readDeviceData();
|
||||||
|
|
||||||
frmMain w;
|
frmMain w;
|
||||||
w.setWindowTitle(QString("网络调试助手V2020 本机IP: %1 QQ: 517216493").arg(QUIHelper::getLocalIP()));
|
w.setWindowTitle(QString("网络调试助手V2020 本机IP: %1 QQ: 517216493").arg(QUIHelper::getLocalIP()));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 MiB |
Binary file not shown.
After Width: | Height: | Size: 303 KiB |
Loading…
Reference in New Issue