新增大屏网页版本

master
feiyangqingyun 2021-01-28 12:55:09 +08:00
parent 63139364c6
commit 9d4b50bd7b
15 changed files with 97 additions and 120 deletions

View File

@ -3245,26 +3245,29 @@ bool QUIHelper::ipLive(const QString &ip, int port, int timeout)
QString QUIHelper::getHtml(const QString &url)
{
QNetworkAccessManager *manager = new QNetworkAccessManager();
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url)));
QByteArray responseData;
QNetworkAccessManager manager;
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
QEventLoop eventLoop;
QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
QObject::connect(&manager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
eventLoop.exec();
responseData = reply->readAll();
return QString(responseData);
QByteArray data = reply->readAll();
reply->deleteLater();
return QString(data);
}
QString QUIHelper::getNetIP(const QString &webCode)
QString QUIHelper::getNetIP(const QString &html)
{
QString web = webCode;
web = web.replace(' ', "");
web = web.replace("\r", "");
web = web.replace("\n", "");
QStringList list = web.split("<br/>");
QString tar = list.at(3);
QStringList ip = tar.split("=");
return ip.at(1);
QString ip;
QStringList list = html.split(" ");
foreach (QString str, list) {
//value=\"101.86.197.178\">
if (str.contains("value=")) {
QStringList temp = str.split("\"");
ip = temp.at(1);
break;
}
}
return ip;
}
QString QUIHelper::getLocalIP()
@ -3335,8 +3338,8 @@ QString QUIHelper::getValue(quint8 value)
bool QUIHelper::isWebOk()
{
//能接通百度IP说明可以通外网
return ipLive("115.239.211.112", 80);
//能接通百度IP 115.239.211.112 说明可以通外网
return ipLive("www.baidu.com", 80);
}
void QUIHelper::initTableView(QTableView *tableView, int rowHeight, bool headVisible, bool edit, bool stretchLast)

View File

@ -756,7 +756,7 @@ public:
//获取网页所有源代码
static QString getHtml(const QString &url);
//获取本机公网IP地址
static QString getNetIP(const QString &webCode);
static QString getNetIP(const QString &html);
//获取本机IP
static QString getLocalIP();
//获取本机IP地址集合

View File

@ -3245,26 +3245,29 @@ bool QUIHelper::ipLive(const QString &ip, int port, int timeout)
QString QUIHelper::getHtml(const QString &url)
{
QNetworkAccessManager *manager = new QNetworkAccessManager();
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url)));
QByteArray responseData;
QNetworkAccessManager manager;
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
QEventLoop eventLoop;
QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
QObject::connect(&manager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
eventLoop.exec();
responseData = reply->readAll();
return QString(responseData);
QByteArray data = reply->readAll();
reply->deleteLater();
return QString(data);
}
QString QUIHelper::getNetIP(const QString &webCode)
QString QUIHelper::getNetIP(const QString &html)
{
QString web = webCode;
web = web.replace(' ', "");
web = web.replace("\r", "");
web = web.replace("\n", "");
QStringList list = web.split("<br/>");
QString tar = list.at(3);
QStringList ip = tar.split("=");
return ip.at(1);
QString ip;
QStringList list = html.split(" ");
foreach (QString str, list) {
//value=\"101.86.197.178\">
if (str.contains("value=")) {
QStringList temp = str.split("\"");
ip = temp.at(1);
break;
}
}
return ip;
}
QString QUIHelper::getLocalIP()
@ -3335,8 +3338,8 @@ QString QUIHelper::getValue(quint8 value)
bool QUIHelper::isWebOk()
{
//能接通百度IP说明可以通外网
return ipLive("115.239.211.112", 80);
//能接通百度IP 115.239.211.112 说明可以通外网
return ipLive("www.baidu.com", 80);
}
void QUIHelper::initTableView(QTableView *tableView, int rowHeight, bool headVisible, bool edit, bool stretchLast)

View File

@ -756,7 +756,7 @@ public:
//获取网页所有源代码
static QString getHtml(const QString &url);
//获取本机公网IP地址
static QString getNetIP(const QString &webCode);
static QString getNetIP(const QString &html);
//获取本机IP
static QString getLocalIP();
//获取本机IP地址集合

View File

@ -28,6 +28,11 @@ void frmTcpClient::initForm()
ui->cboxInterval->addItems(App::Intervals);
ui->cboxData->addItems(App::Datas);
#ifndef emsdk
QString ip = QUIHelper::getNetIP(QUIHelper::getHtml("http://whois.pconline.com.cn/"));
append(1, QString("外网IP -> %1").arg(ip));
#endif
}
void frmTcpClient::initConfig()

View File

@ -273,6 +273,7 @@ void VideoWidget::drawBorder(QPainter *painter)
void VideoWidget::drawBg(QPainter *painter)
{
painter->save();
painter->fillRect(rect(), bgColor);
//背景图片为空则绘制文字,否则绘制背景图片
if (bgImage.isNull()) {
@ -464,6 +465,11 @@ QColor VideoWidget::getFocusColor() const
return this->focusColor;
}
QColor VideoWidget::getBgColor() const
{
return this->bgColor;
}
QString VideoWidget::getBgText() const
{
return this->bgText;
@ -736,96 +742,121 @@ void VideoWidget::setTimeout(int timeout)
void VideoWidget::setBorderWidth(int borderWidth)
{
this->borderWidth = borderWidth;
this->update();
}
void VideoWidget::setBorderColor(const QColor &borderColor)
{
this->borderColor = borderColor;
this->update();
}
void VideoWidget::setFocusColor(const QColor &focusColor)
{
this->focusColor = focusColor;
this->update();
}
void VideoWidget::setBgColor(const QColor &bgColor)
{
this->bgColor = bgColor;
this->update();
}
void VideoWidget::setBgText(const QString &bgText)
{
this->bgText = bgText;
this->update();
}
void VideoWidget::setBgImage(const QImage &bgImage)
{
this->bgImage = bgImage;
this->update();
}
void VideoWidget::setOSD1Visible(bool osdVisible)
{
this->osd1Visible = osdVisible;
this->update();
}
void VideoWidget::setOSD1FontSize(int osdFontSize)
{
this->osd1FontSize = osdFontSize;
this->update();
}
void VideoWidget::setOSD1Text(const QString &osdText)
{
this->osd1Text = osdText;
this->update();
}
void VideoWidget::setOSD1Color(const QColor &osdColor)
{
this->osd1Color = osdColor;
this->update();
}
void VideoWidget::setOSD1Image(const QImage &osdImage)
{
this->osd1Image = osdImage;
this->update();
}
void VideoWidget::setOSD1Format(const VideoWidget::OSDFormat &osdFormat)
{
this->osd1Format = osdFormat;
this->update();
}
void VideoWidget::setOSD1Position(const VideoWidget::OSDPosition &osdPosition)
{
this->osd1Position = osdPosition;
this->update();
}
void VideoWidget::setOSD2Visible(bool osdVisible)
{
this->osd2Visible = osdVisible;
this->update();
}
void VideoWidget::setOSD2FontSize(int osdFontSize)
{
this->osd2FontSize = osdFontSize;
this->update();
}
void VideoWidget::setOSD2Text(const QString &osdText)
{
this->osd2Text = osdText;
this->update();
}
void VideoWidget::setOSD2Color(const QColor &osdColor)
{
this->osd2Color = osdColor;
this->update();
}
void VideoWidget::setOSD2Image(const QImage &osdImage)
{
this->osd2Image = osdImage;
this->update();
}
void VideoWidget::setOSD2Format(const VideoWidget::OSDFormat &osdFormat)
{
this->osd2Format = osdFormat;
this->update();
}
void VideoWidget::setOSD2Position(const VideoWidget::OSDPosition &osdPosition)
{
this->osd2Position = osdPosition;
this->update();
}
void VideoWidget::setOSD1Format(quint8 osdFormat)
@ -851,16 +882,19 @@ void VideoWidget::setOSD2Position(quint8 osdPosition)
void VideoWidget::setFaceBorder(int faceBorder)
{
this->faceBorder = faceBorder;
this->update();
}
void VideoWidget::setFaceColor(const QColor &faceColor)
{
this->faceColor = faceColor;
this->update();
}
void VideoWidget::setFaceRects(const QList<QRect> &faceRects)
{
this->faceRects = faceRects;
this->update();
}
void VideoWidget::open()

View File

@ -46,6 +46,7 @@ class VideoWidget : public QWidget
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
Q_PROPERTY(QColor borderColor READ getBorderColor WRITE setBorderColor)
Q_PROPERTY(QColor focusColor READ getFocusColor WRITE setFocusColor)
Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor)
Q_PROPERTY(QString bgText READ getBgText WRITE setBgText)
Q_PROPERTY(QImage bgImage READ getBgImage WRITE setBgImage)
@ -123,6 +124,7 @@ private:
int borderWidth; //边框宽度
QColor borderColor; //边框颜色
QColor focusColor; //有焦点边框颜色
QColor bgColor; //背景颜色
QString bgText; //默认无图像显示文字
QImage bgImage; //默认无图像背景图片
@ -178,6 +180,7 @@ public:
int getBorderWidth() const;
QColor getBorderColor() const;
QColor getFocusColor() const;
QColor getBgColor() const;
QString getBgText() const;
QImage getBgImage() const;
@ -302,6 +305,8 @@ public slots:
void setBorderColor(const QColor &borderColor);
//设置有焦点边框颜色
void setFocusColor(const QColor &focusColor);
//设置背景颜色
void setBgColor(const QColor &bgColor);
//设置无图像文字
void setBgText(const QString &bgText);
//设置无图像背景图

View File

@ -9,7 +9,7 @@
and Qt device independent pixels. -->
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=0"/>
<title>uidemo24</title>
<title>bigscreen_base</title>
<style>
/* Make the html body cover the entire (visual) viewport with no scroll bars. */
html, body { padding: 0; margin: 0; overflow:hidden; height: 100vh }
@ -25,7 +25,7 @@
<figure style="overflow:visible;" id="qtspinner">
<center style="margin-top:1.5em; line-height:150%">
<img src="qtlogo.svg" width="320" height="200" style="display:block"></img>
<strong>Qt for WebAssembly: uidemo24</strong>
<strong>Qt for WebAssembly: bigscreen_base</strong>
<div id="qtstatus"></div>
<noscript>JavaScript is disabled. Please enable JavaScript to use this application.</noscript>
</center>
@ -64,7 +64,7 @@
canvas.style.display = 'block';
},
});
qtLoader.loadEmscriptenModule("uidemo24");
qtLoader.loadEmscriptenModule("bigscreen_base");
}
</script>
<script type="text/javascript" src="qtloader.js"></script>

1
web/bigscreen_base.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,72 +0,0 @@
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--Set visual viewport size for mobile devices to the device size,
witch results in a scale of 1 and a 1:1 mapping between CSS pixels
and Qt device independent pixels. -->
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=0"/>
<title>uidemo26</title>
<style>
/* Make the html body cover the entire (visual) viewport with no scroll bars. */
html, body { padding: 0; margin: 0; overflow:hidden; height: 100vh }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas { border: 0px none; background-color: white; height:100%; width:100%; }
/* The contenteditable property is set to true for the canvas in order to support
clipboard events. Hide the resulting focus frame and set the cursor back to
the default cursor. */
canvas { outline: 0px solid transparent; caret-color: transparent; cursor:default }
</style>
</head>
<body onload="init()">
<figure style="overflow:visible;" id="qtspinner">
<center style="margin-top:1.5em; line-height:150%">
<img src="qtlogo.svg" width="320" height="200" style="display:block"></img>
<strong>Qt for WebAssembly: uidemo26</strong>
<div id="qtstatus"></div>
<noscript>JavaScript is disabled. Please enable JavaScript to use this application.</noscript>
</center>
</figure>
<canvas id="qtcanvas" oncontextmenu="event.preventDefault()" contenteditable="true"></canvas>
<script type='text/javascript'>
function init() {
var spinner = document.querySelector('#qtspinner');
var canvas = document.querySelector('#qtcanvas');
var status = document.querySelector('#qtstatus')
var qtLoader = QtLoader({
canvasElements : [canvas],
showLoader: function(loaderStatus) {
spinner.style.display = 'block';
canvas.style.display = 'none';
status.innerHTML = loaderStatus + "...";
},
showError: function(errorText) {
status.innerHTML = errorText;
spinner.style.display = 'block';
canvas.style.display = 'none';
},
showExit: function() {
status.innerHTML = "Application exit";
if (qtLoader.exitCode !== undefined)
status.innerHTML += " with code " + qtLoader.exitCode;
if (qtLoader.exitText !== undefined)
status.innerHTML += " (" + qtLoader.exitText + ")";
spinner.style.display = 'block';
canvas.style.display = 'none';
},
showCanvas: function() {
spinner.style.display = 'none';
canvas.style.display = 'block';
},
});
qtLoader.loadEmscriptenModule("uidemo26");
}
</script>
<script type="text/javascript" src="qtloader.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long