新增网页效果图

master
feiyangqingyun 2021-01-22 17:20:01 +08:00
parent 44a237e0a9
commit 95ea56d5e7
10 changed files with 85 additions and 59 deletions

View File

@ -2163,6 +2163,14 @@ void QUIHelper::initRand()
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)
{
initFile(QString(":/%1.db").arg(appName()), dbName);
@ -2544,6 +2552,28 @@ void QUIHelper::setCode()
#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)
{
if (msec > 0) {
@ -3536,6 +3566,9 @@ QStringList QUIHelper::getLocalIPs()
{
static QStringList ips;
if (ips.count() == 0) {
#ifdef emsdk
ips << "127.0.0.1";
#else
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
foreach (const QNetworkInterface &netInterface, netInterfaces) {
//移除虚拟机和抓包工具的虚拟网卡
@ -3559,6 +3592,7 @@ QStringList QUIHelper::getLocalIPs()
}
}
}
#endif
}
return ips;

View File

@ -593,6 +593,8 @@ public:
//初始化随机数种子
static void initRand();
//获取uuid
static QString getUuid();
//初始化数据库
static void initDb(const QString &dbName);
@ -641,6 +643,9 @@ public:
static void setTranslator(const QString &qmFile = ":/image/qt_zh_CN.qm");
//设置编码
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);
//设置系统时间

View File

@ -2163,6 +2163,14 @@ void QUIHelper::initRand()
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)
{
initFile(QString(":/%1.db").arg(appName()), dbName);
@ -2544,6 +2552,28 @@ void QUIHelper::setCode()
#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)
{
if (msec > 0) {
@ -3536,6 +3566,9 @@ QStringList QUIHelper::getLocalIPs()
{
static QStringList ips;
if (ips.count() == 0) {
#ifdef emsdk
ips << "127.0.0.1";
#else
QList<QNetworkInterface> netInterfaces = QNetworkInterface::allInterfaces();
foreach (const QNetworkInterface &netInterface, netInterfaces) {
//移除虚拟机和抓包工具的虚拟网卡
@ -3559,6 +3592,7 @@ QStringList QUIHelper::getLocalIPs()
}
}
}
#endif
}
return ips;

View File

@ -593,6 +593,8 @@ public:
//初始化随机数种子
static void initRand();
//获取uuid
static QString getUuid();
//初始化数据库
static void initDb(const QString &dbName);
@ -641,6 +643,9 @@ public:
static void setTranslator(const QString &qmFile = ":/image/qt_zh_CN.qm");
//设置编码
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);
//设置系统时间

View File

@ -35,31 +35,7 @@ void frmTcpServer::initForm()
void frmTcpServer::initIP()
{
//获取本机所有IP
QStringList ips;
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);
}
}
}
}
}
QStringList ips = QUIHelper::getLocalIPs();
ui->cboxListenIP->addItems(ips);
ui->cboxListenIP->addItem("127.0.0.1");
}
@ -79,7 +55,7 @@ void frmTcpServer::initConfig()
connect(ui->ckDebug, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
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)));
connect(ui->cboxInterval, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
@ -102,7 +78,7 @@ void frmTcpServer::saveConfig()
App::HexReceiveTcpServer = ui->ckHexReceive->isChecked();
App::AsciiTcpServer = ui->ckAscii->isChecked();
App::DebugTcpServer = ui->ckDebug->isChecked();
App::AutoSendTcpServer = ui->ckAutoSend->isChecked();
App::AutoSendTcpServer = ui->ckAutoSend->isChecked();
App::IntervalTcpServer = ui->cboxInterval->currentText().toInt();
App::TcpListenIP = ui->cboxListenIP->currentText();
App::TcpListenPort = ui->txtListenPort->text().trimmed().toInt();

View File

@ -31,31 +31,7 @@ void frmUdpServer::initForm()
void frmUdpServer::initIP()
{
//获取本机所有IP
QStringList ips;
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);
}
}
}
}
}
QStringList ips = QUIHelper::getLocalIPs();
ui->cboxListenIP->addItems(ips);
ui->cboxListenIP->addItem("127.0.0.1");
}

View File

@ -4,15 +4,11 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setWindowIcon(QIcon(":/main.ico"));
QFont font;
font.setFamily(QUIConfig::FontName);
font.setPixelSize(QUIConfig::FontSize);
a.setFont(font);
a.setWindowIcon(QIcon(":/main.ico"));
//设置编码以及加载中文翻译文件
QUIHelper::setCode();
QUIHelper::setFont(":/DroidSansFallback.ttf");
QUIHelper::setTranslator(":/qt_zh_CN.qm");
QUIHelper::setTranslator(":/widgets.qm");
QUIHelper::initRand();
@ -24,7 +20,7 @@ int main(int argc, char *argv[])
App::readDeviceData();
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();
return a.exec();

BIN
websnap/snap_demo1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
websnap/snap_demo2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

BIN
websnap/snap_demo3.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB