This commit is contained in:
Gangphon 2024-06-19 18:54:32 +08:00
parent f4cc005daa
commit bf47b035f9
11 changed files with 208 additions and 106 deletions

View File

@ -27,7 +27,7 @@ CONFIG += embed_translations
# You can also select to disable deprecated APIs only up to a certain version of Qt. # 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 #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\\\" DEFINES += APP_VERSION=\\\"$$VERSION\\\"
msvc { msvc {
contains(QT_ARCH, i386) { contains(QT_ARCH, i386) {

View File

@ -661,24 +661,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->append(card.id+" Prog JSON"); fd->append(card.id+" Prog JSON");
TcpSocket tcp; TcpSocket tcp;
tcp.connectToHost(card.ip, 3333); tcp.connectToHost(card.ip, 3333);
if(! tcp.waitForConnected()) { if(! tcp.waitForConnected(10000)) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp.close();
continue; continue;
} }
auto resNum = tcp.write(JToBytes(json)); auto resNum = tcp.write(JToBytes(json));
tcp.flush(); tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
tcp.close();
continue; continue;
} }
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
tcp.close();
continue; continue;
} }
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
@ -686,9 +686,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
tcp.close();
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append(""); fd->append("");
} }
}); });
@ -716,24 +716,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->append(card.id+" Prog Files"); fd->append(card.id+" Prog Files");
TcpSocket tcp; TcpSocket tcp;
tcp.connectToHost(card.ip, 3333); tcp.connectToHost(card.ip, 3333);
if(! tcp.waitForConnected()) { if(! tcp.waitForConnected(10000)) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp.close();
continue; continue;
} }
auto resNum = tcp.write(JToBytes(json)); auto resNum = tcp.write(JToBytes(json));
tcp.flush(); tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
tcp.close();
continue; continue;
} }
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
tcp.close();
continue; continue;
} }
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
@ -741,9 +741,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
tcp.close();
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append(""); fd->append("");
} }
}); });
@ -771,24 +771,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->append(card.id+" Player Info"); fd->append(card.id+" Player Info");
TcpSocket tcp; TcpSocket tcp;
tcp.connectToHost(card.ip, 3333); tcp.connectToHost(card.ip, 3333);
if(! tcp.waitForConnected()) { if(! tcp.waitForConnected(10000)) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp.close();
continue; continue;
} }
auto resNum = tcp.write(JToBytes(json)); auto resNum = tcp.write(JToBytes(json));
tcp.flush(); tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
tcp.close();
continue; continue;
} }
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
tcp.close();
continue; continue;
} }
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
@ -796,9 +796,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
tcp.close();
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append(""); fd->append("");
} }
}); });
@ -826,24 +826,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->append(card.id+" Player Log"); fd->append(card.id+" Player Log");
TcpSocket tcp; TcpSocket tcp;
tcp.connectToHost(card.ip, 3333); tcp.connectToHost(card.ip, 3333);
if(! tcp.waitForConnected()) { if(! tcp.waitForConnected(10000)) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp.close();
continue; continue;
} }
auto resNum = tcp.write(JToBytes(json)); auto resNum = tcp.write(JToBytes(json));
tcp.flush(); tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
tcp.close();
continue; continue;
} }
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
tcp.close();
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
tcp.close();
continue; continue;
} }
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
@ -851,9 +851,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->insertPlainText(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
tcp.close();
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append(""); fd->append("");
} }
}); });
@ -882,10 +882,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdProgress.setValue(0); fdProgress.setValue(0);
TcpSocket tcp; TcpSocket tcp;
tcp.connectToHost(card.ip, 3333); tcp.connectToHost(card.ip, 3333);
if(! tcp.waitForConnected()) { if(! tcp.waitForConnected(10000)) {
tcp.close();
if(! fdProgress.isVisible()) return; if(! fdProgress.isVisible()) return;
QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected"); QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected");
tcp.close();
continue; continue;
} }
QFile file(tar+" "+card.id); QFile file(tar+" "+card.id);
@ -893,9 +893,9 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
auto resNum = tcp.write(JToBytes(json)); auto resNum = tcp.write(JToBytes(json));
tcp.flush(); tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp.close();
if(! fdProgress.isVisible()) return; if(! fdProgress.isVisible()) return;
QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write"); QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write");
tcp.close();
continue; continue;
} }
resNum = 0; resNum = 0;

View File

@ -237,19 +237,16 @@ QPushButton:hover {background-color: #08b;}
auto card = item->mCard; auto card = item->mCard;
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, &msgBox) [=, &msgBox] { ConnReply(reply, &msgBox) [=, &msgBox] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) {
msgBox.setText(msgpre + tr("Player Version")+": "+err); msgBox.setText(msgpre + tr("Player Version")+": "+err);
return; return;
} }
auto apps = json["apps"].toArray(); auto apps = json["apps"];
foreach(QJsonValue value, apps) { for(auto &app : apps) if(app["packageName"].toString().contains("xixunplayer")) {
QJsonObject app = value.toObject(); msgBox.setText(msgpre + tr("Player Version")+": "+app["versionName"].toString());
if(app["packageName"].toString().contains("xixunplayer")) { return;
msgBox.setText(msgpre + tr("Player Version")+": "+app["versionName"].toString());
return;
}
} }
msgBox.setText(msgpre + tr("Player Version")+":"); msgBox.setText(msgpre + tr("Player Version")+":");
}); });
@ -303,7 +300,7 @@ QPushButton:hover {background-color: #08b;}
return; return;
} }
QByteArray data = QJsonDocument(QJsonObject{{"action", "getInfo"}}).toJson(QJsonDocument::Compact); 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(); specifyIPDlg->accept();
}); });
hBox->addWidget(bnSearch); 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(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"; 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(); auto networkinterfaces = QNetworkInterface::allInterfaces();
foreach(auto face, networkinterfaces) { for(auto &face : networkinterfaces) {
auto flags = face.flags(); auto flags = face.flags();
bool can = (flags & QNetworkInterface::IsRunning) && (flags & QNetworkInterface::CanBroadcast) && ! (flags & QNetworkInterface::IsLoopBack); bool can = (flags & QNetworkInterface::IsRunning) && (flags & QNetworkInterface::CanBroadcast) && ! (flags & QNetworkInterface::IsLoopBack);
if(! can) continue; if(! can) continue;
auto addrEntries = face.addressEntries(); auto addrEntries = face.addressEntries();
foreach(QNetworkAddressEntry addrEntry, addrEntries) { for(QNetworkAddressEntry &addrEntry : addrEntries) {
auto ip = addrEntry.ip(); auto ip = addrEntry.ip();
if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue; if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue;
auto broadcast = addrEntry.broadcast(); auto broadcast = addrEntry.broadcast();
@ -346,7 +343,7 @@ void DevicePanel::sendGetInfo() {
auto ipstr = fdIP->toPlainText(); auto ipstr = fdIP->toPlainText();
if(! ipstr.isEmpty()) { if(! ipstr.isEmpty()) {
auto ips = ipstr.split("\n", Qt::SkipEmptyParts); 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); setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
setWindowTitle(tr("Screenshot")); setWindowTitle(tr("Screenshot"));
mImg.loadFromData(data); mImg.loadFromData(data);
auto www = mImg.width(); auto width = mImg.width();
auto hhh = mImg.height(); auto height = mImg.height();
if(www <= 1600 && hhh <= 900) resize(www, hhh); if(width > 1600 || height > 900) {
else if(www > hhh) resize(900 * www / hhh, 900); auto rate = qMin(1600.0 / width, 900.0 / height);
else resize(1600, 1600 * hhh / www); width *= rate;
height *= rate;
}
resize(width, height);
} }
void ImgDlg::paintEvent(QPaintEvent *) { void ImgDlg::paintEvent(QPaintEvent *) {
QPainter painter(this); QPainter painter(this);

View File

@ -138,9 +138,8 @@ bool copyDir(const QString &source, const QString &destination, bool override) {
} }
return !error; return !error;
} }
unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize) { unsigned char GetCheckCodeIn8(unsigned char *str, unsigned int size) {
unsigned int i=0; unsigned char checkCode = 0;
unsigned char ucCheckCode=0; for(int i=0; i<size; i++) checkCode += str[i];
for (i=0;i<uiSize;i++) ucCheckCode+=pBuffer[i]; return (~checkCode) & 0xff;
return (~ucCheckCode)&0x0ff;
} }

View File

@ -424,7 +424,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
#if(QT_VERSION_MAJOR > 5) #if(QT_VERSION_MAJOR > 5)
updates = json["win-64"].toObject(); updates = json["win-64"].toObject();
#else #else
updates = json["win"].toObject(); updates = json["win-32"].toObject();
#endif #endif
#endif #endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC

View File

@ -21,7 +21,7 @@ int borderImgMaxHeight = 0;
struct Initer { struct Initer {
Initer() { Initer() {
auto names = QDir("borders").entryList(QDir::Files); auto names = QDir("borders").entryList(QDir::Files);
foreach(auto name, names) { for(auto &name : names) {
BorderImg bdImg; BorderImg bdImg;
bdImg.name = name; bdImg.name = name;
bdImg.img = QPixmap("borders/"+bdImg.name); bdImg.img = QPixmap("borders/"+bdImg.name);
@ -52,6 +52,9 @@ void EBase::setBaseAttr(const JObj &json) {
mExitEffect = json["exitEffect"].toStr(); mExitEffect = json["exitEffect"].toStr();
mEntryDur = json["entryDur"].toInt(); mEntryDur = json["entryDur"].toInt();
mExitDur = json["exitDur"].toInt(); mExitDur = json["exitDur"].toInt();
_rotate = json["rotate"].toInt();
_blinkFreq = json["blinkFreq"].toDouble(1.0);
_hasBlink = json["hasBlink"].toBool();
auto geometry = json["geometry"]; auto geometry = json["geometry"];
setPos(geometry["x"].toInt(), geometry["y"].toInt()); setPos(geometry["x"].toInt(), geometry["y"].toInt());
setSize(geometry["w"].toInt(), geometry["h"].toInt()); setSize(geometry["w"].toInt(), geometry["h"].toInt());
@ -83,6 +86,9 @@ void EBase::addBaseAttr(JObj &obj) const {
obj.insert("exitEffect", mExitEffect); obj.insert("exitEffect", mExitEffect);
obj.insert("entryDur", mEntryDur); obj.insert("entryDur", mEntryDur);
obj.insert("exitDur", mExitDur); obj.insert("exitDur", mExitDur);
obj["rotate"] = _rotate;
obj["blinkFreq"] = _blinkFreq;
obj["hasBlink"] = _hasBlink;
if(bdImgIdx>-1) { if(bdImgIdx>-1) {
obj["border"] = borderImgs[bdImgIdx].name; obj["border"] = borderImgs[bdImgIdx].name;
obj["borderSize"] = JArray{borderImgs[bdImgIdx].img.width(), borderImgs[bdImgIdx].img.height()}; obj["borderSize"] = JArray{borderImgs[bdImgIdx].img.width(), borderImgs[bdImgIdx].img.height()};
@ -227,11 +233,11 @@ void EBase::mousePressEvent(QGraphicsSceneMouseEvent *e) {
auto scene = this->scene(); auto scene = this->scene();
if(0 == scene) return; if(0 == scene) return;
auto items = scene->items(); auto items = scene->items();
foreach(auto item, items) { for(auto item : items) {
if(item==this) continue; if(item==this) continue;
auto ele = static_cast<EBase*>(item); auto ele = (EBase*) item;
if(ele->mMultiWin) continue; 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()) { if(Qt::LeftButton == event->button()) {
mPressRel.setX(FLT_MAX); mPressRel.setX(FLT_MAX);
clearSnap(); clearSnap();
foreach(auto ele, mOtherEles) ele->clearSnap(); for(auto ele : mOtherEles) ele->clearSnap();
} }
} }
#define SnapSpace 6 #define SnapSpace 6
@ -253,15 +259,26 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
auto dstHor = mPressRel.x() + mousePos.x(); auto dstHor = mPressRel.x() + mousePos.x();
auto dstVer = mPressRel.y() + mousePos.y(); auto dstVer = mPressRel.y() + mousePos.y();
mLRSnap = mTBSnap = 0; mLRSnap = mTBSnap = 0;
foreach(auto ele, mOtherEles) ele->clearSnap(); for(auto ele : mOtherEles) ele->clearSnap();
if(mFrmSec==Qt::TitleBarArea) { if(mFrmSec==Qt::TitleBarArea) {
dstHor = qBound(0.0, dstHor, gProgItem->mWidth - mWidth); if(type()!=Web) {
dstVer = qBound(0.0, dstVer, gProgItem->mHeight - mHeight); dstHor = qBound(0.0, dstHor, gProgItem->mWidth - mWidth);
if(dstHor==0) mLRSnap = 1; dstVer = qBound(0.0, dstVer, gProgItem->mHeight - mHeight);
else if(dstHor==gProgItem->mWidth - mWidth) mLRSnap = 2; }
if(dstVer==0) mTBSnap = 1; if(fabs(dstHor) < SnapSpace) {
else if(dstVer==gProgItem->mHeight - mHeight) mTBSnap = 2; dstHor = 0;
if(mLRSnap==0) foreach(EBase *ele, mOtherEles) {//左右 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) { if(fabs(dstHor - ele->x()) < SnapSpace && ele->x() <= gProgItem->mWidth - mWidth) {
dstHor = ele->x(); dstHor = ele->x();
mLRSnap = 1; mLRSnap = 1;
@ -293,7 +310,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
break; 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) { if(fabs(dstVer-ele->y()) < SnapSpace && ele->y() <= gProgItem->mHeight - mHeight) {
dstVer = ele->y(); dstVer = ele->y();
mTBSnap = 1; mTBSnap = 1;
@ -329,16 +346,16 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
} else if(mFrmSec==Qt::BottomRightSection) { } else if(mFrmSec==Qt::BottomRightSection) {
if(dstHor < m_handleLen) dstHor = m_handleLen; if(dstHor < m_handleLen) dstHor = m_handleLen;
if(dstVer < m_handleLen) dstVer = 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()); dstHor = qMin(dstHor, gProgItem->mWidth - x());
dstVer = qMin(dstVer, gProgItem->mHeight - y()); dstVer = qMin(dstVer, gProgItem->mHeight - y());
} }
setSize(dstHor, dstVer); setSize(dstHor, dstVer);
} else if(mFrmSec==Qt::RightSection) { } else if(mFrmSec==Qt::RightSection) {
if(dstHor < m_handleLen) dstHor = m_handleLen; 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; 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) { if(fabs(right - ele->x()) < SnapSpace) {
dstHor = ele->x() - x(); dstHor = ele->x() - x();
mLRSnap = 2; mLRSnap = 2;
@ -358,9 +375,9 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
setSize(dstHor, mPressRel.y()); setSize(dstHor, mPressRel.y());
} else if(mFrmSec==Qt::BottomSection) { } else if(mFrmSec==Qt::BottomSection) {
if(dstVer < m_handleLen) dstVer = m_handleLen; 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; 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; auto eleBtm = ele->y() + ele->mHeight;
if(fabs(btm - ele->y()) < SnapSpace) { if(fabs(btm - ele->y()) < SnapSpace) {
dstVer = ele->y() - y(); dstVer = ele->y() - y();
@ -382,8 +399,8 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
QRectF geo(x(), y(), mWidth, mHeight); QRectF geo(x(), y(), mWidth, mHeight);
if(mFrmSec==Qt::LeftSection) { if(mFrmSec==Qt::LeftSection) {
dstHor = qMin(dstHor, geo.right() - m_handleLen); dstHor = qMin(dstHor, geo.right() - m_handleLen);
if(mType!=Audio && dstHor < 0) dstHor = 0; if(mType!=Web && dstHor < 0) dstHor = 0;
if(dstHor > 8) foreach(EBase *ele, mOtherEles) {//左右 if(dstHor > 8) for(EBase *ele : mOtherEles) {//左右
if(fabs(dstHor - ele->x()) < SnapSpace) { if(fabs(dstHor - ele->x()) < SnapSpace) {
dstHor = ele->x(); dstHor = ele->x();
mLRSnap = 1; mLRSnap = 1;
@ -404,8 +421,8 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
setX(dstHor); setX(dstHor);
} else if(mFrmSec==Qt::TopSection) { } else if(mFrmSec==Qt::TopSection) {
dstVer = qMin(dstVer, geo.bottom() - m_handleLen); dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
if(mType!=Audio && dstVer < 0) dstVer = 0; if(mType!=Web && dstVer < 0) dstVer = 0;
if(dstVer > 8) foreach(EBase *ele, mOtherEles) {//上下 if(dstVer > 8) for(EBase *ele : mOtherEles) {//上下
if(fabs(dstVer - ele->y()) < SnapSpace) { if(fabs(dstVer - ele->y()) < SnapSpace) {
dstVer = ele->y(); dstVer = ele->y();
mTBSnap = 1; mTBSnap = 1;
@ -427,7 +444,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
} else if(mFrmSec==Qt::TopLeftSection) { } else if(mFrmSec==Qt::TopLeftSection) {
dstHor = qMin(dstHor, geo.right() - m_handleLen); dstHor = qMin(dstHor, geo.right() - m_handleLen);
dstVer = qMin(dstVer, geo.bottom() - m_handleLen); dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
if(mType!=Audio) { if(mType!=Web) {
if(dstHor < 0) dstHor = 0; if(dstHor < 0) dstHor = 0;
if(dstVer < 0) dstVer = 0; if(dstVer < 0) dstVer = 0;
} }
@ -437,7 +454,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
} else if(mFrmSec==Qt::TopRightSection) { } else if(mFrmSec==Qt::TopRightSection) {
dstHor = qMax(dstHor, geo.x() + m_handleLen); dstHor = qMax(dstHor, geo.x() + m_handleLen);
dstVer = qMin(dstVer, geo.bottom() - m_handleLen); dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
if(mType!=Audio) { if(mType!=Web) {
if(dstHor > gProgItem->mWidth) dstHor = gProgItem->mWidth; if(dstHor > gProgItem->mWidth) dstHor = gProgItem->mWidth;
if(dstVer < 0) dstVer = 0; if(dstVer < 0) dstVer = 0;
} }
@ -447,7 +464,7 @@ void EBase::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
} else if(mFrmSec==Qt::BottomLeftSection) { } else if(mFrmSec==Qt::BottomLeftSection) {
dstHor = qMin(dstHor, geo.right() - m_handleLen); dstHor = qMin(dstHor, geo.right() - m_handleLen);
dstVer = qMax(dstVer, geo.y() + m_handleLen); dstVer = qMax(dstVer, geo.y() + m_handleLen);
if(mType!=Audio) { if(mType!=Web) {
if(dstHor < 0) dstHor = 0; if(dstHor < 0) dstHor = 0;
if(dstVer > gProgItem->mHeight) dstVer = gProgItem->mHeight; if(dstVer > gProgItem->mHeight) dstVer = gProgItem->mHeight;
} }
@ -541,15 +558,17 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
hBox->addLabel(tr("X")+": "); hBox->addLabel(tr("X")+": ");
auto fdX = new QSpinBox; auto fdX = new QSpinBox;
fdX->setRange(0, 999999); fdX->setRange(-99999, 999999);
fdX->setValue(x()); fdX->setValue(x());
connect(fdX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdX](int value) { connect(fdX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdX](int value) {
int max = gProgItem->mWidth - mWidth; if(type()!=Web) {
if(value > max) { int max = gProgItem->mWidth - mWidth;
value = max; if(value < 0 || value > max) {
fdX->blockSignals(true); value = max;
fdX->setValue(value); fdX->blockSignals(true);
fdX->blockSignals(false); fdX->setValue(value);
fdX->blockSignals(false);
}
} }
setX(value); setX(value);
}); });
@ -559,15 +578,17 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
hBox->addLabel(tr("Y")+": "); hBox->addLabel(tr("Y")+": ");
auto fdY = new QSpinBox; auto fdY = new QSpinBox;
fdY->setRange(0, 999999); fdY->setRange(-99999, 999999);
fdY->setValue(y()); fdY->setValue(y());
connect(fdY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdY](int value) { connect(fdY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdY](int value) {
int max = gProgItem->mHeight - mHeight; if(type()!=Web) {
if(value > max) { int max = gProgItem->mHeight - mHeight;
value = max; if(value < 0 || value > max) {
fdY->blockSignals(true); value = max;
fdY->setValue(value); fdY->blockSignals(true);
fdY->blockSignals(false); fdY->setValue(value);
fdY->blockSignals(false);
}
} }
setY(value); setY(value);
}); });
@ -582,12 +603,14 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
fdW->setRange(6, 999999); fdW->setRange(6, 999999);
fdW->setValue(mWidth); fdW->setValue(mWidth);
connect(fdW, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdW](int value) { connect(fdW, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdW](int value) {
int max = gProgItem->mWidth - x(); if(type()!=Web) {
if(value > max) { int max = gProgItem->mWidth - x();
value = max; if(value > max) {
fdW->blockSignals(true); value = max;
fdW->setValue(value); fdW->blockSignals(true);
fdW->blockSignals(false); fdW->setValue(value);
fdW->blockSignals(false);
}
} }
setSize(value, mHeight); setSize(value, mHeight);
}); });
@ -599,20 +622,20 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
fdH->setRange(6, 999999); fdH->setRange(6, 999999);
fdH->setValue(mHeight); fdH->setValue(mHeight);
connect(fdH, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdH](int value) { connect(fdH, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdH](int value) {
int max = gProgItem->mHeight - y(); if(type()!=Web) {
if(value > max) { int max = gProgItem->mHeight - y();
value = max; if(value > max) {
fdH->blockSignals(true); value = max;
fdH->setValue(value); fdH->blockSignals(true);
fdH->blockSignals(false); fdH->setValue(value);
fdH->blockSignals(false);
}
} }
setSize(mWidth, value); setSize(mWidth, value);
}); });
hBox->addWidget(fdH); hBox->addWidget(fdH);
hBox->addStretch(); hBox->addStretch();
vBox->addSpacing(-spacing);
connect(this, &EBase::xChanged, fdX, [this, fdX] { connect(this, &EBase::xChanged, fdX, [this, fdX] {
fdX->blockSignals(true); fdX->blockSignals(true);
fdX->setValue(x()); fdX->setValue(x());
@ -632,6 +655,24 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
fdH->blockSignals(false); 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 = new HBox(vBox);
hBox->addLabel(tr("Border")); hBox->addLabel(tr("Border"));
@ -856,5 +897,28 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
fdExitDur->setValue(value); 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++);
} }
} }

View File

@ -47,10 +47,13 @@ public:
int mType = -1; int mType = -1;
EBase *mMultiWin = 0; EBase *mMultiWin = 0;
qreal mWidth = 0, mHeight = 0; qreal mWidth = 0, mHeight = 0;
int _rotate = 0;
QSpinBox *fdDuration = 0; QSpinBox *fdDuration = 0;
int mStartTime = 0, mDuration = 10; int mStartTime = 0, mDuration = 10;
QString mEntryEffect, mExitEffect; QString mEntryEffect, mExitEffect;
int mEntryDur = 1, mExitDur = 1; int mEntryDur = 1, mExitDur = 1;
double _blinkFreq = 1.0;
bool _hasBlink = 0;
signals: signals:
void sizeChanged(); void sizeChanged();
@ -73,7 +76,7 @@ protected:
QPointF mPressRel{FLT_MAX, FLT_MAX}; QPointF mPressRel{FLT_MAX, FLT_MAX};
Qt::WindowFrameSection mFrmSec{Qt::NoSection}; Qt::WindowFrameSection mFrmSec{Qt::NoSection};
char mLRSnap{0}, mTBSnap{0}; char mLRSnap{0}, mTBSnap{0};
QList<EBase *> mOtherEles; std::vector<EBase *> mOtherEles;
int bdImgIdx{-1}; int bdImgIdx{-1};
QString bdEff{"rotate"}; QString bdEff{"rotate"};

View File

@ -14,6 +14,8 @@ EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) {
zoom = json["zoom"].toInt(100); zoom = json["zoom"].toInt(100);
_x = json["offX"].toInt(0); _x = json["offX"].toInt(0);
_y = json["offY"].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) { void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
@ -84,7 +86,8 @@ QWidget* EWeb::attrWgt() {
_x = value; _x = value;
}); });
hBox->addWidget(fdX); hBox->addWidget(fdX);
hBox->addSpacing(9); hBox->addSpacing(-3);
hBox->addLabel()->setMinimumWidth(30);
hBox->addLabel("Y:"); hBox->addLabel("Y:");
auto fdY = new QSpinBox; auto fdY = new QSpinBox;
@ -96,6 +99,34 @@ QWidget* EWeb::attrWgt() {
hBox->addWidget(fdY); hBox->addWidget(fdY);
hBox->addStretch(); 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(); vBox->addStretch();
return wgtAttr; return wgtAttr;
} }
@ -108,5 +139,7 @@ JObj EWeb::attrJson() const {
obj["zoom"] = zoom; obj["zoom"] = zoom;
obj["offX"] = _x; obj["offX"] = _x;
obj["offY"] = _y; obj["offY"] = _y;
obj["scaleX"] = scaleX;
obj["scaleY"] = scaleY;
return obj; return obj;
} }

View File

@ -21,7 +21,7 @@ public:
JObj attrJson() const override; JObj attrJson() const override;
QString url; QString url;
int zoom = 100, _x = 0, _y = 0; int zoom = 100, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
}; };
#endif // EWEB_H #endif // EWEB_H

View File

@ -509,6 +509,8 @@ JObj GenTmpThread::convertWeb(const JValue &res) {
dst["zoom"] = res["zoom"]; dst["zoom"] = res["zoom"];
dst["offX"] = res["offX"]; dst["offX"] = res["offX"];
dst["offY"] = res["offY"]; dst["offY"] = res["offY"];
dst["scaleX"] = res["scaleX"].toDouble(100)/100;
dst["scaleY"] = res["scaleY"].toDouble(100)/100;
return dst; return dst;
} }
JObj GenTmpThread::convertTimer(const JValue &json) { JObj GenTmpThread::convertTimer(const JValue &json) {

View File

@ -51,13 +51,14 @@ void SendProgThread::run() {
auto resp = tcp.readAll(); auto resp = tcp.readAll();
QString error; QString error;
auto res = JFrom(resp, &error); auto res = JFrom(resp, &error);
while(error.endsWith("end-of-input")) { while(error.contains("end-of-input")) {
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForRead2 'checkExist'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForRead2 'checkExist'");
tcp.close(); tcp.close();
return; return;
} }
resp += tcp.readAll(); resp += tcp.readAll();
error = "";
res = JFrom(resp, &error); res = JFrom(resp, &error);
} }
if(! error.isEmpty()) { if(! error.isEmpty()) {