From bf47b035f987ffc7d5208b33e50014b9554f8e62 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Wed, 19 Jun 2024 18:54:32 +0800 Subject: [PATCH] ledok --- LedOK/LedOK Express.pro | 2 +- LedOK/device/ctrladvancedpanel.cpp | 46 ++++---- LedOK/devicepanel.cpp | 36 +++--- LedOK/globaldefine.cpp | 9 +- LedOK/mainwindow.cpp | 2 +- LedOK/program/ebase.cpp | 172 ++++++++++++++++++++--------- LedOK/program/ebase.h | 5 +- LedOK/program/eweb.cpp | 35 +++++- LedOK/program/eweb.h | 2 +- LedOK/program/gentmpthread.cpp | 2 + LedOK/program/sendprogthread.cpp | 3 +- 11 files changed, 208 insertions(+), 106 deletions(-) diff --git a/LedOK/LedOK Express.pro b/LedOK/LedOK Express.pro index 75f2e01..fcaf3fe 100644 --- a/LedOK/LedOK Express.pro +++ b/LedOK/LedOK Express.pro @@ -27,7 +27,7 @@ CONFIG += embed_translations # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -VERSION = 1.5.2 +VERSION = 2.0.0 DEFINES += APP_VERSION=\\\"$$VERSION\\\" msvc { contains(QT_ARCH, i386) { diff --git a/LedOK/device/ctrladvancedpanel.cpp b/LedOK/device/ctrladvancedpanel.cpp index fb84709..83a5cae 100644 --- a/LedOK/device/ctrladvancedpanel.cpp +++ b/LedOK/device/ctrladvancedpanel.cpp @@ -661,24 +661,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { fd->append(card.id+" Prog JSON"); TcpSocket tcp; tcp.connectToHost(card.ip, 3333); - if(! tcp.waitForConnected()) { + if(! tcp.waitForConnected(10000)) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); - tcp.close(); continue; } auto resNum = tcp.write(JToBytes(json)); tcp.flush(); if(resNum == -1 || ! tcp.waitForBytesWritten()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); - tcp.close(); continue; } if(! tcp.waitForReadyRead()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); - tcp.close(); continue; } fd->insertPlainText(tcp.readAll()); @@ -686,9 +686,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { if(lll.cnt==0) return; fd->insertPlainText(tcp.readAll()); } + tcp.close(); if(lll.cnt==0) return; if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n"); - tcp.close(); fd->append(""); } }); @@ -716,24 +716,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { fd->append(card.id+" Prog Files"); TcpSocket tcp; tcp.connectToHost(card.ip, 3333); - if(! tcp.waitForConnected()) { + if(! tcp.waitForConnected(10000)) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); - tcp.close(); continue; } auto resNum = tcp.write(JToBytes(json)); tcp.flush(); if(resNum == -1 || ! tcp.waitForBytesWritten()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); - tcp.close(); continue; } if(! tcp.waitForReadyRead()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); - tcp.close(); continue; } fd->insertPlainText(tcp.readAll()); @@ -741,9 +741,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { if(lll.cnt==0) return; fd->insertPlainText(tcp.readAll()); } + tcp.close(); if(lll.cnt==0) return; if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n"); - tcp.close(); fd->append(""); } }); @@ -771,24 +771,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { fd->append(card.id+" Player Info"); TcpSocket tcp; tcp.connectToHost(card.ip, 3333); - if(! tcp.waitForConnected()) { + if(! tcp.waitForConnected(10000)) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); - tcp.close(); continue; } auto resNum = tcp.write(JToBytes(json)); tcp.flush(); if(resNum == -1 || ! tcp.waitForBytesWritten()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); - tcp.close(); continue; } if(! tcp.waitForReadyRead()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); - tcp.close(); continue; } fd->insertPlainText(tcp.readAll()); @@ -796,9 +796,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { if(lll.cnt==0) return; fd->insertPlainText(tcp.readAll()); } + tcp.close(); if(lll.cnt==0) return; if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n"); - tcp.close(); fd->append(""); } }); @@ -826,24 +826,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { fd->append(card.id+" Player Log"); TcpSocket tcp; tcp.connectToHost(card.ip, 3333); - if(! tcp.waitForConnected()) { + if(! tcp.waitForConnected(10000)) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); - tcp.close(); continue; } auto resNum = tcp.write(JToBytes(json)); tcp.flush(); if(resNum == -1 || ! tcp.waitForBytesWritten()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); - tcp.close(); continue; } if(! tcp.waitForReadyRead()) { + tcp.close(); if(lll.cnt==0) return; fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); - tcp.close(); continue; } fd->insertPlainText(tcp.readAll()); @@ -851,9 +851,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { if(lll.cnt==0) return; fd->insertPlainText(tcp.readAll()); } + tcp.close(); if(lll.cnt==0) return; if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n"); - tcp.close(); fd->append(""); } }); @@ -882,10 +882,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { fdProgress.setValue(0); TcpSocket tcp; tcp.connectToHost(card.ip, 3333); - if(! tcp.waitForConnected()) { + if(! tcp.waitForConnected(10000)) { + tcp.close(); if(! fdProgress.isVisible()) return; QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected"); - tcp.close(); continue; } QFile file(tar+" "+card.id); @@ -893,9 +893,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { auto resNum = tcp.write(JToBytes(json)); tcp.flush(); if(resNum == -1 || ! tcp.waitForBytesWritten()) { + tcp.close(); if(! fdProgress.isVisible()) return; QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write"); - tcp.close(); continue; } resNum = 0; diff --git a/LedOK/devicepanel.cpp b/LedOK/devicepanel.cpp index f8c4bd0..5db747e 100644 --- a/LedOK/devicepanel.cpp +++ b/LedOK/devicepanel.cpp @@ -237,19 +237,16 @@ QPushButton:hover {background-color: #08b;} auto card = item->mCard; auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); ConnReply(reply, &msgBox) [=, &msgBox] { - QJsonDocument json; - QString err = checkReplyForJson(reply, &json); + JValue json; + auto err = errStrWithJson(reply, &json); if(! err.isEmpty()) { msgBox.setText(msgpre + tr("Player Version")+": "+err); return; } - auto apps = json["apps"].toArray(); - foreach(QJsonValue value, apps) { - QJsonObject app = value.toObject(); - if(app["packageName"].toString().contains("xixunplayer")) { - msgBox.setText(msgpre + tr("Player Version")+": "+app["versionName"].toString()); - return; - } + auto apps = json["apps"]; + for(auto &app : apps) if(app["packageName"].toString().contains("xixunplayer")) { + msgBox.setText(msgpre + tr("Player Version")+": "+app["versionName"].toString()); + return; } msgBox.setText(msgpre + tr("Player Version")+":"); }); @@ -303,7 +300,7 @@ QPushButton:hover {background-color: #08b;} return; } QByteArray data = QJsonDocument(QJsonObject{{"action", "getInfo"}}).toJson(QJsonDocument::Compact); - foreach(auto ip, ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "Specify IP write Failed." << ip; + for(auto &ip : ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "Specify IP write Failed." << ip; specifyIPDlg->accept(); }); hBox->addWidget(bnSearch); @@ -331,12 +328,12 @@ void DevicePanel::sendGetInfo() { if(mUdpSocket.writeDatagram(data, QHostAddress("255.255.255.255"), 22222) != data.length()) qDebug() << "getInfo write to 255.255.255.255 failed"; if(mUdpSocket.writeDatagram((char *)ccc, sizeof(ccc), QHostAddress("255.255.255.255"), 31296) != sizeof(ccc)) qDebug() << "getInfo write to 255.255.255.255 failed"; auto networkinterfaces = QNetworkInterface::allInterfaces(); - foreach(auto face, networkinterfaces) { + for(auto &face : networkinterfaces) { auto flags = face.flags(); bool can = (flags & QNetworkInterface::IsRunning) && (flags & QNetworkInterface::CanBroadcast) && ! (flags & QNetworkInterface::IsLoopBack); if(! can) continue; auto addrEntries = face.addressEntries(); - foreach(QNetworkAddressEntry addrEntry, addrEntries) { + for(QNetworkAddressEntry &addrEntry : addrEntries) { auto ip = addrEntry.ip(); if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue; auto broadcast = addrEntry.broadcast(); @@ -346,7 +343,7 @@ void DevicePanel::sendGetInfo() { auto ipstr = fdIP->toPlainText(); if(! ipstr.isEmpty()) { auto ips = ipstr.split("\n", Qt::SkipEmptyParts); - foreach(auto ip, ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "getInfo specify IP write failed." << ip; + for(auto &ip : ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "getInfo specify IP write failed." << ip; } } @@ -604,11 +601,14 @@ ImgDlg::ImgDlg(const QByteArray &data, QWidget *parent) : QDialog(parent) { setWindowFlag(Qt::WindowContextHelpButtonHint, 0); setWindowTitle(tr("Screenshot")); mImg.loadFromData(data); - auto www = mImg.width(); - auto hhh = mImg.height(); - if(www <= 1600 && hhh <= 900) resize(www, hhh); - else if(www > hhh) resize(900 * www / hhh, 900); - else resize(1600, 1600 * hhh / www); + auto width = mImg.width(); + auto height = mImg.height(); + if(width > 1600 || height > 900) { + auto rate = qMin(1600.0 / width, 900.0 / height); + width *= rate; + height *= rate; + } + resize(width, height); } void ImgDlg::paintEvent(QPaintEvent *) { QPainter painter(this); diff --git a/LedOK/globaldefine.cpp b/LedOK/globaldefine.cpp index ff0198c..218c3fe 100644 --- a/LedOK/globaldefine.cpp +++ b/LedOK/globaldefine.cpp @@ -138,9 +138,8 @@ bool copyDir(const QString &source, const QString &destination, bool override) { } return !error; } -unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize) { - unsigned int i=0; - unsigned char ucCheckCode=0; - for (i=0;i 5) updates = json["win-64"].toObject(); #else - updates = json["win"].toObject(); + updates = json["win-32"].toObject(); #endif #endif #ifdef Q_OS_MAC diff --git a/LedOK/program/ebase.cpp b/LedOK/program/ebase.cpp index 95a967a..155211a 100644 --- a/LedOK/program/ebase.cpp +++ b/LedOK/program/ebase.cpp @@ -21,7 +21,7 @@ int borderImgMaxHeight = 0; struct Initer { Initer() { auto names = QDir("borders").entryList(QDir::Files); - foreach(auto name, names) { + for(auto &name : names) { BorderImg bdImg; bdImg.name = name; bdImg.img = QPixmap("borders/"+bdImg.name); @@ -52,6 +52,9 @@ void EBase::setBaseAttr(const JObj &json) { mExitEffect = json["exitEffect"].toStr(); mEntryDur = json["entryDur"].toInt(); mExitDur = json["exitDur"].toInt(); + _rotate = json["rotate"].toInt(); + _blinkFreq = json["blinkFreq"].toDouble(1.0); + _hasBlink = json["hasBlink"].toBool(); auto geometry = json["geometry"]; setPos(geometry["x"].toInt(), geometry["y"].toInt()); setSize(geometry["w"].toInt(), geometry["h"].toInt()); @@ -83,6 +86,9 @@ void EBase::addBaseAttr(JObj &obj) const { obj.insert("exitEffect", mExitEffect); obj.insert("entryDur", mEntryDur); obj.insert("exitDur", mExitDur); + obj["rotate"] = _rotate; + obj["blinkFreq"] = _blinkFreq; + obj["hasBlink"] = _hasBlink; if(bdImgIdx>-1) { obj["border"] = borderImgs[bdImgIdx].name; obj["borderSize"] = JArray{borderImgs[bdImgIdx].img.width(), borderImgs[bdImgIdx].img.height()}; @@ -227,11 +233,11 @@ void EBase::mousePressEvent(QGraphicsSceneMouseEvent *e) { auto scene = this->scene(); if(0 == scene) return; auto items = scene->items(); - foreach(auto item, items) { + for(auto item : items) { if(item==this) continue; - auto ele = static_cast(item); + auto ele = (EBase*) item; if(ele->mMultiWin) continue; - mOtherEles.append(ele); + mOtherEles.emplace_back(ele); } } } @@ -241,7 +247,7 @@ void EBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if(Qt::LeftButton == event->button()) { mPressRel.setX(FLT_MAX); clearSnap(); - foreach(auto ele, mOtherEles) ele->clearSnap(); + for(auto ele : mOtherEles) ele->clearSnap(); } } #define SnapSpace 6 @@ -253,15 +259,26 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ auto dstHor = mPressRel.x() + mousePos.x(); auto dstVer = mPressRel.y() + mousePos.y(); mLRSnap = mTBSnap = 0; - foreach(auto ele, mOtherEles) ele->clearSnap(); + for(auto ele : mOtherEles) ele->clearSnap(); if(mFrmSec==Qt::TitleBarArea) { - dstHor = qBound(0.0, dstHor, gProgItem->mWidth - mWidth); - dstVer = qBound(0.0, dstVer, gProgItem->mHeight - mHeight); - if(dstHor==0) mLRSnap = 1; - else if(dstHor==gProgItem->mWidth - mWidth) mLRSnap = 2; - if(dstVer==0) mTBSnap = 1; - else if(dstVer==gProgItem->mHeight - mHeight) mTBSnap = 2; - if(mLRSnap==0) foreach(EBase *ele, mOtherEles) {//左右 + if(type()!=Web) { + dstHor = qBound(0.0, dstHor, gProgItem->mWidth - mWidth); + dstVer = qBound(0.0, dstVer, gProgItem->mHeight - mHeight); + } + if(fabs(dstHor) < SnapSpace) { + dstHor = 0; + mLRSnap = 1; + } else if(fabs(dstHor - (gProgItem->mWidth - mWidth)) < SnapSpace) { + dstHor = gProgItem->mWidth - mWidth; + mLRSnap = 2; + }if(fabs(dstVer) < SnapSpace) { + dstVer = 0; + mTBSnap = 1; + } else if(fabs(dstVer - (gProgItem->mHeight - mHeight)) < SnapSpace) { + dstVer = gProgItem->mHeight - mHeight; + mTBSnap = 2; + } + if(mLRSnap==0) for(EBase *ele : mOtherEles) {//左右 if(fabs(dstHor - ele->x()) < SnapSpace && ele->x() <= gProgItem->mWidth - mWidth) { dstHor = ele->x(); mLRSnap = 1; @@ -293,7 +310,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ break; } } - if(mTBSnap==0) foreach(EBase *ele, mOtherEles) {//上下 + if(mTBSnap==0) for(EBase *ele : mOtherEles) {//上下 if(fabs(dstVer-ele->y()) < SnapSpace && ele->y() <= gProgItem->mHeight - mHeight) { dstVer = ele->y(); mTBSnap = 1; @@ -329,16 +346,16 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ } else if(mFrmSec==Qt::BottomRightSection) { if(dstHor < m_handleLen) dstHor = m_handleLen; if(dstVer < m_handleLen) dstVer = m_handleLen; - if(mType!=Audio && gProgItem->mWidth>0 && gProgItem->mHeight>0) { + if(mType!=Web && gProgItem->mWidth>0 && gProgItem->mHeight>0) { dstHor = qMin(dstHor, gProgItem->mWidth - x()); dstVer = qMin(dstVer, gProgItem->mHeight - y()); } setSize(dstHor, dstVer); } else if(mFrmSec==Qt::RightSection) { if(dstHor < m_handleLen) dstHor = m_handleLen; - if(mType!=Audio && gProgItem->mWidth>0 && gProgItem->mHeight>0) dstHor = qMin(dstHor, gProgItem->mWidth - x()); + if(mType!=Web && gProgItem->mWidth>0 && gProgItem->mHeight>0) dstHor = qMin(dstHor, gProgItem->mWidth - x()); auto right = x() + dstHor; - if(right < gProgItem->mWidth-8) foreach(EBase *ele, mOtherEles) {//左右 + if(right < gProgItem->mWidth-8) for(EBase *ele : mOtherEles) {//左右 if(fabs(right - ele->x()) < SnapSpace) { dstHor = ele->x() - x(); mLRSnap = 2; @@ -358,9 +375,9 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ setSize(dstHor, mPressRel.y()); } else if(mFrmSec==Qt::BottomSection) { if(dstVer < m_handleLen) dstVer = m_handleLen; - if(mType!=Audio && gProgItem->mWidth>0 && gProgItem->mHeight>0) dstVer = qMin(dstVer, gProgItem->mHeight - y()); + if(mType!=Web && gProgItem->mWidth>0 && gProgItem->mHeight>0) dstVer = qMin(dstVer, gProgItem->mHeight - y()); auto btm = y() + dstVer; - if(btm < gProgItem->mHeight-8) foreach(EBase *ele, mOtherEles) {//上下 + if(btm < gProgItem->mHeight-8) for(EBase *ele : mOtherEles) {//上下 auto eleBtm = ele->y() + ele->mHeight; if(fabs(btm - ele->y()) < SnapSpace) { dstVer = ele->y() - y(); @@ -382,8 +399,8 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ QRectF geo(x(), y(), mWidth, mHeight); if(mFrmSec==Qt::LeftSection) { dstHor = qMin(dstHor, geo.right() - m_handleLen); - if(mType!=Audio && dstHor < 0) dstHor = 0; - if(dstHor > 8) foreach(EBase *ele, mOtherEles) {//左右 + if(mType!=Web && dstHor < 0) dstHor = 0; + if(dstHor > 8) for(EBase *ele : mOtherEles) {//左右 if(fabs(dstHor - ele->x()) < SnapSpace) { dstHor = ele->x(); mLRSnap = 1; @@ -404,8 +421,8 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ setX(dstHor); } else if(mFrmSec==Qt::TopSection) { dstVer = qMin(dstVer, geo.bottom() - m_handleLen); - if(mType!=Audio && dstVer < 0) dstVer = 0; - if(dstVer > 8) foreach(EBase *ele, mOtherEles) {//上下 + if(mType!=Web && dstVer < 0) dstVer = 0; + if(dstVer > 8) for(EBase *ele : mOtherEles) {//上下 if(fabs(dstVer - ele->y()) < SnapSpace) { dstVer = ele->y(); mTBSnap = 1; @@ -427,7 +444,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ } else if(mFrmSec==Qt::TopLeftSection) { dstHor = qMin(dstHor, geo.right() - m_handleLen); dstVer = qMin(dstVer, geo.bottom() - m_handleLen); - if(mType!=Audio) { + if(mType!=Web) { if(dstHor < 0) dstHor = 0; if(dstVer < 0) dstVer = 0; } @@ -437,7 +454,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ } else if(mFrmSec==Qt::TopRightSection) { dstHor = qMax(dstHor, geo.x() + m_handleLen); dstVer = qMin(dstVer, geo.bottom() - m_handleLen); - if(mType!=Audio) { + if(mType!=Web) { if(dstHor > gProgItem->mWidth) dstHor = gProgItem->mWidth; if(dstVer < 0) dstVer = 0; } @@ -447,7 +464,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){ } else if(mFrmSec==Qt::BottomLeftSection) { dstHor = qMin(dstHor, geo.right() - m_handleLen); dstVer = qMax(dstVer, geo.y() + m_handleLen); - if(mType!=Audio) { + if(mType!=Web) { if(dstHor < 0) dstHor = 0; if(dstVer > gProgItem->mHeight) dstVer = gProgItem->mHeight; } @@ -541,15 +558,17 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { hBox->addLabel(tr("X")+": "); auto fdX = new QSpinBox; - fdX->setRange(0, 999999); + fdX->setRange(-99999, 999999); fdX->setValue(x()); connect(fdX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdX](int value) { - int max = gProgItem->mWidth - mWidth; - if(value > max) { - value = max; - fdX->blockSignals(true); - fdX->setValue(value); - fdX->blockSignals(false); + if(type()!=Web) { + int max = gProgItem->mWidth - mWidth; + if(value < 0 || value > max) { + value = max; + fdX->blockSignals(true); + fdX->setValue(value); + fdX->blockSignals(false); + } } setX(value); }); @@ -559,15 +578,17 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { hBox->addLabel(tr("Y")+": "); auto fdY = new QSpinBox; - fdY->setRange(0, 999999); + fdY->setRange(-99999, 999999); fdY->setValue(y()); connect(fdY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdY](int value) { - int max = gProgItem->mHeight - mHeight; - if(value > max) { - value = max; - fdY->blockSignals(true); - fdY->setValue(value); - fdY->blockSignals(false); + if(type()!=Web) { + int max = gProgItem->mHeight - mHeight; + if(value < 0 || value > max) { + value = max; + fdY->blockSignals(true); + fdY->setValue(value); + fdY->blockSignals(false); + } } setY(value); }); @@ -582,12 +603,14 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { fdW->setRange(6, 999999); fdW->setValue(mWidth); connect(fdW, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdW](int value) { - int max = gProgItem->mWidth - x(); - if(value > max) { - value = max; - fdW->blockSignals(true); - fdW->setValue(value); - fdW->blockSignals(false); + if(type()!=Web) { + int max = gProgItem->mWidth - x(); + if(value > max) { + value = max; + fdW->blockSignals(true); + fdW->setValue(value); + fdW->blockSignals(false); + } } setSize(value, mHeight); }); @@ -599,20 +622,20 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { fdH->setRange(6, 999999); fdH->setValue(mHeight); connect(fdH, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdH](int value) { - int max = gProgItem->mHeight - y(); - if(value > max) { - value = max; - fdH->blockSignals(true); - fdH->setValue(value); - fdH->blockSignals(false); + if(type()!=Web) { + int max = gProgItem->mHeight - y(); + if(value > max) { + value = max; + fdH->blockSignals(true); + fdH->setValue(value); + fdH->blockSignals(false); + } } setSize(mWidth, value); }); hBox->addWidget(fdH); hBox->addStretch(); - vBox->addSpacing(-spacing); - connect(this, &EBase::xChanged, fdX, [this, fdX] { fdX->blockSignals(true); fdX->setValue(x()); @@ -632,6 +655,24 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { fdH->blockSignals(false); }); + hBox = new HBox(vBox); + hBox->addStretch(); + hBox->addLabel(tr("Rotate")+": "); + + auto fdRotate = new QSpinBox; + fdRotate->setRange(0, 359); + fdRotate->setValue(_rotate); + fdRotate->setToolTip("Need Player 2.1.4"); + connect(fdRotate, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) { + _rotate = value; + }); + hBox->addWidget(fdRotate); + hBox->addSpacing(-spacing+2); + hBox->addLabel("°"); + hBox->addStretch(); + + vBox->addSpacing(-spacing); + hBox = new HBox(vBox); hBox->addLabel(tr("Border")); @@ -856,5 +897,28 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { fdExitDur->setValue(value); } }); + + + ccc = 2; + auto fdBlink = new QCheckBox(tr("Blink")); + fdBlink->setChecked(_hasBlink); + fdBlink->setToolTip("Need Player 2.1.4"); + connect(fdBlink, &QCheckBox::stateChanged, this, [=](int state) { + _hasBlink = state==Qt::Checked; + }); + grid->addWidget(fdBlink, 2, ccc++); + ccc++; + + grid->addLabel(tr("Freq"), 2, ccc++, Qt::AlignRight|Qt::AlignVCenter); + + auto fdBlinkFreq = new QDoubleSpinBox; + fdBlinkFreq->setDecimals(1); + fdBlinkFreq->setSingleStep(0.1); + fdBlinkFreq->setValue(_blinkFreq); + connect(fdBlinkFreq, (void(QDoubleSpinBox::*)(double))&QDoubleSpinBox::valueChanged, this, [=](double value) { + _blinkFreq = value; + }); + grid->addWidget(fdBlinkFreq, 2, ccc++); + grid->addLabel("Hz", 2, ccc++); } } diff --git a/LedOK/program/ebase.h b/LedOK/program/ebase.h index 2e4cf5d..f72aeb2 100644 --- a/LedOK/program/ebase.h +++ b/LedOK/program/ebase.h @@ -47,10 +47,13 @@ public: int mType = -1; EBase *mMultiWin = 0; qreal mWidth = 0, mHeight = 0; + int _rotate = 0; QSpinBox *fdDuration = 0; int mStartTime = 0, mDuration = 10; QString mEntryEffect, mExitEffect; int mEntryDur = 1, mExitDur = 1; + double _blinkFreq = 1.0; + bool _hasBlink = 0; signals: void sizeChanged(); @@ -73,7 +76,7 @@ protected: QPointF mPressRel{FLT_MAX, FLT_MAX}; Qt::WindowFrameSection mFrmSec{Qt::NoSection}; char mLRSnap{0}, mTBSnap{0}; - QList mOtherEles; + std::vector mOtherEles; int bdImgIdx{-1}; QString bdEff{"rotate"}; diff --git a/LedOK/program/eweb.cpp b/LedOK/program/eweb.cpp index 3509062..f5160dc 100644 --- a/LedOK/program/eweb.cpp +++ b/LedOK/program/eweb.cpp @@ -14,6 +14,8 @@ EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) { zoom = json["zoom"].toInt(100); _x = json["offX"].toInt(0); _y = json["offY"].toInt(0); + scaleX = json["scaleX"].toInt(100); + scaleY = json["scaleY"].toInt(100); } void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) { @@ -84,7 +86,8 @@ QWidget* EWeb::attrWgt() { _x = value; }); hBox->addWidget(fdX); - hBox->addSpacing(9); + hBox->addSpacing(-3); + hBox->addLabel()->setMinimumWidth(30); hBox->addLabel("Y:"); auto fdY = new QSpinBox; @@ -96,6 +99,34 @@ QWidget* EWeb::attrWgt() { hBox->addWidget(fdY); hBox->addStretch(); + + hBox = new HBox(vBox); + lb = hBox->addLabel(tr("Scale")+" X:"); + lb->setMinimumWidth(70); + lb->setAlignment(Qt::AlignVCenter|Qt::AlignRight); + + auto fdScaleX = new QSpinBox; + fdScaleX->setRange(-9999, 99999); + fdScaleX->setValue(scaleX); + connect(fdScaleX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { + scaleX = value; + }); + hBox->addWidget(fdScaleX); + hBox->addSpacing(-3); + hBox->addLabel("%")->setMinimumWidth(30); + + hBox->addLabel("Y:"); + auto fdScaleY = new QSpinBox; + fdScaleY->setRange(-9999, 99999); + fdScaleY->setValue(scaleY); + connect(fdScaleY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { + scaleY = value; + }); + hBox->addWidget(fdScaleY); + hBox->addSpacing(-3); + hBox->addLabel("%"); + hBox->addStretch(); + vBox->addStretch(); return wgtAttr; } @@ -108,5 +139,7 @@ JObj EWeb::attrJson() const { obj["zoom"] = zoom; obj["offX"] = _x; obj["offY"] = _y; + obj["scaleX"] = scaleX; + obj["scaleY"] = scaleY; return obj; } diff --git a/LedOK/program/eweb.h b/LedOK/program/eweb.h index 7731f0f..2d373a3 100644 --- a/LedOK/program/eweb.h +++ b/LedOK/program/eweb.h @@ -21,7 +21,7 @@ public: JObj attrJson() const override; QString url; - int zoom = 100, _x = 0, _y = 0; + int zoom = 100, _x = 0, _y = 0, scaleX = 100, scaleY = 100; }; #endif // EWEB_H diff --git a/LedOK/program/gentmpthread.cpp b/LedOK/program/gentmpthread.cpp index c19c2bc..805c2db 100644 --- a/LedOK/program/gentmpthread.cpp +++ b/LedOK/program/gentmpthread.cpp @@ -509,6 +509,8 @@ JObj GenTmpThread::convertWeb(const JValue &res) { dst["zoom"] = res["zoom"]; dst["offX"] = res["offX"]; dst["offY"] = res["offY"]; + dst["scaleX"] = res["scaleX"].toDouble(100)/100; + dst["scaleY"] = res["scaleY"].toDouble(100)/100; return dst; } JObj GenTmpThread::convertTimer(const JValue &json) { diff --git a/LedOK/program/sendprogthread.cpp b/LedOK/program/sendprogthread.cpp index 57d1b91..0bbce5d 100644 --- a/LedOK/program/sendprogthread.cpp +++ b/LedOK/program/sendprogthread.cpp @@ -51,13 +51,14 @@ void SendProgThread::run() { auto resp = tcp.readAll(); QString error; auto res = JFrom(resp, &error); - while(error.endsWith("end-of-input")) { + while(error.contains("end-of-input")) { if(! tcp.waitForReadyRead()) { emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForRead2 'checkExist'"); tcp.close(); return; } resp += tcp.readAll(); + error = ""; res = JFrom(resp, &error); } if(! error.isEmpty()) {