所有项目
|
@ -18,6 +18,7 @@ moc_*.cpp
|
||||||
qrc_*.cpp
|
qrc_*.cpp
|
||||||
ui_*.h
|
ui_*.h
|
||||||
Makefile*
|
Makefile*
|
||||||
|
*/build/*
|
||||||
build-*
|
build-*
|
||||||
|
|
||||||
# QtCreator
|
# QtCreator
|
||||||
|
|
|
@ -10,7 +10,7 @@ RESOURCES += res.qrc
|
||||||
win32 {
|
win32 {
|
||||||
EXE_SUFFIX = .exe
|
EXE_SUFFIX = .exe
|
||||||
|
|
||||||
copy.files += $$files(ffmpeg/bin/*.dll)
|
# copy.files += $$files(ffmpeg/bin/*.dll)
|
||||||
# copy.files += 7z/7z.dll
|
# copy.files += 7z/7z.dll
|
||||||
# copy.files += 7z/7z.exe
|
# copy.files += 7z/7z.exe
|
||||||
|
|
||||||
|
@ -28,17 +28,17 @@ osx {
|
||||||
QMAKE_BUNDLE_DATA += copy
|
QMAKE_BUNDLE_DATA += copy
|
||||||
QMAKE_BUNDLE_DATA += copydir
|
QMAKE_BUNDLE_DATA += copydir
|
||||||
}
|
}
|
||||||
copy.files += ffmpeg$$DIR_SUFFIX/bin/ffmpeg$$EXE_SUFFIX
|
# copy.files += ffmpeg$$DIR_SUFFIX/bin/ffmpeg$$EXE_SUFFIX
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/ffmpeg$$DIR_SUFFIX/include
|
# INCLUDEPATH += $$PWD/ffmpeg$$DIR_SUFFIX/include
|
||||||
LIBS += -L$$PWD/ffmpeg$$DIR_SUFFIX/lib/\
|
# LIBS += -L$$PWD/ffmpeg$$DIR_SUFFIX/lib/\
|
||||||
-lavcodec \
|
# -lavcodec \
|
||||||
-lavdevice \
|
# -lavdevice \
|
||||||
-lavfilter \
|
# -lavfilter \
|
||||||
-lavformat \
|
# -lavformat \
|
||||||
-lavutil \
|
# -lavutil \
|
||||||
-lswresample \
|
# -lswresample \
|
||||||
-lswscale
|
# -lswscale
|
||||||
|
|
||||||
|
|
||||||
# You can make your code fail to compile if it uses deprecated APIs.
|
# You can make your code fail to compile if it uses deprecated APIs.
|
||||||
|
@ -46,7 +46,6 @@ LIBS += -L$$PWD/ffmpeg$$DIR_SUFFIX/lib/\
|
||||||
#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
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ffutil.cpp \
|
|
||||||
gutil/cu.cpp \
|
gutil/cu.cpp \
|
||||||
gutil/qaesencryption.cpp \
|
gutil/qaesencryption.cpp \
|
||||||
gutil/qcore.cpp \
|
gutil/qcore.cpp \
|
||||||
|
@ -59,10 +58,11 @@ SOURCES += \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
mediapanel.cpp \
|
mediapanel.cpp \
|
||||||
opendlg.cpp \
|
opendlg.cpp \
|
||||||
planpanel.cpp
|
outputpanel.cpp \
|
||||||
|
planpanel.cpp \
|
||||||
|
progresspanel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
ffutil.h \
|
|
||||||
gutil/cu.h \
|
gutil/cu.h \
|
||||||
gutil/qaesencryption.h \
|
gutil/qaesencryption.h \
|
||||||
gutil/qcore.h \
|
gutil/qcore.h \
|
||||||
|
@ -75,7 +75,9 @@ HEADERS += \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
mediapanel.h \
|
mediapanel.h \
|
||||||
opendlg.h \
|
opendlg.h \
|
||||||
planpanel.h
|
outputpanel.h \
|
||||||
|
planpanel.h \
|
||||||
|
progresspanel.h
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
#include "ffutil.h"
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QDebug>
|
|
||||||
extern "C"{
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libswscale/swscale.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
static void imgCleanupHandler(void *info) {
|
|
||||||
delete [] (uchar*)info;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id) {
|
|
||||||
AVFormatContext *fmt_ctx = avformat_alloc_context();
|
|
||||||
QString err;
|
|
||||||
{
|
|
||||||
if(avformat_open_input(&fmt_ctx, url.constData(), 0, 0) != 0) {
|
|
||||||
err = "Couldn't open input stream";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
if(avformat_find_stream_info(fmt_ctx, 0) < 0) {
|
|
||||||
err = "Couldn't find stream information";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
if(dur) *dur = fmt_ctx->duration;
|
|
||||||
int vi_idx = -1;
|
|
||||||
for(uint ss=0; ss<fmt_ctx->nb_streams; ss++) if(fmt_ctx->streams[ss]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {vi_idx = ss; break;}
|
|
||||||
if(vi_idx == -1) {
|
|
||||||
err = "Didn't find a Video Stream";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
auto codecpar = fmt_ctx->streams[vi_idx]->codecpar;
|
|
||||||
if(codec_id) *codec_id = codecpar->codec_id;
|
|
||||||
qDebug()<<"codecpar w h"<<codecpar->width<<"x"<<codecpar->height<<"codec_id"<<codecpar->codec_id<<avcodec_get_name(codecpar->codec_id);
|
|
||||||
if(av_seek_frame(fmt_ctx, -1, 1000000, AVSEEK_FLAG_BACKWARD) < 0) {
|
|
||||||
err = "av_seek_frame fail";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
const AVCodec *decoder = avcodec_find_decoder(codecpar->codec_id);
|
|
||||||
if(decoder==0) {
|
|
||||||
err = "Could not found Video Decoder";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
auto vcCtx = avcodec_alloc_context3(decoder);
|
|
||||||
avcodec_parameters_to_context(vcCtx, codecpar);
|
|
||||||
if(avcodec_open2(vcCtx, decoder, 0) < 0) {
|
|
||||||
err = "Could not open Video Codec Ctx";
|
|
||||||
avcodec_free_context(&vcCtx);
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
auto sws_ctx = sws_getContext(vcCtx->width, vcCtx->height, vcCtx->pix_fmt, vcCtx->width, vcCtx->height, AV_PIX_FMT_RGB32, SWS_FAST_BILINEAR, 0, 0, 0);
|
|
||||||
auto packet = av_packet_alloc();
|
|
||||||
auto frm = av_frame_alloc();
|
|
||||||
int dstStride[4]{(vcCtx->width*4+63)/64*64};
|
|
||||||
dstStride[3] = dstStride[0] * vcCtx->height;
|
|
||||||
uint8_t *dst[4]{0};
|
|
||||||
while(1) {
|
|
||||||
if(av_read_frame(fmt_ctx, packet) < 0) break;
|
|
||||||
if(packet->stream_index != vi_idx) continue;
|
|
||||||
int res = avcodec_send_packet(vcCtx, packet);
|
|
||||||
if(res < 0) break;
|
|
||||||
while((res = avcodec_receive_frame(vcCtx, frm)) != AVERROR(EAGAIN)) {
|
|
||||||
if(res < 0) goto free2;
|
|
||||||
dst[0] = new uchar[dstStride[3]];
|
|
||||||
sws_scale(sws_ctx, frm->data, frm->linesize, 0, vcCtx->height, dst, dstStride);
|
|
||||||
img = QImage(dst[0], vcCtx->width, vcCtx->height, dstStride[0], QImage::Format_ARGB32, imgCleanupHandler, dst[0]);
|
|
||||||
goto free2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free2:
|
|
||||||
av_frame_free(&frm);
|
|
||||||
av_packet_free(&packet);
|
|
||||||
avcodec_free_context(&vcCtx);
|
|
||||||
sws_freeContext(sws_ctx);
|
|
||||||
}
|
|
||||||
free:
|
|
||||||
avformat_close_input(&fmt_ctx);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
QString audioInfo(QByteArray url, int64_t *dur) {
|
|
||||||
AVFormatContext *fmt_ctx = avformat_alloc_context();
|
|
||||||
QString err;
|
|
||||||
{
|
|
||||||
if(avformat_open_input(&fmt_ctx, url.constData(), nullptr, nullptr) != 0) {
|
|
||||||
err = "Couldn't open input stream";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
if(avformat_find_stream_info(fmt_ctx, nullptr) < 0) {
|
|
||||||
err = "Couldn't find stream information";
|
|
||||||
goto free;
|
|
||||||
}
|
|
||||||
if(dur!=nullptr) *dur = fmt_ctx->duration;
|
|
||||||
}
|
|
||||||
free:
|
|
||||||
avformat_close_input(&fmt_ctx);
|
|
||||||
return err;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef FFUTIL_H
|
|
||||||
#define FFUTIL_H
|
|
||||||
|
|
||||||
#include <QImage>
|
|
||||||
extern "C"{
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
QString videoInfo(QByteArray url, QImage &, int64_t *dur, AVCodecID *);
|
|
||||||
QString audioInfo(QByteArray url, int64_t *dur);
|
|
||||||
|
|
||||||
#endif // FFUTIL_H
|
|
|
@ -7,71 +7,54 @@
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QGraphicsVideoItem>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
|
||||||
Layer::Layer(int idx, const QString &name, QWidget *parent) : QWidget(parent), idx(idx), name(name) {
|
void Layer::paintEvent(QPaintEvent *) {
|
||||||
mSidePen.setCapStyle(Qt::FlatCap);
|
|
||||||
mSidePen.setDashPattern(QVector<qreal>{1,3});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::paintEvent(QPaintEvent *event) {
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
if(isSelected) {
|
if(gEditView->selected == this) {
|
||||||
mSidePen.setColor(Qt::green);
|
painter.setPen(item ? Qt::cyan : Qt::green);
|
||||||
painter.setPen(mSidePen);
|
|
||||||
painter.drawRect(0, 0, width(), height());
|
painter.drawRect(0, 0, width(), height());
|
||||||
m_rLT = QRectF(-HandleSize/2, -HandleSize/2, HandleSize, HandleSize);//左上角
|
painter.drawRect(hdlLT);
|
||||||
m_rT = QRectF(width()/2 - HandleSize/2, -HandleSize/2, HandleSize, HandleSize);//上中
|
painter.drawRect(hdlT);
|
||||||
m_rRT = QRectF(width() - HandleSize/2, - HandleSize/2, HandleSize, HandleSize);//右上角
|
painter.drawRect(hdlRT);
|
||||||
m_rL = QRectF(-HandleSize/2, height()/2 - HandleSize/2, HandleSize, HandleSize);
|
painter.drawRect(hdlL);
|
||||||
m_rR = QRectF(width() - HandleSize/2, height()/2 - HandleSize/2, HandleSize, HandleSize);
|
painter.drawRect(hdlR);
|
||||||
m_rLB = QRectF(-HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
|
painter.drawRect(hdlLB);
|
||||||
m_rB = QRectF(width()/2 - HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
|
painter.drawRect(hdlB);
|
||||||
m_rRB = QRectF(width() - HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
|
painter.drawRect(hdlRB);
|
||||||
painter.setPen(Qt::green);
|
|
||||||
painter.drawRect(m_rLT);
|
|
||||||
painter.drawRect(m_rT);
|
|
||||||
painter.drawRect(m_rRT);
|
|
||||||
painter.drawRect(m_rL);
|
|
||||||
painter.drawRect(m_rR);
|
|
||||||
painter.drawRect(m_rLB);
|
|
||||||
painter.drawRect(m_rB);
|
|
||||||
painter.drawRect(m_rRB);
|
|
||||||
} else {
|
} else {
|
||||||
mSidePen.setColor(Qt::darkGreen);
|
painter.setPen(item ? Qt::darkCyan : Qt::darkGreen);
|
||||||
painter.setPen(mSidePen);
|
|
||||||
painter.drawRect(0, 0, width(), height());
|
painter.drawRect(0, 0, width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
//磁条吸附时两化吸附的边
|
QRectF rect(8, 8, width()-16, height()-16);
|
||||||
static QPen snapPen(Qt::green);
|
if(item) painter.drawText(rect, QString("%1\n%2×%3").arg(name).arg(sSize.width()).arg(sSize.height()), QTextOption(Qt::AlignCenter));
|
||||||
painter.setPen(snapPen);
|
else {
|
||||||
|
painter.drawText(rect, QString("%1 %2").arg(name).arg(idx), QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
||||||
|
painter.drawText(rect, QString("%1×%2").arg(sSize.width()).arg(sSize.height()), QTextOption(Qt::AlignRight | Qt::AlignBottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
//吸附 high light
|
||||||
|
if(gEditView->selected != this)painter.setPen(item ? Qt::cyan : Qt::green);
|
||||||
if(snapLR==1) painter.drawLine(0, 0, 0, height());
|
if(snapLR==1) painter.drawLine(0, 0, 0, height());
|
||||||
else if(snapLR==2) painter.drawLine(width(), 0, width(), height());
|
else if(snapLR==2) painter.drawLine(width(), 0, width(), height());
|
||||||
if(snapTB==1) painter.drawLine(0, 0, width(), 0);
|
if(snapTB==1) painter.drawLine(0, 0, width(), 0);
|
||||||
else if(snapTB==2) painter.drawLine(0, height(), width(), height());
|
else if(snapTB==2) painter.drawLine(0, height(), width(), height());
|
||||||
|
|
||||||
QRectF rect(8, 8, width()-16, height()-16);
|
|
||||||
painter.drawText(rect, QString("%1 %2").arg(name).arg(idx), QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
|
||||||
painter.drawText(rect, QString("%1*%2").arg(sSize.width()).arg(sSize.height()), QTextOption(Qt::AlignRight | Qt::AlignBottom));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::mousePressEvent(QMouseEvent *e) {
|
void Layer::mousePressEvent(QMouseEvent *e) {
|
||||||
QWidget::mousePressEvent(e);
|
QWidget::mousePressEvent(e);
|
||||||
if(e->button() != Qt::LeftButton) return;
|
if(e->button() != Qt::LeftButton) return;
|
||||||
if(! isSelected) {
|
if(item) {
|
||||||
isSelected = true;
|
if(! gOutPanel->isVisible()) return;
|
||||||
otherLayers.clear();
|
if(gEditView->selected!=this) {
|
||||||
auto parent = this->parentWidget();
|
gOutPanel->enCurChanged = false;
|
||||||
if(parent) {
|
gOutPanel->tree->setCurrentItem(item);
|
||||||
auto children = parent->children();
|
gOutPanel->enCurChanged = true;
|
||||||
for(auto child : children) if(child!=this) {
|
|
||||||
auto layer = dynamic_cast<Layer*>(child);
|
|
||||||
if(layer==0) continue;
|
|
||||||
layer->isSelected = false;
|
|
||||||
otherLayers.emplace_back(layer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else if(gOutPanel->isVisible()) return;
|
||||||
|
gEditView->select(this);
|
||||||
setFrmSec(e->pos());
|
setFrmSec(e->pos());
|
||||||
auto mousePos = e->globalPosition();
|
auto mousePos = e->globalPosition();
|
||||||
auto elePos = pos();
|
auto elePos = pos();
|
||||||
|
@ -91,8 +74,7 @@ void Layer::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
QWidget::mouseReleaseEvent(event);
|
QWidget::mouseReleaseEvent(event);
|
||||||
if(Qt::LeftButton == event->button()) {
|
if(Qt::LeftButton == event->button()) {
|
||||||
mPressRel.setX(FLT_MAX);
|
mPressRel.setX(FLT_MAX);
|
||||||
clearSnap();
|
for(auto layer : gEditView->layers) layer->clearSnap();
|
||||||
for(auto ele : otherLayers) ele->clearSnap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define SnapSpace 6
|
#define SnapSpace 6
|
||||||
|
@ -101,163 +83,167 @@ void Layer::mouseMoveEvent(QMouseEvent *e) {
|
||||||
setFrmSec(e->pos());
|
setFrmSec(e->pos());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! isSelected) return;
|
if(gEditView->selected != this) return;
|
||||||
if(mFrmSec==Qt::NoSection || mPressRel.x()>=FLT_MAX) return;
|
if(mFrmSec==Qt::NoSection || mPressRel.x()>=FLT_MAX) return;
|
||||||
auto mousePos = e->globalPosition();
|
auto mousePos = e->globalPosition();
|
||||||
auto dstHor = mPressRel.x() + mousePos.x();
|
auto dstHor = mPressRel.x() + mousePos.x();
|
||||||
auto dstVer = mPressRel.y() + mousePos.y();
|
auto dstVer = mPressRel.y() + mousePos.y();
|
||||||
snapLR = snapTB = 0;
|
bool posChanged = false, sizeChanged = false;
|
||||||
for(auto ele : otherLayers) ele->clearSnap();
|
for(auto layer : gEditView->layers) layer->clearSnap();
|
||||||
if(mFrmSec==Qt::TitleBarArea) {
|
if(mFrmSec==Qt::TitleBarArea) {
|
||||||
if(snapLR==0) for(auto ele : otherLayers) {//左右
|
if(snapLR==0) for(auto layer : gEditView->layers) if(layer!=this) {//左右
|
||||||
if(fabs(dstHor - ele->x()) < SnapSpace) {
|
if(fabs(dstHor - layer->x()) < SnapSpace) {
|
||||||
dstHor = ele->x();
|
dstHor = layer->x();
|
||||||
snapLR = 1;
|
snapLR = 1;
|
||||||
ele->snapLR = 1;
|
layer->snapLR = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto eleRight = ele->x() + ele->width();
|
auto eleRight = layer->x() + layer->width();
|
||||||
if(fabs(dstHor - eleRight) < SnapSpace) {
|
if(fabs(dstHor - eleRight) < SnapSpace) {
|
||||||
dstHor = eleRight;
|
dstHor = eleRight;
|
||||||
snapLR = 1;
|
snapLR = 1;
|
||||||
ele->snapLR = 2;
|
layer->snapLR = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto right = dstHor + width();
|
auto right = dstHor + width();
|
||||||
if(fabs(right - ele->x()) < SnapSpace && ele->x() - width() >= 0) {
|
if(fabs(right - layer->x()) < SnapSpace && layer->x() - width() >= 0) {
|
||||||
dstHor = ele->x() - width();
|
dstHor = layer->x() - width();
|
||||||
snapLR = 2;
|
snapLR = 2;
|
||||||
ele->snapLR = 1;
|
layer->snapLR = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(fabs(right - eleRight) < SnapSpace && eleRight - width() >= 0) {
|
if(fabs(right - eleRight) < SnapSpace && eleRight - width() >= 0) {
|
||||||
dstHor = eleRight - width();
|
dstHor = eleRight - width();
|
||||||
snapLR = 2;
|
snapLR = 2;
|
||||||
ele->snapLR = 2;
|
layer->snapLR = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(snapTB==0) for(auto ele : otherLayers) {//上下
|
if(snapTB==0) for(auto layer : gEditView->layers) if(layer!=this) {//上下
|
||||||
if(fabs(dstVer-ele->y()) < SnapSpace) {
|
if(fabs(dstVer-layer->y()) < SnapSpace) {
|
||||||
dstVer = ele->y();
|
dstVer = layer->y();
|
||||||
snapTB = 1;
|
snapTB = 1;
|
||||||
ele->snapTB = 1;
|
layer->snapTB = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto eleBtm = ele->y() + ele->height();
|
auto eleBtm = layer->y() + layer->height();
|
||||||
if(fabs(dstVer - eleBtm) < SnapSpace) {
|
if(fabs(dstVer - eleBtm) < SnapSpace) {
|
||||||
dstVer = eleBtm;
|
dstVer = eleBtm;
|
||||||
snapTB = 1;
|
snapTB = 1;
|
||||||
ele->snapTB = 2;
|
layer->snapTB = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto btm = dstVer + height();
|
auto btm = dstVer + height();
|
||||||
if(fabs(btm - ele->y()) < SnapSpace && ele->y() - height() >= 0) {
|
if(fabs(btm - layer->y()) < SnapSpace && layer->y() - height() >= 0) {
|
||||||
dstVer = ele->y() - height();
|
dstVer = layer->y() - height();
|
||||||
snapTB = 2;
|
snapTB = 2;
|
||||||
ele->snapTB = 1;
|
layer->snapTB = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(fabs(btm - eleBtm) < SnapSpace && eleBtm - height() >= 0) {
|
if(fabs(btm - eleBtm) < SnapSpace && eleBtm - height() >= 0) {
|
||||||
dstVer = eleBtm - height();
|
dstVer = eleBtm - height();
|
||||||
snapTB = 2;
|
snapTB = 2;
|
||||||
ele->snapTB = 2;
|
layer->snapTB = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
move(dstHor, dstVer);
|
move(dstHor, dstVer);
|
||||||
|
posChanged = true;
|
||||||
} else if(mFrmSec==Qt::BottomRightSection) {
|
} else if(mFrmSec==Qt::BottomRightSection) {
|
||||||
if(dstHor < HandleSize) dstHor = HandleSize;
|
if(dstHor < HandleSize) dstHor = HandleSize;
|
||||||
if(dstVer < HandleSize) dstVer = HandleSize;
|
if(dstVer < HandleSize) dstVer = HandleSize;
|
||||||
resize(dstHor, dstVer);
|
resize(dstHor, dstVer);
|
||||||
|
sizeChanged = true;
|
||||||
} else if(mFrmSec==Qt::RightSection) {
|
} else if(mFrmSec==Qt::RightSection) {
|
||||||
if(dstHor < HandleSize) dstHor = HandleSize;
|
if(dstHor < HandleSize) dstHor = HandleSize;
|
||||||
auto right = x() + dstHor;
|
auto right = x() + dstHor;
|
||||||
for(Layer *ele : otherLayers) {//左右
|
for(Layer *layer : gEditView->layers) if(layer!=this) {//左右
|
||||||
if(fabs(right - ele->x()) < SnapSpace) {
|
if(fabs(right - layer->x()) < SnapSpace) {
|
||||||
dstHor = ele->x() - x();
|
dstHor = layer->x() - x();
|
||||||
snapLR = 2;
|
snapLR = 2;
|
||||||
ele->snapLR = 1;
|
layer->snapLR = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto eleRight = ele->x() + ele->width();
|
auto eleRight = layer->x() + layer->width();
|
||||||
if(fabs(right - eleRight) < SnapSpace) {
|
if(fabs(right - eleRight) < SnapSpace) {
|
||||||
dstHor = eleRight - x();
|
dstHor = eleRight - x();
|
||||||
snapLR = 2;
|
snapLR = 2;
|
||||||
ele->snapLR = 2;
|
layer->snapLR = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resize(dstHor, mPressRel.y());
|
resize(dstHor, mPressRel.y());
|
||||||
|
sizeChanged = true;
|
||||||
} else if(mFrmSec==Qt::BottomSection) {
|
} else if(mFrmSec==Qt::BottomSection) {
|
||||||
if(dstVer < HandleSize) dstVer = HandleSize;
|
if(dstVer < HandleSize) dstVer = HandleSize;
|
||||||
auto btm = y() + dstVer;
|
auto btm = y() + dstVer;
|
||||||
for(Layer *ele : otherLayers) {//上下
|
for(Layer *layer : gEditView->layers) if(layer!=this) {//上下
|
||||||
auto eleBtm = ele->y() + ele->height();
|
auto eleBtm = layer->y() + layer->height();
|
||||||
if(fabs(btm - ele->y()) < SnapSpace) {
|
if(fabs(btm - layer->y()) < SnapSpace) {
|
||||||
dstVer = ele->y() - y();
|
dstVer = layer->y() - y();
|
||||||
snapTB = 2;
|
snapTB = 2;
|
||||||
ele->snapTB = 1;
|
layer->snapTB = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(fabs(btm - eleBtm) < SnapSpace) {
|
if(fabs(btm - eleBtm) < SnapSpace) {
|
||||||
dstVer = eleBtm - y();
|
dstVer = eleBtm - y();
|
||||||
snapTB = 2;
|
snapTB = 2;
|
||||||
ele->snapTB = 2;
|
layer->snapTB = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resize(mPressRel.rx(), dstVer);
|
resize(mPressRel.rx(), dstVer);
|
||||||
|
sizeChanged = true;
|
||||||
} else {
|
} else {
|
||||||
QRectF geo(x(), y(), width(), height());
|
QRectF geo(x(), y(), width(), height());
|
||||||
if(mFrmSec==Qt::LeftSection) {
|
if(mFrmSec==Qt::LeftSection) {
|
||||||
dstHor = qMin(dstHor, geo.right() - HandleSize);
|
dstHor = qMin(dstHor, geo.right() - HandleSize);
|
||||||
if(dstHor > 8) for(auto ele : otherLayers) {//左右
|
if(dstHor > 8) for(auto layer : gEditView->layers) if(layer!=this) {//左右
|
||||||
if(fabs(dstHor - ele->x()) < SnapSpace) {
|
if(fabs(dstHor - layer->x()) < SnapSpace) {
|
||||||
dstHor = ele->x();
|
dstHor = layer->x();
|
||||||
snapLR = 1;
|
snapLR = 1;
|
||||||
ele->snapLR = 1;
|
layer->snapLR = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto eleRight = ele->x() + ele->width();
|
auto eleRight = layer->x() + layer->width();
|
||||||
if(fabs(dstHor - eleRight) < SnapSpace) {
|
if(fabs(dstHor - eleRight) < SnapSpace) {
|
||||||
dstHor = eleRight;
|
dstHor = eleRight;
|
||||||
snapLR = 1;
|
snapLR = 1;
|
||||||
ele->snapLR = 2;
|
layer->snapLR = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
geo.setLeft(dstHor);
|
geo.setLeft(dstHor);
|
||||||
} else if(mFrmSec==Qt::TopSection) {
|
} else if(mFrmSec==Qt::TopSection) {
|
||||||
dstVer = qMin(dstVer, geo.bottom() - HandleSize);
|
dstVer = qMin(dstVer, geo.bottom() - HandleSize);
|
||||||
if(dstVer > 8) for(Layer *ele : otherLayers) {//上下
|
if(dstVer > 8) for(Layer *layer : gEditView->layers) if(layer!=this) {//上下
|
||||||
if(fabs(dstVer - ele->y()) < SnapSpace) {
|
if(fabs(dstVer - layer->y()) < SnapSpace) {
|
||||||
dstVer = ele->y();
|
dstVer = layer->y();
|
||||||
snapTB = 1;
|
snapTB = 1;
|
||||||
ele->snapTB = 1;
|
layer->snapTB = 1;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto eleBtm = ele->y() + ele->height();
|
auto eleBtm = layer->y() + layer->height();
|
||||||
if(fabs(dstVer - eleBtm) < SnapSpace) {
|
if(fabs(dstVer - eleBtm) < SnapSpace) {
|
||||||
dstVer = eleBtm;
|
dstVer = eleBtm;
|
||||||
snapTB = 1;
|
snapTB = 1;
|
||||||
ele->snapTB = 2;
|
layer->snapTB = 2;
|
||||||
ele->update();
|
layer->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,10 +265,44 @@ void Layer::mouseMoveEvent(QMouseEvent *e) {
|
||||||
geo.setBottom(dstVer);
|
geo.setBottom(dstVer);
|
||||||
}
|
}
|
||||||
setGeometry(geo.toRect());
|
setGeometry(geo.toRect());
|
||||||
|
posChanged = true;
|
||||||
|
sizeChanged = true;
|
||||||
|
}
|
||||||
|
if(posChanged) sPos = (pos()-gOrigin) / gScale;
|
||||||
|
if(sizeChanged) sSize = size() / gScale;
|
||||||
|
if(item) {
|
||||||
|
view->setSceneRect({sPos, sSize});
|
||||||
|
if(posChanged) {
|
||||||
|
gOutPanel->edX->blockSignals(true);
|
||||||
|
gOutPanel->edY->blockSignals(true);
|
||||||
|
gOutPanel->edX->setValue(sPos.x());
|
||||||
|
gOutPanel->edY->setValue(sPos.y());
|
||||||
|
gOutPanel->edX->blockSignals(false);
|
||||||
|
gOutPanel->edY->blockSignals(false);
|
||||||
|
}
|
||||||
|
if(sizeChanged) {
|
||||||
|
view->resize(sSize);
|
||||||
|
gOutPanel->edW->blockSignals(true);
|
||||||
|
gOutPanel->edH->blockSignals(true);
|
||||||
|
gOutPanel->edW->setValue(sSize.width());
|
||||||
|
gOutPanel->edH->setValue(sSize.height());
|
||||||
|
gOutPanel->edW->blockSignals(false);
|
||||||
|
gOutPanel->edH->blockSignals(false);
|
||||||
|
item->setText("size"**gOutPanel->tree, QString("%1×%2").arg(sSize.width()).arg(sSize.height()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto cell = (Cell*) gTable->data(rowIdx, gPlayinC).toULongLong();
|
||||||
|
if(cell) {
|
||||||
|
if(posChanged) cell->wgt->setPos(sPos);
|
||||||
|
if(sizeChanged) {
|
||||||
|
if(cell->type=='V') {
|
||||||
|
((QGraphicsVideoItem*) cell->wgt)->setSize(sSize);
|
||||||
|
} else if(cell->type=='I') {
|
||||||
|
((ImgItem*) cell->wgt)->size = sSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sPos = (pos()-gOrigin) / gScale;
|
|
||||||
auto cell = (Cell*) gTable->data(rowIdx, gPlayinC).toULongLong();
|
|
||||||
if(cell) cell->wgt->setPos(sPos);
|
|
||||||
}
|
}
|
||||||
void Layer::leaveEvent(QEvent *) {
|
void Layer::leaveEvent(QEvent *) {
|
||||||
setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
||||||
|
@ -290,14 +310,14 @@ void Layer::leaveEvent(QEvent *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::setFrmSec(const QPointF &pos) {
|
void Layer::setFrmSec(const QPointF &pos) {
|
||||||
if(m_rLT.contains(pos)) setFrmSecIfNeed(Qt::TopLeftSection, Qt::SizeFDiagCursor);
|
if(hdlLT.contains(pos)) setFrmSecIfNeed(Qt::TopLeftSection, Qt::SizeFDiagCursor);
|
||||||
else if(m_rT.contains(pos)) setFrmSecIfNeed(Qt::TopSection, Qt::SizeVerCursor);
|
else if(hdlT.contains(pos)) setFrmSecIfNeed(Qt::TopSection, Qt::SizeVerCursor);
|
||||||
else if(m_rRT.contains(pos)) setFrmSecIfNeed(Qt::TopRightSection, Qt::SizeBDiagCursor);
|
else if(hdlRT.contains(pos)) setFrmSecIfNeed(Qt::TopRightSection, Qt::SizeBDiagCursor);
|
||||||
else if(m_rL.contains(pos)) setFrmSecIfNeed(Qt::LeftSection, Qt::SizeHorCursor);
|
else if(hdlL.contains(pos)) setFrmSecIfNeed(Qt::LeftSection, Qt::SizeHorCursor);
|
||||||
else if(m_rR.contains(pos)) setFrmSecIfNeed(Qt::RightSection, Qt::SizeHorCursor);
|
else if(hdlR.contains(pos)) setFrmSecIfNeed(Qt::RightSection, Qt::SizeHorCursor);
|
||||||
else if(m_rLB.contains(pos)) setFrmSecIfNeed(Qt::BottomLeftSection, Qt::SizeBDiagCursor);
|
else if(hdlLB.contains(pos)) setFrmSecIfNeed(Qt::BottomLeftSection, Qt::SizeBDiagCursor);
|
||||||
else if(m_rB.contains(pos)) setFrmSecIfNeed(Qt::BottomSection, Qt::SizeVerCursor);
|
else if(hdlB.contains(pos)) setFrmSecIfNeed(Qt::BottomSection, Qt::SizeVerCursor);
|
||||||
else if(m_rRB.contains(pos)) setFrmSecIfNeed(Qt::BottomRightSection, Qt::SizeFDiagCursor);
|
else if(hdlRB.contains(pos)) setFrmSecIfNeed(Qt::BottomRightSection, Qt::SizeFDiagCursor);
|
||||||
else if(pos.x()>=0 && pos.x()<=width() && pos.y()>=0 && pos.y()<=height()) setFrmSecIfNeed(Qt::TitleBarArea, Qt::SizeAllCursor);
|
else if(pos.x()>=0 && pos.x()<=width() && pos.y()>=0 && pos.y()<=height()) setFrmSecIfNeed(Qt::TitleBarArea, Qt::SizeAllCursor);
|
||||||
else setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
else setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
@ -313,3 +333,114 @@ void Layer::clearSnap() {
|
||||||
snapLR = snapTB = 0;
|
snapLR = snapTB = 0;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutputView::OutputView(QWidget *parent) : QGraphicsView(parent) {
|
||||||
|
auto format = QSurfaceFormat::defaultFormat();
|
||||||
|
format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
|
||||||
|
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
|
auto glWgt = new QOpenGLWidget;
|
||||||
|
glWgt->setFormat(format);
|
||||||
|
|
||||||
|
setViewport(glWgt);
|
||||||
|
setWindowFlag(Qt::FramelessWindowHint);
|
||||||
|
setAttribute(Qt::WA_AlwaysStackOnTop);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setBackgroundBrush(Qt::black);
|
||||||
|
setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||||
|
setTransformationAnchor(QGraphicsView::NoAnchor);
|
||||||
|
setInteractive(false);
|
||||||
|
setScene(gScene);
|
||||||
|
}
|
||||||
|
void OutputView::mousePressEvent(QMouseEvent *e) {
|
||||||
|
QWidget::mousePressEvent(e);
|
||||||
|
if(e->button() != Qt::LeftButton) return;
|
||||||
|
auto mousePos = e->globalPosition();
|
||||||
|
auto elePos = pos();
|
||||||
|
mPressRel = elePos - mousePos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputView::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
|
QWidget::mouseReleaseEvent(event);
|
||||||
|
if(Qt::LeftButton == event->button()) {
|
||||||
|
mPressRel.setX(FLT_MAX);
|
||||||
|
}
|
||||||
|
setAttribute(Qt::WA_AlwaysStackOnTop);
|
||||||
|
}
|
||||||
|
#define SnapSpace 6
|
||||||
|
void OutputView::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
if(! (e->buttons() & Qt::LeftButton)) return;
|
||||||
|
if(mPressRel.x()>=FLT_MAX) return;
|
||||||
|
auto mousePos = e->globalPosition();
|
||||||
|
auto dstHor = mPressRel.x() + mousePos.x();
|
||||||
|
auto dstVer = mPressRel.y() + mousePos.y();
|
||||||
|
// if(snapLR==0) for(auto layer : gEditView->layers) if(layer!=this) {//左右
|
||||||
|
// if(fabs(dstHor - layer->x()) < SnapSpace) {
|
||||||
|
// dstHor = layer->x();
|
||||||
|
// snapLR = 1;
|
||||||
|
// layer->snapLR = 1;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// auto eleRight = layer->x() + layer->width();
|
||||||
|
// if(fabs(dstHor - eleRight) < SnapSpace) {
|
||||||
|
// dstHor = eleRight;
|
||||||
|
// snapLR = 1;
|
||||||
|
// layer->snapLR = 2;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// auto right = dstHor + width();
|
||||||
|
// if(fabs(right - layer->x()) < SnapSpace && layer->x() - width() >= 0) {
|
||||||
|
// dstHor = layer->x() - width();
|
||||||
|
// snapLR = 2;
|
||||||
|
// layer->snapLR = 1;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// if(fabs(right - eleRight) < SnapSpace && eleRight - width() >= 0) {
|
||||||
|
// dstHor = eleRight - width();
|
||||||
|
// snapLR = 2;
|
||||||
|
// layer->snapLR = 2;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(snapTB==0) for(auto layer : gEditView->layers) if(layer!=this) {//上下
|
||||||
|
// if(fabs(dstVer-layer->y()) < SnapSpace) {
|
||||||
|
// dstVer = layer->y();
|
||||||
|
// snapTB = 1;
|
||||||
|
// layer->snapTB = 1;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// auto eleBtm = layer->y() + layer->height();
|
||||||
|
// if(fabs(dstVer - eleBtm) < SnapSpace) {
|
||||||
|
// dstVer = eleBtm;
|
||||||
|
// snapTB = 1;
|
||||||
|
// layer->snapTB = 2;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// auto btm = dstVer + height();
|
||||||
|
// if(fabs(btm - layer->y()) < SnapSpace && layer->y() - height() >= 0) {
|
||||||
|
// dstVer = layer->y() - height();
|
||||||
|
// snapTB = 2;
|
||||||
|
// layer->snapTB = 1;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// if(fabs(btm - eleBtm) < SnapSpace && eleBtm - height() >= 0) {
|
||||||
|
// dstVer = eleBtm - height();
|
||||||
|
// snapTB = 2;
|
||||||
|
// layer->snapTB = 2;
|
||||||
|
// layer->update();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
move(dstHor, dstVer);
|
||||||
|
}
|
||||||
|
void OutputView::leaveEvent(QEvent *) {
|
||||||
|
//setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
||||||
|
mPressRel.setX(FLT_MAX);
|
||||||
|
}
|
||||||
|
|
|
@ -2,25 +2,25 @@
|
||||||
#define LAYER_H
|
#define LAYER_H
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <QWidget>
|
|
||||||
#include <QPen>
|
|
||||||
|
|
||||||
#define HandleSize 10
|
#define HandleSize 10
|
||||||
|
class OutputView;
|
||||||
|
|
||||||
class Layer : public QWidget {
|
class Layer : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Layer(int idx, const QString &name, QWidget *parent = 0);
|
explicit Layer(int idx, const QString &name, QWidget *parent = 0) : QWidget(parent), idx(idx), name(name) {}
|
||||||
inline void setGeo() {
|
inline void updateGeo() {
|
||||||
setGeometry(QRect(sPos*gScale+gOrigin, sSize*gScale));
|
setGeometry(QRect(sPos*gScale+gOrigin, sSize*gScale));
|
||||||
}
|
}
|
||||||
|
void select();
|
||||||
|
|
||||||
QPoint sPos;
|
QPoint sPos;
|
||||||
QSize sSize{1920, 1080};
|
QSize sSize{1920, 1080};
|
||||||
int idx = 1, rowIdx = 0;
|
int idx = 1, rowIdx = 0;
|
||||||
QString name;
|
QString name;
|
||||||
char type = 'L';
|
TreeWidgetItem *item = 0;
|
||||||
bool isSelected = false;
|
OutputView *view = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
@ -28,18 +28,41 @@ protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *) override;
|
void mouseReleaseEvent(QMouseEvent *) override;
|
||||||
void mouseMoveEvent(QMouseEvent *) override;
|
void mouseMoveEvent(QMouseEvent *) override;
|
||||||
void leaveEvent(QEvent *) override;
|
void leaveEvent(QEvent *) override;
|
||||||
|
void resizeEvent(QResizeEvent *event) override {
|
||||||
|
hdlT = QRectF(width()/2 - HandleSize/2, -HandleSize/2, HandleSize, HandleSize);
|
||||||
|
hdlRT = QRectF(width() - HandleSize/2, - HandleSize/2, HandleSize, HandleSize);
|
||||||
|
hdlL = QRectF(-HandleSize/2, height()/2 - HandleSize/2, HandleSize, HandleSize);
|
||||||
|
hdlR = QRectF(width() - HandleSize/2, height()/2 - HandleSize/2, HandleSize, HandleSize);
|
||||||
|
hdlLB = QRectF(-HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
|
||||||
|
hdlB = QRectF(width()/2 - HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
|
||||||
|
hdlRB = QRectF(width() - HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
|
||||||
|
}
|
||||||
|
|
||||||
void setFrmSec(const QPointF &);
|
void setFrmSec(const QPointF &);
|
||||||
void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
|
void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
|
||||||
void clearSnap();
|
void clearSnap();
|
||||||
|
|
||||||
QPen mSidePen;
|
QRectF hdlLT = QRectF(-HandleSize/2, -HandleSize/2, HandleSize, HandleSize), hdlT, hdlRT, hdlL, hdlR, hdlLB, hdlB, hdlRB;
|
||||||
|
|
||||||
QRectF m_rL, m_rR, m_rT, m_rB, m_rLT, m_rRT, m_rRB, m_rLB;
|
|
||||||
QPointF mPressRel{FLT_MAX, FLT_MAX};
|
QPointF mPressRel{FLT_MAX, FLT_MAX};
|
||||||
Qt::WindowFrameSection mFrmSec = Qt::NoSection;
|
Qt::WindowFrameSection mFrmSec = Qt::NoSection;
|
||||||
char snapLR = 0, snapTB = 0;
|
char snapLR = 0, snapTB = 0;
|
||||||
std::vector<Layer *> otherLayers;
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class OutputView : public QGraphicsView {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit OutputView(QWidget *parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent *) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *) override;
|
||||||
|
void leaveEvent(QEvent *) override;
|
||||||
|
void clearSnap();
|
||||||
|
|
||||||
|
QPointF mPressRel{FLT_MAX, FLT_MAX};
|
||||||
|
char snapLR = 0, snapTB = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAYER_H
|
#endif // LAYER_H
|
||||||
|
|
|
@ -4,26 +4,31 @@
|
||||||
#include "layer.h"
|
#include "layer.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
|
||||||
LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
|
LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
|
||||||
gScene = new QGraphicsScene(this);
|
|
||||||
|
|
||||||
auto hBox = new HBox(this);
|
auto hBox = new HBox(this);
|
||||||
hBox->setContentsMargins(0, 0, 0, 0);
|
hBox->setContentsMargins(0, 0, 0, 0);
|
||||||
hBox->setSpacing(0);
|
hBox->setSpacing(0);
|
||||||
|
|
||||||
gEditView = new GraphicsView;
|
auto format = QSurfaceFormat::defaultFormat();
|
||||||
|
format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
|
||||||
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
|
|
||||||
|
gEditView = new EditView;
|
||||||
|
gEditView->setViewport(new QOpenGLWidget);
|
||||||
gEditView->setBackgroundBrush(Qt::black);
|
gEditView->setBackgroundBrush(Qt::black);
|
||||||
gEditView->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
gEditView->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||||
gEditView->setTransformationAnchor(GraphicsView::NoAnchor);
|
gEditView->setTransformationAnchor(QGraphicsView::NoAnchor);
|
||||||
gEditView->setInteractive(false);
|
gEditView->setInteractive(false);
|
||||||
gEditView->setSceneRect({-gOrigin / gScale, QSizeF(1, 1)});
|
gEditView->setSceneRect({-gOrigin / gScale, QSizeF(1, 1)});
|
||||||
gEditView->setScene(gScene);
|
gEditView->setScene(gScene = new QGraphicsScene(this));
|
||||||
gEditView->scale(gScale, gScale);
|
gEditView->scale(gScale, gScale);
|
||||||
|
|
||||||
auto origin = ((GraphicsView*)gEditView)->originWgt = new OriginWgt(gEditView);
|
gEditView->originWgt = new OriginWgt(gEditView);
|
||||||
origin->setGeometry(gOrigin.x()-10, gOrigin.y()-10, 20, 20);
|
gEditView->originWgt->setGeometry(gOrigin.x()-10, gOrigin.y()-10, 20, 20);
|
||||||
|
|
||||||
hBox->addWidget(gEditView);
|
hBox->addWidget(gEditView);
|
||||||
|
|
||||||
|
@ -32,9 +37,9 @@ LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
|
||||||
toolBar->setStyleSheet("QToolBar{spacing: 2px;}");
|
toolBar->setStyleSheet("QToolBar{spacing: 2px;}");
|
||||||
toolBar->setIconSize({18, 18});
|
toolBar->setIconSize({18, 18});
|
||||||
|
|
||||||
auto actScaleUp = new QAction(QIcon(":/res/program/ScaleUp.png"), tr("Zoom In"));
|
auto actScaleAdd = new QAction(QIcon(":/res/program/ScaleUp.png"), tr("Zoom In"));
|
||||||
toolBar->addAction(actScaleUp);
|
toolBar->addAction(actScaleAdd);
|
||||||
connect(actScaleUp, &QAction::triggered, this, [this] {
|
connect(actScaleAdd, &QAction::triggered, this, [this] {
|
||||||
if(gScale >= 8) return;
|
if(gScale >= 8) return;
|
||||||
gScale *= 1.1;
|
gScale *= 1.1;
|
||||||
scaleChanged();
|
scaleChanged();
|
||||||
|
@ -45,9 +50,9 @@ LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
|
||||||
edScale->setAlignment(Qt::AlignCenter);
|
edScale->setAlignment(Qt::AlignCenter);
|
||||||
toolBar->addWidget(edScale);
|
toolBar->addWidget(edScale);
|
||||||
|
|
||||||
auto actScaleDown = new QAction(QIcon(":/res/program/ScaleDown.png"), tr("Zoom Out"));
|
auto actScaleMinus = new QAction(QIcon(":/res/program/ScaleDown.png"), tr("Zoom Out"));
|
||||||
toolBar->addAction(actScaleDown);
|
toolBar->addAction(actScaleMinus);
|
||||||
connect(actScaleDown, &QAction::triggered, this, [this] {
|
connect(actScaleMinus, &QAction::triggered, this, [this] {
|
||||||
if(gScale <= 0.01) return;
|
if(gScale <= 0.01) return;
|
||||||
gScale *= 0.909090909090;
|
gScale *= 0.909090909090;
|
||||||
scaleChanged();
|
scaleChanged();
|
||||||
|
@ -65,15 +70,13 @@ LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
|
||||||
toolBar->addAction(actFull);
|
toolBar->addAction(actFull);
|
||||||
hBox->addWidget(toolBar);
|
hBox->addWidget(toolBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiveEditor::scaleChanged() {
|
void LiveEditor::scaleChanged() {
|
||||||
gEditView->setSceneRect({-gOrigin / gScale, QSizeF(1, 1)});
|
gEditView->setSceneRect({-gOrigin / gScale, QSizeF(1, 1)});
|
||||||
QTransform tran;
|
QTransform tran;
|
||||||
tran.scale(gScale, gScale);
|
tran.scale(gScale, gScale);
|
||||||
gEditView->setTransform(tran);
|
gEditView->setTransform(tran);
|
||||||
for(auto child : gEditView->children()) {
|
for(auto layer : gEditView->layers) layer->updateGeo();
|
||||||
auto layer = dynamic_cast<Layer *>(child);
|
|
||||||
if(layer) layer->setGeo();
|
|
||||||
}
|
|
||||||
edScale->setText(QString::number(gScale));
|
edScale->setText(QString::number(gScale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,20 +86,40 @@ void LiveEditor::onTileFull() {
|
||||||
// element->setPos(0,0);
|
// element->setPos(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditView::select(Layer *layer) {
|
||||||
void GraphicsView::mousePressEvent(QMouseEvent *e) {
|
if(selected==layer) return;
|
||||||
|
if(selected) selected->update();
|
||||||
|
selected = layer;
|
||||||
|
if(selected==0) return;
|
||||||
|
selected->update();
|
||||||
|
if(selected->item) {
|
||||||
|
gOutPanel->edName->setText(selected->item->text("name"**gOutPanel->tree));
|
||||||
|
gOutPanel->edX->blockSignals(true);
|
||||||
|
gOutPanel->edY->blockSignals(true);
|
||||||
|
gOutPanel->edW->blockSignals(true);
|
||||||
|
gOutPanel->edH->blockSignals(true);
|
||||||
|
gOutPanel->edX->setValue(selected->sPos.x());
|
||||||
|
gOutPanel->edY->setValue(selected->sPos.y());
|
||||||
|
gOutPanel->edW->setValue(selected->sSize.width());
|
||||||
|
gOutPanel->edH->setValue(selected->sSize.height());
|
||||||
|
gOutPanel->edX->blockSignals(false);
|
||||||
|
gOutPanel->edY->blockSignals(false);
|
||||||
|
gOutPanel->edW->blockSignals(false);
|
||||||
|
gOutPanel->edH->blockSignals(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void EditView::mousePressEvent(QMouseEvent *e) {
|
||||||
QWidget::mousePressEvent(e);
|
QWidget::mousePressEvent(e);
|
||||||
if(e->button() != Qt::LeftButton) return;
|
if(e->button() != Qt::LeftButton) return;
|
||||||
pressRel = gOrigin - e->globalPosition().toPoint();
|
pressRel = gOrigin - e->globalPosition().toPoint();
|
||||||
}
|
}
|
||||||
|
void EditView::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
void GraphicsView::mouseReleaseEvent(QMouseEvent *event) {
|
|
||||||
QWidget::mouseReleaseEvent(event);
|
QWidget::mouseReleaseEvent(event);
|
||||||
if(Qt::LeftButton == event->button()) {
|
if(Qt::LeftButton == event->button()) {
|
||||||
pressRel.setX(INT_MAX);
|
pressRel.setX(INT_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GraphicsView::mouseMoveEvent(QMouseEvent *e) {
|
void EditView::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if(! (e->buttons() & Qt::LeftButton)) return;
|
if(! (e->buttons() & Qt::LeftButton)) return;
|
||||||
if(pressRel.x()==INT_MAX) return;
|
if(pressRel.x()==INT_MAX) return;
|
||||||
auto mousePos = e->globalPosition().toPoint();
|
auto mousePos = e->globalPosition().toPoint();
|
||||||
|
|
|
@ -4,6 +4,17 @@
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
|
class Layer;
|
||||||
|
class LiveEditor : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LiveEditor(QWidget *parent = 0);
|
||||||
|
void scaleChanged();
|
||||||
|
void onTileFull();
|
||||||
|
|
||||||
|
QLabel *edScale;
|
||||||
|
};
|
||||||
|
|
||||||
class OriginWgt : public QWidget {
|
class OriginWgt : public QWidget {
|
||||||
public:
|
public:
|
||||||
using QWidget::QWidget;
|
using QWidget::QWidget;
|
||||||
|
@ -14,23 +25,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Layer;
|
class EditView : public QGraphicsView {
|
||||||
class LiveEditor : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit LiveEditor(QWidget *parent = 0);
|
|
||||||
|
|
||||||
Layer* selected();
|
|
||||||
void scaleChanged();
|
|
||||||
void onTileFull();
|
|
||||||
|
|
||||||
QLabel *edScale;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GraphicsView : public QGraphicsView {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
using QGraphicsView::QGraphicsView;
|
using QGraphicsView::QGraphicsView;
|
||||||
|
void select(Layer *layer);
|
||||||
|
|
||||||
|
Layer* selected = 0;
|
||||||
|
std::vector<Layer*> layers;
|
||||||
OriginWgt *originWgt;
|
OriginWgt *originWgt;
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *) override;
|
void mousePressEvent(QMouseEvent *) override;
|
||||||
|
|
|
@ -10,9 +10,10 @@ QString gProgFile;
|
||||||
JObj gProg;
|
JObj gProg;
|
||||||
const QString UpdVerUrl;
|
const QString UpdVerUrl;
|
||||||
QGraphicsScene *gScene;
|
QGraphicsScene *gScene;
|
||||||
QGraphicsView *gEditView;
|
EditView *gEditView;
|
||||||
double gScale = 0.1;
|
double gScale = 0.1;
|
||||||
QPoint gOrigin{20, 20};
|
QPoint gOrigin{20, 20};
|
||||||
|
OutputPanel *gOutPanel;
|
||||||
TableWidget *gTable, *gTableH, *gTableV;
|
TableWidget *gTable, *gTableH, *gTableV;
|
||||||
int gPlayinC = 0;
|
int gPlayinC = 0;
|
||||||
//Tick *gTick;
|
//Tick *gTick;
|
||||||
|
@ -107,6 +108,5 @@ int main(int argc, char *argv[]) {
|
||||||
//if(dlg.exec()!=QDialog::Accepted) return 0;
|
//if(dlg.exec()!=QDialog::Accepted) return 0;
|
||||||
}
|
}
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qjson.h"
|
#include "gutil/qjson.h"
|
||||||
|
#include "liveeditor.h"
|
||||||
|
#include "outputpanel.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include "QImageReader"
|
#include "QImageReader"
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
@ -15,9 +17,10 @@ extern QString gProgFile;
|
||||||
extern JObj gProg;
|
extern JObj gProg;
|
||||||
extern const QString UpdVerUrl;
|
extern const QString UpdVerUrl;
|
||||||
extern QGraphicsScene *gScene;
|
extern QGraphicsScene *gScene;
|
||||||
extern QGraphicsView *gEditView;
|
extern EditView *gEditView;
|
||||||
extern double gScale;
|
extern double gScale;
|
||||||
extern QPoint gOrigin;
|
extern QPoint gOrigin;
|
||||||
|
extern OutputPanel *gOutPanel;
|
||||||
extern TableWidget *gTable, *gTableH, *gTableV;
|
extern TableWidget *gTable, *gTableH, *gTableV;
|
||||||
extern int gPlayinC;
|
extern int gPlayinC;
|
||||||
//extern Tick *gTick;
|
//extern Tick *gTick;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mediapanel.h"
|
#include "mediapanel.h"
|
||||||
|
#include "outputpanel.h"
|
||||||
#include "planpanel.h"
|
#include "planpanel.h"
|
||||||
|
#include "progresspanel.h"
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -14,32 +16,37 @@
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
MainWindow::MainWindow() {
|
MainWindow::MainWindow() {
|
||||||
resize(1280, 800);
|
resize(1400, 840);
|
||||||
setWindowTitle("Compass");
|
setWindowTitle("Compass");
|
||||||
|
|
||||||
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
||||||
setCentralWidget(liveEditor = new LiveEditor);
|
setCentralWidget(liveEditor = new LiveEditor);
|
||||||
|
|
||||||
tabPorper = new QTabWidget;
|
tab = new QTabWidget;
|
||||||
tabPorper->setMinimumWidth(360);
|
tab->setMinimumWidth(360);
|
||||||
tabPorper->setStyleSheet("QTabWidget::pane{border:none;}");
|
tab->setStyleSheet("QTabWidget::pane{border:none;}");
|
||||||
|
|
||||||
auto scroll = new QScrollArea;
|
auto scroll = new QScrollArea;
|
||||||
scroll->setFrameShape(QFrame::NoFrame);
|
scroll->setFrameShape(QFrame::NoFrame);
|
||||||
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
scroll->setWidgetResizable(true);
|
scroll->setWidgetResizable(true);
|
||||||
tabPorper->addTab(scroll, tr("Properties"));
|
tab->addTab(scroll, tr("Layer Properties"));
|
||||||
|
|
||||||
auto mediapanel = new MediaPanel;
|
auto mediaPanel = new MediaPanel;
|
||||||
tabPorper->addTab(mediapanel, tr("Library"));
|
tab->addTab(mediaPanel, tr("Media Library"));
|
||||||
tabPorper->setCurrentIndex(1);
|
|
||||||
|
auto outputPanel = new OutputPanel;
|
||||||
|
tab->addTab(outputPanel, tr("Output"));
|
||||||
|
|
||||||
|
tab->setCurrentIndex(1);
|
||||||
|
|
||||||
auto dockProperties = new QDockWidget;
|
auto dockProperties = new QDockWidget;
|
||||||
dockProperties->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
dockProperties->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
||||||
dockProperties->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
dockProperties->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
dockProperties->setWidget(tabPorper);
|
dockProperties->setWidget(tab);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, dockProperties);
|
addDockWidget(Qt::RightDockWidgetArea, dockProperties);
|
||||||
|
|
||||||
auto dockPlan = new QDockWidget(tr("Plan"));
|
auto dockPlan = new QDockWidget(tr("Plan"));
|
||||||
|
@ -51,7 +58,7 @@ MainWindow::MainWindow() {
|
||||||
auto dockProgress = new QDockWidget(tr("Progress"));
|
auto dockProgress = new QDockWidget(tr("Progress"));
|
||||||
dockProgress->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
dockProgress->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
||||||
dockProgress->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
dockProgress->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
||||||
//dockProgress->setWidget(dockWidgetContents);
|
dockProgress->setWidget(new ProgressPanel);
|
||||||
addDockWidget(Qt::BottomDockWidgetArea, dockProgress);
|
addDockWidget(Qt::BottomDockWidgetArea, dockProgress);
|
||||||
splitDockWidget(dockPlan, dockProgress, Qt::Vertical);
|
splitDockWidget(dockPlan, dockProgress, Qt::Vertical);
|
||||||
|
|
||||||
|
@ -65,4 +72,11 @@ MainWindow::MainWindow() {
|
||||||
action = new QAction(QIcon(":/res/program/Setting.png"), tr("Setting"));
|
action = new QAction(QIcon(":/res/program/Setting.png"), tr("Setting"));
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
toolBar->addSeparator();
|
toolBar->addSeparator();
|
||||||
|
|
||||||
|
show();
|
||||||
|
dockProgress->setMaximumHeight(80);
|
||||||
|
|
||||||
|
QTimer::singleShot(68, [=] {
|
||||||
|
dockProgress->setMaximumHeight(200);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class MainWindow : public QMainWindow {
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
LiveEditor *liveEditor;
|
LiveEditor *liveEditor;
|
||||||
QTabWidget *tabPorper;
|
QTabWidget *tab;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -14,19 +14,18 @@
|
||||||
#include <QVideoSink>
|
#include <QVideoSink>
|
||||||
#include <QVideoFrame>
|
#include <QVideoFrame>
|
||||||
|
|
||||||
|
MediaTree *gMediaTree;
|
||||||
|
|
||||||
MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
auto vBox = new VBox(this);
|
auto vBox = new VBox(this);
|
||||||
vBox->setContentsMargins(0, 0, 0, 0);
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
vBox->setSpacing(0);
|
vBox->setSpacing(0);
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->setContentsMargins(6,6,6,6);
|
|
||||||
hBox->setSpacing(6);
|
|
||||||
|
|
||||||
bnNew = new QPushButton(translate("","New"));
|
auto bnAdd = new QPushButton("🞥");
|
||||||
bnNew->setMinimumSize(75, 30);
|
bnAdd->setMaximumWidth(50);
|
||||||
bnNew->setProperty("ssType", "progManageTool");
|
hBox->addWidget(bnAdd);
|
||||||
hBox->addWidget(bnNew);
|
connect(bnAdd, &QPushButton::clicked, this, [this] {
|
||||||
connect(bnNew, &QPushButton::clicked, this, [this] {
|
|
||||||
auto file = QFileDialog::getOpenFileName(this, 0, gFileHome);
|
auto file = QFileDialog::getOpenFileName(this, 0, gFileHome);
|
||||||
if(file.isEmpty()) return;
|
if(file.isEmpty()) return;
|
||||||
QFileInfo info(file);
|
QFileInfo info(file);
|
||||||
|
@ -38,7 +37,7 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
if(suffix.startsWith("mp")) {
|
if(suffix.startsWith("mp")) {
|
||||||
auto player = new QMediaPlayer;
|
auto player = new QMediaPlayer;
|
||||||
player->setSource(QUrl::fromLocalFile(file));
|
player->setSource(QUrl::fromLocalFile(file));
|
||||||
item = new MediaItem(file, tree);
|
item = new MediaItem(file, gMediaTree);
|
||||||
item->setText("type", "Video");
|
item->setText("type", "Video");
|
||||||
auto videoWgt = new QVideoWidget;
|
auto videoWgt = new QVideoWidget;
|
||||||
player->setVideoOutput(videoWgt);
|
player->setVideoOutput(videoWgt);
|
||||||
|
@ -48,7 +47,8 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
player->stop();
|
player->stop();
|
||||||
player->deleteLater();
|
player->deleteLater();
|
||||||
videoWgt->deleteLater();
|
videoWgt->deleteLater();
|
||||||
item->setText("size", QString("%1*%2").arg(frame.width()).arg(frame.height()));
|
qDebug()<<"pixelFormat"<<frame.pixelFormat();
|
||||||
|
item->setText("size", QString("%1×%2").arg(frame.width()).arg(frame.height()));
|
||||||
item->setText("dur", QTime::fromMSecsSinceStartOfDay(player->duration()).toString("hh:mm:ss.zzz"));
|
item->setText("dur", QTime::fromMSecsSinceStartOfDay(player->duration()).toString("hh:mm:ss.zzz"));
|
||||||
item->profile = frame.toImage().scaledToHeight(60, Qt::SmoothTransformation);
|
item->profile = frame.toImage().scaledToHeight(60, Qt::SmoothTransformation);
|
||||||
auto edProfile = new QLabel;
|
auto edProfile = new QLabel;
|
||||||
|
@ -66,10 +66,10 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
QMessageBox::critical(this, "Image Read Error", QString::number(reader.error())+" "+reader.errorString());
|
QMessageBox::critical(this, "Image Read Error", QString::number(reader.error())+" "+reader.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
item = new MediaItem(file, tree);
|
item = new MediaItem(file, gMediaTree);
|
||||||
item->setText("type", "Image");
|
item->setText("type", "Image");
|
||||||
item->setText("dur", "00:10:00.000");
|
item->setText("dur", "00:10:00.000");
|
||||||
item->setText("size", QString("%1*%2").arg(img.width()).arg(img.height()));
|
item->setText("size", QString("%1×%2").arg(img.width()).arg(img.height()));
|
||||||
item->profile = img.scaledToHeight(60, Qt::SmoothTransformation);
|
item->profile = img.scaledToHeight(60, Qt::SmoothTransformation);
|
||||||
auto edProfile = new QLabel;
|
auto edProfile = new QLabel;
|
||||||
edProfile->setPixmap(QPixmap::fromImage(item->profile));
|
edProfile->setPixmap(QPixmap::fromImage(item->profile));
|
||||||
|
@ -82,11 +82,10 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bnDelete = new QPushButton(tr("Delete"));
|
auto bnDelet = new QPushButton("🗑");
|
||||||
bnDelete->setMinimumSize(75, 30);
|
bnDelet->setMaximumWidth(50);
|
||||||
bnDelete->setProperty("ssType", "progManageTool");
|
hBox->addWidget(bnDelet);
|
||||||
hBox->addWidget(bnDelete);
|
connect(bnDelet, &QPushButton::clicked, this, [=] {
|
||||||
connect(bnDelete, &QPushButton::clicked, this, [=] {
|
|
||||||
// for(int i=0; i<tree->topLevelItemCount(); i++) if(tree->item(i)->checkState("check") == Qt::Checked) {
|
// for(int i=0; i<tree->topLevelItemCount(); i++) if(tree->item(i)->checkState("check") == Qt::Checked) {
|
||||||
// auto item = (MediaItem*) tree->topLevelItem(i--);
|
// auto item = (MediaItem*) tree->topLevelItem(i--);
|
||||||
// item->del();
|
// item->del();
|
||||||
|
@ -94,31 +93,6 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
bnRename = new QPushButton(tr("Rename"));
|
|
||||||
bnRename->setMinimumSize(60, 30);
|
|
||||||
bnRename->setProperty("ssType", "progManageTool");
|
|
||||||
hBox->addWidget(bnRename);
|
|
||||||
connect(bnRename, &QPushButton::clicked, this, [=] {
|
|
||||||
// int cnt = tree->topLevelItemCount();
|
|
||||||
// QString progName;
|
|
||||||
// for(int i=0; i<cnt; i++) if(tree->item(i)->checkState("check") == Qt::Checked) {
|
|
||||||
// progName = ((MediaItem*) tree->topLevelItem(i))->mName;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if(progName.isEmpty()) return;
|
|
||||||
// bool ok = false;
|
|
||||||
// auto newName = QInputDialog::getText(this, "Rename '"+progName+"'", "New Name", QLineEdit::Normal, "", &ok);
|
|
||||||
// if(! ok) return;
|
|
||||||
// if(newName.isEmpty()) {
|
|
||||||
// QMessageBox::warning(this, "Warning", "New Name is Empty");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// auto progsDir = programsDir();
|
|
||||||
// auto res = QDir(progsDir).rename(progName, newName);
|
|
||||||
// if(res) addProFiles();
|
|
||||||
// else QMessageBox::warning(this, "Error", "Rename Failed");
|
|
||||||
});
|
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdSearch = new QLineEdit;
|
auto fdSearch = new QLineEdit;
|
||||||
|
@ -128,33 +102,33 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
fdSearch->addAction(search, QLineEdit::LeadingPosition);
|
fdSearch->addAction(search, QLineEdit::LeadingPosition);
|
||||||
fdSearch->setClearButtonEnabled(true);
|
fdSearch->setClearButtonEnabled(true);
|
||||||
//fdSearch->setStyleSheet("border: 1px solid #888;");
|
//fdSearch->setStyleSheet("border: 1px solid #888;");
|
||||||
connect(fdSearch, &QLineEdit::textChanged, this, [this](const QString &text) {
|
connect(fdSearch, &QLineEdit::textChanged, this, [](const QString &text) {
|
||||||
auto cnt = tree->topLevelItemCount();
|
auto cnt = gMediaTree->topLevelItemCount();
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
auto item = tree->item(i);
|
auto item = gMediaTree->item(i);
|
||||||
item->setHidden(! (text.isEmpty() || item->text("name").contains(text) || item->text("resolution").contains(text)));
|
item->setHidden(! (text.isEmpty() || item->text("name").contains(text) || item->text("resolution").contains(text)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdSearch);
|
hBox->addWidget(fdSearch);
|
||||||
|
|
||||||
tree = new MediaTree;
|
gMediaTree = new MediaTree;
|
||||||
tree->addCol("#", "", 20);
|
gMediaTree->addCol("#", "", 20);
|
||||||
tree->addCol("profile", "", 42);
|
gMediaTree->addCol("profile", "", 42);
|
||||||
tree->addCol("name", "", 140);
|
gMediaTree->addCol("name", "", 140);
|
||||||
tree->addCol("type", "", 45);
|
gMediaTree->addCol("type", "", 45);
|
||||||
tree->addCol("size", "", 60);
|
gMediaTree->addCol("size", "", 60);
|
||||||
tree->addCol("dur", "", 80);
|
gMediaTree->addCol("dur", "", 80);
|
||||||
tree->setDefs()->setHeaderAlignC();
|
gMediaTree->setDefs()->setHeaderAlignC();
|
||||||
tree->minRowHeight = 26;
|
gMediaTree->minRowHeight = 26;
|
||||||
tree->setSortingEnabled(true);
|
gMediaTree->setSortingEnabled(true);
|
||||||
tree->setDragEnabled(true);
|
gMediaTree->setDragEnabled(true);
|
||||||
tree->setAcceptDrops(true);
|
gMediaTree->setAcceptDrops(true);
|
||||||
tree->setDropIndicatorShown(true);
|
gMediaTree->setDropIndicatorShown(true);
|
||||||
vBox->addWidget(tree);
|
vBox->addWidget(gMediaTree);
|
||||||
|
|
||||||
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
if(mProgsDir.isEmpty()) return;
|
if(mProgsDir.isEmpty()) return;
|
||||||
tree->clear();
|
gMediaTree->clear();
|
||||||
// for(auto &progName : progNames) {
|
// for(auto &progName : progNames) {
|
||||||
// auto file = mProgsDir + "/" + progName + "/pro.json";
|
// auto file = mProgsDir + "/" + progName + "/pro.json";
|
||||||
// QFile qFile(file);
|
// QFile qFile(file);
|
||||||
|
@ -172,7 +146,7 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
tree->sortByColumn(settings.value("MediaSortColumn").toInt(), (Qt::SortOrder)settings.value("MediaSortOrder").toInt());
|
gMediaTree->sortByColumn(settings.value("MediaSortColumn").toInt(), (Qt::SortOrder)settings.value("MediaSortOrder").toInt());
|
||||||
|
|
||||||
transUi();
|
transUi();
|
||||||
}
|
}
|
||||||
|
@ -182,17 +156,10 @@ void MediaPanel::changeEvent(QEvent *event) {
|
||||||
if(event->type() == QEvent::LanguageChange) transUi();
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
}
|
}
|
||||||
void MediaPanel::transUi() {
|
void MediaPanel::transUi() {
|
||||||
tree->headerItem()->setText("name"**tree, tr("Name"));
|
gMediaTree->headerItem()->setText("name"**gMediaTree, tr("Name"));
|
||||||
tree->headerItem()->setText("type"**tree, tr("Type"));
|
gMediaTree->headerItem()->setText("type"**gMediaTree, tr("Type"));
|
||||||
tree->headerItem()->setText("size"**tree, tr("Size"));
|
gMediaTree->headerItem()->setText("size"**gMediaTree, tr("Size"));
|
||||||
tree->headerItem()->setText("dur"**tree, tr("Duration"));
|
gMediaTree->headerItem()->setText("dur"**gMediaTree, tr("Duration"));
|
||||||
bnNew->setText(tr("New"));
|
|
||||||
bnDelete->setText(tr("Delete"));
|
|
||||||
bnRename->setText(tr("Rename"));
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaItem::MediaItem(const QString &file, TreeWidget *tree) : TreeWidgetItem(tree), file(file) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaTree::dropEvent(QDropEvent *event) {
|
void MediaTree::dropEvent(QDropEvent *event) {
|
||||||
|
@ -201,7 +168,4 @@ void MediaTree::dropEvent(QDropEvent *event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TreeWidget::dropEvent(event);
|
TreeWidget::dropEvent(event);
|
||||||
qDebug()<<" event"<<event;
|
|
||||||
qDebug()<<" source"<<event->source();
|
|
||||||
qDebug()<<" mimeData"<<event->mimeData();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,26 +16,24 @@ protected:
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern MediaTree *gMediaTree;
|
||||||
|
|
||||||
class MediaPanel : public QWidget {
|
class MediaPanel : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MediaPanel(QWidget *parent = 0);
|
explicit MediaPanel(QWidget *parent = 0);
|
||||||
|
|
||||||
MediaTree *tree;
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *) override;
|
void changeEvent(QEvent *) override;
|
||||||
void transUi();
|
void transUi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mProgsDir;
|
QString mProgsDir;
|
||||||
QPushButton *bnNew;
|
|
||||||
QPushButton *bnDelete;
|
|
||||||
QPushButton *bnRename;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MediaItem : public TreeWidgetItem {
|
class MediaItem : public TreeWidgetItem {
|
||||||
public:
|
public:
|
||||||
explicit MediaItem(const QString &dir, TreeWidget *parent);
|
explicit MediaItem(const QString &file, TreeWidget *parent) : TreeWidgetItem(parent), file(file) {}
|
||||||
|
|
||||||
QString file;
|
QString file;
|
||||||
QImage profile;
|
QImage profile;
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
#include "outputpanel.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "layer.h"
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
OutputPanel::OutputPanel(QWidget *parent) : QWidget(parent) {
|
||||||
|
gOutPanel = this;
|
||||||
|
auto vBox = new VBox(this);
|
||||||
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
|
vBox->setSpacing(0);
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
|
||||||
|
auto bnAdd = new QPushButton("🞥");
|
||||||
|
bnAdd->setMaximumWidth(50);
|
||||||
|
hBox->addWidget(bnAdd);
|
||||||
|
connect(bnAdd, &QPushButton::clicked, this, [=] {
|
||||||
|
QString name;
|
||||||
|
auto cnt = tree->topLevelItemCount();
|
||||||
|
for(int i=1;;i++) {
|
||||||
|
name = QString("Output %1").arg(i);
|
||||||
|
for(int r=0; r<cnt; ++r) if(tree->topLevelItem(r)->text("name"**tree)==name) goto conti;
|
||||||
|
break;
|
||||||
|
conti:;
|
||||||
|
}
|
||||||
|
auto out = new Layer(0, name, gEditView);
|
||||||
|
gEditView->layers.push_back(out);
|
||||||
|
out->updateGeo();
|
||||||
|
out->show();
|
||||||
|
out->item = new OutputItem(tree);
|
||||||
|
out->item->setText("name", out->name);
|
||||||
|
out->item->setText("size", QString("%1×%2").arg(out->sSize.width()).arg(out->sSize.height()));
|
||||||
|
out->item->setData(0, (quint64) out);
|
||||||
|
tree->setCurrentItem(out->item);
|
||||||
|
out->view = new OutputView;
|
||||||
|
out->view->setGeometry({QPoint(), out->sSize});
|
||||||
|
out->view->setSceneRect({out->sPos, out->sSize});
|
||||||
|
});
|
||||||
|
|
||||||
|
auto bnDelet = new QPushButton("🗑");
|
||||||
|
bnDelet->setMaximumWidth(50);
|
||||||
|
hBox->addWidget(bnDelet);
|
||||||
|
connect(bnDelet, &QPushButton::clicked, this, [=] {
|
||||||
|
// for(int i=0; i<tree->topLevelItemCount(); i++) if(tree->item(i)->checkState("check") == Qt::Checked) {
|
||||||
|
// auto item = (MediaItem*) tree->topLevelItem(i--);
|
||||||
|
// item->del();
|
||||||
|
// delete item;
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
tree = new TreeWidget;
|
||||||
|
tree->addCol("#", "", 20);
|
||||||
|
tree->addCol("name", "", 140);
|
||||||
|
tree->addCol("size", "", 120);
|
||||||
|
tree->setDefs()->setHeaderAlignC();
|
||||||
|
tree->minRowHeight = 26;
|
||||||
|
connect(tree, &TreeWidget::currentItemChanged, this, [=](QTreeWidgetItem *current, QTreeWidgetItem *) {
|
||||||
|
if(enCurChanged) gEditView->select((Layer*) current->data(0, Qt::UserRole).toULongLong());
|
||||||
|
});
|
||||||
|
vBox->addWidget(tree);
|
||||||
|
|
||||||
|
vBox->addSpacing(8);
|
||||||
|
vBox->addLabel("Output Area Properties");
|
||||||
|
vBox->addSpacing(6);
|
||||||
|
|
||||||
|
auto grid = new Grid(vBox);
|
||||||
|
grid->setHorizontalSpacing(6);
|
||||||
|
int r = 0;
|
||||||
|
grid->addLabel("Name", r, 0);
|
||||||
|
edName = new QLineEdit;
|
||||||
|
grid->addWidget(edName, r, 1);
|
||||||
|
r++;
|
||||||
|
|
||||||
|
grid->addLabel("Position", r, 0);
|
||||||
|
|
||||||
|
hBox = new HBox;
|
||||||
|
hBox->addLabel("X:")->setMinimumWidth(20);
|
||||||
|
|
||||||
|
edX = new QSpinBox;
|
||||||
|
edX->setRange(-99999, 999999);
|
||||||
|
connect(edX, &QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
auto layer = gEditView->selected;
|
||||||
|
if(! layer) return;
|
||||||
|
layer->sPos.rx() = value;
|
||||||
|
layer->view->move(layer->sPos);
|
||||||
|
layer->updateGeo();
|
||||||
|
layer->update();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edX);
|
||||||
|
|
||||||
|
hBox->addSpacing(10);
|
||||||
|
|
||||||
|
hBox->addLabel("Y:")->setMinimumWidth(20);
|
||||||
|
edY = new QSpinBox;
|
||||||
|
edY->setRange(-99999, 999999);
|
||||||
|
edY->setValue(y());
|
||||||
|
connect(edY, &QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
auto layer = gEditView->selected;
|
||||||
|
if(! layer) return;
|
||||||
|
layer->sPos.ry() = value;
|
||||||
|
layer->view->move(layer->sPos);
|
||||||
|
layer->updateGeo();
|
||||||
|
layer->update();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edY);
|
||||||
|
hBox->addStretch();
|
||||||
|
grid->addLayout(hBox, r, 1);
|
||||||
|
r++;
|
||||||
|
|
||||||
|
grid->addLabel("Size", r, 0);
|
||||||
|
hBox = new HBox;
|
||||||
|
hBox->addLabel("W:")->setMinimumWidth(20);
|
||||||
|
|
||||||
|
edW = new QSpinBox;
|
||||||
|
edW->setRange(10, 999999);
|
||||||
|
connect(edW, &QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
auto layer = gEditView->selected;
|
||||||
|
if(! layer || ! layer->item) return;
|
||||||
|
layer->sSize.rwidth() = value;
|
||||||
|
layer->view->resize(layer->sSize);
|
||||||
|
layer->updateGeo();
|
||||||
|
layer->update();
|
||||||
|
layer->item->setText("size"**tree, QString("%1×%2").arg(layer->sSize.rwidth()).arg(layer->sSize.rheight()));
|
||||||
|
});
|
||||||
|
hBox->addWidget(edW);
|
||||||
|
|
||||||
|
hBox->addSpacing(10);
|
||||||
|
hBox->addLabel("H:")->setMinimumWidth(20);
|
||||||
|
edH = new QSpinBox;
|
||||||
|
edH->setRange(10, 999999);
|
||||||
|
connect(edH, &QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
auto layer = gEditView->selected;
|
||||||
|
if(! layer || ! layer->item) return;
|
||||||
|
layer->sSize.rheight() = value;
|
||||||
|
layer->view->resize(layer->sSize);
|
||||||
|
layer->updateGeo();
|
||||||
|
layer->update();
|
||||||
|
layer->item->setText("size"**tree, QString("%1×%2").arg(layer->sSize.rwidth()).arg(layer->sSize.rheight()));
|
||||||
|
});
|
||||||
|
hBox->addWidget(edH);
|
||||||
|
hBox->addStretch();
|
||||||
|
grid->addLayout(hBox, r, 1);
|
||||||
|
r++;
|
||||||
|
|
||||||
|
auto edShow = new QCheckBox("Open");
|
||||||
|
connect(edShow, &QCheckBox::checkStateChanged, this, [=](Qt::CheckState checkState) {
|
||||||
|
auto area = gEditView->selected;
|
||||||
|
if(! area || ! area->view) return;
|
||||||
|
area->view->setVisible(checkState==Qt::Checked);
|
||||||
|
});
|
||||||
|
grid->addWidget(edShow, r, 1);
|
||||||
|
r++;
|
||||||
|
|
||||||
|
transUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPanel::showEvent(QShowEvent *event) {
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
for(auto layer : gEditView->layers) if(layer->item) layer->raise();
|
||||||
|
auto item = tree->curItem();
|
||||||
|
if(item) gEditView->select((Layer*) item->data(0).toULongLong());
|
||||||
|
qDebug()<<"showEvent";
|
||||||
|
}
|
||||||
|
void OutputPanel::hideEvent(QHideEvent *event) {
|
||||||
|
QWidget::hideEvent(event);
|
||||||
|
for(auto layer : gEditView->layers) if(layer->item) layer->stackUnder(gEditView->originWgt);
|
||||||
|
qDebug()<<"hideEvent";
|
||||||
|
}
|
||||||
|
void OutputPanel::changeEvent(QEvent *event) {
|
||||||
|
QWidget::changeEvent(event);
|
||||||
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
|
}
|
||||||
|
void OutputPanel::transUi() {
|
||||||
|
tree->headerItem()->setText("name"**tree, tr("Name"));
|
||||||
|
tree->headerItem()->setText("size"**tree, tr("Size"));
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef OUTPUTPANEL_H
|
||||||
|
#define OUTPUTPANEL_H
|
||||||
|
|
||||||
|
#include "gutil/qgui.h"
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
|
class OutputPanel : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit OutputPanel(QWidget *parent = 0);
|
||||||
|
|
||||||
|
TreeWidget *tree;
|
||||||
|
QLineEdit *edName;
|
||||||
|
QSpinBox *edX, *edY, *edW, *edH;
|
||||||
|
bool enCurChanged = true;
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent *event) override;
|
||||||
|
void hideEvent(QHideEvent *event) override;
|
||||||
|
void changeEvent(QEvent *) override;
|
||||||
|
void transUi();
|
||||||
|
};
|
||||||
|
|
||||||
|
class OutputItem : public TreeWidgetItem {
|
||||||
|
public:
|
||||||
|
using TreeWidgetItem::TreeWidgetItem;
|
||||||
|
|
||||||
|
QPoint pos;
|
||||||
|
QSize size{1920, 1080};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OUTPUTPANEL_H
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
|
#include <QAudioOutput>
|
||||||
#include <QGraphicsVideoItem>
|
#include <QGraphicsVideoItem>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
@ -37,8 +38,8 @@ PlanPanel::PlanPanel(QWidget *parent) : QWidget{parent} {
|
||||||
auto hBox = new HBox(wgt);
|
auto hBox = new HBox(wgt);
|
||||||
hBox->setContentsMargins(0,0,0,0);
|
hBox->setContentsMargins(0,0,0,0);
|
||||||
hBox->setSpacing(0);
|
hBox->setSpacing(0);
|
||||||
auto btn = new QPushButton(">");
|
auto btn = new QPushButton("⏵");
|
||||||
btn->setMaximumWidth(26);
|
btn->setMaximumWidth(24);
|
||||||
grp->addButton(btn);
|
grp->addButton(btn);
|
||||||
hBox->addWidget(btn);
|
hBox->addWidget(btn);
|
||||||
hBox->addLabel(QString("P%1").arg(c+1));
|
hBox->addLabel(QString("P%1").arg(c+1));
|
||||||
|
@ -47,8 +48,9 @@ PlanPanel::PlanPanel(QWidget *parent) : QWidget{parent} {
|
||||||
connect(grp, &QButtonGroup::buttonClicked, this, &PlanPanel::play);
|
connect(grp, &QButtonGroup::buttonClicked, this, &PlanPanel::play);
|
||||||
grid->addWidget(gTableH, 0, 1);
|
grid->addWidget(gTableH, 0, 1);
|
||||||
|
|
||||||
gTableV = new PlanTableV(1, 1);
|
gTableV = new PlanTableV(0, 1);
|
||||||
gTableV->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
gTableV->horizontalScrollBar()->hide();
|
||||||
|
gTableV->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
gTableV->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
gTableV->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
gTableV->horizontalHeader()->hide();
|
gTableV->horizontalHeader()->hide();
|
||||||
gTableV->verticalHeader()->hide();
|
gTableV->verticalHeader()->hide();
|
||||||
|
@ -61,8 +63,10 @@ PlanPanel::PlanPanel(QWidget *parent) : QWidget{parent} {
|
||||||
grid->addWidget(gTableV, 1, 0);
|
grid->addWidget(gTableV, 1, 0);
|
||||||
|
|
||||||
gTable = new PlanTable(0, 50);
|
gTable = new PlanTable(0, 50);
|
||||||
gTable->horizontalHeader()->setVisible(false);
|
gTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
gTable->verticalHeader()->setVisible(false);
|
gTable->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
gTable->horizontalHeader()->hide();
|
||||||
|
gTable->verticalHeader()->hide();
|
||||||
gTable->setColWidth(CellWidth)->setRowHeight(CellHeight)->setRowResize(QHeaderView::Fixed);
|
gTable->setColWidth(CellWidth)->setRowHeight(CellHeight)->setRowResize(QHeaderView::Fixed);
|
||||||
gTable->setDragEnabled(true);
|
gTable->setDragEnabled(true);
|
||||||
gTable->setAcceptDrops(true);
|
gTable->setAcceptDrops(true);
|
||||||
|
@ -94,7 +98,8 @@ void PlanPanel::addRow() {
|
||||||
gTableV->setCellWidget(r, 0, wgt);
|
gTableV->setCellWidget(r, 0, wgt);
|
||||||
|
|
||||||
auto layer = new Layer(r+1, "Layer", gEditView);
|
auto layer = new Layer(r+1, "Layer", gEditView);
|
||||||
layer->setGeo();
|
gEditView->layers.push_back(layer);
|
||||||
|
layer->updateGeo();
|
||||||
layer->show();
|
layer->show();
|
||||||
gTableV->setData(r, 0, (quint64) layer);
|
gTableV->setData(r, 0, (quint64) layer);
|
||||||
|
|
||||||
|
@ -139,8 +144,10 @@ void ImgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||||
painter->drawPixmap(boundingRect(), img, QRectF(0, 0, img.width(), img.height()));
|
painter->drawPixmap(boundingRect(), img, QRectF(0, 0, img.width(), img.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlanTable::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
|
if(event->source()==this || event->source()==gMediaTree) QTableWidget::dragEnterEvent(event);
|
||||||
|
}
|
||||||
void PlanTable::dropEvent(QDropEvent *event) {
|
void PlanTable::dropEvent(QDropEvent *event) {
|
||||||
MediaTree *tree;
|
|
||||||
if(event->source()==this) {
|
if(event->source()==this) {
|
||||||
auto idxFrom = currentIndex();
|
auto idxFrom = currentIndex();
|
||||||
auto cell = data(idxFrom.row(), idxFrom.column());
|
auto cell = data(idxFrom.row(), idxFrom.column());
|
||||||
|
@ -158,22 +165,25 @@ void PlanTable::dropEvent(QDropEvent *event) {
|
||||||
if(cellOld.isValid() && cellOld!=cell) delete (Cell*) cellOld.toULongLong();
|
if(cellOld.isValid() && cellOld!=cell) delete (Cell*) cellOld.toULongLong();
|
||||||
setData(idx.row(), idx.column(), cell);
|
setData(idx.row(), idx.column(), cell);
|
||||||
event->accept();
|
event->accept();
|
||||||
} else if((tree = dynamic_cast<MediaTree*>(event->source()))) {
|
} else if(event->source()==gMediaTree) {
|
||||||
auto idx = indexAt(event->position().toPoint());
|
auto idx = indexAt(event->position().toPoint());
|
||||||
auto wgt = cellWidget(idx.row(), idx.column());
|
auto wgt = cellWidget(idx.row(), idx.column());
|
||||||
auto item = (MediaItem*) tree->currentItem();
|
auto item = (MediaItem*) gMediaTree->currentItem();
|
||||||
auto lb = (QLabel*) wgt->children().at(2);
|
auto lb = (QLabel*) wgt->children().at(2);
|
||||||
qDebug()<<" currentIndex"<<idx;
|
lb->setText(item->text("name"**gMediaTree));
|
||||||
lb->setText(item->text("name"**tree));
|
|
||||||
lb = (QLabel*) wgt->children().at(1);
|
lb = (QLabel*) wgt->children().at(1);
|
||||||
lb->setPixmap(QPixmap::fromImage(item->profile));
|
lb->setPixmap(QPixmap::fromImage(item->profile));
|
||||||
auto type = item->text("type"**tree);
|
auto type = item->text("type"**gMediaTree);
|
||||||
if(type=="Video") {
|
if(type=="Video") {
|
||||||
auto wgt = new QGraphicsVideoItem;
|
auto wgt = new QGraphicsVideoItem;
|
||||||
wgt->setAspectRatioMode(Qt::IgnoreAspectRatio);
|
wgt->setAspectRatioMode(Qt::IgnoreAspectRatio);
|
||||||
auto player = new QMediaPlayer;
|
auto player = new QMediaPlayer;
|
||||||
player->setSource(QUrl::fromLocalFile(item->file));
|
player->setSource(QUrl::fromLocalFile(item->file));
|
||||||
player->setVideoOutput(wgt);
|
player->setVideoOutput(wgt);
|
||||||
|
player->setAudioOutput(new QAudioOutput);
|
||||||
|
connect(wgt, &QGraphicsVideoItem::parentChanged, player, [=]() {
|
||||||
|
if(wgt->parent()!=gScene) player->stop();
|
||||||
|
});
|
||||||
setData(idx.row(), idx.column(), (quint64) new Cell('V', wgt, player));
|
setData(idx.row(), idx.column(), (quint64) new Cell('V', wgt, player));
|
||||||
} else if(type=="Image") {
|
} else if(type=="Image") {
|
||||||
QImageReader reader(item->file);
|
QImageReader reader(item->file);
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
using TableWidget::TableWidget;
|
using TableWidget::TableWidget;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
#include "progresspanel.h"
|
||||||
|
#include "mediapanel.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "layer.h"
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
#include <QAudioOutput>
|
||||||
|
#include <QGraphicsVideoItem>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
ProgressPanel::ProgressPanel(QWidget *parent) : QWidget{parent} {
|
||||||
|
auto hBox = new HBox(this);
|
||||||
|
hBox->setContentsMargins(0,0,0,0);
|
||||||
|
hBox->setSpacing(0);
|
||||||
|
auto btnPlay = new QPushButton("||>");
|
||||||
|
btnPlay->setMaximumWidth(100);
|
||||||
|
btnPlay->setFixedHeight(60);
|
||||||
|
connect(btnPlay, &QPushButton::clicked, this, &ProgressPanel::play);
|
||||||
|
hBox->addWidget(btnPlay);
|
||||||
|
|
||||||
|
auto scrollArea = new QScrollArea;
|
||||||
|
hBox->addWidget(scrollArea);
|
||||||
|
vBox = new VBox(scrollArea);
|
||||||
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
vBox->setSpacing(0);
|
||||||
|
//connect(gTable->verticalScrollBar(), &QScrollBar::valueChanged, gTableV->verticalScrollBar(), &QScrollBar::setValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressPanel::addRow() {
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
auto btnPlay = new QPushButton("||>");
|
||||||
|
connect(btnPlay, &QPushButton::clicked, this, [=]{
|
||||||
|
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnPlay);
|
||||||
|
|
||||||
|
auto slider = new QSlider(Qt::Horizontal);
|
||||||
|
slider->setRange(0, 100);
|
||||||
|
|
||||||
|
auto lb = hBox->addLabel();
|
||||||
|
connect(slider, &QSlider::valueChanged, lb, [lb](int value) {
|
||||||
|
lb->setText(QTime::fromMSecsSinceStartOfDay(value).toString("HH:mm:ss.zzz"));
|
||||||
|
});
|
||||||
|
lb = hBox->addLabel();
|
||||||
|
}
|
||||||
|
void ProgressPanel::play() {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef PROGRESSPANEL_H
|
||||||
|
#define PROGRESSPANEL_H
|
||||||
|
|
||||||
|
#include "gutil/qgui.h"
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
|
class ProgressPanel : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ProgressPanel(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void addRow();
|
||||||
|
void play();
|
||||||
|
|
||||||
|
VBox *vBox;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROGRESSPANEL_H
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 140 KiB |
|
@ -1,20 +1,19 @@
|
||||||
QT += core gui widgets
|
QT += core gui widgets
|
||||||
QT += multimedia
|
QT += multimedia
|
||||||
QT += network
|
QT += network
|
||||||
|
QT += webenginewidgets
|
||||||
QT += concurrent
|
QT += concurrent
|
||||||
QT += serialport
|
QT += serialport
|
||||||
QT += opengl
|
QT += opengl
|
||||||
QT += webenginewidgets
|
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||||
QT += openglwidgets
|
QT += openglwidgets
|
||||||
CONFIG += c++20
|
|
||||||
} else {
|
} else {
|
||||||
CONFIG += c++17
|
|
||||||
QMAKE_CFLAGS += /utf-8
|
QMAKE_CFLAGS += /utf-8
|
||||||
QMAKE_CXXFLAGS += /utf-8
|
QMAKE_CXXFLAGS += /utf-8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONFIG += c++17
|
||||||
CONFIG += lrelease
|
CONFIG += lrelease
|
||||||
CONFIG += embed_translations
|
CONFIG += embed_translations
|
||||||
|
|
||||||
|
@ -27,7 +26,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 = 2.0.1
|
VERSION = 2.0.3
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
msvc {
|
msvc {
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
|
@ -112,12 +111,12 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
RESOURCES += res.qrc
|
RESOURCES += res.qrc
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
base/calendarbutton.cpp \
|
||||||
base/changepasswordform.cpp \
|
base/changepasswordform.cpp \
|
||||||
base/switchcontrol.cpp \
|
base/switchcontrol.cpp \
|
||||||
base/extendedgroupbox.cpp \
|
base/extendedgroupbox.cpp \
|
||||||
base/ffutil.cpp \
|
base/ffutil.cpp \
|
||||||
base/locolorselector.cpp \
|
base/locolorselector.cpp \
|
||||||
base/lodateselector.cpp \
|
|
||||||
base/loqtitlebar.cpp \
|
base/loqtitlebar.cpp \
|
||||||
base/loqtreewidget.cpp \
|
base/loqtreewidget.cpp \
|
||||||
device/progressesdlg.cpp \
|
device/progressesdlg.cpp \
|
||||||
|
@ -181,11 +180,11 @@ SOURCES += \
|
||||||
program/videosplitthread.cpp
|
program/videosplitthread.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
base/calendarbutton.h \
|
||||||
base/changepasswordform.h \
|
base/changepasswordform.h \
|
||||||
base/switchcontrol.h \
|
base/switchcontrol.h \
|
||||||
base/extendedgroupbox.h \
|
base/extendedgroupbox.h \
|
||||||
base/locolorselector.h \
|
base/locolorselector.h \
|
||||||
base/lodateselector.h \
|
|
||||||
base/loqtitlebar.h \
|
base/loqtitlebar.h \
|
||||||
base/loqtreewidget.h \
|
base/loqtreewidget.h \
|
||||||
device/progressesdlg.h \
|
device/progressesdlg.h \
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include "calendarbutton.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
|
||||||
|
CalendarButton::CalendarButton(QWidget *parent) : QPushButton(parent) {
|
||||||
|
setStyleSheet(R"rrr(
|
||||||
|
CalendarButton {
|
||||||
|
image: url(:/res/Calendar.png);
|
||||||
|
padding: 0;
|
||||||
|
max-width: 32px;
|
||||||
|
max-height: 32px;
|
||||||
|
}
|
||||||
|
CalendarButton:!enabled{
|
||||||
|
image: url(:/res/Calendar-gray.png);
|
||||||
|
}
|
||||||
|
CalendarButton:pressed {
|
||||||
|
margin-top: 1px;
|
||||||
|
margin-left: 1px;
|
||||||
|
margin-bottom: -1px;
|
||||||
|
margin-right: -1px;
|
||||||
|
}
|
||||||
|
)rrr");
|
||||||
|
auto dlg = new QDialog(this);
|
||||||
|
dlg->setWindowTitle(tr("Select a Date"));
|
||||||
|
dlg->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
|
auto vBox = new QVBoxLayout(dlg);
|
||||||
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
calendar = new QCalendarWidget;
|
||||||
|
connect(calendar, &QCalendarWidget::clicked, dlg, &QDialog::accept);
|
||||||
|
vBox->addWidget(calendar);
|
||||||
|
connect(this, &QPushButton::clicked, dlg, &QDialog::exec);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef CALENDARBUTTON_H
|
||||||
|
#define CALENDARBUTTON_H
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
|
||||||
|
class CalendarButton : public QPushButton {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CalendarButton(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QCalendarWidget *calendar = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CALENDARBUTTON_H
|
|
@ -1,4 +1,5 @@
|
||||||
#include "changepasswordform.h"
|
#include "changepasswordform.h"
|
||||||
|
#include "main.h"
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -48,7 +49,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
||||||
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
||||||
QString pwdOld = fdOld->text();
|
QString pwdOld = fdOld->text();
|
||||||
if(pwdOld.isEmpty()) {
|
if(pwdOld.isEmpty()) {
|
||||||
QMessageBox::warning(this, tr("Tip"), tr("Please input old password"));
|
QMessageBox::warning(this, translate("","Tip"), tr("Please input old password"));
|
||||||
fdOld->setFocus();
|
fdOld->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -56,24 +57,24 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
||||||
auto pwdRaw = settings.value("advUiPs");
|
auto pwdRaw = settings.value("advUiPs");
|
||||||
QString pwd = pwdRaw.isNull() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toString().toLatin1()));
|
QString pwd = pwdRaw.isNull() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toString().toLatin1()));
|
||||||
if(pwd != pwdOld) {
|
if(pwd != pwdOld) {
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("Old password is wrong"));
|
QMessageBox::critical(this, translate("","Tip"), tr("Old password is wrong"));
|
||||||
fdOld->setFocus();
|
fdOld->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString pwdNew = fdNew->text();
|
QString pwdNew = fdNew->text();
|
||||||
if(pwdNew.length() < 3 && ! pwdNew.isEmpty()) {
|
if(pwdNew.length() < 3 && ! pwdNew.isEmpty()) {
|
||||||
QMessageBox::warning(this, tr("Tip"), tr("Please enter a password with more than 3 characters"));
|
QMessageBox::warning(this, translate("","Tip"), tr("Please enter a password with more than 3 characters"));
|
||||||
fdNew->setFocus();
|
fdNew->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString pwdAgn = fdAgn->text();
|
QString pwdAgn = fdAgn->text();
|
||||||
if(pwdAgn != pwdNew) {
|
if(pwdAgn != pwdNew) {
|
||||||
QMessageBox::warning(this, tr("Tip"), tr("The new password is not consistent in two times"));
|
QMessageBox::warning(this, translate("","Tip"), tr("The new password is not consistent in two times"));
|
||||||
fdAgn->setFocus();
|
fdAgn->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
settings.setValue("advUiPs", QString::fromLatin1(pwdNew.toUtf8().toBase64()));
|
settings.setValue("advUiPs", QString::fromLatin1(pwdNew.toUtf8().toBase64()));
|
||||||
QMessageBox::information(this, tr("Tip"), tr("Password changed successfully"));
|
QMessageBox::information(this, translate("","Tip"), tr("Password changed successfully"));
|
||||||
accept();
|
accept();
|
||||||
});
|
});
|
||||||
vBox->addWidget(btnBox);
|
vBox->addWidget(btnBox);
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#include "lodateselector.h"
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QCalendarWidget>
|
|
||||||
|
|
||||||
LoDateSelector::LoDateSelector(QWidget *parent) : QPushButton(parent) {
|
|
||||||
setStyleSheet(R"rrr(
|
|
||||||
LoDateSelector {
|
|
||||||
background-color: transparent;
|
|
||||||
image: url(:/res/program/DateSelect_enable.png);
|
|
||||||
padding: 0;
|
|
||||||
max-width: 32px;
|
|
||||||
max-height: 32px;
|
|
||||||
}
|
|
||||||
LoDateSelector:!enabled{
|
|
||||||
image: url(:/res/program/DateSelect_e.png);
|
|
||||||
}
|
|
||||||
LoDateSelector:pressed {
|
|
||||||
margin-top: 1px;
|
|
||||||
margin-left: 1px;
|
|
||||||
margin-bottom: -1px;
|
|
||||||
margin-right: -1px;
|
|
||||||
}
|
|
||||||
)rrr");
|
|
||||||
connect(this, &QPushButton::clicked, this, [this] {
|
|
||||||
QDialog dlg(this);
|
|
||||||
dlg.setWindowTitle(tr("Date selector"));
|
|
||||||
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
||||||
auto vBox = new QVBoxLayout(&dlg);
|
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
|
||||||
auto calendar = new QCalendarWidget();
|
|
||||||
connect(calendar, &QCalendarWidget::clicked, &dlg, &QDialog::accept);
|
|
||||||
connect(calendar, &QCalendarWidget::clicked, this, &LoDateSelector::sDateSelected);
|
|
||||||
vBox->addWidget(calendar);
|
|
||||||
dlg.exec();
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef LODATESELECTOR_H
|
|
||||||
#define LODATESELECTOR_H
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
class LoDateSelector : public QPushButton{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit LoDateSelector(QWidget *parent = nullptr);
|
|
||||||
signals:
|
|
||||||
void sDateSelected(const QDate &);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LODATESELECTOR_H
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "loqtitlebar.h"
|
#include "loqtitlebar.h"
|
||||||
#include <QApplication>
|
#include "main.h"
|
||||||
|
|
||||||
LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
|
LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
|
||||||
bn_Minimize = new QPushButton(this);
|
bn_Minimize = new QPushButton(this);
|
||||||
|
@ -11,7 +11,7 @@ LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
|
||||||
|
|
||||||
bn_Minimize->setToolTip(tr("Minimize"));
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||||||
bn_Maximize->setToolTip(tr("Maximize"));
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||||||
bn_Close->setToolTip(tr("Close"));
|
bn_Close->setToolTip(translate("","Close"));
|
||||||
|
|
||||||
connect(bn_Minimize, &QPushButton::clicked, window(), &QWidget::showMinimized);
|
connect(bn_Minimize, &QPushButton::clicked, window(), &QWidget::showMinimized);
|
||||||
connect(bn_Maximize, &QPushButton::clicked, this, [this](){
|
connect(bn_Maximize, &QPushButton::clicked, this, [this](){
|
||||||
|
@ -24,7 +24,7 @@ LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
|
||||||
void LoQTitleBar::refreshLable() {
|
void LoQTitleBar::refreshLable() {
|
||||||
bn_Minimize->setToolTip(tr("Minimize"));
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||||||
bn_Maximize->setToolTip(tr("Maximize"));
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||||||
bn_Close->setToolTip(tr("Close"));
|
bn_Close->setToolTip(translate("","Close"));
|
||||||
}
|
}
|
||||||
bool LoQTitleBar::eventFilter(QObject *, QEvent *e) {
|
bool LoQTitleBar::eventFilter(QObject *, QEvent *e) {
|
||||||
if(e->type()==QEvent::WindowStateChange) bn_Maximize->setToolTip(window()->isMaximized() ? tr("Restore") : tr("Maximize"));
|
if(e->type()==QEvent::WindowStateChange) bn_Maximize->setToolTip(window()->isMaximized() ? tr("Restore") : tr("Maximize"));
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
BaseDlg::BaseDlg(QWidget *parent) : QDialog(parent) {
|
BaseDlg::BaseDlg(QWidget *parent) : QDialog(parent) {
|
||||||
setWindowFlag(Qt::FramelessWindowHint);
|
setWindowFlag(Qt::FramelessWindowHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
if(QSysInfo::productVersion()!="7" || ! QSysInfo::productType().startsWith("win")) setAttribute(Qt::WA_TranslucentBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDlg::paintEvent(QPaintEvent *e) {
|
void BaseDlg::paintEvent(QPaintEvent *e) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
BaseWin::BaseWin(QWidget *parent) : QWidget(parent){
|
BaseWin::BaseWin(QWidget *parent) : QWidget(parent){
|
||||||
setWindowFlag(Qt::FramelessWindowHint);
|
setWindowFlag(Qt::FramelessWindowHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
if(QSysInfo::productVersion()!="7" || ! QSysInfo::productType().startsWith("win")) setAttribute(Qt::WA_TranslucentBackground);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
auto layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
auto layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
||||||
layout->setContentsMargins(8,8,8,8);
|
layout->setContentsMargins(8,8,8,8);
|
||||||
|
@ -40,7 +40,7 @@ void BaseWin::paintEvent(QPaintEvent *e) {
|
||||||
void BaseWin::mousePressEvent(QMouseEvent *e) {
|
void BaseWin::mousePressEvent(QMouseEvent *e) {
|
||||||
if(e->button() != Qt::LeftButton) return;
|
if(e->button() != Qt::LeftButton) return;
|
||||||
setFrmSec(e->pos());
|
setFrmSec(e->pos());
|
||||||
if(mFrmSec==Qt::TitleBarArea || mFrmSec==Qt::TopSection || mFrmSec==Qt::LeftSection || mFrmSec==Qt::TopLeftSection) mPressRel = -e->pos();
|
if(mFrmSec==Qt::TitleBarArea || mFrmSec==Qt::TopSection || mFrmSec==Qt::LeftSection || mFrmSec==Qt::TopLeftSection) mPressRel = e->pos();
|
||||||
else if(mFrmSec==Qt::BottomRightSection) mPressRel = QPoint(width() - e->globalX(), height() - e->globalY());
|
else if(mFrmSec==Qt::BottomRightSection) mPressRel = QPoint(width() - e->globalX(), height() - e->globalY());
|
||||||
else if(mFrmSec==Qt::RightSection ) mPressRel = QPoint(width() - e->globalX(), height() );
|
else if(mFrmSec==Qt::RightSection ) mPressRel = QPoint(width() - e->globalX(), height() );
|
||||||
else if(mFrmSec==Qt::BottomSection ) mPressRel = QPoint(width() , height() - e->globalY());
|
else if(mFrmSec==Qt::BottomSection ) mPressRel = QPoint(width() , height() - e->globalY());
|
||||||
|
@ -55,15 +55,15 @@ void BaseWin::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if(e->buttons() & Qt::LeftButton) {
|
if(e->buttons() & Qt::LeftButton) {
|
||||||
if(mFrmSec==Qt::NoSection || mPressRel.x()==INT_MAX) return;
|
if(mFrmSec==Qt::NoSection || mPressRel.x()==INT_MAX) return;
|
||||||
if(isMaximized()) return;
|
if(isMaximized()) return;
|
||||||
if(mFrmSec==Qt::TitleBarArea) move(mPressRel + e->globalPos());
|
if(mFrmSec==Qt::TitleBarArea) move(e->globalPos() - mPressRel);
|
||||||
else if(mFrmSec==Qt::BottomRightSection) resize(mPressRel.rx() + e->globalX(), mPressRel.ry() + e->globalY());
|
else if(mFrmSec==Qt::BottomRightSection) resize(mPressRel.rx() + e->globalX(), mPressRel.ry() + e->globalY());
|
||||||
else if(mFrmSec==Qt::RightSection ) resize(mPressRel.rx() + e->globalX(), mPressRel.ry() );
|
else if(mFrmSec==Qt::RightSection ) resize(mPressRel.rx() + e->globalX(), mPressRel.ry() );
|
||||||
else if(mFrmSec==Qt::BottomSection ) resize(mPressRel.rx() , mPressRel.ry() + e->globalY());
|
else if(mFrmSec==Qt::BottomSection ) resize(mPressRel.rx() , mPressRel.ry() + e->globalY());
|
||||||
else {
|
else {
|
||||||
auto geo = geometry();
|
auto geo = geometry();
|
||||||
if(mFrmSec==Qt::LeftSection) geo.setLeft(mPressRel.rx() + e->globalX());
|
if(mFrmSec==Qt::LeftSection) geo.setLeft(e->globalX() - mPressRel.rx());
|
||||||
else if(mFrmSec==Qt::TopSection) geo.setTop(mPressRel.ry() + e->globalY());
|
else if(mFrmSec==Qt::TopSection) geo.setTop(e->globalY() - mPressRel.ry());
|
||||||
else if(mFrmSec==Qt::TopLeftSection) geo.setTopLeft(mPressRel + e->globalPos());
|
else if(mFrmSec==Qt::TopLeftSection) geo.setTopLeft(e->globalPos() - mPressRel);
|
||||||
else if(mFrmSec==Qt::TopRightSection) geo.setTopRight(mPressRel + e->globalPos());
|
else if(mFrmSec==Qt::TopRightSection) geo.setTopRight(mPressRel + e->globalPos());
|
||||||
else if(mFrmSec==Qt::BottomLeftSection) geo.setBottomLeft(mPressRel + e->globalPos());
|
else if(mFrmSec==Qt::BottomLeftSection) geo.setBottomLeft(mPressRel + e->globalPos());
|
||||||
setGeometry(geo);
|
setGeometry(geo);
|
||||||
|
|
|
@ -55,21 +55,20 @@ private:
|
||||||
|
|
||||||
QLabel *lbTimingReboot;
|
QLabel *lbTimingReboot;
|
||||||
|
|
||||||
QGroupBox *grpPlayer, *grpM80, *grpY50;
|
QGroupBox *grpPlayer, *grpY50, *grpG12, *grpM80;
|
||||||
QComboBox *fdM80Resolu, *fdDisMode;
|
QComboBox *fdM80Resolu, *fdDisMode;
|
||||||
QPushButton *btnM80Set, *btnY50Set;
|
QPushButton *btnY50Set, *btnM80Set, *btnM80Refresh, *btnM80Restore;
|
||||||
QPushButton *btnM80Refresh;
|
|
||||||
QPushButton *btnM80Restore;
|
|
||||||
|
|
||||||
QLabel *lbDisMode;
|
QLabel *lbDisMode;
|
||||||
QLabel *lbScreenPos, *lbScreenOff;
|
QLabel *lbScreenPos, *lbScreenOff;
|
||||||
QLabel *lbOffset, *lbCameraDis;
|
QLabel *lbOffset, *lbCameraDis, *lbLockCard, *lbLockPswd;
|
||||||
|
QPushButton *btnLock, *btnUnlock;
|
||||||
|
|
||||||
QGroupBox *grpHighForBusy;
|
QGroupBox *grpHighForBusy;
|
||||||
QRadioButton *fdHighForBusy;
|
QRadioButton *fdHighForBusy;
|
||||||
QRadioButton *fdTopLevelLH;
|
QRadioButton *fdTopLevelLH;
|
||||||
QPushButton *btnGetTopLevel;
|
QPushButton *btnGetTopLevel;
|
||||||
QPushButton *btnLedSet;
|
QPushButton *btnLedSet = 0;
|
||||||
QPushButton *btnReceCardsGet, *btnBindTaxiIc;
|
QPushButton *btnReceCardsGet, *btnBindTaxiIc;
|
||||||
|
|
||||||
QGroupBox *grpMinMaxBrightness;
|
QGroupBox *grpMinMaxBrightness;
|
||||||
|
|
|
@ -87,7 +87,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnSensiSet->setProperty("ssType", "progManageTool");
|
btnSensiSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnSensiSet, &QPushButton::clicked, this, [this] {
|
connect(btnSensiSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -113,7 +113,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnSensiGet->setProperty("ssType", "progManageTool");
|
btnSensiGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnSensiGet, &QPushButton::clicked, this, [this] {
|
connect(btnSensiGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -128,12 +128,12 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
fdSensi->setValue(json["sensitivity"].toInt());
|
fdSensi->setValue(json["sensitivity"].toInt());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
|
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
|
||||||
gFdResInfo->append(cardId+" "+tr("GetBrightnessSensitivity")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetBrightnessSensitivity")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -170,7 +170,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnMinBrightSet->setProperty("ssType", "progManageTool");
|
btnMinBrightSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnMinBrightSet, &QPushButton::clicked, this, [this] {
|
connect(btnMinBrightSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||||
|
@ -200,7 +200,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnMinBrightGet->setProperty("ssType", "progManageTool");
|
btnMinBrightGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnMinBrightGet, &QPushButton::clicked, this, [this] {
|
connect(btnMinBrightGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -218,13 +218,13 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
fdMinBright->setValue(value);
|
fdMinBright->setValue(value);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
auto brightLevel = card.BrightnessLevel;
|
auto brightLevel = card.BrightnessLevel;
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
auto value = json["minBrightnessPercentage"].toInt(-1);
|
auto value = json["minBrightnessPercentage"].toInt(-1);
|
||||||
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
||||||
|
@ -267,14 +267,14 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnUpload->setProperty("ssType", "progManageTool");
|
btnUpload->setProperty("ssType", "progManageTool");
|
||||||
connect(btnUpload, &QPushButton::clicked, this, [this] {
|
connect(btnUpload, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString sensorName;
|
QString sensorName;
|
||||||
if(fdRL2->isChecked()) sensorName = fdRL2->text();
|
if(fdRL2->isChecked()) sensorName = fdRL2->text();
|
||||||
else if(fdR68->isChecked()) sensorName = fdR68->text();
|
else if(fdR68->isChecked()) sensorName = fdR68->text();
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NeedSelectSensorTypeTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("NeedSelectSensorTypeTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString xlsxFile = QFileDialog::getOpenFileName(this, tr("Open file dialog"), "/", "brightness files(*.xlsx)");
|
QString xlsxFile = QFileDialog::getOpenFileName(this, tr("Open file dialog"), "/", "brightness files(*.xlsx)");
|
||||||
|
@ -285,7 +285,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
if(workbook->sheetCount() < 2) {
|
if(workbook->sheetCount() < 2) {
|
||||||
sheet = xlsx.currentWorksheet();
|
sheet = xlsx.currentWorksheet();
|
||||||
if(sheet==0) {
|
if(sheet==0) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("Not found current worksheet"));
|
QMessageBox::information(this, translate("","Tip"), tr("Not found current worksheet"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -299,7 +299,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sheet==0) {
|
if(sheet==0) {
|
||||||
QMessageBox::information(this, tr("Tip"), "Not found sheet "+sensorName);
|
QMessageBox::information(this, translate("","Tip"), "Not found sheet "+sensorName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
for(int j=0; j<255; j++) {
|
for(int j=0; j<255; j++) {
|
||||||
auto val = sheet->read(3, j+3).toString();
|
auto val = sheet->read(3, j+3).toString();
|
||||||
if(val.isEmpty()) {
|
if(val.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), "Cell is empty at 3, "+QString::number(j+3));
|
QMessageBox::information(this, translate("","Tip"), "Cell is empty at 3, "+QString::number(j+3));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
values.append(val);
|
values.append(val);
|
||||||
|
@ -335,14 +335,14 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnTableGet->setProperty("ssType", "progManageTool");
|
btnTableGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnTableGet, &QPushButton::clicked, this, [this] {
|
connect(btnTableGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString strSensorType;
|
QString strSensorType;
|
||||||
if(fdRL2->isChecked()) strSensorType = fdRL2->text();
|
if(fdRL2->isChecked()) strSensorType = fdRL2->text();
|
||||||
else if(fdR68->isChecked()) strSensorType = fdR68->text();
|
else if(fdR68->isChecked()) strSensorType = fdR68->text();
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NeedSelectSensorTypeTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("NeedSelectSensorTypeTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -354,24 +354,24 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card, strSensorType] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card, strSensorType] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QStringList values = json["values"].toVariant().value<QStringList>();
|
auto values = json["values"];
|
||||||
if(values.isEmpty()) {
|
if(values.empty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("no sensorBrightnessTable"));
|
QMessageBox::information(this, translate("","Tip"), tr("no sensorBrightnessTable"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString tempFile = QCoreApplication::applicationDirPath()+"/files/bright-template.xlsx";
|
auto tempFile = QCoreApplication::applicationDirPath()+"/files/bright-template.xlsx";
|
||||||
QFile tempQFile(tempFile);
|
QFile tempQFile(tempFile);
|
||||||
if(! tempQFile.exists()) {
|
if(! tempQFile.exists()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tempFile+" is not exist");
|
QMessageBox::information(this, translate("","Tip"), tempFile+" is not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString selectFilter = "*.xlsx";
|
QString selectFilter = "*.xlsx";
|
||||||
QString savingFile = QFileDialog::getSaveFileName(this, tr("Save file"), card.id + "BrightnessTable.xlsx", "brightness(*.xlsx );", &selectFilter, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
auto savingFile = QFileDialog::getSaveFileName(this, tr("Save file"), card.id + "BrightnessTable.xlsx", "brightness(*.xlsx );", &selectFilter, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
if(savingFile.isEmpty()) return;
|
if(savingFile.isEmpty()) return;
|
||||||
tempQFile.copy(savingFile);
|
tempQFile.copy(savingFile);
|
||||||
QXlsx::Document xlsx(savingFile);
|
QXlsx::Document xlsx(savingFile);
|
||||||
xlsx.selectSheet(strSensorType);
|
xlsx.selectSheet(strSensorType);
|
||||||
for(int m=0; m<values.count(); m++) xlsx.write(3, m+3, values.at(m).toInt());
|
for(int m=0; m<values.size(); m++) xlsx.write(3, m+3, values[m].toInt());
|
||||||
xlsx.save();
|
xlsx.save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnCurBrightGet->setProperty("ssType", "progManageTool");
|
btnCurBrightGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnCurBrightGet, &QPushButton::clicked, this, [this] {
|
connect(btnCurBrightGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -406,12 +406,12 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("GetCurrentSensorBrightness"));
|
auto waitingDlg = new WaitingDlg(this, tr("GetCurrentSensorBrightness"));
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QString err = checkReplyForJson(reply, &json, &data);
|
auto err = errStrWithJson(reply, &json, &data);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
@ -420,11 +420,11 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
fdCurBright->setText(QString::number(qRound(json["value"].toInt() * 100.0 / card.BrightnessLevel))+"%");
|
fdCurBright->setText(QString::number(qRound(json["value"].toInt() * 100.0 / card.BrightnessLevel))+"%");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = (json["is485"].toBool() ? "R60 " : "RL1 ") + QString::number(qRound(json["value"].toInt() * 100.0 / card.BrightnessLevel))+"%";
|
if(err.isEmpty()) err = (json["is485"].toBool() ? "R60 " : "RL1 ") + QString::number(qRound(json["value"].toInt() * 100.0 / card.BrightnessLevel))+"%";
|
||||||
gFdResInfo->append(card.id+" "+tr("GetCurrentSensorBrightness")+" "+err);
|
gFdResInfo->append(card.id+" "+tr("GetCurrentSensorBrightness")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -471,7 +471,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnFixedSet->setProperty("ssType", "progManageTool");
|
btnFixedSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnFixedSet, &QPushButton::clicked, this, [this] {
|
connect(btnFixedSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||||
|
@ -488,7 +488,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
if(isAdaptToOld) json.insert("brightness", (percent * card.BrightnessLevel + 50) / 100);
|
if(isAdaptToOld) json.insert("brightness", (percent * card.BrightnessLevel + 50) / 100);
|
||||||
Def_CtrlSetMulti(tr("SetBrightness"))
|
Def_CtrlSetMulti(tr("SetBrightness"))
|
||||||
}
|
}
|
||||||
|
@ -502,7 +502,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnFixedGet->setProperty("ssType", "progManageTool");
|
btnFixedGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnFixedGet, &QPushButton::clicked, this, [this] {
|
connect(btnFixedGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -512,12 +512,12 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("GetBrightness"));
|
auto waitingDlg = new WaitingDlg(this, tr("GetBrightness"));
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QString err = checkReplyForJson(reply, &json, &data);
|
auto err = errStrWithJson(reply, &json, &data);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
QMessageBox::critical(this, translate("", "Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
@ -531,11 +531,11 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
auto bright = json["brightnessPercentage"].toInt(-1);
|
auto bright = json["brightnessPercentage"].toInt(-1);
|
||||||
if(bright==-1) bright = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
if(bright==-1) bright = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
||||||
|
@ -736,7 +736,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnScheSet->setProperty("ssType", "progManageTool");
|
btnScheSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScheSet, &QPushButton::clicked, this, [this] {
|
connect(btnScheSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||||
|
@ -767,7 +767,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
btnScheGet->setProperty("ssType", "progManageTool");
|
btnScheGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScheGet, &QPushButton::clicked, this, [this] {
|
connect(btnScheGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -818,13 +818,13 @@ void CtrlBrightPanel::init() {
|
||||||
mSensi = -1;
|
mSensi = -1;
|
||||||
mTask = -1;
|
mTask = -1;
|
||||||
|
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetAutoBrightnessTask");
|
json.insert("_id", "GetAutoBrightnessTask");
|
||||||
json.insert("_type", "GetAutoBrightnessTask");
|
json.insert("_type", "GetAutoBrightnessTask");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
mTask = restoreScheduleJson(json, card.BrightnessLevel);
|
mTask = restoreScheduleJson(json, card.BrightnessLevel);
|
||||||
if(mTask) radioSchedule->setChecked(true);
|
if(mTask) radioSchedule->setChecked(true);
|
||||||
|
@ -832,13 +832,13 @@ void CtrlBrightPanel::init() {
|
||||||
else if(mSensi == 0) radioManual->setChecked(true);
|
else if(mSensi == 0) radioManual->setChecked(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetBrightnessSensitivity");
|
json.insert("_id", "GetBrightnessSensitivity");
|
||||||
json.insert("_type", "GetBrightnessSensitivity");
|
json.insert("_type", "GetBrightnessSensitivity");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
mSensi = json["sensitivity"].toInt();
|
mSensi = json["sensitivity"].toInt();
|
||||||
fdSensi->setValue(mSensi);
|
fdSensi->setValue(mSensi);
|
||||||
|
@ -847,13 +847,13 @@ void CtrlBrightPanel::init() {
|
||||||
else radioManual->setChecked(true);
|
else radioManual->setChecked(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetMinBrightness");
|
json.insert("_id", "GetMinBrightness");
|
||||||
json.insert("_type", "GetMinBrightness");
|
json.insert("_type", "GetMinBrightness");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
auto value = json["minBrightnessPercentage"].toInt(-1);
|
auto value = json["minBrightnessPercentage"].toInt(-1);
|
||||||
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
||||||
|
@ -876,22 +876,22 @@ void CtrlBrightPanel::transUi() {
|
||||||
fdSensiTypeTip->setText(tr("BrightTip2"));
|
fdSensiTypeTip->setText(tr("BrightTip2"));
|
||||||
lbSensi->setText(tr("Sensitivity"));
|
lbSensi->setText(tr("Sensitivity"));
|
||||||
lbMinBright->setText(tr("Minbrightness"));
|
lbMinBright->setText(tr("Minbrightness"));
|
||||||
btnMinBrightSet->setText(tr("Set"));
|
btnMinBrightSet->setText(translate("","Set"));
|
||||||
btnSensiSet->setText(tr("Set"));
|
btnSensiSet->setText(translate("","Set"));
|
||||||
btnUpload->setText(tr("Upload"));
|
btnUpload->setText(tr("Upload File"));
|
||||||
btnMinBrightGet->setText(tr("Readback"));
|
btnMinBrightGet->setText(translate("","Readback"));
|
||||||
btnSensiGet->setText(tr("Readback"));
|
btnSensiGet->setText(translate("","Readback"));
|
||||||
btnTableGet->setText(tr("ReadbackTable"));
|
btnTableGet->setText(translate("","Readback"));
|
||||||
btnCurBrightGet->setText(tr("Refresh"));
|
btnCurBrightGet->setText(translate("","Refresh"));
|
||||||
lbCurBright->setText(tr("Cur Brigntness")+": ");
|
lbCurBright->setText(tr("Cur Brigntness")+": ");
|
||||||
|
|
||||||
lbFixedBright->setText(tr("Brightness value"));
|
lbFixedBright->setText(tr("Brightness value"));
|
||||||
btnFixedSet->setText(tr("Set"));
|
btnFixedSet->setText(translate("","Set"));
|
||||||
btnFixedGet->setText(tr("Readback"));
|
btnFixedGet->setText(translate("","Readback"));
|
||||||
|
|
||||||
lbDefBright->setText(tr("Default brightness"));
|
lbDefBright->setText(tr("Default brightness"));
|
||||||
btnScheAdd->setText(tr("Add"));
|
btnScheAdd->setText(tr("Add"));
|
||||||
btnScheClear->setText(tr("Clear"));
|
btnScheClear->setText(translate("","Clear"));
|
||||||
btnScheDel->setText(tr("Delete"));
|
btnScheDel->setText(tr("Delete"));
|
||||||
btnScheImport->setText(tr("Import"));
|
btnScheImport->setText(tr("Import"));
|
||||||
btnScheExport->setText(tr("Export"));
|
btnScheExport->setText(tr("Export"));
|
||||||
|
@ -901,11 +901,11 @@ void CtrlBrightPanel::transUi() {
|
||||||
tableSche->setHeaderText("end", tr("End Time"));
|
tableSche->setHeaderText("end", tr("End Time"));
|
||||||
|
|
||||||
btnScheSet->setText(tr("Apply"));
|
btnScheSet->setText(tr("Apply"));
|
||||||
btnScheGet->setText(tr("Readback"));
|
btnScheGet->setText(translate("","Readback"));
|
||||||
fdScheTip->setText(tr("Default brightness tip"));
|
fdScheTip->setText(tr("Default brightness tip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
|
bool CtrlBrightPanel::restoreScheduleJson(JValue &json, int max) {
|
||||||
tableSche->setRowCount(0);
|
tableSche->setRowCount(0);
|
||||||
auto taskBrightness = json["taskBrightness"];
|
auto taskBrightness = json["taskBrightness"];
|
||||||
auto brightness = json["defaultBrightnessPercentage"].toInt(-1);
|
auto brightness = json["defaultBrightnessPercentage"].toInt(-1);
|
||||||
|
@ -914,7 +914,7 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
|
||||||
auto jsitems = taskBrightness["items"].toArray();
|
auto jsitems = taskBrightness["items"].toArray();
|
||||||
auto brightnesses = json["brightnessPercentageList"].toArray();
|
auto brightnesses = json["brightnessPercentageList"].toArray();
|
||||||
for(int i=0; i<jsitems.size(); i++) {
|
for(int i=0; i<jsitems.size(); i++) {
|
||||||
auto schedule = jsitems.at(i)["schedules"][0];
|
auto schedule = jsitems[i]["schedules"][0];
|
||||||
int row = tableSche->rowCount();
|
int row = tableSche->rowCount();
|
||||||
tableSche->insertRow(row);
|
tableSche->insertRow(row);
|
||||||
|
|
||||||
|
@ -924,7 +924,7 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
|
||||||
auto slider = new QSlider(Qt::Horizontal);
|
auto slider = new QSlider(Qt::Horizontal);
|
||||||
slider->setRange(1, 100);
|
slider->setRange(1, 100);
|
||||||
if(brightnesses.size() > i) slider->setValue(brightnesses[i].toInt());
|
if(brightnesses.size() > i) slider->setValue(brightnesses[i].toInt());
|
||||||
else slider->setValue(qRound(jsitems.at(i)["brightness"].toInt() * 100.0 / max));
|
else slider->setValue(qRound(jsitems[i]["brightness"].toInt() * 100.0 / max));
|
||||||
hBox->addWidget(slider);
|
hBox->addWidget(slider);
|
||||||
|
|
||||||
auto lb = new QLabel(QString::number(slider->value())+"%");
|
auto lb = new QLabel(QString::number(slider->value())+"%");
|
||||||
|
@ -944,7 +944,7 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
|
||||||
timeEdit->setAlignment(Qt::AlignCenter);
|
timeEdit->setAlignment(Qt::AlignCenter);
|
||||||
tableSche->setCellWidget(row, "end", timeEdit);
|
tableSche->setCellWidget(row, "end", timeEdit);
|
||||||
}
|
}
|
||||||
return jsitems.count() > 0;
|
return jsitems.size() > 0;
|
||||||
}
|
}
|
||||||
void CtrlBrightPanel::getScheduleJson(QJsonObject &json, int max) {
|
void CtrlBrightPanel::getScheduleJson(QJsonObject &json, int max) {
|
||||||
QJsonArray items, brightnesses;
|
QJsonArray items, brightnesses;
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
#define CTRLBRIGHTPANEL_H
|
#define CTRLBRIGHTPANEL_H
|
||||||
|
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
|
#include "gutil/qjson.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
class CtrlBrightPanel : public QWidget {
|
class CtrlBrightPanel : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -18,7 +20,7 @@ protected:
|
||||||
void transUi();
|
void transUi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool restoreScheduleJson(QJsonDocument &, int);
|
bool restoreScheduleJson(JValue &, int);
|
||||||
void getScheduleJson(QJsonObject &, int);
|
void getScheduleJson(QJsonObject &, int);
|
||||||
QLabel *lbTitle;
|
QLabel *lbTitle;
|
||||||
QRadioButton *radioAuto;
|
QRadioButton *radioAuto;
|
||||||
|
|
|
@ -51,12 +51,19 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
hBox->addSpacing(20);
|
hBox->addSpacing(20);
|
||||||
fdHdmi2 = new QRadioButton("HDMI 2");
|
fdHdmi2 = new QRadioButton("HDMI 2");
|
||||||
hBox->addWidget(fdHdmi2);
|
hBox->addWidget(fdHdmi2);
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
auto btnGroup = new QButtonGroup(this);
|
auto btnGroup = new QButtonGroup(this);
|
||||||
btnGroup->addButton(fdAsync, 0);
|
btnGroup->addButton(fdAsync, 0);
|
||||||
btnGroup->addButton(fdHdmi, 1);
|
btnGroup->addButton(fdHdmi, 1);
|
||||||
btnGroup->addButton(fdHdmi2, 2);
|
btnGroup->addButton(fdHdmi2, 2);
|
||||||
|
|
||||||
|
hBox->addSpacing(20);
|
||||||
|
|
||||||
|
edAutoSwitch = new QCheckBox;
|
||||||
|
edAutoSwitch->setChecked(true);
|
||||||
|
hBox->addWidget(edAutoSwitch);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addSpacing(20);
|
vBox->addSpacing(20);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
|
@ -67,11 +74,11 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
btnSyncSet->setProperty("ssType", "progManageTool");
|
btnSyncSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnSyncSet, &QPushButton::clicked, this, [=] {
|
connect(btnSyncSet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto id = btnGroup->checkedId();
|
auto id = btnGroup->checkedId();
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "SyncSwitch");
|
json.insert("_id", "SyncSwitch");
|
||||||
json.insert("_type", "SyncSwitch");
|
json.insert("_type", "SyncSwitch");
|
||||||
json.insert("switchOn", (bool)id);
|
json.insert("switchOn", (bool)id);
|
||||||
|
@ -83,7 +90,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
if(id) {
|
if(id) {
|
||||||
Def_CtrlSetMulti(tr("SyncSwitch"))
|
Def_CtrlSetMulti(tr("SyncSwitch"))
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,6 +98,25 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(id) {
|
||||||
|
json = JObj();
|
||||||
|
json.insert("_id", "AutoSyncSwitch");
|
||||||
|
json.insert("_type", "AutoSyncSwitch");
|
||||||
|
json.insert("isAuto", edAutoSwitch->isChecked());
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
if(gSelCards[0].id.startsWith("g", Qt::CaseInsensitive)) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("SyncSwitch"));
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) if(card.id.startsWith("g", Qt::CaseInsensitive)) {
|
||||||
|
Def_CtrlSetMulti(tr("SyncSwitch"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnSyncSet);
|
hBox->addWidget(btnSyncSet);
|
||||||
hBox->addSpacing(20);
|
hBox->addSpacing(20);
|
||||||
|
@ -100,10 +126,10 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
btnSyncGet->setProperty("ssType", "progManageTool");
|
btnSyncGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnSyncGet, &QPushButton::clicked, this, [this] {
|
connect(btnSyncGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "IsSync");
|
json.insert("_id", "IsSync");
|
||||||
json.insert("_type", "IsSync");
|
json.insert("_type", "IsSync");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -113,21 +139,21 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
auto switchOn = json["switchOn"];
|
auto switchOn = json["switchOn"];
|
||||||
if(switchOn.isUndefined()) switchOn = json["result"];
|
if(switchOn.isNull()) switchOn = json["result"];
|
||||||
if(! switchOn.toBool()) fdAsync->setChecked(true);
|
if(! switchOn.toBool()) fdAsync->setChecked(true);
|
||||||
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
|
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
|
||||||
else fdHdmi->setChecked(true);
|
else fdHdmi->setChecked(true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
auto switchOn = json["switchOn"];
|
auto switchOn = json["switchOn"];
|
||||||
if(switchOn.isUndefined()) switchOn = json["result"];
|
if(switchOn.isNull()) switchOn = json["result"];
|
||||||
if(! switchOn.toBool()) err = tr("Async");
|
if(! switchOn.toBool()) err = tr("Async");
|
||||||
else {
|
else {
|
||||||
err = "HDMI";
|
err = "HDMI";
|
||||||
|
@ -214,7 +240,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
||||||
auto data = scheQFile.readAll();
|
auto data = scheQFile.readAll();
|
||||||
scheQFile.close();
|
scheQFile.close();
|
||||||
restoreScheduleJson(QJsonDocument::fromJson(data).object());
|
restoreScheduleJson(JFrom(data).toObj());
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnScheImport);
|
hBox->addWidget(btnScheImport);
|
||||||
|
|
||||||
|
@ -249,7 +275,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
btnScheSet->setMinimumSize(QSize(60, 30));
|
btnScheSet->setMinimumSize(QSize(60, 30));
|
||||||
connect(btnScheSet, &QPushButton::clicked, this, [this] {
|
connect(btnScheSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -277,7 +303,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
btnScheGet->setProperty("ssType", "progManageTool");
|
btnScheGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScheGet, &QPushButton::clicked, this, [this] {
|
connect(btnScheGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -289,7 +315,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
restoreScheduleJson(json["creenTask"].toObject());
|
restoreScheduleJson(json["creenTask"].toObj());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -317,21 +343,24 @@ void CtrlHdmiPanel::init() {
|
||||||
btnScheGet->setEnabled(isSingle);
|
btnScheGet->setEnabled(isSingle);
|
||||||
if(! isSingle) {
|
if(! isSingle) {
|
||||||
fdHdmi2->setVisible(true);
|
fdHdmi2->setVisible(true);
|
||||||
|
edAutoSwitch->setVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
fdHdmi2->setVisible(card.id.startsWith("m8s", Qt::CaseInsensitive));
|
auto needShow = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8s", Qt::CaseInsensitive);
|
||||||
|
fdHdmi2->setVisible(needShow);
|
||||||
|
edAutoSwitch->setVisible(needShow);
|
||||||
|
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "IsSync");
|
json.insert("_id", "IsSync");
|
||||||
json.insert("_type", "IsSync");
|
json.insert("_type", "IsSync");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
auto switchOn = json["switchOn"];
|
auto switchOn = json["switchOn"];
|
||||||
if(switchOn.isUndefined()) switchOn = json["result"];
|
if(switchOn.isNull()) switchOn = json["result"];
|
||||||
if(! switchOn.toBool()) fdAsync->setChecked(true);
|
if(! switchOn.toBool()) fdAsync->setChecked(true);
|
||||||
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
|
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
|
||||||
else fdHdmi->setChecked(true);
|
else fdHdmi->setChecked(true);
|
||||||
|
@ -346,9 +375,11 @@ void CtrlHdmiPanel::transUi() {
|
||||||
fdManual->setText(tr("Manual"));
|
fdManual->setText(tr("Manual"));
|
||||||
fdSchedule->setText(tr("Schedule"));
|
fdSchedule->setText(tr("Schedule"));
|
||||||
|
|
||||||
|
edAutoSwitch->setText(tr("Auto Switch"));
|
||||||
|
|
||||||
fdAsync->setText(tr("Async"));
|
fdAsync->setText(tr("Async"));
|
||||||
btnSyncSet->setText(tr("Set"));
|
btnSyncSet->setText(translate("","Set"));
|
||||||
btnSyncGet->setText(tr("Readback"));
|
btnSyncGet->setText(translate("","Readback"));
|
||||||
|
|
||||||
tableSche->setHeaderText("start", tr("Start Time"));
|
tableSche->setHeaderText("start", tr("Start Time"));
|
||||||
tableSche->setHeaderText("end", tr("End Time"));
|
tableSche->setHeaderText("end", tr("End Time"));
|
||||||
|
@ -362,19 +393,19 @@ void CtrlHdmiPanel::transUi() {
|
||||||
|
|
||||||
btnScheAdd->setText(tr("Add"));
|
btnScheAdd->setText(tr("Add"));
|
||||||
btnScheSet->setText(tr("Apply"));
|
btnScheSet->setText(tr("Apply"));
|
||||||
btnScheClear->setText(tr("Clear"));
|
btnScheClear->setText(translate("","Clear"));
|
||||||
btnScheDel->setText(tr("Delete"));
|
btnScheDel->setText(tr("Delete"));
|
||||||
btnScheImport->setText(tr("Import"));
|
btnScheImport->setText(tr("Import"));
|
||||||
btnScheExport->setText(tr("Export"));
|
btnScheExport->setText(tr("Export"));
|
||||||
labelSyncScheduleTip->setText(tr("By default, the asynchronous content is played, and the synchronous signal content is played in the fixed time period"));
|
labelSyncScheduleTip->setText(tr("By default, the asynchronous content is played, and the synchronous signal content is played in the fixed time period"));
|
||||||
btnScheSet->setText(tr("Apply"));
|
btnScheSet->setText(tr("Apply"));
|
||||||
btnScheGet->setText(tr("Readback"));
|
btnScheGet->setText(translate("","Readback"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlHdmiPanel::restoreScheduleJson(QJsonObject oTaskSync) {
|
void CtrlHdmiPanel::restoreScheduleJson(JObj oTaskSync) {
|
||||||
tableSche->setRowCount(0);
|
tableSche->setRowCount(0);
|
||||||
auto oSchedules = oTaskSync["schedules"].toArray();
|
auto oSchedules = oTaskSync["schedules"].toArray();
|
||||||
foreach(QJsonValue oSchedule, oSchedules) {
|
for(auto &oSchedule : oSchedules) {
|
||||||
int row = tableSche->rowCount();
|
int row = tableSche->rowCount();
|
||||||
tableSche->insertRow(row);
|
tableSche->insertRow(row);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
#define CTRLHDMIPANEL_H
|
#define CTRLHDMIPANEL_H
|
||||||
|
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QLabel>
|
#include "gutil/qjson.h"
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ class CtrlHdmiPanel : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CtrlHdmiPanel();
|
CtrlHdmiPanel();
|
||||||
void restoreScheduleJson(QJsonObject oTaskSync);
|
void restoreScheduleJson(JObj oTaskSync);
|
||||||
QJsonObject getScheduleJson();
|
QJsonObject getScheduleJson();
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
|
@ -21,6 +22,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
QLabel *lbHdmiCfg;
|
QLabel *lbHdmiCfg;
|
||||||
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
|
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
|
||||||
|
QCheckBox *edAutoSwitch;
|
||||||
QPushButton *btnSyncSet, *btnSyncGet;
|
QPushButton *btnSyncSet, *btnSyncGet;
|
||||||
|
|
||||||
TableWidget *tableSche;
|
TableWidget *tableSche;
|
||||||
|
|
|
@ -23,7 +23,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
fdDhcp = new QRadioButton;
|
fdDhcp = new QRadioButton("DHCP");
|
||||||
fdDhcp->setChecked(true);
|
fdDhcp->setChecked(true);
|
||||||
hBox->addWidget(fdDhcp, 0, Qt::AlignTop);
|
hBox->addWidget(fdDhcp, 0, Qt::AlignTop);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnLanSet->setProperty("ssType", "progManageTool");
|
btnLanSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnLanSet, &QPushButton::clicked, this, [this] {
|
connect(btnLanSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString ip = fdIP->text();
|
QString ip = fdIP->text();
|
||||||
|
@ -137,7 +137,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "SetEthernet");
|
json.insert("_id", "SetEthernet");
|
||||||
json.insert("_type", "SetEthernet");
|
json.insert("_type", "SetEthernet");
|
||||||
json.insert("dhcp", fdDhcp->isChecked());
|
json.insert("dhcp", fdDhcp->isChecked());
|
||||||
|
@ -152,7 +152,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
Def_CtrlSetMulti(tr("SetEthernet"))
|
Def_CtrlSetMulti(tr("SetEthernet"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,10 +166,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnLanGet->setProperty("ssType", "progManageTool");
|
btnLanGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnLanGet, &QPushButton::clicked, this, [this] {
|
connect(btnLanGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetEthernet");
|
json.insert("_id", "GetEthernet");
|
||||||
json.insert("_type", "GetEthernet");
|
json.insert("_type", "GetEthernet");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -191,12 +191,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
fdDns->setText(json["dnsAddr"].toString());
|
fdDns->setText(json["dnsAddr"].toString());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["dhcp"].toBool() ? tr("DHCP IP") : tr("STATIC IP");
|
if(err.isEmpty()) err = json["dhcp"].toBool() ? tr("DHCP IP") : tr("STATIC IP");
|
||||||
gFdResInfo->append(cardId+" "+tr("GetEthernet")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetEthernet")+" "+err);
|
||||||
gFdResInfo->append(" IP: "+json["ipAddr"].toString());
|
gFdResInfo->append(" IP: "+json["ipAddr"].toString());
|
||||||
|
@ -216,33 +216,20 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
vBox->addWidget(line);
|
vBox->addWidget(line);
|
||||||
|
|
||||||
label_5 = new QLabel;
|
lbWifiCfg = new QLabel;
|
||||||
label_5->setFont(ftTitle);
|
lbWifiCfg->setFont(ftTitle);
|
||||||
label_5->setAlignment(Qt::AlignCenter);
|
lbWifiCfg->setAlignment(Qt::AlignCenter);
|
||||||
vBox->addWidget(label_5);
|
vBox->addWidget(lbWifiCfg);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto stackedWifi = new QStackedLayout;
|
|
||||||
fdIsWifi = new QRadioButton;
|
|
||||||
connect(fdIsWifi, &QRadioButton::toggled, this, [stackedWifi](bool checked) {
|
|
||||||
stackedWifi->setCurrentIndex(checked ? 0 : 1);
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdIsWifi);
|
|
||||||
hBox->addSpacing(50);
|
|
||||||
|
|
||||||
fdIsHotspot = new QRadioButton;
|
|
||||||
hBox->addWidget(fdIsHotspot);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
auto aaaQButtonGroup = new QButtonGroup(fdIsWifi);
|
|
||||||
aaaQButtonGroup->addButton(fdIsWifi);
|
|
||||||
aaaQButtonGroup->addButton(fdIsHotspot);
|
|
||||||
|
|
||||||
vBox->addLayout(stackedWifi);
|
|
||||||
{
|
{
|
||||||
auto vvv = new VBox(stackedWifi);
|
auto vvv = new VBox(hBox);
|
||||||
|
auto hBox = new HBox(vvv);
|
||||||
|
hBox->addStretch();
|
||||||
|
hBox->addWidget(fdIsWifi = new QCheckBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
|
||||||
lbWifiName = new QLabel;
|
lbWifiName = new QLabel;
|
||||||
|
@ -250,18 +237,18 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
lbWifiName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
lbWifiName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
hBox->addWidget(lbWifiName);
|
hBox->addWidget(lbWifiName);
|
||||||
|
|
||||||
fdWifiName = new QComboBox;
|
edWifiName = new QComboBox;
|
||||||
fdWifiName->setEditable(true);
|
edWifiName->setEditable(true);
|
||||||
fdWifiName->setMinimumWidth(200);
|
edWifiName->setMinimumWidth(180);
|
||||||
fdWifiName->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
edWifiName->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
hBox->addWidget(fdWifiName);
|
hBox->addWidget(edWifiName);
|
||||||
|
|
||||||
btnScan = new QPushButton;
|
btnScan = new QPushButton;
|
||||||
btnScan->setMinimumWidth(60);
|
btnScan->setMinimumWidth(60);
|
||||||
btnScan->setProperty("ssType", "progManageTool");
|
btnScan->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScan, &QPushButton::clicked, this, [this] {
|
connect(btnScan, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -274,10 +261,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
auto wifis = json["wifiList"].toArray();
|
auto wifis = json["wifiList"].toArray();
|
||||||
auto cur = fdWifiName->currentText();
|
auto cur = edWifiName->currentText();
|
||||||
fdWifiName->clear();
|
edWifiName->clear();
|
||||||
foreach(QJsonValue wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
|
for(auto &wifi : wifis) edWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
|
||||||
if(! cur.isEmpty()) fdWifiName->setCurrentText(cur);
|
if(! cur.isEmpty()) edWifiName->setCurrentText(cur);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -286,20 +273,107 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
|
||||||
lbWifiPassword = new QLabel;
|
lbWifiPswd = new QLabel;
|
||||||
lbWifiPassword->setMinimumWidth(80);
|
lbWifiPswd->setMinimumWidth(80);
|
||||||
lbWifiPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
lbWifiPswd->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
hBox->addWidget(lbWifiPassword);
|
hBox->addWidget(lbWifiPswd);
|
||||||
|
|
||||||
fdWifiPassword = new QLineEdit;
|
edWifiPswd = new QLineEdit;
|
||||||
fdWifiPassword->setFixedWidth(200);
|
edWifiPswd->setFixedWidth(180);
|
||||||
fdWifiPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
edWifiPswd->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
||||||
hBox->addWidget(fdWifiPassword);
|
hBox->addWidget(edWifiPswd);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vvv);
|
||||||
|
hBox->addStretch();
|
||||||
|
btnWiFiSet = new QPushButton;
|
||||||
|
btnWiFiSet->setMinimumSize(QSize(60, 30));
|
||||||
|
btnWiFiSet->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnWiFiSet, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto isWifi = fdIsWifi->isChecked();
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetSwitchWiFi");
|
||||||
|
json.insert("_type", "SetSwitchWiFi");
|
||||||
|
json.insert("enable", true);
|
||||||
|
JObj jsonG;
|
||||||
|
jsonG.insert("_id", "ControllerWifiSwitch");
|
||||||
|
jsonG.insert("_type", "ControllerWifiSwitch");
|
||||||
|
jsonG.insert("isWifi", true);
|
||||||
|
jsonG.insert("isOpen", isWifi);
|
||||||
|
JObj json2;
|
||||||
|
json2.insert("_id", "ConfigurationWiFi");
|
||||||
|
json2.insert("_type", "ConfigurationWiFi");
|
||||||
|
json2.insert("ssid", edWifiName->currentText());
|
||||||
|
json2.insert("password", edWifiPswd->text());
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
|
||||||
|
waitingDlg->show();
|
||||||
|
auto card = gSelCards[0];
|
||||||
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
|
if(isWifi) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||||
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json2);
|
||||||
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if(isG) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||||
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else waitingDlg->success();
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
|
if(isWifi) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||||
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
gFdResInfo->append(card.id+" "+tr("ConfigurationWiFi")+" "+err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json2);
|
||||||
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
gFdResInfo->append(card.id+" "+tr("ConfigurationWiFi")+" "+(err.isEmpty()?translate("","Success"):err));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if(isG) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||||
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
gFdResInfo->append(card.id+" "+tr("ConfigurationWiFi")+" "+(err.isEmpty()?translate("","Success"):err));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else gFdResInfo->append(card.id+" "+tr("ConfigurationWiFi")+" "+translate("","Success"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnWiFiSet);
|
||||||
|
hBox->addStretch();
|
||||||
vvv->addStretch();
|
vvv->addStretch();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto vvv = new VBox(hBox);
|
||||||
|
auto hBox = new HBox(vvv);
|
||||||
|
hBox->addStretch();
|
||||||
|
hBox->addWidget(fdIsAP = new QCheckBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
vvv = new VBox(stackedWifi);
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
|
||||||
lbHotspotName = new QLabel;
|
lbHotspotName = new QLabel;
|
||||||
|
@ -307,22 +381,22 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
lbHotspotName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
lbHotspotName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
hBox->addWidget(lbHotspotName);
|
hBox->addWidget(lbHotspotName);
|
||||||
|
|
||||||
fdHotspotName = new QLineEdit;
|
edHotspotName = new QLineEdit;
|
||||||
fdHotspotName->setFixedWidth(200);
|
edHotspotName->setFixedWidth(180);
|
||||||
hBox->addWidget(fdHotspotName);
|
hBox->addWidget(edHotspotName);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
|
||||||
lbHotspotPassword = new QLabel;
|
lbHotspotPswd = new QLabel;
|
||||||
lbHotspotPassword->setMinimumWidth(80);
|
lbHotspotPswd->setMinimumWidth(80);
|
||||||
lbHotspotPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
lbHotspotPswd->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
hBox->addWidget(lbHotspotPassword);
|
hBox->addWidget(lbHotspotPswd);
|
||||||
|
|
||||||
fdHotspotPassword = new QLineEdit;
|
edHotspotPswd = new QLineEdit;
|
||||||
fdHotspotPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
edHotspotPswd->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
||||||
fdHotspotPassword->setFixedWidth(200);
|
edHotspotPswd->setFixedWidth(180);
|
||||||
hBox->addWidget(fdHotspotPassword);
|
hBox->addWidget(edHotspotPswd);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
@ -331,133 +405,157 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
lll->setMinimumWidth(80);
|
lll->setMinimumWidth(80);
|
||||||
hBox->addWidget(lll);
|
hBox->addWidget(lll);
|
||||||
|
|
||||||
fdIs2_4G = new QRadioButton("2.4G");
|
auto edIs2_4G = new QRadioButton("2.4G");
|
||||||
fdIs2_4G->setChecked(true);
|
edIs2_4G->setChecked(true);
|
||||||
hBox->addWidget(fdIs2_4G);
|
hBox->addWidget(edIs2_4G);
|
||||||
|
|
||||||
auto fdIs5G = new QRadioButton("5G");
|
edIs5G = new QRadioButton("5G");
|
||||||
hBox->addWidget(fdIs5G);
|
hBox->addWidget(edIs5G);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vvv);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
btnHotspotSet = new QPushButton;
|
||||||
|
btnHotspotSet->setMinimumSize(60, 30);
|
||||||
|
btnHotspotSet->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnHotspotSet, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto isAp = fdIsAP->isChecked();
|
||||||
|
JObj jsonG;
|
||||||
|
jsonG.insert("_id", "ControllerWifiSwitch");
|
||||||
|
jsonG.insert("_type", "ControllerWifiSwitch");
|
||||||
|
jsonG.insert("isWifi", false);
|
||||||
|
jsonG.insert("isOpen", isAp);
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "ConfigurationHotSpot");
|
||||||
|
json.insert("_type", "ConfigurationHotSpot");
|
||||||
|
json.insert("apName", edHotspotName->text());
|
||||||
|
json.insert("apBand", edIs5G->isChecked() ? 1 : 0);
|
||||||
|
json.insert("password", edHotspotPswd->text());
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Config Hotspot")+" ...");
|
||||||
|
waitingDlg->show();
|
||||||
|
auto card = gSelCards[0];
|
||||||
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
|
if(isG) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||||
|
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||||
|
connect(reply, &QNetworkReply::finished, waitingDlg, [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(isAp) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else waitingDlg->success();
|
||||||
|
});
|
||||||
|
} else if(isAp) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else waitingDlg->success();
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
|
if(isG) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||||
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
gFdResInfo->append(card.id+" "+tr("Config Hotspot")+" "+err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(isAp) {
|
||||||
|
Def_CtrlSetMulti(tr("Config Hotspot"));
|
||||||
|
} else gFdResInfo->append(card.id+" "+tr("Config Hotspot")+" "+translate("","Success"));
|
||||||
|
});
|
||||||
|
} else if(isAp) {
|
||||||
|
Def_CtrlSetMulti(tr("Config Hotspot"));
|
||||||
|
} else gFdResInfo->append(card.id+" "+tr("Config Hotspot")+" "+translate("","Success"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnHotspotSet);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
vvv->addStretch();
|
vvv->addStretch();
|
||||||
}
|
}
|
||||||
|
hBox->addStretch();
|
||||||
fdIsWifi->setChecked(true);
|
fdIsWifi->setChecked(true);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
btnWiFiSet = new QPushButton;
|
|
||||||
btnWiFiSet->setMinimumSize(QSize(60, 30));
|
|
||||||
btnWiFiSet->setProperty("ssType", "progManageTool");
|
|
||||||
connect(btnWiFiSet, &QPushButton::clicked, this, [this] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto isWifi = fdIsWifi->isChecked();
|
|
||||||
if(isWifi) {
|
|
||||||
QJsonObject json;
|
|
||||||
json.insert("_id", "SetSwitchWiFi");
|
|
||||||
json.insert("_type", "SetSwitchWiFi");
|
|
||||||
json.insert("enable", true);
|
|
||||||
QJsonObject json2;
|
|
||||||
json2.insert("_id", "ConfigurationWiFi");
|
|
||||||
json2.insert("_type", "ConfigurationWiFi");
|
|
||||||
json2.insert("ssid", fdWifiName->currentText());
|
|
||||||
json2.insert("password", fdWifiPassword->text());
|
|
||||||
if(gSelCards.count() == 1) {
|
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
|
|
||||||
Def_CtrlReqPre
|
|
||||||
connect(reply, &QNetworkReply::finished, waitingDlg, [=] {
|
|
||||||
QString err = checkReplyForJson(reply);
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json2);
|
|
||||||
ConnReply(reply, waitingDlg) [=] {
|
|
||||||
Def_CtrlSetReqAfter
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
foreach(auto card, gSelCards) {
|
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
|
||||||
QString err = checkReplyForJson(reply);
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
gFdResInfo->append(card.id+" "+tr("ConfigurationWiFi")+" "+err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json2);
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
|
||||||
QString err = checkReplyForJson(reply);
|
|
||||||
gFdResInfo->append(card.id+" "+tr("ConfigurationWiFi")+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QJsonObject json;
|
|
||||||
json.insert("_id", "ConfigurationHotSpot");
|
|
||||||
json.insert("_type", "ConfigurationHotSpot");
|
|
||||||
json.insert("apName", fdHotspotName->text());
|
|
||||||
json.insert("apBand", fdIs2_4G->isChecked() ? 0 : 1);
|
|
||||||
json.insert("password", fdHotspotPassword->text());
|
|
||||||
if(gSelCards.count() == 1) {
|
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationHotSpot")+" ...");
|
|
||||||
Def_CtrlReqPre
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
|
||||||
Def_CtrlSetReqAfter
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
foreach(auto card, gSelCards) {
|
|
||||||
Def_CtrlSetMulti(tr("ConfigurationHotSpot"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
hBox->addWidget(btnWiFiSet);
|
|
||||||
hBox->addSpacing(50);
|
|
||||||
|
|
||||||
btnWiFiGet = new QPushButton;
|
btnWiFiGet = new QPushButton;
|
||||||
btnWiFiGet->setMinimumSize(QSize(60, 30));
|
btnWiFiGet->setMinimumSize(60, 30);
|
||||||
btnWiFiGet->setProperty("ssType", "progManageTool");
|
btnWiFiGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnWiFiGet, &QPushButton::clicked, this, [this] {
|
connect(btnWiFiGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "IsPortableHotSpot");
|
json.insert("_id", "IsPortableHotSpot");
|
||||||
json.insert("_type", "IsPortableHotSpot");
|
json.insert("_type", "IsPortableHotSpot");
|
||||||
|
JObj jsonG;
|
||||||
|
jsonG.insert("_id", "GetWifiSwitchState");
|
||||||
|
jsonG.insert("_type", "GetWifiSwitchState");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("IsPortableHotSpot")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("Get AP or WiFi")+" ...");
|
||||||
Def_CtrlReqPre
|
waitingDlg->show();
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
auto card = gSelCards[0];
|
||||||
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||||
|
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
fdWifiName->setCurrentText(json["wifi"].toString());
|
if(isG) {
|
||||||
auto hotSpots = json["hotSpots"].toString();
|
fdIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||||
fdHotspotName->setText(hotSpots);
|
fdIsAP->setChecked(json["apEnable"].toBool());
|
||||||
if(hotSpots.isEmpty()) fdIsWifi->setChecked(true);
|
edWifiName->setCurrentText(json["wifiName"].toString());
|
||||||
else fdIsHotspot->setChecked(true);
|
edHotspotName->setText(json["hotSpotName"].toString());
|
||||||
|
edIs5G->setChecked(json["apBand"].toBool());
|
||||||
|
} else {
|
||||||
|
edWifiName->setCurrentText(json["wifi"].toString());
|
||||||
|
auto hotSpots = json["hotSpots"].toString();
|
||||||
|
edHotspotName->setText(hotSpots);
|
||||||
|
fdIsWifi->setChecked(hotSpots.isEmpty());
|
||||||
|
fdIsAP->setChecked(! hotSpots.isEmpty());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
QJsonDocument json;
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QString err = checkReplyForJson(reply, &json);
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
err = tr("success");
|
err = translate("","Success");
|
||||||
auto wifi = json["wifi"].toString();
|
if(isG) {
|
||||||
if(! wifi.isEmpty()) err += " "+tr("WifiName")+":"+wifi;
|
err = err+"\nWifi: "+(json["wifiEnable"].toBool()?"On":"Off")+" "+json["wifiName"].toString();
|
||||||
auto hotSpots = json["hotSpots"].toString();
|
err = err+"\nAP: "+(json["apEnable"].toBool()?"On":"Off")+" "+json["hotSpotName"].toString()
|
||||||
if(! hotSpots.isEmpty()) err += " "+tr("ApName")+":"+hotSpots;
|
+(json["apBand"].toBool() ? " 5G" : " 2.4G");
|
||||||
|
} else {
|
||||||
|
auto wifi = json["wifi"].toString();
|
||||||
|
if(! wifi.isEmpty()) err += " "+tr("WifiName")+":"+wifi;
|
||||||
|
auto hotSpots = json["hotSpots"].toString();
|
||||||
|
if(! hotSpots.isEmpty()) err += " "+tr("ApName")+":"+hotSpots;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gFdResInfo->append(cardId+" "+tr("IsPortableHotSpot")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("Get AP or WiFi")+" "+err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +586,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
fdCarrierName->setEnabled(checked);
|
fdCarrierName->setEnabled(checked);
|
||||||
|
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -514,7 +612,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnSIMStatusGet->setProperty("ssType", "progManageTool");
|
btnSIMStatusGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnSIMStatusGet, &QPushButton::clicked, this, [this] {
|
connect(btnSIMStatusGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -526,7 +624,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QString str4GStatus = tr("状态:");
|
QString str4GStatus = tr("Status")+":";
|
||||||
auto state = json["state"].toInt();
|
auto state = json["state"].toInt();
|
||||||
if(state<2) str4GStatus += tr("未知");
|
if(state<2) str4GStatus += tr("未知");
|
||||||
else if(state==2) str4GStatus += tr("锁定状态,需要用户的PIN码解锁");
|
else if(state==2) str4GStatus += tr("锁定状态,需要用户的PIN码解锁");
|
||||||
|
@ -580,7 +678,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
}
|
}
|
||||||
str4GStatus += tr("信号强度:") + QString::number(json["signalStrength"].toInt())+"\n";
|
str4GStatus += tr("信号强度:") + QString::number(json["signalStrength"].toInt())+"\n";
|
||||||
}
|
}
|
||||||
QMessageBox::information(this, tr("Tip"), str4GStatus);
|
QMessageBox::information(this, translate("","Tip"), str4GStatus);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -608,7 +706,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
fdCarrierName->clear();
|
fdCarrierName->clear();
|
||||||
fdCarrierName->addItem("");
|
fdCarrierName->addItem("");
|
||||||
auto apnInfos = fdMcc->itemData(index).toJsonArray();
|
auto apnInfos = fdMcc->itemData(index).toJsonArray();
|
||||||
foreach(QJsonValue apnInfo, apnInfos) fdCarrierName->addItem(apnInfo["carrier"].toString(), apnInfo);
|
for(QJsonValue apnInfo : apnInfos) fdCarrierName->addItem(apnInfo["carrier"].toString(), apnInfo);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdMcc);
|
hBox->addWidget(fdMcc);
|
||||||
|
|
||||||
|
@ -702,7 +800,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnAPNCusSet->setProperty("ssType", "progManageTool");
|
btnAPNCusSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnAPNCusSet, &QPushButton::clicked, this, [=] {
|
connect(btnAPNCusSet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -740,10 +838,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnAPNCusGet->setProperty("ssType", "progManageTool");
|
btnAPNCusGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnAPNCusGet, &QPushButton::clicked, this, [=] {
|
connect(btnAPNCusGet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetCurrentAPN");
|
json.insert("_id", "GetCurrentAPN");
|
||||||
json.insert("_type", "GetCurrentAPN");
|
json.insert("_type", "GetCurrentAPN");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -765,12 +863,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
fdCus_mmsPort->setText(json["mmsport"].toString());
|
fdCus_mmsPort->setText(json["mmsport"].toString());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
err = json["apn"].toString();
|
err = json["apn"].toString();
|
||||||
auto user = json["user"].toString();
|
auto user = json["user"].toString();
|
||||||
|
@ -804,10 +902,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
fdFightModel->setText(tr("OFF"), tr("ON"));
|
fdFightModel->setText(tr("OFF"), tr("ON"));
|
||||||
connect(fdFightModel, &SwitchControl::checkedChanged, this, [=](bool checked) {
|
connect(fdFightModel, &SwitchControl::checkedChanged, this, [=](bool checked) {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "ContrFlightMode");
|
json.insert("_id", "ContrFlightMode");
|
||||||
json.insert("_type", "ContrFlightMode");
|
json.insert("_type", "ContrFlightMode");
|
||||||
json.insert("state", checked);
|
json.insert("state", checked);
|
||||||
|
@ -818,7 +916,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
Def_CtrlSetMulti(tr("ContrFlightMode"))
|
Def_CtrlSetMulti(tr("ContrFlightMode"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -830,10 +928,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnFlightModelGet->setProperty("ssType", "progManageTool");
|
btnFlightModelGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnFlightModelGet, &QPushButton::clicked, this, [this] {
|
connect(btnFlightModelGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetFlightModeState");
|
json.insert("_id", "GetFlightModeState");
|
||||||
json.insert("_type", "GetFlightModeState");
|
json.insert("_type", "GetFlightModeState");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -846,12 +944,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
fdFightModel->update();
|
fdFightModel->update();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["result"].toBool() ? "true" : "false";
|
if(err.isEmpty()) err = json["result"].toBool() ? "true" : "false";
|
||||||
gFdResInfo->append(cardId+" "+tr("GetFlightModeState")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetFlightModeState")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -880,13 +978,13 @@ void CtrlNetworkPanel::init() {
|
||||||
if(! isSingle) return;
|
if(! isSingle) return;
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
|
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetEthernet");
|
json.insert("_id", "GetEthernet");
|
||||||
json.insert("_type", "GetEthernet");
|
json.insert("_type", "GetEthernet");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
|
||||||
if(json["dhcp"].toBool()) {
|
if(json["dhcp"].toBool()) {
|
||||||
|
@ -902,63 +1000,76 @@ void CtrlNetworkPanel::init() {
|
||||||
fdDns->setText(json["dnsAddr"].toString());
|
fdDns->setText(json["dnsAddr"].toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetWifiList");
|
json.insert("_id", "GetWifiList");
|
||||||
json.insert("_type", "GetWifiList");
|
json.insert("_type", "GetWifiList");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
auto wifis = json["wifiList"].toArray();
|
auto wifis = json["wifiList"].toArray();
|
||||||
fdWifiName->clear();
|
edWifiName->clear();
|
||||||
foreach(QJsonValue wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
|
for(JValue &wifi : wifis) edWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
|
||||||
{
|
{
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "IsPortableHotSpot");
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
||||||
json.insert("_type", "IsPortableHotSpot");
|
if(isG) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
json.insert("_id", "GetWifiSwitchState");
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
json.insert("_type", "GetWifiSwitchState");
|
||||||
QJsonDocument json;
|
} else {
|
||||||
QString err = checkReplyForJson(reply, &json);
|
json.insert("_id", "IsPortableHotSpot");
|
||||||
|
json.insert("_type", "IsPortableHotSpot");
|
||||||
|
}
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
auto wifi = json["wifi"].toString();
|
if(isG) {
|
||||||
fdWifiName->setCurrentText(wifi);
|
fdIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||||
auto hotSpots = json["hotSpots"].toString();
|
fdIsAP->setChecked(json["apEnable"].toBool());
|
||||||
fdHotspotName->setText(hotSpots);
|
edWifiName->setCurrentText(json["wifiName"].toString());
|
||||||
if(hotSpots.isEmpty()) fdIsWifi->setChecked(true);
|
edHotspotName->setText(json["hotSpotName"].toString());
|
||||||
else fdIsHotspot->setChecked(true);
|
edIs5G->setChecked(json["apBand"].toBool());
|
||||||
|
} else {
|
||||||
|
edWifiName->setCurrentText(json["wifi"].toString());
|
||||||
|
auto hotspots = json["hotSpots"].toString();
|
||||||
|
edHotspotName->setText(hotspots);
|
||||||
|
fdIsWifi->setChecked(hotspots.isEmpty());
|
||||||
|
fdIsAP->setChecked(! hotspots.isEmpty());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetSwitchSimData");
|
json.insert("_id", "GetSwitchSimData");
|
||||||
json.insert("_type", "GetSwitchSimData");
|
json.insert("_type", "GetSwitchSimData");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
bool b = json["enable"].toBool();
|
auto enable = json["enable"].toBool();
|
||||||
fdEnableCellular->setChecked(b);
|
fdEnableCellular->setChecked(enable);
|
||||||
fdMcc->setEnabled(b);
|
fdMcc->setEnabled(enable);
|
||||||
fdCarrierName->setEnabled(b);
|
fdCarrierName->setEnabled(enable);
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetAPNList");
|
json.insert("_id", "GetAPNList");
|
||||||
json.insert("_type", "GetAPNList");
|
json.insert("_type", "GetAPNList");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
fdMcc->clear();
|
fdMcc->clear();
|
||||||
fdMcc->addItem("");
|
fdMcc->addItem("");
|
||||||
auto apns = json["apns"].toArray();
|
auto apns = json["apns"].toArray();
|
||||||
foreach(QJsonValue apn, apns) {
|
for(QJsonValue apn : apns) {
|
||||||
QString mcc = apn["mcc"].toString();
|
auto mcc = apn["mcc"].toString();
|
||||||
for(int i=0; i<fdMcc->count(); i++) if(mcc==fdMcc->itemText(i)) {
|
for(int i=0; i<fdMcc->count(); i++) if(mcc==fdMcc->itemText(i)) {
|
||||||
auto var = fdMcc->itemData(i);
|
auto var = fdMcc->itemData(i);
|
||||||
fdMcc->setItemData(i, QVariant());
|
fdMcc->setItemData(i, QVariant());
|
||||||
|
@ -973,13 +1084,13 @@ void CtrlNetworkPanel::init() {
|
||||||
|
|
||||||
getCurrentAPN(card.ip);
|
getCurrentAPN(card.ip);
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetFlightModeState");
|
json.insert("_id", "GetFlightModeState");
|
||||||
json.insert("_type", "GetFlightModeState");
|
json.insert("_type", "GetFlightModeState");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
fdFightModel->setCheckedStatus(json["result"].toBool());
|
fdFightModel->setCheckedStatus(json["result"].toBool());
|
||||||
fdFightModel->update();
|
fdFightModel->update();
|
||||||
|
@ -992,27 +1103,27 @@ void CtrlNetworkPanel::changeEvent(QEvent *event) {
|
||||||
}
|
}
|
||||||
void CtrlNetworkPanel::transUi() {
|
void CtrlNetworkPanel::transUi() {
|
||||||
lbLanCfg->setText(tr("Wire Enther(RJ45) Configuration"));
|
lbLanCfg->setText(tr("Wire Enther(RJ45) Configuration"));
|
||||||
fdDhcp->setText(tr("DHCP"));
|
|
||||||
fdSpecifyIp->setText(tr("Specify IP"));
|
fdSpecifyIp->setText(tr("Specify IP"));
|
||||||
lbHotspotName->setText(tr("AP name"));
|
lbHotspotName->setText(tr("AP name"));
|
||||||
labelGateway->setText(tr("Gateway"));
|
labelGateway->setText(tr("Gateway"));
|
||||||
lbWifiName->setText(tr("WiFi name"));
|
lbWifiName->setText(tr("WiFi name"));
|
||||||
labelIpAddress->setText(tr("IP Address"));
|
labelIpAddress->setText(tr("IP Address"));
|
||||||
lbHotspotPassword->setText(tr("Password"));
|
lbHotspotPswd->setText(tr("Password"));
|
||||||
labelDnsAddress->setText(tr("DNS Address"));
|
labelDnsAddress->setText(tr("DNS Address"));
|
||||||
labelMaskAddress->setText(tr("Subnet mask"));
|
labelMaskAddress->setText(tr("Subnet mask"));
|
||||||
lbWifiPassword->setText(tr("Password"));
|
lbWifiPswd->setText(tr("Password"));
|
||||||
btnScan->setText(tr("Scan"));
|
btnScan->setText(tr("Scan"));
|
||||||
btnWiFiSet->setText(tr("Set"));
|
btnWiFiSet->setText(translate("","Set"));
|
||||||
btnLanSet->setText(tr("Set"));
|
btnHotspotSet->setText(translate("","Set"));
|
||||||
btnWiFiGet->setText(tr("Readback"));
|
btnLanSet->setText(translate("","Set"));
|
||||||
btnLanGet->setText(tr("Readback"));
|
btnWiFiGet->setText(translate("","Readback"));
|
||||||
fdIsWifi->setText(tr("WiFi Mode"));
|
btnLanGet->setText(translate("","Readback"));
|
||||||
fdIsHotspot->setText(tr("Ap Mode"));
|
fdIsWifi->setText(tr("Enable WiFi"));
|
||||||
label_5->setText(tr("WIFI Configuration"));
|
fdIsAP->setText(tr("Enable AP"));
|
||||||
fdHotspotPassword->setPlaceholderText(tr("Input password"));
|
lbWifiCfg->setText(tr("WiFi Config"));
|
||||||
fdWifiPassword->setPlaceholderText(tr("Input password"));
|
edHotspotPswd->setPlaceholderText(translate("","Input Password"));
|
||||||
fdHotspotName->setPlaceholderText(tr("Input ap name"));
|
edWifiPswd->setPlaceholderText(translate("","Input Password"));
|
||||||
|
edHotspotName->setPlaceholderText(tr("Input ap name"));
|
||||||
lbCellularConfig->setText(tr("Cellular Config"));
|
lbCellularConfig->setText(tr("Cellular Config"));
|
||||||
lbCheckStatusTip->setText(tr("Through the check status button"));
|
lbCheckStatusTip->setText(tr("Through the check status button"));
|
||||||
fdEnableCellular->setText(tr("Enable Cellular Data"));
|
fdEnableCellular->setText(tr("Enable Cellular Data"));
|
||||||
|
@ -1021,7 +1132,7 @@ void CtrlNetworkPanel::transUi() {
|
||||||
label_2->setText(tr("Country ID(mcc):"));
|
label_2->setText(tr("Country ID(mcc):"));
|
||||||
label_3->setText(tr("Carrier Name"));
|
label_3->setText(tr("Carrier Name"));
|
||||||
fdCus_apn->setPlaceholderText(tr("APN(Required)"));
|
fdCus_apn->setPlaceholderText(tr("APN(Required)"));
|
||||||
btnFlightModelGet->setText(tr("Readback"));
|
btnFlightModelGet->setText(translate("","Readback"));
|
||||||
btnSIMStatusGet->setText(tr("Get cellular network status information"));
|
btnSIMStatusGet->setText(tr("Get cellular network status information"));
|
||||||
label_10->setText(tr("Flight Mode"));
|
label_10->setText(tr("Flight Mode"));
|
||||||
|
|
||||||
|
@ -1034,18 +1145,18 @@ void CtrlNetworkPanel::transUi() {
|
||||||
lbCus_proxy->setText(tr("Proxy"));
|
lbCus_proxy->setText(tr("Proxy"));
|
||||||
lbCus_mmsPort->setText(tr("MMS Port"));
|
lbCus_mmsPort->setText(tr("MMS Port"));
|
||||||
lbCus_mmsProxy->setText(tr("MMS Proxy"));
|
lbCus_mmsProxy->setText(tr("MMS Proxy"));
|
||||||
btnAPNCusSet->setText(tr("Set"));
|
btnAPNCusSet->setText(translate("","Set"));
|
||||||
btnAPNCusGet->setText(tr("Readback"));
|
btnAPNCusGet->setText(translate("","Readback"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlNetworkPanel::getCurrentAPN(QString &ip) {
|
void CtrlNetworkPanel::getCurrentAPN(QString &ip) {
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetCurrentAPN");
|
json.insert("_id", "GetCurrentAPN");
|
||||||
json.insert("_type", "GetCurrentAPN");
|
json.insert("_type", "GetCurrentAPN");
|
||||||
auto reply = NetReq("http://"+ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
fdCus_Name->setText(json["carrier"].toString());
|
fdCus_Name->setText(json["carrier"].toString());
|
||||||
fdCus_apn->setText(json["apn"].toString());
|
fdCus_apn->setText(json["apn"].toString());
|
||||||
|
|
|
@ -45,21 +45,17 @@ private:
|
||||||
QLabel *labelIpAddress, *labelMaskAddress, *labelGateway, *labelDnsAddress;
|
QLabel *labelIpAddress, *labelMaskAddress, *labelGateway, *labelDnsAddress;
|
||||||
QLineEdit *fdIP, *fdMask, *fdGateWay, *fdDns;
|
QLineEdit *fdIP, *fdMask, *fdGateWay, *fdDns;
|
||||||
QPushButton *btnLanSet, *btnLanGet;
|
QPushButton *btnLanSet, *btnLanGet;
|
||||||
QLabel *label_5;
|
QLabel *lbWifiCfg, *lbWifiName;
|
||||||
QLabel *lbWifiName;
|
QComboBox *edWifiName;
|
||||||
QComboBox *fdWifiName;
|
QRadioButton *edIs5G;
|
||||||
QRadioButton *fdIs2_4G;
|
QLabel *lbWifiPswd;
|
||||||
QLabel *lbWifiPassword;
|
|
||||||
|
|
||||||
QRadioButton *fdIsWifi, *fdIsHotspot;
|
QCheckBox *fdIsWifi, *fdIsAP;
|
||||||
QLineEdit *fdWifiPassword;
|
QLineEdit *edWifiPswd;
|
||||||
QPushButton *btnScan;
|
QPushButton *btnScan;
|
||||||
QPushButton *btnWiFiSet;
|
QPushButton *btnWiFiSet, *btnHotspotSet, *btnWiFiGet;
|
||||||
QPushButton *btnWiFiGet;
|
QLabel *lbHotspotName, *lbHotspotPswd;
|
||||||
QLabel *lbHotspotName;
|
QLineEdit *edHotspotName, *edHotspotPswd;
|
||||||
QLabel *lbHotspotPassword;
|
|
||||||
QLineEdit *fdHotspotName;
|
|
||||||
QLineEdit *fdHotspotPassword;
|
|
||||||
QFrame *line_3;
|
QFrame *line_3;
|
||||||
QLabel *lbCellularConfig;
|
QLabel *lbCellularConfig;
|
||||||
QCheckBox *fdEnableCellular;
|
QCheckBox *fdEnableCellular;
|
||||||
|
|
|
@ -52,7 +52,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
fdScreen->setTextColor(QColor(100,100,100), QColor(0, 160, 230));
|
fdScreen->setTextColor(QColor(100,100,100), QColor(0, 160, 230));
|
||||||
connect(fdScreen, &SwitchControl::checkedChanged, this, [this](bool checked) {
|
connect(fdScreen, &SwitchControl::checkedChanged, this, [this](bool checked) {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -82,7 +82,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
btnScreenGet->setProperty("ssType", "progManageTool");
|
btnScreenGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScreenGet, &QPushButton::clicked, this, [this] {
|
connect(btnScreenGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -106,8 +106,8 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
foreach(auto card, gSelCards) {
|
foreach(auto card, gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
err = json["on"].toBool() ? tr("On") : tr("Off");
|
err = json["on"].toBool() ? tr("On") : tr("Off");
|
||||||
auto item = findItem(card.id);
|
auto item = findItem(card.id);
|
||||||
|
@ -194,7 +194,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
||||||
auto data = scheQFile.readAll();
|
auto data = scheQFile.readAll();
|
||||||
scheQFile.close();
|
scheQFile.close();
|
||||||
restoreScheduleJson(QJsonDocument::fromJson(data).object());
|
restoreScheduleJson(JFrom(data));
|
||||||
});
|
});
|
||||||
hBox->addWidget(pushButtonImport);
|
hBox->addWidget(pushButtonImport);
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
pushButtonApply->setMinimumSize(QSize(60, 30));
|
pushButtonApply->setMinimumSize(QSize(60, 30));
|
||||||
connect(pushButtonApply, &QPushButton::clicked, this, [this] {
|
connect(pushButtonApply, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(tableSche->rowCount()==0) clearSche();
|
if(tableSche->rowCount()==0) clearSche();
|
||||||
|
@ -259,7 +259,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
pushButtonClearSchedule->setProperty("ssType", "progManageTool");
|
pushButtonClearSchedule->setProperty("ssType", "progManageTool");
|
||||||
connect(pushButtonClearSchedule, &QPushButton::clicked, this, [this] {
|
connect(pushButtonClearSchedule, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearSche();
|
clearSche();
|
||||||
|
@ -272,7 +272,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
pushButtonReadback->setProperty("ssType", "progManageTool");
|
pushButtonReadback->setProperty("ssType", "progManageTool");
|
||||||
connect(pushButtonReadback, &QPushButton::clicked, this, [this] {
|
connect(pushButtonReadback, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -284,7 +284,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
restoreScheduleJson(json["screenTask"].toObject());
|
restoreScheduleJson(json["screenTask"].toObj());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -318,10 +318,10 @@ void CtrlPowerPanel::init() {
|
||||||
json.insert("_type", "GetTimingScreenTask");
|
json.insert("_type", "GetTimingScreenTask");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
if(restoreScheduleJson(json["screenTask"].toObject())) fdSchedule->setChecked(true);
|
if(restoreScheduleJson(json["screenTask"].toObj())) fdSchedule->setChecked(true);
|
||||||
else fdManual->setChecked(true);
|
else fdManual->setChecked(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ void CtrlPowerPanel::transUi() {
|
||||||
|
|
||||||
lbScreen->setText(tr("Power"));
|
lbScreen->setText(tr("Power"));
|
||||||
fdScreen->setText(tr("Off"), tr("On"));
|
fdScreen->setText(tr("Off"), tr("On"));
|
||||||
btnScreenGet->setText(tr("Readback"));
|
btnScreenGet->setText(translate("","Readback"));
|
||||||
|
|
||||||
tableSche->setHeaderText("start", tr("Start Time"));
|
tableSche->setHeaderText("start", tr("Start Time"));
|
||||||
tableSche->setHeaderText("end", tr("End Time"));
|
tableSche->setHeaderText("end", tr("End Time"));
|
||||||
|
@ -351,18 +351,18 @@ void CtrlPowerPanel::transUi() {
|
||||||
|
|
||||||
pushButtonAdd->setText(tr("Add"));
|
pushButtonAdd->setText(tr("Add"));
|
||||||
pushButtonApply->setText(tr("Apply"));
|
pushButtonApply->setText(tr("Apply"));
|
||||||
pushButtonClear->setText(tr("Clear"));
|
pushButtonClear->setText(translate("","Clear"));
|
||||||
pushButtonDelete->setText(tr("Delete"));
|
pushButtonDelete->setText(tr("Delete"));
|
||||||
pushButtonImport->setText(tr("Import"));
|
pushButtonImport->setText(tr("Import"));
|
||||||
pushButtonExport->setText(tr("Export"));
|
pushButtonExport->setText(tr("Export"));
|
||||||
labelPowerScheduleTip->setText(tr("It is power off state outside the schedule time period"));
|
labelPowerScheduleTip->setText(tr("It is power off state outside the schedule time period"));
|
||||||
pushButtonClearSchedule->setText(tr("Clear Schedule"));
|
pushButtonClearSchedule->setText(tr("Clear Schedule"));
|
||||||
pushButtonReadback->setText(tr("Readback"));
|
pushButtonReadback->setText(translate("","Readback"));
|
||||||
}
|
}
|
||||||
bool CtrlPowerPanel::restoreScheduleJson(QJsonObject oTaskSync) {
|
bool CtrlPowerPanel::restoreScheduleJson(JValue oTaskSync) {
|
||||||
tableSche->setRowCount(0);
|
tableSche->setRowCount(0);
|
||||||
auto schedules = oTaskSync["schedules"].toArray();
|
auto schedules = oTaskSync["schedules"].toArray();
|
||||||
foreach(QJsonValue schedule, schedules) {
|
for(auto &schedule : schedules) {
|
||||||
int row = tableSche->rowCount();
|
int row = tableSche->rowCount();
|
||||||
tableSche->insertRow(row);
|
tableSche->insertRow(row);
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ bool CtrlPowerPanel::restoreScheduleJson(QJsonObject oTaskSync) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return schedules.count() > 0;
|
return schedules.size() > 0;
|
||||||
}
|
}
|
||||||
QJsonObject CtrlPowerPanel::getScheduleJson() {
|
QJsonObject CtrlPowerPanel::getScheduleJson() {
|
||||||
QJsonArray schedules;
|
QJsonArray schedules;
|
||||||
|
@ -416,7 +416,7 @@ QJsonObject CtrlPowerPanel::getScheduleJson() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
void CtrlPowerPanel::clearSche() {
|
void CtrlPowerPanel::clearSche() {
|
||||||
auto btn = QMessageBox::question(this, tr("Tip Info"), tr("Clear schedule task?"));
|
auto btn = QMessageBox::question(this, translate("","Tip"), tr("Clear schedule task?"));
|
||||||
if(btn != QMessageBox::Yes) return;
|
if(btn != QMessageBox::Yes) return;
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "CleanTimingScreenTask");
|
json.insert("_id", "CleanTimingScreenTask");
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CTRLPOWERPANEL_H
|
#define CTRLPOWERPANEL_H
|
||||||
|
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
|
#include "gutil/qjson.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -11,7 +12,7 @@ class CtrlPowerPanel : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CtrlPowerPanel();
|
CtrlPowerPanel();
|
||||||
bool restoreScheduleJson(QJsonObject oTaskSync);
|
bool restoreScheduleJson(JValue oTaskSync);
|
||||||
QJsonObject getScheduleJson();
|
QJsonObject getScheduleJson();
|
||||||
void clearSche();
|
void clearSche();
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -61,26 +61,26 @@ CtrlPwdPanel::CtrlPwdPanel() {
|
||||||
btnPwdSet->setProperty("ssType", "progManageTool");
|
btnPwdSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnPwdSet, &QPushButton::clicked, this, [this] {
|
connect(btnPwdSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
|
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("InputOriginalPasswordTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("InputOriginalPasswordTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fdNewPwd->text().isEmpty()) {
|
if(fdNewPwd->text().isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("InputNewPasswordTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("InputNewPasswordTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fdPwdAgain->text().isEmpty()) {
|
if(fdPwdAgain->text().isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("InputRepeatPasswordTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("InputRepeatPasswordTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fdNewPwd->text() != fdPwdAgain->text()) {
|
if(fdNewPwd->text() != fdPwdAgain->text()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("InputRepeatPasswordNotSameTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("InputRepeatPasswordNotSameTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"), tr("After setting the password, please remember the password and record it. If you forget the password, the device will be unable to operate. Are you sure you want to continue with this operation?"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::information(this, translate("","Tip"), tr("After setting the password, please remember the password and record it. If you forget the password, the device will be unable to operate. Are you sure you want to continue with this operation?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
if(res != QMessageBox::Ok) return;
|
if(res != QMessageBox::Ok) return;
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "SetControllerPassword");
|
json.insert("_id", "SetControllerPassword");
|
||||||
|
@ -91,16 +91,16 @@ CtrlPwdPanel::CtrlPwdPanel() {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(json["result"].toInt()) {
|
if(json["result"].toInt()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("OriginalPasswordErrorTip"));
|
QMessageBox::critical(this, translate("","Tip"), tr("OriginalPasswordErrorTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
@ -121,12 +121,12 @@ CtrlPwdPanel::CtrlPwdPanel() {
|
||||||
foreach(auto card, gSelCards) {
|
foreach(auto card, gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
|
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
|
||||||
else {
|
else {
|
||||||
err = tr("Success");
|
err = translate("","Success");
|
||||||
lbOldPwd->show();
|
lbOldPwd->show();
|
||||||
fdOldPwd->show();
|
fdOldPwd->show();
|
||||||
btnPwdClear->show();
|
btnPwdClear->show();
|
||||||
|
@ -150,11 +150,11 @@ CtrlPwdPanel::CtrlPwdPanel() {
|
||||||
btnPwdClear->setProperty("ssType", "progManageTool");
|
btnPwdClear->setProperty("ssType", "progManageTool");
|
||||||
connect(btnPwdClear, &QPushButton::clicked, this, [this] {
|
connect(btnPwdClear, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
|
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("InputOriginalPasswordTip"));
|
QMessageBox::information(this, translate("","Tip"), tr("InputOriginalPasswordTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -166,16 +166,16 @@ CtrlPwdPanel::CtrlPwdPanel() {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(json["result"].toInt()) {
|
if(json["result"].toInt()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("OriginalPasswordErrorTip"));
|
QMessageBox::critical(this, translate("","Tip"), tr("OriginalPasswordErrorTip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
@ -196,12 +196,12 @@ CtrlPwdPanel::CtrlPwdPanel() {
|
||||||
foreach(auto card, gSelCards) {
|
foreach(auto card, gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
|
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
|
||||||
else {
|
else {
|
||||||
err = tr("Success");
|
err = translate("","Success");
|
||||||
lbOldPwd->hide();
|
lbOldPwd->hide();
|
||||||
fdOldPwd->hide();
|
fdOldPwd->hide();
|
||||||
btnPwdClear->hide();
|
btnPwdClear->hide();
|
||||||
|
|
|
@ -238,7 +238,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
btnAnycastReset->setProperty("ssType", "progManageTool");
|
btnAnycastReset->setProperty("ssType", "progManageTool");
|
||||||
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
|
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SendAnycastCmd(0);
|
SendAnycastCmd(0);
|
||||||
|
@ -253,7 +253,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
btnAnycast->setProperty("ssType", "progManageTool");
|
btnAnycast->setProperty("ssType", "progManageTool");
|
||||||
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SendAnycastCmd(fdAnycast->text().toInt());
|
SendAnycastCmd(fdAnycast->text().toInt());
|
||||||
|
@ -287,7 +287,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
|
|
||||||
connect(pushButtonStartLine, &QPushButton::clicked, this, [this] {
|
connect(pushButtonStartLine, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -323,7 +323,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
});
|
});
|
||||||
connect(pushButtonStartGray, &QPushButton::clicked, this, [this] {
|
connect(pushButtonStartGray, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -359,7 +359,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
});
|
});
|
||||||
connect(pushButtonStartColor, &QPushButton::clicked, this, [this] {
|
connect(pushButtonStartColor, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -395,7 +395,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
});
|
});
|
||||||
connect(btnStopTest, &QPushButton::clicked, this, [this] {
|
connect(btnStopTest, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -458,7 +458,7 @@ void CtrlTestPanel::transUi() {
|
||||||
radioButton_Blue->setText(tr("Blue"));
|
radioButton_Blue->setText(tr("Blue"));
|
||||||
radioButton_White->setText(tr("White"));
|
radioButton_White->setText(tr("White"));
|
||||||
btnStopTest->setText(tr("Stop"));
|
btnStopTest->setText(tr("Stop"));
|
||||||
btnAnycastClear->setText(tr("Clear"));
|
btnAnycastClear->setText(translate("","Clear"));
|
||||||
btnAnycastReset->setText(tr("Reset"));
|
btnAnycastReset->setText(tr("Reset"));
|
||||||
btnAnycast->setText(tr("Anycast"));
|
btnAnycast->setText(tr("Anycast"));
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,7 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
QMessageBox::critical(this, translate("","Tip"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
});
|
});
|
||||||
tcp->connectToHost(card.ip, 31299);
|
tcp->connectToHost(card.ip, 31299);
|
||||||
tcp->startTimer(10000);
|
tcp->startTimer(10000);
|
||||||
|
@ -516,7 +516,7 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
tcp->stopTimer();
|
tcp->stopTimer();
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
gFdResInfo->append(cardId+" "+action+" "+tr("Success"));
|
gFdResInfo->append(cardId+" "+action+" "+translate("","Success"));
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
tcp->close();
|
tcp->close();
|
||||||
|
|
|
@ -25,7 +25,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
fdTimeZoneSet = new QPushButton;
|
fdTimeZoneSet = new QPushButton;
|
||||||
connect(fdTimeZoneSet, &QPushButton::clicked, this, [this] {
|
connect(fdTimeZoneSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -59,7 +59,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnLangSet = new QPushButton;
|
btnLangSet = new QPushButton;
|
||||||
connect(btnLangSet, &QPushButton::clicked, this, [this] {
|
connect(btnLangSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -83,10 +83,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnLangGet = new QPushButton;
|
btnLangGet = new QPushButton;
|
||||||
connect(btnLangGet, &QPushButton::clicked, this, [this] {
|
connect(btnLangGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetLanguage");
|
json.insert("_id", "GetLanguage");
|
||||||
json.insert("_type", "GetLanguage");
|
json.insert("_type", "GetLanguage");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -99,12 +99,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
else fdIsEn->setChecked(true);
|
else fdIsEn->setChecked(true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["language"].toInt()==1 ? "中文" : "英文";
|
if(err.isEmpty()) err = json["language"].toInt()==1 ? "中文" : "英文";
|
||||||
gFdResInfo->append(cardId+" 获取语言 "+err);
|
gFdResInfo->append(cardId+" 获取语言 "+err);
|
||||||
});
|
});
|
||||||
|
@ -131,7 +131,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnSyncTime->setMinimumSize(QSize(60, 30));
|
btnSyncTime->setMinimumSize(QSize(60, 30));
|
||||||
connect(btnSyncTime, &QPushButton::clicked, this, [this] {
|
connect(btnSyncTime, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -162,10 +162,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnDateGet->setMinimumSize(QSize(0, 30));
|
btnDateGet->setMinimumSize(QSize(0, 30));
|
||||||
connect(btnDateGet, &QPushButton::clicked, this, [this] {
|
connect(btnDateGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetControllerDate");
|
json.insert("_id", "GetControllerDate");
|
||||||
json.insert("_type", "GetControllerDate");
|
json.insert("_type", "GetControllerDate");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -177,12 +177,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
labelCurTime->setText(json["date"].toString());
|
labelCurTime->setText(json["date"].toString());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["date"].toString();
|
if(err.isEmpty()) err = json["date"].toString();
|
||||||
gFdResInfo->append(cardId+" "+tr("GetControllerDate")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetControllerDate")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -284,7 +284,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnSyncSet->setMinimumSize(QSize(60, 30));
|
btnSyncSet->setMinimumSize(QSize(60, 30));
|
||||||
connect(btnSyncSet, &QPushButton::clicked, this, [this] {
|
connect(btnSyncSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -320,10 +320,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
fdSyncGet->setMinimumSize(QSize(60, 30));
|
fdSyncGet->setMinimumSize(QSize(60, 30));
|
||||||
connect(fdSyncGet, &QPushButton::clicked, this, [this] {
|
connect(fdSyncGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetingSyncMethod");
|
json.insert("_id", "GetingSyncMethod");
|
||||||
json.insert("_type", "GetingSyncMethod");
|
json.insert("_type", "GetingSyncMethod");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -335,13 +335,13 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
dealGetSync(json);
|
dealGetSync(json);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QString err = checkReplyForJson(reply, &json, &data);
|
auto err = errStrWithJson(reply, &json, &data);
|
||||||
if(err.isEmpty()) {
|
if(err.isEmpty()) {
|
||||||
QString strOtherSyncItem = tr("screenSwitch") + ":" + (json["screenSwitch"].toBool() ? tr("YES") : tr("NO"))
|
QString strOtherSyncItem = tr("screenSwitch") + ":" + (json["screenSwitch"].toBool() ? tr("YES") : tr("NO"))
|
||||||
+ " " + tr("volume") + ":" + (json["volume"].toBool() ? tr("YES") : tr("NO"))
|
+ " " + tr("volume") + ":" + (json["volume"].toBool() ? tr("YES") : tr("NO"))
|
||||||
|
@ -406,7 +406,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnLoraMasterSet->setMinimumSize(QSize(0, 30));
|
btnLoraMasterSet->setMinimumSize(QSize(0, 30));
|
||||||
connect(btnLoraMasterSet, &QPushButton::clicked, this, [this] {
|
connect(btnLoraMasterSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -424,8 +424,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
foreach(auto card, gSelCards) {
|
foreach(auto card, gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, card, isMaster] {
|
connect(reply, &QNetworkReply::finished, this, [reply, card, isMaster] {
|
||||||
QString err = checkReplyForJson(reply);
|
QString err = errStrWithJson(reply);
|
||||||
gFdResInfo->append(card.id+" "+(isMaster ? tr("MasterSwitch ") : tr("SlaveSwitch "))+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));
|
gFdResInfo->append(card.id+" "+(isMaster ? tr("MasterSwitch ") : tr("SlaveSwitch "))+" "+(err.isEmpty()?translate("","Success"):err));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,10 +436,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnLoraMasterGet->setMinimumSize(QSize(0, 30));
|
btnLoraMasterGet->setMinimumSize(QSize(0, 30));
|
||||||
connect(btnLoraMasterGet, &QPushButton::clicked, this, [this] {
|
connect(btnLoraMasterGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "IsMasterSlave");
|
json.insert("_id", "IsMasterSlave");
|
||||||
json.insert("_type", "IsMasterSlave");
|
json.insert("_type", "IsMasterSlave");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -453,12 +453,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
fdSlave->setChecked(! isMaster);
|
fdSlave->setChecked(! isMaster);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["result"].toBool() ? tr("Master") : tr("Slave");
|
if(err.isEmpty()) err = json["result"].toBool() ? tr("Master") : tr("Slave");
|
||||||
gFdResInfo->append(cardId+" "+tr("Lora identity")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("Lora identity")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -494,10 +494,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnNtpSet->setMinimumSize(QSize(60, 30));
|
btnNtpSet->setMinimumSize(QSize(60, 30));
|
||||||
connect(btnNtpSet, &QPushButton::clicked, this, [this] {
|
connect(btnNtpSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "SetNtpServer");
|
json.insert("_id", "SetNtpServer");
|
||||||
json.insert("_type", "SetNtpServer");
|
json.insert("_type", "SetNtpServer");
|
||||||
json.insert("ntpServer", fdNtpServer->text());
|
json.insert("ntpServer", fdNtpServer->text());
|
||||||
|
@ -508,7 +508,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
Def_CtrlSetMulti(tr("SetNtpServer"))
|
Def_CtrlSetMulti(tr("SetNtpServer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -519,10 +519,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
btnNtpGet->setMinimumSize(QSize(60, 30));
|
btnNtpGet->setMinimumSize(QSize(60, 30));
|
||||||
connect(btnNtpGet, &QPushButton::clicked, this, [this] {
|
connect(btnNtpGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetNtpServer");
|
json.insert("_id", "GetNtpServer");
|
||||||
json.insert("_type", "GetNtpServer");
|
json.insert("_type", "GetNtpServer");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
@ -534,12 +534,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
|
||||||
fdNtpServer->setText(json["ntpServer"].toString());
|
fdNtpServer->setText(json["ntpServer"].toString());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["ntpServer"].toString();
|
if(err.isEmpty()) err = json["ntpServer"].toString();
|
||||||
gFdResInfo->append(cardId+" "+tr("GetNtpServer")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetNtpServer")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -598,35 +598,35 @@ void CtrlVerifyClockPanel::init() {
|
||||||
if(! isSingle) return;
|
if(! isSingle) return;
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
|
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetingSyncMethod");
|
json.insert("_id", "GetingSyncMethod");
|
||||||
json.insert("_type", "GetingSyncMethod");
|
json.insert("_type", "GetingSyncMethod");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
dealGetSync(json);
|
dealGetSync(json);
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetTimezone");
|
json.insert("_id", "GetTimezone");
|
||||||
json.insert("_type", "GetTimezone");
|
json.insert("_type", "GetTimezone");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
fdTimezone->setCurrentText(json["timezone"].toString());
|
fdTimezone->setCurrentText(json["timezone"].toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
json = QJsonObject();
|
json = JObj();
|
||||||
json.insert("_id", "GetLanguage");
|
json.insert("_id", "GetLanguage");
|
||||||
json.insert("_type", "GetLanguage");
|
json.insert("_type", "GetLanguage");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
if(json["language"].toInt()==1) fdIsCn->setChecked(true);
|
if(json["language"].toInt()==1) fdIsCn->setChecked(true);
|
||||||
else fdIsEn->setChecked(true);
|
else fdIsEn->setChecked(true);
|
||||||
|
@ -637,21 +637,21 @@ void CtrlVerifyClockPanel::changeEvent(QEvent *event) {
|
||||||
if(event->type() == QEvent::LanguageChange) transUi();
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
}
|
}
|
||||||
void CtrlVerifyClockPanel::transUi() {
|
void CtrlVerifyClockPanel::transUi() {
|
||||||
btnDateGet->setText(tr("Readback"));
|
btnDateGet->setText(translate("","Readback"));
|
||||||
btnLangGet->setText(tr("Readback"));
|
btnLangGet->setText(translate("","Readback"));
|
||||||
btnLangSet->setText(tr("Set"));
|
btnLangSet->setText(translate("","Set"));
|
||||||
btnLoraMasterGet->setText(tr("Readback"));
|
btnLoraMasterGet->setText(translate("","Readback"));
|
||||||
btnLoraMasterSet->setText(tr("Set"));
|
btnLoraMasterSet->setText(translate("","Set"));
|
||||||
btnNtpGet->setText(tr("Readback"));
|
btnNtpGet->setText(translate("","Readback"));
|
||||||
btnNtpSet->setText(tr("Set"));
|
btnNtpSet->setText(translate("","Set"));
|
||||||
btnSyncTime->setText(tr("Verify to Computer time"));
|
btnSyncTime->setText(tr("Verify to Computer time"));
|
||||||
checkBoxBrightness->setText(tr("Brightness"));
|
checkBoxBrightness->setText(tr("Brightness"));
|
||||||
checkBoxScreenSwitch->setText(tr("Screen on/off"));
|
checkBoxScreenSwitch->setText(tr("Screen on/off"));
|
||||||
checkBoxVolume->setText(tr("Volume"));
|
checkBoxVolume->setText(tr("Volume"));
|
||||||
fdIsLan->setText(tr("LAN"));
|
fdIsLan->setText(tr("LAN"));
|
||||||
fdNtpServer->setPlaceholderText(tr("NTP Server address"));
|
fdNtpServer->setPlaceholderText(tr("NTP Server address"));
|
||||||
fdSyncGet->setText(tr("Readback"));
|
fdSyncGet->setText(translate("","Readback"));
|
||||||
fdTimeZoneSet->setText(tr("Set"));
|
fdTimeZoneSet->setText(translate("","Set"));
|
||||||
groupBox->setTitle(tr("Enable Synchronous playing"));
|
groupBox->setTitle(tr("Enable Synchronous playing"));
|
||||||
groupBox_5->setTitle(tr("Cur time of controller"));
|
groupBox_5->setTitle(tr("Cur time of controller"));
|
||||||
groupNTP->setTitle(tr("NTP Server"));
|
groupNTP->setTitle(tr("NTP Server"));
|
||||||
|
@ -665,11 +665,11 @@ void CtrlVerifyClockPanel::transUi() {
|
||||||
lbLang->setText(tr("Language:"));
|
lbLang->setText(tr("Language:"));
|
||||||
lineEditIdCode->setPlaceholderText(tr("identification code"));
|
lineEditIdCode->setPlaceholderText(tr("identification code"));
|
||||||
lineEdit_3->setPlaceholderText(tr("Sync time interval"));
|
lineEdit_3->setPlaceholderText(tr("Sync time interval"));
|
||||||
btnSyncSet->setText(tr("Set"));
|
btnSyncSet->setText(translate("","Set"));
|
||||||
fdMaster->setText(tr("Master"));
|
fdMaster->setText(tr("Master"));
|
||||||
fdSlave->setText(tr("Slave"));
|
fdSlave->setText(tr("Slave"));
|
||||||
}
|
}
|
||||||
void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
|
void CtrlVerifyClockPanel::dealGetSync(JValue &json) {
|
||||||
QString strType = json["time"].toString().toLower();
|
QString strType = json["time"].toString().toLower();
|
||||||
if(strType=="serial" || strType=="lan") {
|
if(strType=="serial" || strType=="lan") {
|
||||||
if(strType=="serial") fdIsLora->setChecked(true);
|
if(strType=="serial") fdIsLora->setChecked(true);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef CTRLVERIFYCLOCKPANEL_H
|
#ifndef CTRLVERIFYCLOCKPANEL_H
|
||||||
#define CTRLVERIFYCLOCKPANEL_H
|
#define CTRLVERIFYCLOCKPANEL_H
|
||||||
|
|
||||||
|
#include "gutil/qjson.h"
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
@ -18,7 +19,7 @@ protected:
|
||||||
void init();
|
void init();
|
||||||
void changeEvent(QEvent *) override;
|
void changeEvent(QEvent *) override;
|
||||||
void transUi();
|
void transUi();
|
||||||
void dealGetSync(QJsonDocument &json);
|
void dealGetSync(JValue &json);
|
||||||
protected slots:
|
protected slots:
|
||||||
void OnRadioButton();
|
void OnRadioButton();
|
||||||
void OnRadioButton2();
|
void OnRadioButton2();
|
||||||
|
|
|
@ -66,7 +66,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
fdVolumeSet->setProperty("ssType", "progManageTool");
|
fdVolumeSet->setProperty("ssType", "progManageTool");
|
||||||
connect(fdVolumeSet, &QPushButton::clicked, this, [=] {
|
connect(fdVolumeSet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -93,7 +93,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
fdVolumeGet->setProperty("ssType", "progManageTool");
|
fdVolumeGet->setProperty("ssType", "progManageTool");
|
||||||
connect(fdVolumeGet, &QPushButton::clicked, this, [=] {
|
connect(fdVolumeGet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -108,12 +108,12 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
fdVolume->setValue(json["volume"].toInt());
|
fdVolume->setValue(json["volume"].toInt());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = QString::number(json["volume"].toInt());
|
if(err.isEmpty()) err = QString::number(json["volume"].toInt());
|
||||||
gFdResInfo->append(cardId+" "+tr("GetVolume")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetVolume")+" "+err);
|
||||||
});
|
});
|
||||||
|
@ -218,7 +218,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
||||||
auto data = scheQFile.readAll();
|
auto data = scheQFile.readAll();
|
||||||
scheQFile.close();
|
scheQFile.close();
|
||||||
restoreScheduleJson(QJsonDocument::fromJson(data).object());
|
restoreScheduleJson(JFrom(data));
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnScheImport);
|
hBox->addWidget(btnScheImport);
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
btnScheSet->setProperty("ssType", "progManageTool");
|
btnScheSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScheSet, &QPushButton::clicked, this, [this] {
|
connect(btnScheSet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -291,7 +291,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
btnScheGet->setProperty("ssType", "progManageTool");
|
btnScheGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnScheGet, &QPushButton::clicked, this, [this] {
|
connect(btnScheGet, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -303,7 +303,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
restoreScheduleJson(json["taskVolume"].toObject());
|
restoreScheduleJson(json["taskVolume"]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -334,10 +334,10 @@ void CtrlVolumePanel::init() {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "GetVolume");
|
json.insert("_id", "GetVolume");
|
||||||
json.insert("_type", "GetVolume");
|
json.insert("_type", "GetVolume");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
fdVolume->setValue(json["volume"].toInt());
|
fdVolume->setValue(json["volume"].toInt());
|
||||||
});
|
});
|
||||||
|
@ -345,12 +345,12 @@ void CtrlVolumePanel::init() {
|
||||||
json = QJsonObject();
|
json = QJsonObject();
|
||||||
json.insert("_id", "GetAutoVolumeTask");
|
json.insert("_id", "GetAutoVolumeTask");
|
||||||
json.insert("_type", "GetAutoVolumeTask");
|
json.insert("_type", "GetAutoVolumeTask");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
if(restoreScheduleJson(json["taskVolume"].toObject())) fdSchedule->setChecked(true);
|
if(restoreScheduleJson(json["taskVolume"].toObj())) fdSchedule->setChecked(true);
|
||||||
else fdManual->setChecked(true);
|
else fdManual->setChecked(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -365,12 +365,12 @@ void CtrlVolumePanel::transUi() {
|
||||||
fdSchedule->setText(tr("Schedule"));
|
fdSchedule->setText(tr("Schedule"));
|
||||||
|
|
||||||
lbVolume->setText(tr("Volume"));
|
lbVolume->setText(tr("Volume"));
|
||||||
fdVolumeSet->setText(tr("Set"));
|
fdVolumeSet->setText(translate("","Set"));
|
||||||
fdVolumeGet->setText(tr("Readback"));
|
fdVolumeGet->setText(translate("","Readback"));
|
||||||
|
|
||||||
lbDefBright->setText(tr("Default volume"));
|
lbDefBright->setText(tr("Default volume"));
|
||||||
btnScheAdd->setText(tr("Add"));
|
btnScheAdd->setText(tr("Add"));
|
||||||
btnScheClear->setText(tr("Clear"));
|
btnScheClear->setText(translate("","Clear"));
|
||||||
btnScheDel->setText(tr("Delete"));
|
btnScheDel->setText(tr("Delete"));
|
||||||
btnScheImport->setText(tr("Import"));
|
btnScheImport->setText(tr("Import"));
|
||||||
btnScheExport->setText(tr("Export"));
|
btnScheExport->setText(tr("Export"));
|
||||||
|
@ -387,16 +387,16 @@ void CtrlVolumePanel::transUi() {
|
||||||
tableSche->setHeaderText("6", tr("SAT"));
|
tableSche->setHeaderText("6", tr("SAT"));
|
||||||
|
|
||||||
btnScheSet->setText(tr("Apply"));
|
btnScheSet->setText(tr("Apply"));
|
||||||
btnScheGet->setText(tr("Readback"));
|
btnScheGet->setText(translate("","Readback"));
|
||||||
fdScheTip->setText(tr("Default volume tip"));
|
fdScheTip->setText(tr("Default volume tip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CtrlVolumePanel::restoreScheduleJson(QJsonObject json) {
|
bool CtrlVolumePanel::restoreScheduleJson(JValue json) {
|
||||||
tableSche->setRowCount(0);
|
tableSche->setRowCount(0);
|
||||||
auto items = json["items"].toArray();
|
auto items = json["items"].toArray();
|
||||||
fdDefBright->setValue(items.size()==0 ? 10 : json["defaultVolume"].toInt());
|
fdDefBright->setValue(items.size()==0 ? 10 : json["defaultVolume"].toInt());
|
||||||
for(int i=0; i<items.size(); i++) {
|
for(int i=0; i<(int)items.size(); i++) {
|
||||||
auto schedule = items.at(i)["schedules"][0];
|
auto schedule = items[i]["schedules"][0];
|
||||||
int row = tableSche->rowCount();
|
int row = tableSche->rowCount();
|
||||||
tableSche->insertRow(row);
|
tableSche->insertRow(row);
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ bool CtrlVolumePanel::restoreScheduleJson(QJsonObject json) {
|
||||||
|
|
||||||
auto slider = new QSlider(Qt::Horizontal);
|
auto slider = new QSlider(Qt::Horizontal);
|
||||||
slider->setRange(0, 15);
|
slider->setRange(0, 15);
|
||||||
slider->setValue(items.at(i)["volume"].toInt());
|
slider->setValue(items[i]["volume"].toInt());
|
||||||
hBox->addWidget(slider);
|
hBox->addWidget(slider);
|
||||||
|
|
||||||
auto lb = new QLabel;
|
auto lb = new QLabel;
|
||||||
|
@ -437,7 +437,7 @@ bool CtrlVolumePanel::restoreScheduleJson(QJsonObject json) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items.count() > 0;
|
return items.size() > 0;
|
||||||
}
|
}
|
||||||
QJsonObject CtrlVolumePanel::getScheduleJson() {
|
QJsonObject CtrlVolumePanel::getScheduleJson() {
|
||||||
QJsonArray items;
|
QJsonArray items;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CTRLVOLUMEPANEL_H
|
#define CTRLVOLUMEPANEL_H
|
||||||
|
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
|
#include "gutil/qjson.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
@ -17,7 +18,7 @@ protected:
|
||||||
void transUi();
|
void transUi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool restoreScheduleJson(QJsonObject);
|
bool restoreScheduleJson(JValue);
|
||||||
QJsonObject getScheduleJson();
|
QJsonObject getScheduleJson();
|
||||||
|
|
||||||
QLabel *lbVolumeControl;
|
QLabel *lbVolumeControl;
|
||||||
|
|
|
@ -35,22 +35,22 @@ ProgressesDlg::ProgressesDlg(QWidget *parent) : QDialog(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressesItem::sendProgress(const QString &id) {
|
void ProgressesItem::sendProgress(const QString &id) {
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", id);
|
json.insert("_id", id);
|
||||||
json.insert("_type", id);
|
json.insert("_type", id);
|
||||||
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(30000).post(json);
|
auto reply = NetReq("http://"+text("ip")+":2016/settings").post(json);
|
||||||
ConnReply(reply, this) [=] {
|
ConnReply(reply, this) [=] {
|
||||||
if(treeWidget()==0) return;
|
if(treeWidget()==0) return;
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
setRes(id+" "+tr("Error")+": "+err, Qt::red);
|
setRes(id+" "+translate("","Error")+": "+err, Qt::red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto progre = json["progress"].toInt();
|
auto progre = json["progress"].toInt();
|
||||||
if(progre >= 100) {
|
if(progre >= 100) {
|
||||||
fdProgress->setValue(100);
|
fdProgress->setValue(100);
|
||||||
setRes("FPGA "+tr("Install Success"), Qt::darkGreen);
|
setRes("MCU "+tr("Install Success"), Qt::darkGreen);
|
||||||
} else if(progre == -1) {
|
} else if(progre == -1) {
|
||||||
fdProgress->setValue(100);
|
fdProgress->setValue(100);
|
||||||
setRes(tr("Same version, needn't update"), Qt::darkGreen);
|
setRes(tr("Same version, needn't update"), Qt::darkGreen);
|
||||||
|
|
|
@ -142,7 +142,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
else items.append(item);
|
else items.append(item);
|
||||||
}
|
}
|
||||||
if(items.isEmpty()) {
|
if(items.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray fileData;
|
QByteArray fileData;
|
||||||
|
@ -153,7 +153,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
fileData = file.readAll();
|
fileData = file.readAll();
|
||||||
file.close();
|
file.close();
|
||||||
if(fileData.size() != file.size()) {
|
if(fileData.size() != file.size()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("File Read Fail"));
|
QMessageBox::information(this, translate("","Tip"), tr("Failed to Read File"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if(! fileId.isEmpty()) {
|
} else if(! fileId.isEmpty()) {
|
||||||
|
@ -170,15 +170,15 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
fileData = reply->readAll();
|
fileData = reply->readAll();
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
if(! fileData.isEmpty()) err += "\n"+fileData;
|
if(! fileData.isEmpty()) err += "\n"+fileData;
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fileData.isEmpty()) {
|
if(fileData.isEmpty()) {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Online file is empty"));
|
QMessageBox::critical(this, translate("","Error"), tr("Online file is empty"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("File is empty"));
|
QMessageBox::critical(this, translate("","Error"), tr("File is empty"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto nameBytes = fileName.toUtf8();
|
auto nameBytes = fileName.toUtf8();
|
||||||
|
@ -193,7 +193,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
item->setResult(tr("Uploading")+" ...");
|
item->setResult(tr("Uploading")+" ...");
|
||||||
item->fdProgress->setValue(0);
|
item->fdProgress->setValue(0);
|
||||||
NetReq req("http://"+item->text("ip")+":2016/upload?type="+(isApk ? "software":"hardware"));
|
NetReq req("http://"+item->text("ip")+":2016/upload?type="+(isApk ? "software":"hardware"));
|
||||||
auto reply = req.timeout(60000).type("multipart/form-data; boundary="+Boundary).post(data);
|
auto reply = req.timeout(120000).type("multipart/form-data; boundary="+Boundary).post(data);
|
||||||
connect(reply, &QNetworkReply::uploadProgress, item, [item](qint64 bytesSent, qint64 bytesTotal) {
|
connect(reply, &QNetworkReply::uploadProgress, item, [item](qint64 bytesSent, qint64 bytesTotal) {
|
||||||
if(bytesTotal==0) return;
|
if(bytesTotal==0) return;
|
||||||
item->fdProgress->setValue(bytesSent*100/bytesTotal);
|
item->fdProgress->setValue(bytesSent*100/bytesTotal);
|
||||||
|
@ -219,14 +219,14 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
json.insert("_type", "SynchronousHardwareVersion");
|
json.insert("_type", "SynchronousHardwareVersion");
|
||||||
}
|
}
|
||||||
item->setResult(info);
|
item->setResult(info);
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
if(item->treeWidget()==0) return;
|
if(item->treeWidget()==0) return;
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
item->isUpdating = false;
|
item->isUpdating = false;
|
||||||
item->setResult(tr("Install error")+": "+err, Qt::red);
|
item->setResult(translate("","Install")+" "+translate("","Error")+": "+err, Qt::red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(isApk || ! json["hasProgress"].toBool()) {
|
if(isApk || ! json["hasProgress"].toBool()) {
|
||||||
|
@ -264,7 +264,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
connect(btnUninstall, &QPushButton::clicked, this, [this, fdApk] {
|
connect(btnUninstall, &QPushButton::clicked, this, [this, fdApk] {
|
||||||
auto strApkName = fdApk->currentText();
|
auto strApkName = fdApk->currentText();
|
||||||
if(strApkName.isEmpty()) {
|
if(strApkName.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), "APK is Empty");
|
QMessageBox::information(this, translate("","Tip"), "APK is Empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! strApkName.endsWith(".xixunplayer") && ! strApkName.endsWith(".taxiapp") && QMessageBox::warning(this, tr("Reminder"), tr("Reminder: Uninstalling this program may cause the device to offline, cannot be found, lost configs and have a black screen. Please uninstall with caution!")+"\n"+tr("Do you want to continue?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return;
|
if(! strApkName.endsWith(".xixunplayer") && ! strApkName.endsWith(".taxiapp") && QMessageBox::warning(this, tr("Reminder"), tr("Reminder: Uninstalling this program may cause the device to offline, cannot be found, lost configs and have a black screen. Please uninstall with caution!")+"\n"+tr("Do you want to continue?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return;
|
||||||
|
@ -272,18 +272,18 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("id") == Qt::Checked) {
|
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("id") == Qt::Checked) {
|
||||||
auto item = (UpdateApkItem *) table->topLevelItem(i);
|
auto item = (UpdateApkItem *) table->topLevelItem(i);
|
||||||
item->setResult(tr("Uninstalling")+" ...");
|
item->setResult(tr("Uninstalling")+" ...");
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "UninstallSoftware");
|
json.insert("_id", "UninstallSoftware");
|
||||||
json.insert("_type", "UninstallSoftware");
|
json.insert("_type", "UninstallSoftware");
|
||||||
json.insert("packageName", strApkName);
|
json.insert("packageName", strApkName);
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").post(json);
|
||||||
ConnReply(reply, item) [reply, item, strApkName] {
|
ConnReply(reply, item) [=] {
|
||||||
QString err = checkReplyForJson(reply, "error");
|
auto err = errStrWithJson(reply, "error");
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
item->setResult(tr("Uninstall error")+": "+err, Qt::red);
|
item->setResult(translate("","Uninstall")+" "+translate("","Error")+": "+err, Qt::red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
item->setResult(tr("Uninstall success"), Qt::darkGreen);
|
item->setResult(translate("","Uninstall")+" "+translate("","Success"), Qt::darkGreen);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -291,7 +291,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
|
|
||||||
auto btnCheck = new QPushButton(tr("check running state"));
|
auto btnCheck = new QPushButton(tr("check running state"));
|
||||||
connect(btnCheck, &QPushButton::clicked, this, [this, fdApk] {
|
connect(btnCheck, &QPushButton::clicked, this, [this, fdApk] {
|
||||||
QString strApkName = fdApk->currentText();
|
auto strApkName = fdApk->currentText();
|
||||||
int cnt = table->topLevelItemCount();
|
int cnt = table->topLevelItemCount();
|
||||||
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("id") == Qt::Checked) {
|
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("id") == Qt::Checked) {
|
||||||
auto item = (UpdateApkItem *) table->topLevelItem(i);
|
auto item = (UpdateApkItem *) table->topLevelItem(i);
|
||||||
|
@ -322,7 +322,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto btnRefresh = new QPushButton(tr("Refresh"));
|
auto btnRefresh = new QPushButton(translate("","Refresh"));
|
||||||
connect(btnRefresh, &QPushButton::clicked, this, [=] {
|
connect(btnRefresh, &QPushButton::clicked, this, [=] {
|
||||||
table->clear();
|
table->clear();
|
||||||
table->fdCheckAll->setCheckState(Qt::Unchecked);
|
table->fdCheckAll->setCheckState(Qt::Unchecked);
|
||||||
|
@ -369,26 +369,26 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
|
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
|
||||||
if(! item->isLocked) return;
|
if(! item->isLocked) return;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
auto pwd = QInputDialog::getText(this, translate("","Input Password"), translate("","Input Password"), QLineEdit::Password, QString(), &ok);
|
||||||
if(! ok) return;
|
if(! ok) return;
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "VerifyPassword");
|
json.insert("_id", "VerifyPassword");
|
||||||
json.insert("_type", "VerifyPassword");
|
json.insert("_type", "VerifyPassword");
|
||||||
json.insert("pwd", pwd);
|
json.insert("pwd", pwd);
|
||||||
auto waitingDlg = new WaitingDlg(item->btnUnlock, tr("VerifyPassword")+" ...");
|
auto waitingDlg = new WaitingDlg(item->btnUnlock, tr("Verify Password")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
|
||||||
ConnReply(reply, waitingDlg) [=] {
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Error"), err);
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! json["result"].toBool()) {
|
if(! json["result"].toBool()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::warning(this, tr("Tip Info"), tr("password is wrong"));
|
QMessageBox::warning(this, translate("","Tip"), tr("password is wrong"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
@ -495,11 +495,11 @@ void UpgradeApkDialog::sendProgress(UpdateApkItem *item) {
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(30000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(30000).post(json);
|
||||||
ConnReply(reply, item) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
if(item->treeWidget()==0) return;
|
if(item->treeWidget()==0) return;
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
item->isUpdating = false;
|
item->isUpdating = false;
|
||||||
item->setResult("GetFpgaUpdateProgress "+tr("Error")+": "+err, Qt::red);
|
item->setResult("GetFpgaUpdateProgress "+translate("","Error")+": "+err, Qt::red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto progre = json["progress"].toInt();
|
auto progre = json["progress"].toInt();
|
||||||
|
@ -532,9 +532,9 @@ void UpgradeApkDialog::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
|
|
||||||
void UpdateApkItem::OnCheckFpgaVersions() {
|
void UpdateApkItem::OnCheckFpgaVersions() {
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "CheckHardwareVersions");
|
json["_id"] = "CheckHardwareVersions";
|
||||||
json.insert("_type", "CheckHardwareVersions");
|
json["_type"] = "CheckHardwareVersions";
|
||||||
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
|
||||||
ConnReply(reply, fdProgress) [=] {
|
ConnReply(reply, fdProgress) [=] {
|
||||||
if(treeWidget()==0) return;
|
if(treeWidget()==0) return;
|
||||||
|
@ -553,9 +553,9 @@ void UpdateApkItem::OnCheckFpgaVersions() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void UpdateApkItem::OnCheckSoftVersions(int repeat) {
|
void UpdateApkItem::OnCheckSoftVersions(int repeat) {
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "CheckSoftVersions");
|
json["_id"] = "CheckSoftVersions";
|
||||||
json.insert("_type", "CheckSoftVersions");
|
json["_type"] = "CheckSoftVersions";
|
||||||
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
|
||||||
ConnReply(reply, fdProgress) [=] {
|
ConnReply(reply, fdProgress) [=] {
|
||||||
if(treeWidget()==0) return;
|
if(treeWidget()==0) return;
|
||||||
|
|
|
@ -23,15 +23,15 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) {
|
||||||
JObj json;
|
JObj json;
|
||||||
json.insert("_id", "GetScreenshotFull");
|
json.insert("_id", "GetScreenshotFull");
|
||||||
json.insert("_type", "GetScreenshotFull");
|
json.insert("_type", "GetScreenshotFull");
|
||||||
auto waitingDlg = new WaitingDlg(btnGetCapture, DevicePanel::tr("Getting ")+DevicePanel::tr("Screenshot")+" ...");
|
auto waitingDlg = new WaitingDlg(btnGetCapture, translate("","Getting ")+DevicePanel::tr("Screenshot")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, waitingDlg) [=] {
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
QMessageBox::critical(treeWidget(), DevicePanel::tr("Error"), err);
|
QMessageBox::critical(treeWidget(), translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImgDlg dlg(QByteArray::fromBase64(json["data"].toString().toLatin1()), treeWidget());
|
ImgDlg dlg(QByteArray::fromBase64(json["data"].toString().toLatin1()), treeWidget());
|
||||||
|
@ -55,26 +55,26 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) {
|
||||||
QObject::connect(btnUnlock, &QPushButton::clicked, btnUnlock, [this] {
|
QObject::connect(btnUnlock, &QPushButton::clicked, btnUnlock, [this] {
|
||||||
if(! mCard.isLocked) return;
|
if(! mCard.isLocked) return;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto pwd = QInputDialog::getText(treeWidget(), DevicePanel::tr("Input password"), DevicePanel::tr("Input password"), QLineEdit::Password, QString(), &ok);
|
auto pwd = QInputDialog::getText(treeWidget(), translate("","Input Password"), translate("","Input Password"), QLineEdit::Password, QString(), &ok);
|
||||||
if(! ok) return;
|
if(! ok) return;
|
||||||
JObj json;
|
JObj json;
|
||||||
json.insert("_id", "VerifyPassword");
|
json.insert("_id", "VerifyPassword");
|
||||||
json.insert("_type", "VerifyPassword");
|
json.insert("_type", "VerifyPassword");
|
||||||
json.insert("pwd", pwd);
|
json.insert("pwd", pwd);
|
||||||
auto waitingDlg = new WaitingDlg(btnUnlock, DevicePanel::tr("VerifyPassword")+" ...");
|
auto waitingDlg = new WaitingDlg(btnUnlock, DevicePanel::tr("Verify Password")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(60000).post(json);
|
||||||
ConnReply(reply, waitingDlg) [=] {
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(treeWidget(), DevicePanel::tr("Error"), err);
|
QMessageBox::critical(treeWidget(), translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! json["result"].toBool()) {
|
if(! json["result"].toBool()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(treeWidget(), DevicePanel::tr("Tip Info"), DevicePanel::tr("password is wrong"));
|
QMessageBox::critical(treeWidget(), translate("","Tip"), DevicePanel::tr("password is wrong"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
|
|
@ -120,7 +120,7 @@ QComboBox QAbstractItemView::item {
|
||||||
QComboBox QAbstractItemView::item:selected {background-color: #09c;}
|
QComboBox QAbstractItemView::item:selected {background-color: #09c;}
|
||||||
)rrr");
|
)rrr");
|
||||||
|
|
||||||
btnRefresh = new QPushButton(tr("Refresh"), areaFlash);
|
btnRefresh = new QPushButton(translate("","Refresh"), areaFlash);
|
||||||
btnRefresh->setGeometry(0, 0, 75, areaFlash->height());
|
btnRefresh->setGeometry(0, 0, 75, areaFlash->height());
|
||||||
connect(btnRefresh, &QPushButton::clicked, this, [this] {
|
connect(btnRefresh, &QPushButton::clicked, this, [this] {
|
||||||
mDeviceTable->clear();
|
mDeviceTable->clear();
|
||||||
|
@ -230,7 +230,7 @@ QPushButton:hover {background-color: #08b;}
|
||||||
msgpre.append(tr("FPGA Version")).append(": ").append(item->mCard.HardVersion).append("\n");
|
msgpre.append(tr("FPGA Version")).append(": ").append(item->mCard.HardVersion).append("\n");
|
||||||
msgpre.append(tr("Firmware Version")).append(": ").append(item->mCard.firmwareVer).append("\n");
|
msgpre.append(tr("Firmware Version")).append(": ").append(item->mCard.firmwareVer).append("\n");
|
||||||
msgpre.append("IMEI: ").append(item->mCard.IMEI).append("\n");
|
msgpre.append("IMEI: ").append(item->mCard.IMEI).append("\n");
|
||||||
QMessageBox msgBox(QMessageBox::Information, item->mCard.id+" "+tr("Detail Info"), msgpre + tr("Player Version")+": "+tr("Getting")+" ...");
|
QMessageBox msgBox(QMessageBox::Information, item->mCard.id+" "+tr("Detail Info"), msgpre + tr("Player Version")+": "+translate("","Getting")+" ...");
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "CheckSoftVersions");
|
json.insert("_id", "CheckSoftVersions");
|
||||||
json.insert("_type", "CheckSoftVersions");
|
json.insert("_type", "CheckSoftVersions");
|
||||||
|
@ -289,7 +289,7 @@ QPushButton:hover {background-color: #08b;}
|
||||||
|
|
||||||
auto bnSearch = new QPushButton(tr("Search"));
|
auto bnSearch = new QPushButton(tr("Search"));
|
||||||
connect(bnSearch, &QPushButton::clicked, fdIP, [this] {
|
connect(bnSearch, &QPushButton::clicked, fdIP, [this] {
|
||||||
QString ipsStr = fdIP->toPlainText();
|
auto ipsStr = fdIP->toPlainText();
|
||||||
if(ipsStr.isEmpty()) {
|
if(ipsStr.isEmpty()) {
|
||||||
QMessageBox::warning(this, tr("Attention"), tr("Please input IP address!"));
|
QMessageBox::warning(this, tr("Attention"), tr("Please input IP address!"));
|
||||||
return;
|
return;
|
||||||
|
@ -299,8 +299,11 @@ QPushButton:hover {background-color: #08b;}
|
||||||
QMessageBox::warning(this, tr("Attention"), tr("Please input IP address!"));
|
QMessageBox::warning(this, tr("Attention"), tr("Please input IP address!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray data = QJsonDocument(QJsonObject{{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
|
auto data = QJsonDocument(QJsonObject{{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
|
||||||
for(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;
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
specifyIPDlg->accept();
|
specifyIPDlg->accept();
|
||||||
});
|
});
|
||||||
hBox->addWidget(bnSearch);
|
hBox->addWidget(bnSearch);
|
||||||
|
@ -312,8 +315,8 @@ QPushButton:hover {background-color: #08b;}
|
||||||
|
|
||||||
transUi();
|
transUi();
|
||||||
|
|
||||||
sendGetInfo();
|
auto cnt = sendGetInfo();
|
||||||
mUdpTimer.start(30000);
|
if(cnt<=100) mUdpTimer.start(30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
DevicePanel::~DevicePanel() {
|
DevicePanel::~DevicePanel() {
|
||||||
|
@ -321,7 +324,7 @@ DevicePanel::~DevicePanel() {
|
||||||
mUdpTimer.stop();
|
mUdpTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePanel::sendGetInfo() {
|
int DevicePanel::sendGetInfo() {
|
||||||
auto data = QJsonDocument(QJsonObject{{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
|
auto data = QJsonDocument(QJsonObject{{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
|
||||||
uchar ccc[]{0x7E, 0x7E, 0x7E, 0x90, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x21,
|
uchar ccc[]{0x7E, 0x7E, 0x7E, 0x90, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x21,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x9F};
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x9F};
|
||||||
|
@ -333,7 +336,7 @@ void DevicePanel::sendGetInfo() {
|
||||||
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();
|
||||||
for(QNetworkAddressEntry &addrEntry : addrEntries) {
|
for(auto &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();
|
||||||
|
@ -341,10 +344,18 @@ void DevicePanel::sendGetInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto ipstr = fdIP->toPlainText();
|
auto ipstr = fdIP->toPlainText();
|
||||||
|
int cnt = 0;
|
||||||
if(! ipstr.isEmpty()) {
|
if(! ipstr.isEmpty()) {
|
||||||
auto ips = ipstr.split("\n", Qt::SkipEmptyParts);
|
auto ips = ipstr.split("\n", Qt::SkipEmptyParts);
|
||||||
for(auto &ip : ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "getInfo specify IP write failed." << ip;
|
cnt = ips.size();
|
||||||
|
QTimer::singleShot(100, [=] {
|
||||||
|
for(auto &ip : ips) {
|
||||||
|
if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "getInfo specify IP write failed." << ip;
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePanel::changeEvent(QEvent *event) {
|
void DevicePanel::changeEvent(QEvent *event) {
|
||||||
|
@ -352,13 +363,13 @@ void DevicePanel::changeEvent(QEvent *event) {
|
||||||
if(event->type() == QEvent::LanguageChange) transUi();
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
}
|
}
|
||||||
void DevicePanel::transUi() {
|
void DevicePanel::transUi() {
|
||||||
btnRefresh->setText(tr("Refresh"));
|
btnRefresh->setText(translate("","Refresh"));
|
||||||
bnSpecifyIP->setItemText(0,tr("Specify IP"));
|
bnSpecifyIP->setItemText(0,tr("Specify IP"));
|
||||||
label_3->setText(tr("All"));
|
label_3->setText(tr("All"));
|
||||||
|
|
||||||
mDeviceTable->setHeaderText("online", tr("Online"));
|
mDeviceTable->setHeaderText("online", tr("Online"));
|
||||||
mDeviceTable->setHeaderText("id", tr("Screen ID"));
|
mDeviceTable->setHeaderText("id", tr("Screen ID"));
|
||||||
mDeviceTable->setHeaderText("screenSize", tr("Screen Size"));
|
mDeviceTable->setHeaderText("screenSize", translate("","Screen Size"));
|
||||||
mDeviceTable->setHeaderText("alias", tr("Alias"));
|
mDeviceTable->setHeaderText("alias", tr("Alias"));
|
||||||
mDeviceTable->setHeaderText("brightness", tr("Screen Brightness"));
|
mDeviceTable->setHeaderText("brightness", tr("Screen Brightness"));
|
||||||
mDeviceTable->setHeaderText("power", tr("Power Status"));
|
mDeviceTable->setHeaderText("power", tr("Power Status"));
|
||||||
|
@ -388,7 +399,7 @@ void DevicePanel::transCtrl() {
|
||||||
if(gSelCards.count() < 1) fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
|
if(gSelCards.count() < 1) fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
|
||||||
else if(gSelCards.count()==1) fdCardNumInfo->setText(tr("Current Screen")+": "+gSelCards[0].id);
|
else if(gSelCards.count()==1) fdCardNumInfo->setText(tr("Current Screen")+": "+gSelCards[0].id);
|
||||||
else fdCardNumInfo->setText(tr("Multi screen operation")+". "+tr("selected num")+": "+QString::number(gSelCards.count()));
|
else fdCardNumInfo->setText(tr("Multi screen operation")+". "+tr("selected num")+": "+QString::number(gSelCards.count()));
|
||||||
btnClear->setText(tr("Clear"));
|
btnClear->setText(translate("","Clear"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DevicePanel::newCtrl() {
|
void DevicePanel::newCtrl() {
|
||||||
|
@ -465,7 +476,7 @@ void DevicePanel::newCtrl() {
|
||||||
fdInfo->setMaximumWidth(360);
|
fdInfo->setMaximumWidth(360);
|
||||||
vBox2->addWidget(fdInfo);
|
vBox2->addWidget(fdInfo);
|
||||||
|
|
||||||
btnClear = new QPushButton(tr("Clear"));
|
btnClear = new QPushButton(translate("","Clear"));
|
||||||
btnClear->setMinimumHeight(30);
|
btnClear->setMinimumHeight(30);
|
||||||
btnClear->setProperty("ssType", "progManageTool");
|
btnClear->setProperty("ssType", "progManageTool");
|
||||||
connect(btnClear, &QPushButton::clicked, fdInfo, &QTextEdit::clear);
|
connect(btnClear, &QPushButton::clicked, fdInfo, &QTextEdit::clear);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
explicit DevicePanel(QSettings &, QWidget *parent = nullptr);
|
explicit DevicePanel(QSettings &, QWidget *parent = nullptr);
|
||||||
~DevicePanel();
|
~DevicePanel();
|
||||||
|
|
||||||
void sendGetInfo();
|
int sendGetInfo();
|
||||||
void newCtrl();
|
void newCtrl();
|
||||||
void init(DeviceItem *item);
|
void init(DeviceItem *item);
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,9 @@ public:
|
||||||
iterator end() const noexcept {
|
iterator end() const noexcept {
|
||||||
return this->ptr ? this->ptr->data.end() : iterator();
|
return this->ptr ? this->ptr->data.end() : iterator();
|
||||||
}
|
}
|
||||||
|
bool contains(const V &val) const noexcept {
|
||||||
|
return this->ptr ? std::find(this->ptr->data.begin(), this->ptr->data.end(), val)!=this->ptr->data.end() : false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,13 @@ inline QString byteSizeStr(double size) {
|
||||||
return (size > 99 ? QString::number(size, 'f', 0) : QString::number(size, 'g', 3))+" "+units[i];
|
return (size > 99 ? QString::number(size, 'f', 0) : QString::number(size, 'g', 3))+" "+units[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void wait(int msec, QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents) {
|
inline int wait(int msec, QObject *context = 0, QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents) {
|
||||||
QTimer timer;
|
|
||||||
timer.setSingleShot(true);
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
QTimer::singleShot(msec, &loop, &QEventLoop::quit);
|
||||||
timer.start(msec);
|
if(context) QObject::connect(context, &QObject::destroyed, &loop, [&] {
|
||||||
loop.exec(flags);
|
loop.exit(1);
|
||||||
|
});
|
||||||
|
return loop.exec(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
|
|
|
@ -33,7 +33,7 @@ QString errStrWithData(QNetworkReply *reply, JValue *outJson) {
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
QString error;
|
QString error;
|
||||||
*outJson = JFrom(data, &error);
|
*outJson = JFrom(data, &error);
|
||||||
if(! error.isEmpty()) return "JSON "+QCoreApplication::translate("Net","Error")+": "+error+"\n"+data;
|
if(! error.isEmpty()) return "JSON "+QCoreApplication::translate("","Error")+": "+error+"\n"+data;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ QString errStrWithData(QNetworkReply *reply, QJsonDocument *outJson) {
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
QJsonParseError jsonErr;
|
QJsonParseError jsonErr;
|
||||||
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "JSON "+QCoreApplication::translate("Net","Error")+": "+jsonErr.errorString()+"\n"+data;
|
if(jsonErr.error != QJsonParseError::NoError) return "JSON "+QCoreApplication::translate("","Error")+": "+jsonErr.errorString()+"\n"+data;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ QString errStr(QNetworkReply *);
|
||||||
QString errStrWithData(QNetworkReply *, JValue * = 0);
|
QString errStrWithData(QNetworkReply *, JValue * = 0);
|
||||||
QString errStrWithData(QNetworkReply *, QJsonDocument *);
|
QString errStrWithData(QNetworkReply *, QJsonDocument *);
|
||||||
|
|
||||||
inline int waitFinished(QNetworkReply *reply, QObject *context, bool excludeUser = false) {
|
inline int waitFinished(QNetworkReply *reply, QObject *context = 0, bool excludeUser = false) {
|
||||||
if(reply->isFinished()) return 0;
|
if(reply->isFinished()) return 0;
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||||
|
|
|
@ -3,6 +3,49 @@
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
LoadingDlg::LoadingDlg(QWidget *parent, QString text, QString sucText) : QDialog{parent, Qt::Tool}, sucText(sucText) {
|
||||||
|
setModal(true);
|
||||||
|
setResult(-1);
|
||||||
|
auto vBox = new VBox(this);
|
||||||
|
|
||||||
|
mIndicator = new WaitingIndicator(this);
|
||||||
|
mIndicator->setFixedSize(100, 100);
|
||||||
|
vBox->addWidget(mIndicator, 0, Qt::AlignCenter);
|
||||||
|
|
||||||
|
fdText = new QLabel(text);
|
||||||
|
fdText->setAlignment(Qt::AlignCenter);
|
||||||
|
gFont(fdText, 18, true);
|
||||||
|
vBox->addWidget(fdText);
|
||||||
|
|
||||||
|
show();
|
||||||
|
raise();
|
||||||
|
activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadingDlg::closeEvent(QCloseEvent *event) {
|
||||||
|
if(closeTimerId) {
|
||||||
|
killTimer(closeTimerId);
|
||||||
|
closeTimerId = 0;
|
||||||
|
}
|
||||||
|
QDialog::closeEvent(event);
|
||||||
|
}
|
||||||
|
void LoadingDlg::timerEvent(QTimerEvent *event) {
|
||||||
|
if(closeTimerId==event->timerId()) {
|
||||||
|
killTimer(closeTimerId);
|
||||||
|
closeTimerId = 0;
|
||||||
|
accept();
|
||||||
|
close();
|
||||||
|
} else QDialog::timerEvent(event);
|
||||||
|
}
|
||||||
|
void LoadingDlg::success() {
|
||||||
|
fdText->setText(sucText.isEmpty() ? QCoreApplication::translate("","Success") : sucText);
|
||||||
|
mIndicator->success();
|
||||||
|
if(! isVisible()) show();
|
||||||
|
if(closeTimerId) killTimer(closeTimerId);
|
||||||
|
closeTimerId = startTimer(keepTime);
|
||||||
|
}
|
||||||
|
|
||||||
WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : QDialog{parent, Qt::Tool}, sucText(sucText) {
|
WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : QDialog{parent, Qt::Tool}, sucText(sucText) {
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -39,6 +82,7 @@ void WaitingDlg::timerEvent(QTimerEvent *event) {
|
||||||
} else if(closeTimerId==event->timerId()) {
|
} else if(closeTimerId==event->timerId()) {
|
||||||
killTimer(closeTimerId);
|
killTimer(closeTimerId);
|
||||||
closeTimerId = 0;
|
closeTimerId = 0;
|
||||||
|
accept();
|
||||||
close();
|
close();
|
||||||
} else QDialog::timerEvent(event);
|
} else QDialog::timerEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +97,7 @@ void WaitingDlg::showLater() {
|
||||||
showTimerId = startTimer(200);
|
showTimerId = startTimer(200);
|
||||||
}
|
}
|
||||||
void WaitingDlg::success() {
|
void WaitingDlg::success() {
|
||||||
fdText->setText(sucText.isEmpty() ? tr("Success") : sucText);
|
fdText->setText(sucText.isEmpty() ? QCoreApplication::translate("","Success") : sucText);
|
||||||
mIndicator->success();
|
mIndicator->success();
|
||||||
if(showTimerId) {
|
if(showTimerId) {
|
||||||
killTimer(showTimerId);
|
killTimer(showTimerId);
|
||||||
|
|
|
@ -9,15 +9,33 @@ class WaitingIndicator : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
using QWidget::QWidget;
|
using QWidget::QWidget;
|
||||||
QColor mColor{0x0088ff};
|
QColor mColor = 0x0088ff;
|
||||||
public slots:
|
public slots:
|
||||||
void success();
|
void success();
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent * event) override;
|
void timerEvent(QTimerEvent * event) override;
|
||||||
void paintEvent(QPaintEvent * event) override;
|
void paintEvent(QPaintEvent * event) override;
|
||||||
|
|
||||||
int angle{0};
|
int angle = 0;
|
||||||
int timerId{0};
|
int timerId = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LoadingDlg : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoadingDlg(QWidget *parent = nullptr, QString text = 0, QString sucText = 0);
|
||||||
|
|
||||||
|
QLabel *fdText;
|
||||||
|
QString sucText;
|
||||||
|
WaitingIndicator *mIndicator;
|
||||||
|
int keepTime = 750;
|
||||||
|
public slots:
|
||||||
|
void success();
|
||||||
|
protected:
|
||||||
|
void timerEvent(QTimerEvent *) override;
|
||||||
|
void closeEvent(QCloseEvent *) override;
|
||||||
|
private:
|
||||||
|
int closeTimerId = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WaitingDlg : public QDialog {
|
class WaitingDlg : public QDialog {
|
||||||
|
|
|
@ -51,6 +51,12 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
#endif
|
#endif
|
||||||
|
auto config = QSslConfiguration::defaultConfiguration();
|
||||||
|
config.setProtocol(QSsl::AnyProtocol);
|
||||||
|
config.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||||
|
config.setPeerVerifyDepth(1);
|
||||||
|
QSslConfiguration::setDefaultConfiguration(config);
|
||||||
|
|
||||||
QApplication::setOrganizationName("Sysolution");
|
QApplication::setOrganizationName("Sysolution");
|
||||||
QApplication::setOrganizationDomain("ledok.cn");
|
QApplication::setOrganizationDomain("ledok.cn");
|
||||||
QApplication::setApplicationName("LedOK Express");
|
QApplication::setApplicationName("LedOK Express");
|
||||||
|
@ -108,14 +114,14 @@ QString checkReply(QNetworkReply *reply, QJsonDocument *outJson) {
|
||||||
auto err = errStr(reply);
|
auto err = errStr(reply);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(! data.isEmpty()) err = err+"\n"+translate("","Device replied")+": "+data;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if(outJson) {
|
if(outJson) {
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
QJsonParseError jsonErr;
|
QJsonParseError jsonErr;
|
||||||
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+translate("","Device replied")+": "+data;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -124,47 +130,47 @@ QString errStrWithJson(QNetworkReply *reply, JValue *outJson, QByteArray *outDat
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
if(outData) *outData = data;
|
if(outData) *outData = data;
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(! data.isEmpty()) err = err+"\n"+translate("","Device replied")+": "+data;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
QString error;
|
QString error;
|
||||||
auto json = JFrom(data, &error);
|
auto json = JFrom(data, &error);
|
||||||
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+translate("","Device replied")+": "+data;
|
||||||
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(! json["success"].toBool()) return translate("","Fail")+". "+translate("","Device replied")+": "+data;
|
||||||
if(outJson) *outJson = json;
|
if(outJson) *outJson = json;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
QString errStrWithJson(QNetworkReply *reply, QString errField) {
|
||||||
|
auto err = errStr(reply);
|
||||||
|
auto data = reply->readAll();
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
if(! data.isEmpty()) err = err+"\n"+translate("","Device replied")+": "+data;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
QString error;
|
||||||
|
auto json = JFrom(data, &error);
|
||||||
|
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+translate("","Device replied")+": "+data;
|
||||||
|
if(! json["success"].toBool()) {
|
||||||
|
auto errStr = json[errField].toString();
|
||||||
|
return translate("","Fail")+". "+translate("","Device replied")+": "+(errStr.isEmpty() ? data : errStr);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
|
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
|
||||||
auto err = errStr(reply);
|
auto err = errStr(reply);
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
if(outData) *outData = data;
|
if(outData) *outData = data;
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(! data.isEmpty()) err = err+"\n"+translate("","Device replied")+": "+data;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
QJsonParseError jsonErr;
|
QJsonParseError jsonErr;
|
||||||
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+translate("","Device replied")+": "+data;
|
||||||
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
if(! json["success"].toBool()) return translate("","Fail")+". "+translate("","Device replied")+": "+data;
|
||||||
if(outJson) outJson->swap(json);
|
if(outJson) outJson->swap(json);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
QString checkReplyForJson(QNetworkReply *reply, QString errField) {
|
|
||||||
auto err = errStr(reply);
|
|
||||||
auto data = reply->readAll();
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
QJsonParseError jsonErr;
|
|
||||||
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
if(! json["success"].toBool()) {
|
|
||||||
auto errStr = json[errField].toString();
|
|
||||||
return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+(errStr.isEmpty() ? data : errStr);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
quint64 dirFileSize(const QString &path) {
|
quint64 dirFileSize(const QString &path) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
@ -214,7 +220,7 @@ bool copyDir(const QString &source, const QString &destination, bool override) {
|
||||||
}
|
}
|
||||||
unsigned char GetCheckCodeIn8(unsigned char *str, unsigned int size) {
|
unsigned char GetCheckCodeIn8(unsigned char *str, unsigned int size) {
|
||||||
unsigned char checkCode = 0;
|
unsigned char checkCode = 0;
|
||||||
for(int i=0; i<size; i++) checkCode += str[i];
|
for(int i=0; i<(int)size; i++) checkCode += str[i];
|
||||||
return (~checkCode) & 0xff;
|
return (~checkCode) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
32
LedOK/main.h
|
@ -2,12 +2,14 @@
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
#include "gutil/qjson.h"
|
#include "gutil/qjson.h"
|
||||||
|
#include "program/progitem.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
#define PAGEDEL_SUFFIX "@D$E$L&20111005&"
|
#define PAGEDEL_SUFFIX "~temp~temp~temp"
|
||||||
#define RECTF_INVALID QRectF(-9999, -9999, 0, 0)
|
#define RECTF_INVALID QRectF(-9999, -9999, 0, 0)
|
||||||
|
|
||||||
struct LedCard {
|
struct LedCard {
|
||||||
|
@ -63,6 +65,7 @@ QString programsDir();
|
||||||
extern Tick *gTick;
|
extern Tick *gTick;
|
||||||
extern QString gFileHome;
|
extern QString gFileHome;
|
||||||
extern QString gApkHome;
|
extern QString gApkHome;
|
||||||
|
extern int gProgWidth, gProgHeight;
|
||||||
class DevicePanel;
|
class DevicePanel;
|
||||||
extern DevicePanel *gDevicePanel;
|
extern DevicePanel *gDevicePanel;
|
||||||
extern QList<LedCard> gSelCards;
|
extern QList<LedCard> gSelCards;
|
||||||
|
@ -76,6 +79,10 @@ extern bool gShowIP;
|
||||||
extern bool gShowAlias;
|
extern bool gShowAlias;
|
||||||
extern bool gShowLora;
|
extern bool gShowLora;
|
||||||
|
|
||||||
|
|
||||||
|
extern QTextEdit *gFdResInfo;
|
||||||
|
extern ProgItem *gProgItem;
|
||||||
|
|
||||||
extern quint64 dirFileSize(const QString &path);
|
extern quint64 dirFileSize(const QString &path);
|
||||||
extern bool copyDir(const QString &source, const QString &destination, bool override);
|
extern bool copyDir(const QString &source, const QString &destination, bool override);
|
||||||
extern unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize);
|
extern unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize);
|
||||||
|
@ -95,6 +102,9 @@ enum _ENUM_CONTRL_WIDGET {
|
||||||
class DeviceItem;
|
class DeviceItem;
|
||||||
extern DeviceItem *findItem(QString id);
|
extern DeviceItem *findItem(QString id);
|
||||||
|
|
||||||
|
inline QString translate(const char *ctx, const char *key) {
|
||||||
|
return QCoreApplication::translate(ctx, key);
|
||||||
|
}
|
||||||
inline int verCompare(const QString& a, const QString& b) {
|
inline int verCompare(const QString& a, const QString& b) {
|
||||||
auto aparts = a.split(".");
|
auto aparts = a.split(".");
|
||||||
auto bparts = b.split(".");
|
auto bparts = b.split(".");
|
||||||
|
@ -110,40 +120,40 @@ inline int verCompare(const QString& a, const QString& b) {
|
||||||
|
|
||||||
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
|
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
|
||||||
QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
|
QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
|
||||||
|
QString errStrWithJson(QNetworkReply *, QString errField);
|
||||||
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
|
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
|
||||||
QString checkReplyForJson(QNetworkReply *, QString errField);
|
|
||||||
|
|
||||||
void MergeFmt(QTextEdit *textEdit, const QTextCharFormat &fmt);
|
void MergeFmt(QTextEdit *textEdit, const QTextCharFormat &fmt);
|
||||||
|
|
||||||
#define Def_CtrlReqPre \
|
#define Def_CtrlReqPre \
|
||||||
waitingDlg->show();\
|
waitingDlg->show();\
|
||||||
auto card = gSelCards[0];\
|
auto card = gSelCards[0];\
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);\
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);\
|
||||||
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||||
|
|
||||||
#define Def_CtrlSetReqAfter \
|
#define Def_CtrlSetReqAfter \
|
||||||
QString err = checkReplyForJson(reply);\
|
auto err = errStrWithJson(reply);\
|
||||||
if(! err.isEmpty()) {\
|
if(! err.isEmpty()) {\
|
||||||
waitingDlg->close();\
|
waitingDlg->close();\
|
||||||
QMessageBox::critical(this, tr("Error"), err);\
|
QMessageBox::critical(this, translate("","Error"), err);\
|
||||||
return;\
|
return;\
|
||||||
}\
|
}\
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
|
||||||
#define Def_CtrlSingleGetReply \
|
#define Def_CtrlSingleGetReply \
|
||||||
QJsonDocument json;\
|
JValue json;\
|
||||||
QString err = checkReplyForJson(reply, &json);\
|
auto err = errStrWithJson(reply, &json);\
|
||||||
if(! err.isEmpty()) {\
|
if(! err.isEmpty()) {\
|
||||||
waitingDlg->close();\
|
waitingDlg->close();\
|
||||||
QMessageBox::critical(this, tr("Error"), err);\
|
QMessageBox::critical(this, translate("","Error"), err);\
|
||||||
return;\
|
return;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Def_CtrlSetMulti(tip) \
|
#define Def_CtrlSetMulti(tip) \
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);\
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);\
|
||||||
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {\
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {\
|
||||||
QString err = checkReplyForJson(reply);\
|
auto err = errStrWithJson(reply);\
|
||||||
gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\
|
gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?translate("","Success"):err));\
|
||||||
});
|
});
|
||||||
|
|
||||||
class LocalObj : public QObject {
|
class LocalObj : public QObject {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
extern QPoint gPlayPos;
|
extern QPoint gPlayPos;
|
||||||
|
|
||||||
QString gApkHome;
|
QString gApkHome;
|
||||||
|
int gProgWidth = 512, gProgHeight = 256;
|
||||||
bool gVideoCompress = false;
|
bool gVideoCompress = false;
|
||||||
bool gVideoTranscoding = false;
|
bool gVideoTranscoding = false;
|
||||||
bool gTextAntialiasing = false;
|
bool gTextAntialiasing = false;
|
||||||
|
@ -350,7 +351,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
fdUpdLog->setReadOnly(true);
|
fdUpdLog->setReadOnly(true);
|
||||||
vBox->addWidget(fdUpdLog);
|
vBox->addWidget(fdUpdLog);
|
||||||
|
|
||||||
auto reply = NetReq(updates["changelog_zh_CN"].toString()).timeout(60000).get();
|
auto reply = NetReq(updates["changelog_zh_CN"].toString()).get();
|
||||||
ConnReply(reply, fdUpdLog) [=] {
|
ConnReply(reply, fdUpdLog) [=] {
|
||||||
auto err = errStr(reply);
|
auto err = errStr(reply);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
|
@ -391,7 +392,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
auto err = errStr(reply);
|
auto err = errStr(reply);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setText(tr("Error")+": "+err);
|
msgBox.setText(translate("","Error")+": "+err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msgBox.accept();
|
msgBox.accept();
|
||||||
|
@ -409,7 +410,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
});
|
});
|
||||||
menu_setting->addAction(act_upd);
|
menu_setting->addAction(act_upd);
|
||||||
|
|
||||||
auto reply = NetReq(UpdVerUrl).timeout(60000).get();
|
auto reply = NetReq(UpdVerUrl).get();
|
||||||
ConnReply(reply, this) [=] {
|
ConnReply(reply, this) [=] {
|
||||||
auto err = errStr(reply);
|
auto err = errStr(reply);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
|
@ -567,11 +568,11 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
fdDetectCard->setCursor(Qt::PointingHandCursor);
|
fdDetectCard->setCursor(Qt::PointingHandCursor);
|
||||||
fdDetectCard->setProperty("ssType", "progManageTool");
|
fdDetectCard->setProperty("ssType", "progManageTool");
|
||||||
connect(fdDetectCard, &QPushButton::clicked, this, [this] {
|
connect(fdDetectCard, &QPushButton::clicked, this, [this] {
|
||||||
auto res = QMessageBox::warning(this, tr("Tip Info"), tr("RestoreLedCardIpByUdpTip"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::warning(this, translate("","Tip"), tr("RestoreLedCardIpByUdpTip"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
if(res != QMessageBox::Ok) return;
|
if(res != QMessageBox::Ok) return;
|
||||||
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
|
||||||
foreach(QNetworkInterface interfaces, networkinterfaces) {//networkinterfaces负责提供主机的IP地址和网络接口的列表
|
for(QNetworkInterface &interfaces : networkinterfaces) {//networkinterfaces负责提供主机的IP地址和网络接口的列表
|
||||||
foreach(QNetworkAddressEntry entry, interfaces.addressEntries()) {//QNetworkAddressEntry存储了一个IP地址,子网掩码和广播地址
|
for(QNetworkAddressEntry &entry : interfaces.addressEntries()) {//QNetworkAddressEntry存储了一个IP地址,子网掩码和广播地址
|
||||||
entry.setBroadcast(QHostAddress::Broadcast);
|
entry.setBroadcast(QHostAddress::Broadcast);
|
||||||
QHostAddress broadcastAddress("255.255.255.255");
|
QHostAddress broadcastAddress("255.255.255.255");
|
||||||
entry.setBroadcast(QHostAddress::Broadcast);
|
entry.setBroadcast(QHostAddress::Broadcast);
|
||||||
|
@ -617,6 +618,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
hBox->addLabel("V" APP_VERSION" - " __DATE__);
|
hBox->addLabel("V" APP_VERSION" - " __DATE__);
|
||||||
|
|
||||||
gApkHome = settings.value("ApkHome").toString();
|
gApkHome = settings.value("ApkHome").toString();
|
||||||
|
gProgWidth = settings.value("ProgWidth", 512).toInt();
|
||||||
|
gProgHeight = settings.value("ProgHeight", 256).toInt();
|
||||||
gVideoCompress = settings.value("VideoCompress").toBool();
|
gVideoCompress = settings.value("VideoCompress").toBool();
|
||||||
gVideoTranscoding = settings.value("VideoTranscoding").toBool();
|
gVideoTranscoding = settings.value("VideoTranscoding").toBool();
|
||||||
gTextAntialiasing = settings.value("TextAntialiasing").toBool();
|
gTextAntialiasing = settings.value("TextAntialiasing").toBool();
|
||||||
|
@ -680,6 +683,8 @@ MainWindow::~MainWindow() {
|
||||||
settings.setValue("MainIsMax", isMaximized());
|
settings.setValue("MainIsMax", isMaximized());
|
||||||
settings.setValue("PlayPos", gPlayPos);
|
settings.setValue("PlayPos", gPlayPos);
|
||||||
if(! gApkHome.isEmpty()) settings.setValue("ApkHome", gApkHome);
|
if(! gApkHome.isEmpty()) settings.setValue("ApkHome", gApkHome);
|
||||||
|
settings.setValue("ProgWidth", gProgWidth);
|
||||||
|
settings.setValue("ProgHeight", gProgHeight);
|
||||||
if(mDevicePanel->fdIP) {
|
if(mDevicePanel->fdIP) {
|
||||||
auto ipstr = mDevicePanel->fdIP->toPlainText();
|
auto ipstr = mDevicePanel->fdIP->toPlainText();
|
||||||
if(! ipstr.isEmpty()) settings.setValue("SpecifyIP", ipstr);
|
if(! ipstr.isEmpty()) settings.setValue("SpecifyIP", ipstr);
|
||||||
|
|
|
@ -383,8 +383,8 @@ mGuangYingPinWidget::mGuangYingPinWidget(QWidget *parent) : QWidget(parent) {
|
||||||
}
|
}
|
||||||
connect(grp, &QButtonGroup::idClicked, this, [=](int id) {
|
connect(grp, &QButtonGroup::idClicked, this, [=](int id) {
|
||||||
if(groupBox_com->isChecked()) {
|
if(groupBox_com->isChecked()) {
|
||||||
if(pushButtonMainOpen->text()==tr("Close")) Set_program_buf_and_send(comboBox_SPortName->currentIndex(), id);
|
if(pushButtonMainOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortName->currentIndex(), id);
|
||||||
if(pushButtonAuxOpen->text()==tr("Close")) Set_program_buf_and_send(comboBox_SPortNameAux->currentIndex(), id);
|
if(pushButtonAuxOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortNameAux->currentIndex(), id);
|
||||||
}
|
}
|
||||||
if(groupBox_Network->isChecked()) Set_program_buf_and_send_by_udp(id);
|
if(groupBox_Network->isChecked()) Set_program_buf_and_send_by_udp(id);
|
||||||
});
|
});
|
||||||
|
@ -609,13 +609,13 @@ void mGuangYingPinWidget::changeEvent(QEvent *event) {
|
||||||
if(event->type() == QEvent::LanguageChange) transUi();
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
}
|
}
|
||||||
void mGuangYingPinWidget::transUi() {
|
void mGuangYingPinWidget::transUi() {
|
||||||
pushButtonSend->setText(tr("Send"));
|
pushButtonSend->setText(translate("","Send"));
|
||||||
pushButtonMainOpen->setText(tr("Open"));
|
pushButtonMainOpen->setText(tr("Open"));
|
||||||
pushButtonAuxOpen->setText(tr("Open"));
|
pushButtonAuxOpen->setText(tr("Open"));
|
||||||
pushButtonBrightnessSet->setText(tr("Set"));
|
pushButtonBrightnessSet->setText(translate("","Set"));
|
||||||
pushButtonScreenOn->setText(tr("Screen On"));
|
pushButtonScreenOn->setText(tr("Screen On"));
|
||||||
pushButtonScreenOff->setText(tr("Screen Off"));
|
pushButtonScreenOff->setText(tr("Screen Off"));
|
||||||
pushButtonRefresh->setText(tr("Refresh"));
|
pushButtonRefresh->setText(translate("","Refresh"));
|
||||||
groupBoxMain->setTitle(tr("Main"));
|
groupBoxMain->setTitle(tr("Main"));
|
||||||
groupBoxAux->setTitle(tr("Auxiliary"));
|
groupBoxAux->setTitle(tr("Auxiliary"));
|
||||||
groupBoxParam->setTitle(tr("Param configuration"));
|
groupBoxParam->setTitle(tr("Param configuration"));
|
||||||
|
@ -636,7 +636,7 @@ void mGuangYingPinWidget::transUi() {
|
||||||
label_BrightNess->setText(tr("Brightness"));
|
label_BrightNess->setText(tr("Brightness"));
|
||||||
label_ComStatus->setText(tr("State:Off"));
|
label_ComStatus->setText(tr("State:Off"));
|
||||||
label_ComStatusAux->setText(tr("State:Off"));
|
label_ComStatusAux->setText(tr("State:Off"));
|
||||||
pushButtonClearLog->setText(tr("Clear"));
|
pushButtonClearLog->setText(translate("","Clear"));
|
||||||
checkBoxDebug->setText(tr("Debug"));
|
checkBoxDebug->setText(tr("Debug"));
|
||||||
groupBox_Network->setTitle(tr("Network"));
|
groupBox_Network->setTitle(tr("Network"));
|
||||||
groupBox_com->setTitle(tr("Com"));
|
groupBox_com->setTitle(tr("Com"));
|
||||||
|
@ -650,24 +650,24 @@ void mGuangYingPinWidget::OnAnsyProgramCustom(void)
|
||||||
{
|
{
|
||||||
int id = spinBox_ProgramIndex->value();
|
int id = spinBox_ProgramIndex->value();
|
||||||
if(groupBox_com->isChecked()) {
|
if(groupBox_com->isChecked()) {
|
||||||
if(pushButtonMainOpen->text()==tr("Close")) Set_program_buf_and_send(comboBox_SPortName->currentIndex(), id);
|
if(pushButtonMainOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortName->currentIndex(), id);
|
||||||
if(pushButtonAuxOpen->text()==tr("Close")) Set_program_buf_and_send(comboBox_SPortNameAux->currentIndex(), id);
|
if(pushButtonAuxOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortNameAux->currentIndex(), id);
|
||||||
}
|
}
|
||||||
if(groupBox_Network->isChecked()) Set_program_buf_and_send_by_udp(id);
|
if(groupBox_Network->isChecked()) Set_program_buf_and_send_by_udp(id);
|
||||||
if(checkBoxDebug->isChecked()) textEditReadBuf->append("OnAnsyProgramCustom");
|
if(checkBoxDebug->isChecked()) textEditReadBuf->append("OnAnsyProgramCustom");
|
||||||
}
|
}
|
||||||
void mGuangYingPinWidget::OnAnsyProgramCustomByChanged(int id) {
|
void mGuangYingPinWidget::OnAnsyProgramCustomByChanged(int id) {
|
||||||
if(groupBox_com->isChecked()) {
|
if(groupBox_com->isChecked()) {
|
||||||
if(pushButtonMainOpen->text()==tr("Close")) Set_program_buf_and_send(comboBox_SPortName->currentIndex(), id);
|
if(pushButtonMainOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortName->currentIndex(), id);
|
||||||
if(pushButtonAuxOpen->text()==tr("Close")) Set_program_buf_and_send(comboBox_SPortNameAux->currentIndex(), id);
|
if(pushButtonAuxOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortNameAux->currentIndex(), id);
|
||||||
}
|
}
|
||||||
if(groupBox_Network->isChecked()) Set_program_buf_and_send_by_udp(id);
|
if(groupBox_Network->isChecked()) Set_program_buf_and_send_by_udp(id);
|
||||||
}
|
}
|
||||||
void mGuangYingPinWidget::OnBrightnessSetByChanged(int icurValue)
|
void mGuangYingPinWidget::OnBrightnessSetByChanged(int icurValue)
|
||||||
{
|
{
|
||||||
if(pushButtonMainOpen->text()==tr("Close"))
|
if(pushButtonMainOpen->text()==translate("","Close"))
|
||||||
Set_Brightness_buf_and_send(comboBox_SPortName->currentIndex(),icurValue);
|
Set_Brightness_buf_and_send(comboBox_SPortName->currentIndex(),icurValue);
|
||||||
if(pushButtonAuxOpen->text()==tr("Close"))
|
if(pushButtonAuxOpen->text()==translate("","Close"))
|
||||||
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),icurValue);
|
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),icurValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,9 +686,9 @@ void mGuangYingPinWidget::OnBrightnessSet(void)
|
||||||
{
|
{
|
||||||
if(groupBox_com->isChecked())
|
if(groupBox_com->isChecked())
|
||||||
{
|
{
|
||||||
if(pushButtonMainOpen->text()==tr("Close"))
|
if(pushButtonMainOpen->text()==translate("","Close"))
|
||||||
Set_Brightness_buf_and_send(comboBox_SPortName->currentIndex(),spinBox_BrightnessValue->value());
|
Set_Brightness_buf_and_send(comboBox_SPortName->currentIndex(),spinBox_BrightnessValue->value());
|
||||||
if(pushButtonAuxOpen->text()==tr("Close"))
|
if(pushButtonAuxOpen->text()==translate("","Close"))
|
||||||
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),spinBox_BrightnessValue->value());
|
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),spinBox_BrightnessValue->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,9 +701,9 @@ void mGuangYingPinWidget::OnScreenOn(void)
|
||||||
{
|
{
|
||||||
if(groupBox_com->isChecked())
|
if(groupBox_com->isChecked())
|
||||||
{
|
{
|
||||||
if(pushButtonMainOpen->text()==tr("Close"))
|
if(pushButtonMainOpen->text()==translate("","Close"))
|
||||||
Screen_OnOff_buf_and_send(comboBox_SPortName->currentIndex(),0x11);
|
Screen_OnOff_buf_and_send(comboBox_SPortName->currentIndex(),0x11);
|
||||||
if(pushButtonAuxOpen->text()==tr("Close"))
|
if(pushButtonAuxOpen->text()==translate("","Close"))
|
||||||
Screen_OnOff_buf_and_send(comboBox_SPortNameAux->currentIndex(),0x11);
|
Screen_OnOff_buf_and_send(comboBox_SPortNameAux->currentIndex(),0x11);
|
||||||
}
|
}
|
||||||
if(groupBox_Network->isChecked())
|
if(groupBox_Network->isChecked())
|
||||||
|
@ -715,9 +715,9 @@ void mGuangYingPinWidget::OnScreenOff(void)
|
||||||
{
|
{
|
||||||
if(groupBox_com->isChecked())
|
if(groupBox_com->isChecked())
|
||||||
{
|
{
|
||||||
if(pushButtonMainOpen->text()==tr("Close"))
|
if(pushButtonMainOpen->text()==translate("","Close"))
|
||||||
Screen_OnOff_buf_and_send(comboBox_SPortName->currentIndex(),0x10);
|
Screen_OnOff_buf_and_send(comboBox_SPortName->currentIndex(),0x10);
|
||||||
if(pushButtonAuxOpen->text()==tr("Close"))
|
if(pushButtonAuxOpen->text()==translate("","Close"))
|
||||||
Screen_OnOff_buf_and_send(comboBox_SPortNameAux->currentIndex(),0x10);
|
Screen_OnOff_buf_and_send(comboBox_SPortNameAux->currentIndex(),0x10);
|
||||||
}
|
}
|
||||||
if(groupBox_Network->isChecked())
|
if(groupBox_Network->isChecked())
|
||||||
|
@ -854,13 +854,13 @@ void mGuangYingPinWidget::MWOnoffPort(void)
|
||||||
comboBox_SPortDataBit->setEnabled(false);
|
comboBox_SPortDataBit->setEnabled(false);
|
||||||
comboBox_SPortOEBit->setEnabled(false);
|
comboBox_SPortOEBit->setEnabled(false);
|
||||||
comboBox_SPortStopBit->setEnabled(false);
|
comboBox_SPortStopBit->setEnabled(false);
|
||||||
pushButtonMainOpen->setText(tr("Close"));
|
pushButtonMainOpen->setText(translate("","Close"));
|
||||||
//发送设置使能
|
//发送设置使能
|
||||||
graphicsView_ComStatus->setStyleSheet("background-color: rgb(0, 255, 0);");
|
graphicsView_ComStatus->setStyleSheet("background-color: rgb(0, 255, 0);");
|
||||||
label_ComStatus->setText(tr("State:On"));
|
label_ComStatus->setText(tr("State:On"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("OpenPort COM failed"));
|
QMessageBox::information(this, translate("","Tip"), tr("OpenPort COM failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -926,14 +926,14 @@ void mGuangYingPinWidget::MWOnoffPortAux(void)
|
||||||
comboBox_SPortDataBitAux->setEnabled(false);
|
comboBox_SPortDataBitAux->setEnabled(false);
|
||||||
comboBox_SPortOEBitAux->setEnabled(false);
|
comboBox_SPortOEBitAux->setEnabled(false);
|
||||||
comboBox_SPortStopBitAux->setEnabled(false);
|
comboBox_SPortStopBitAux->setEnabled(false);
|
||||||
pushButtonAuxOpen->setText(tr("Close"));
|
pushButtonAuxOpen->setText(translate("","Close"));
|
||||||
//发送设置使能
|
//发送设置使能
|
||||||
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(0, 255, 0);");
|
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(0, 255, 0);");
|
||||||
label_ComStatusAux->setText(tr("State:On"));
|
label_ComStatusAux->setText(tr("State:On"));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("OpenPort COM failed"));
|
QMessageBox::information(this, translate("","Tip"), tr("OpenPort COM failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "playwin.h"
|
#include "playwin.h"
|
||||||
|
#include "main.h"
|
||||||
#include "eledigiclock.h"
|
#include "eledigiclock.h"
|
||||||
#include "eleanaclock.h"
|
#include "eleanaclock.h"
|
||||||
#include "eleborder.h"
|
#include "eleborder.h"
|
||||||
|
@ -198,7 +199,7 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue
|
||||||
PosDlg dlg(this);
|
PosDlg dlg(this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
});
|
});
|
||||||
act = menu->addAction(tr("Close"));
|
act = menu->addAction(translate("","Close"));
|
||||||
connect(act, &QAction::triggered, this, [this] {
|
connect(act, &QAction::triggered, this, [this] {
|
||||||
if(self==this) self = nullptr;
|
if(self==this) self = nullptr;
|
||||||
close();
|
close();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QInputDialog>
|
||||||
|
|
||||||
ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -29,11 +30,11 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
bnNew = new QPushButton(tr("New"));
|
bnNew = new QPushButton(tr("New"));
|
||||||
bnNew->setFixedSize(88, 38);
|
bnNew->setMinimumSize(75, 30);
|
||||||
bnNew->setProperty("ssType", "progManageTool");
|
bnNew->setProperty("ssType", "progManageTool");
|
||||||
hBox->addWidget(bnNew);
|
hBox->addWidget(bnNew);
|
||||||
connect(bnNew, &QPushButton::clicked, this, [this] {
|
connect(bnNew, &QPushButton::clicked, this, [this] {
|
||||||
ProgCreateDlg dlg("", 512, 256, "", "", false, this);
|
ProgCreateDlg dlg("", gProgWidth, gProgHeight, "", "", false, this);
|
||||||
if(dlg.exec() != QDialog::Accepted) return;
|
if(dlg.exec() != QDialog::Accepted) return;
|
||||||
if(checkIfNameRepeated(dlg.fdName->text())) return;
|
if(checkIfNameRepeated(dlg.fdName->text())) return;
|
||||||
std::vector<int> widths;
|
std::vector<int> widths;
|
||||||
|
@ -58,7 +59,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
if(ttl > width) widths.back() -= ttl - width;
|
if(ttl > width) widths.back() -= ttl - width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), dlg.fdWidth->value(), dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, dlg.fdVer->isChecked(), mProgTree);
|
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), gProgWidth = dlg.fdWidth->value(), gProgHeight = dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, dlg.fdVer->isChecked(), mProgTree);
|
||||||
item->isInsert = dlg.edIsInsert->isChecked();
|
item->isInsert = dlg.edIsInsert->isChecked();
|
||||||
item->save();//保存pro.json
|
item->save();//保存pro.json
|
||||||
if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
|
if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
|
||||||
|
@ -71,70 +72,67 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
});
|
});
|
||||||
|
|
||||||
bnEdit = new QPushButton(tr("Edit"));
|
bnEdit = new QPushButton(tr("Edit"));
|
||||||
bnEdit->setFixedSize(QSize(88, 38));
|
bnEdit->setMinimumSize(75, 30);
|
||||||
bnEdit->setProperty("ssType", "progManageTool");
|
bnEdit->setProperty("ssType", "progManageTool");
|
||||||
bnEdit->setEnabled(false);
|
bnEdit->setEnabled(false);
|
||||||
hBox->addWidget(bnEdit);
|
hBox->addWidget(bnEdit);
|
||||||
connect(bnEdit, SIGNAL(clicked(bool)), this, SLOT(onEditClicked(bool)));
|
connect(bnEdit, SIGNAL(clicked(bool)), this, SLOT(onEditClicked(bool)));
|
||||||
|
|
||||||
bnDelete = new QPushButton(tr("Delete"));
|
bnDelete = new QPushButton(tr("Delete"));
|
||||||
bnDelete->setFixedSize(QSize(88, 38));
|
bnDelete->setMinimumSize(75, 30);
|
||||||
bnDelete->setProperty("ssType", "progManageTool");
|
bnDelete->setProperty("ssType", "progManageTool");
|
||||||
bnDelete->setEnabled(false);
|
bnDelete->setEnabled(false);
|
||||||
hBox->addWidget(bnDelete);
|
hBox->addWidget(bnDelete);
|
||||||
connect(bnDelete, SIGNAL(clicked(bool)), this, SLOT(onDeleteClicked(bool)));
|
connect(bnDelete, SIGNAL(clicked(bool)), this, SLOT(onDeleteClicked(bool)));
|
||||||
|
|
||||||
bnImport = new QPushButton(tr("Import"));
|
bnImport = new QPushButton(tr("Import"));
|
||||||
bnImport->setFixedSize(88, 38);
|
bnImport->setMinimumSize(75, 30);
|
||||||
bnImport->setProperty("ssType", "progManageTool");
|
bnImport->setProperty("ssType", "progManageTool");
|
||||||
hBox->addWidget(bnImport);
|
hBox->addWidget(bnImport);
|
||||||
connect(bnImport, &QPushButton::clicked, this, [this] {
|
connect(bnImport, &QPushButton::clicked, this, [this] {
|
||||||
auto dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
auto dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
if(dir.isEmpty()) return;
|
if(dir.isEmpty()) return;
|
||||||
QString progsDir = programsDir();
|
auto progsDir = programsDir();
|
||||||
if(dir.contains(progsDir, Qt::CaseInsensitive)) {
|
if(dir.contains(progsDir, Qt::CaseInsensitive)) {
|
||||||
QMessageBox::warning(this, tr("Tip"), tr("The imported directory is already in the working directory, so there is no need to import it again!"));
|
QMessageBox::warning(this, translate("","Tip"), tr("The imported directory is already in the working directory, so there is no need to import it again!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList progDirs;
|
PathPairList pathPairs;
|
||||||
if(QFileInfo::exists(dir + "/pro.json")) progDirs.append(dir);
|
if(QFileInfo::exists(dir + "/pro.json")) pathPairs.append({dir, progsDir+"/"+QFileInfo(dir).fileName()});
|
||||||
else {
|
else {
|
||||||
QStringList subdirNames = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
QStringList subdirNames = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
for(QString &subdirName : subdirNames) {
|
for(QString &subdirName : subdirNames) {
|
||||||
auto subdir = dir + "/" + subdirName;
|
auto subdir = dir + "/" + subdirName;
|
||||||
if(! QFileInfo::exists(subdir + "/pro.json")) continue;
|
if(! QFileInfo::exists(subdir + "/pro.json")) continue;
|
||||||
if(QFileInfo::exists(progsDir + "/" + subdirName)) {
|
if(QFileInfo::exists(progsDir + "/" + subdirName)) {
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"), subdirName + tr(":solution(s) already exist.are you sure you want to overwrite the existing solution(s)?"), QMessageBox::Yes, QMessageBox::No);
|
auto res = QMessageBox::information(this, translate("","Tip"), subdirName + tr(":solution(s) already exist.are you sure you want to overwrite the existing solution(s)?"), QMessageBox::Yes, QMessageBox::No);
|
||||||
if(res == QMessageBox::No) continue;
|
if(res == QMessageBox::No) continue;
|
||||||
}
|
}
|
||||||
progDirs.append(subdir);
|
pathPairs.append({subdir, progsDir+"/"+subdirName});
|
||||||
}
|
}
|
||||||
if(progDirs.isEmpty()) return;
|
if(pathPairs.isEmpty()) return;
|
||||||
}
|
}
|
||||||
ProgPortDlg dlg(this, tr("Import"));
|
ProgPortDlg dlg(this, tr("Import"));
|
||||||
dlg.table->setRowCount(progDirs.count());
|
dlg.table->setRowCount(pathPairs.count());
|
||||||
for(int i=0; i<progDirs.count(); i++) {
|
for(int i=0; i<pathPairs.count(); i++) {
|
||||||
dlg.table->setItem(i, 0, new QTableWidgetItem(QFileInfo(progDirs[i]).fileName()));
|
dlg.table->setItem(i, 0, new QTableWidgetItem(QFileInfo(pathPairs[i].first).fileName()));
|
||||||
dlg.table->setCellWidget(i, 1, new QProgressBar);
|
dlg.table->setCellWidget(i, 1, new QProgressBar);
|
||||||
}
|
}
|
||||||
connect(dlg.bnOK, &QPushButton::clicked, this, [=, &dlg] {
|
connect(dlg.bnOK, &QPushButton::clicked, this, [=, &dlg] {
|
||||||
for(int i=0; i<progDirs.count(); i++) ((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(progDirs[i]));
|
for(int i=0; i<pathPairs.count(); i++) ((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(pathPairs[i].first));
|
||||||
auto thread = new CopyDirThread();
|
auto thread = new CopyDirThread;
|
||||||
thread->dirSrcs = progDirs;
|
thread->paths = pathPairs;
|
||||||
thread->dirDst = progsDir;
|
|
||||||
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
|
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
|
||||||
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
|
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
|
||||||
});
|
});
|
||||||
thread->start();
|
thread->start();
|
||||||
});
|
});
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
|
|
||||||
mProgTree->clear();
|
|
||||||
addProFiles();
|
addProFiles();
|
||||||
});
|
});
|
||||||
|
|
||||||
bnExport = new QPushButton(tr("Export"));
|
bnExport = new QPushButton(tr("Export"));
|
||||||
bnExport->setFixedSize(QSize(88, 38));
|
bnExport->setMinimumSize(75, 30);
|
||||||
bnExport->setEnabled(false);
|
bnExport->setEnabled(false);
|
||||||
bnExport->setProperty("ssType", "progManageTool");
|
bnExport->setProperty("ssType", "progManageTool");
|
||||||
hBox->addWidget(bnExport);
|
hBox->addWidget(bnExport);
|
||||||
|
@ -151,16 +149,15 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
dlg.table->setCellWidget(i, 1, new QProgressBar);
|
dlg.table->setCellWidget(i, 1, new QProgressBar);
|
||||||
}
|
}
|
||||||
connect(dlg.bnOK, &QPushButton::clicked, this, [=, &dlg] {
|
connect(dlg.bnOK, &QPushButton::clicked, this, [=, &dlg] {
|
||||||
QString dirDst = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
auto dirDst = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
if(dirDst.isEmpty()) return;
|
if(dirDst.isEmpty()) return;
|
||||||
auto progsDir = programsDir();
|
auto progsDir = programsDir();
|
||||||
auto thread = new CopyDirThread();
|
auto thread = new CopyDirThread;
|
||||||
for(int i=0; i<progNames.count(); i++) {
|
for(int i=0; i<progNames.count(); i++) {
|
||||||
auto dir = progsDir+"/"+progNames[i];
|
auto dir = progsDir+"/"+progNames[i];
|
||||||
((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(dir));
|
((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(dir));
|
||||||
thread->dirSrcs.append(dir);
|
thread->paths.append({dir, dirDst+"/"});
|
||||||
}
|
}
|
||||||
thread->dirDst = dirDst;
|
|
||||||
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
|
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
|
||||||
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
|
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
|
||||||
});
|
});
|
||||||
|
@ -169,15 +166,75 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
bnSend = new QPushButton(tr("Send"));
|
bnRename = new QPushButton(tr("Rename"));
|
||||||
bnSend->setFixedSize(QSize(88, 38));
|
bnRename->setMinimumSize(60, 30);
|
||||||
|
bnRename->setProperty("ssType", "progManageTool");
|
||||||
|
hBox->addWidget(bnRename);
|
||||||
|
connect(bnRename, &QPushButton::clicked, this, [=] {
|
||||||
|
int cnt = mProgTree->topLevelItemCount();
|
||||||
|
QString progName;
|
||||||
|
for(int i=0; i<cnt; i++) if(mProgTree->item(i)->checkState("check") == Qt::Checked) {
|
||||||
|
progName = ((ProgItem*) mProgTree->topLevelItem(i))->mName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(progName.isEmpty()) return;
|
||||||
|
bool ok = false;
|
||||||
|
auto newName = QInputDialog::getText(this, "Rename '"+progName+"'", "New Name", QLineEdit::Normal, "", &ok);
|
||||||
|
if(! ok) return;
|
||||||
|
if(newName.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, "Warning", "New Name is Empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto progsDir = programsDir();
|
||||||
|
auto res = QDir(progsDir).rename(progName, newName);
|
||||||
|
if(res) addProFiles();
|
||||||
|
else QMessageBox::warning(this, "Error", "Rename Failed");
|
||||||
|
});
|
||||||
|
// bnCopy = new QPushButton(tr("Copy"));
|
||||||
|
// bnCopy->setMinimumSize(60, 30);
|
||||||
|
// bnCopy->setProperty("ssType", "progManageTool");
|
||||||
|
// hBox->addWidget(bnCopy);
|
||||||
|
// connect(bnCopy, &QPushButton::clicked, this, [=] {
|
||||||
|
// int cnt = mProgTree->topLevelItemCount();
|
||||||
|
// QString progName;
|
||||||
|
// for(int i=0; i<cnt; i++) if(mProgTree->item(i)->checkState("check") == Qt::Checked) {
|
||||||
|
// progName = ((ProgItem*) mProgTree->topLevelItem(i))->mName;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// if(progName.isEmpty()) return;
|
||||||
|
// bool ok = false;
|
||||||
|
// auto newName = QInputDialog::getText(this, "Copy '"+progName+"'", "New Name", QLineEdit::Normal, "", &ok);
|
||||||
|
// if(! ok) return;
|
||||||
|
// if(newName.isEmpty()) {
|
||||||
|
// QMessageBox::warning(this, "Warning", "New Name is Empty");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// auto progsDir = programsDir();
|
||||||
|
// auto dir = progsDir+"/"+progName;
|
||||||
|
// QDialog dlg(this);
|
||||||
|
// auto vBox = new VBox(&dlg);
|
||||||
|
// auto edProgress = new QProgressBar;
|
||||||
|
// edProgress->setMaximum(dirFileSize(dir));
|
||||||
|
// vBox->addWidget(edProgress);
|
||||||
|
// auto thread = new CopyDirThread;
|
||||||
|
// thread->paths.append({dir, progsDir+"/"+newName});
|
||||||
|
// connect(thread, &CopyDirThread::sigProgress, edProgress, [=](int value) {
|
||||||
|
// edProgress->setValue(value);
|
||||||
|
// if(value>=edProgress->maximum()) addProFiles();
|
||||||
|
// });
|
||||||
|
// progress->show();
|
||||||
|
// thread->start();
|
||||||
|
// });
|
||||||
|
|
||||||
|
bnSend = new QPushButton(translate("","Send"));
|
||||||
|
bnSend->setMinimumSize(75, 30);
|
||||||
bnSend->setProperty("ssType", "progManageTool");
|
bnSend->setProperty("ssType", "progManageTool");
|
||||||
bnSend->setEnabled(false);
|
bnSend->setEnabled(false);
|
||||||
bnSend->hide();
|
bnSend->hide();
|
||||||
hBox->addWidget(bnSend);
|
hBox->addWidget(bnSend);
|
||||||
|
|
||||||
btnPlay = new QPushButton(tr("Play")+"/"+tr("Stop"));
|
btnPlay = new QPushButton(tr("Play")+"/"+tr("Stop"));
|
||||||
btnPlay->setFixedSize(QSize(88, 38));
|
btnPlay->setMinimumSize(75, 30);
|
||||||
btnPlay->setProperty("ssType", "progManageTool");
|
btnPlay->setProperty("ssType", "progManageTool");
|
||||||
hBox->addWidget(btnPlay);
|
hBox->addWidget(btnPlay);
|
||||||
connect(btnPlay, &QPushButton::clicked, this, [this] {
|
connect(btnPlay, &QPushButton::clicked, this, [this] {
|
||||||
|
@ -251,7 +308,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
auto str = ((ProgItem*)item)->mProgDir;
|
auto str = ((ProgItem*)item)->mProgDir;
|
||||||
QProcess::execute("explorer", {str.replace('/','\\')});
|
QProcess::execute("explorer", {str.replace('/','\\')});
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MAC
|
||||||
QProcess::execute("open", {"-R", ((ProgItem*)item)->mProgDir});
|
QProcess::execute("open", {"-R", ((ProgItem*)item)->mProgDir});
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
@ -269,16 +326,14 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
QDir oldProgsQDir(oldProgsDir);
|
QDir oldProgsQDir(oldProgsDir);
|
||||||
if(oldProgsQDir.exists()) {
|
if(oldProgsQDir.exists()) {
|
||||||
CopyDirThread thread;
|
CopyDirThread thread;
|
||||||
thread.dirDst = mProgsDir;
|
|
||||||
auto names = oldProgsQDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
auto names = oldProgsQDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
for(auto &name : names) if(! name.endsWith("_tmp")) thread.dirSrcs.append(oldProgsDir + "/" + name);
|
for(auto &name : names) if(! name.endsWith("_tmp")) thread.paths.append({oldProgsDir+"/"+name, mProgsDir+"/"+name});
|
||||||
if(! thread.dirSrcs.isEmpty()) thread.move();
|
if(! thread.paths.isEmpty()) thread.move();
|
||||||
oldProgsQDir.removeRecursively();
|
oldProgsQDir.removeRecursively();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//查找根路径下的项目文件夹,查找文件夹下的节目pro.json信息,包括节目名称,大小,像素,备注等信息
|
addProFiles();
|
||||||
if(! mProgsDir.isEmpty()) addProFiles();
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder);
|
if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder);
|
||||||
else mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::DescendingOrder);
|
else mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::DescendingOrder);
|
||||||
|
@ -302,12 +357,15 @@ void ProgPanel::transUi() {
|
||||||
bnDelete->setText(tr("Delete"));
|
bnDelete->setText(tr("Delete"));
|
||||||
bnImport->setText(tr("Import"));
|
bnImport->setText(tr("Import"));
|
||||||
bnExport->setText(tr("Export"));
|
bnExport->setText(tr("Export"));
|
||||||
bnSend->setText(tr("Send"));
|
bnRename->setText(tr("Rename"));
|
||||||
|
bnSend->setText(translate("","Send"));
|
||||||
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
|
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgPanel::addProFiles() {
|
void ProgPanel::addProFiles() {
|
||||||
|
if(mProgsDir.isEmpty()) return;
|
||||||
auto progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
auto progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
|
mProgTree->clear();
|
||||||
for(auto &progName : progNames) {
|
for(auto &progName : progNames) {
|
||||||
auto file = mProgsDir + "/" + progName + "/pro.json";
|
auto file = mProgsDir + "/" + progName + "/pro.json";
|
||||||
QFile qFile(file);
|
QFile qFile(file);
|
||||||
|
@ -365,7 +423,7 @@ bool ProgPanel::checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void ProgPanel::onDeleteClicked(bool){
|
void ProgPanel::onDeleteClicked(bool){
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::information(this, translate("","Tip"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
if(res == QMessageBox::Ok) {
|
if(res == QMessageBox::Ok) {
|
||||||
for(int i=0; i<mProgTree->topLevelItemCount(); i++) if(mProgTree->item(i)->checkState("check") == Qt::Checked) {
|
for(int i=0; i<mProgTree->topLevelItemCount(); i++) if(mProgTree->item(i)->checkState("check") == Qt::Checked) {
|
||||||
auto item = (ProgItem*) mProgTree->topLevelItem(i--);
|
auto item = (ProgItem*) mProgTree->topLevelItem(i--);
|
||||||
|
|
|
@ -28,7 +28,7 @@ private:
|
||||||
QPushButton *bnNew;
|
QPushButton *bnNew;
|
||||||
QPushButton *bnEdit;
|
QPushButton *bnEdit;
|
||||||
QPushButton *bnDelete;
|
QPushButton *bnDelete;
|
||||||
QPushButton *bnImport, *bnExport;
|
QPushButton *bnImport, *bnExport, *bnRename, *bnCopy;
|
||||||
QPushButton *bnSend, *btnPlay;
|
QPushButton *bnSend, *btnPlay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ CopyDirThread::CopyDirThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyDirThread::run() {
|
void CopyDirThread::run() {
|
||||||
for(; i<dirSrcs.size(); i++) {
|
for(auto &path : paths) {
|
||||||
copiedSize = 0;
|
copiedSize = 0;
|
||||||
copyDir(dirSrcs[i], dirDst+"/"+QFileInfo(dirSrcs[i]).fileName(), true);
|
copyDir(path.first, path.second, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ bool CopyDirThread::copyDir(const QString &fromDir, const QString &toDir, bool c
|
||||||
|
|
||||||
|
|
||||||
void CopyDirThread::move() {
|
void CopyDirThread::move() {
|
||||||
for(; i<dirSrcs.size(); i++) {
|
for(auto &path : paths) {
|
||||||
copiedSize = 0;
|
copiedSize = 0;
|
||||||
moveDir(dirSrcs[i], dirDst+"/"+QFileInfo(dirSrcs[i]).fileName());
|
moveDir(path.first, path.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,20 @@
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
using PathPairList = QList<std::pair<QString, QString>>;
|
||||||
|
|
||||||
class CopyDirThread : public QThread {
|
class CopyDirThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CopyDirThread();
|
CopyDirThread();
|
||||||
QStringList dirSrcs;
|
PathPairList paths;
|
||||||
QString dirDst;
|
|
||||||
void run();
|
void run();
|
||||||
void move();
|
void move();
|
||||||
protected:
|
protected:
|
||||||
bool copyDir(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
|
bool copyDir(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
|
||||||
bool moveDir(const QString &fromDir, const QString &toDir);
|
bool moveDir(const QString &fromDir, const QString &toDir);
|
||||||
|
|
||||||
int i{0};
|
int i = 0;
|
||||||
int copiedSize = 0;
|
int copiedSize = 0;
|
||||||
signals:
|
signals:
|
||||||
void sigProgress(int, int);
|
void sigProgress(int, int);
|
||||||
|
|
|
@ -201,7 +201,7 @@ QWidget* EAClock::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addWidget(new QLabel(translate("","Basic Properties")));
|
||||||
|
|
||||||
auto line = new QFrame;
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ebase.h"
|
#include "ebase.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "tools.h"
|
#include "main.h"
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
@ -20,11 +20,11 @@ int borderImgMaxWidth = 0;
|
||||||
int borderImgMaxHeight = 0;
|
int borderImgMaxHeight = 0;
|
||||||
struct Initer {
|
struct Initer {
|
||||||
Initer() {
|
Initer() {
|
||||||
auto names = QDir(QApplication::applicationDirPath()+"/borders").entryList(QDir::Files);
|
auto names = QDir(QCoreApplication::applicationDirPath()+"/borders").entryList(QDir::Files);
|
||||||
for(auto &name : names) {
|
for(auto &name : names) {
|
||||||
BorderImg bdImg;
|
BorderImg bdImg;
|
||||||
bdImg.name = name;
|
bdImg.name = name;
|
||||||
bdImg.img = QPixmap(QApplication::applicationDirPath()+"/borders/"+bdImg.name);
|
bdImg.img = QPixmap(QCoreApplication::applicationDirPath()+"/borders/"+bdImg.name);
|
||||||
borderImgs.append(bdImg);
|
borderImgs.append(bdImg);
|
||||||
if(bdImg.img.width() > borderImgMaxWidth) borderImgMaxWidth = bdImg.img.width();
|
if(bdImg.img.width() > borderImgMaxWidth) borderImgMaxWidth = bdImg.img.width();
|
||||||
if(bdImg.img.height() > borderImgMaxHeight) borderImgMaxHeight = bdImg.img.height();
|
if(bdImg.img.height() > borderImgMaxHeight) borderImgMaxHeight = bdImg.img.height();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "edclock.h"
|
#include "edclock.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
|
#include "tools.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFontComboBox>
|
#include <QFontComboBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
@ -11,22 +11,7 @@
|
||||||
|
|
||||||
EDClock::EDClock(EBase *multiWin) : EBase(multiWin) {
|
EDClock::EDClock(EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::DClock;
|
mType = EBase::DClock;
|
||||||
m_attr.timeZoneId = QTimeZone::systemTimeZoneId();
|
timeZone = QTimeZone::systemTimeZone();
|
||||||
m_attr.font = qfont("Arial", 12);
|
|
||||||
m_attr.year = true;
|
|
||||||
m_attr.month = true;
|
|
||||||
m_attr.day = true;
|
|
||||||
m_attr.hour = true;
|
|
||||||
m_attr.min = true;
|
|
||||||
m_attr.sec = true;
|
|
||||||
m_attr.weekly = true;
|
|
||||||
m_attr.fullYear = true;
|
|
||||||
m_attr.hour12 = true;
|
|
||||||
m_attr.AmPm = true;
|
|
||||||
m_attr.dateStyle = 0;
|
|
||||||
m_attr.timeStyle = 0;
|
|
||||||
m_attr.multiline = true;
|
|
||||||
m_attr.textColor = Qt::red;
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,31 +19,49 @@ EDClock::EDClock(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::DClock;
|
mType = EBase::DClock;
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
auto font = widget["font"];
|
if(widget.isNull()) {
|
||||||
m_attr.font = qfont(font["family"].toString(), font["size"].toInt(), font["bold"].toBool(), font["italics"].toBool());
|
widget = json;
|
||||||
m_attr.font.setUnderline(font["underline"].toBool());
|
font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
||||||
m_attr.textColor = Tools::int2Color(font["color"].toInt());
|
font.setUnderline(json["fontUnderline"].toBool());
|
||||||
m_attr.timeZoneId = widget["timeZone"].toString().toUtf8();
|
color = json["color"].toStr("#ffff0000");
|
||||||
m_attr.year = widget["year"].toBool();
|
hasYear = widget["hasYear"].toBool();
|
||||||
m_attr.month = widget["month"].toBool();
|
hasMonth = widget["hasMonth"].toBool();
|
||||||
m_attr.day = widget["day"].toBool();
|
hasDay = widget["hasDay"].toBool();
|
||||||
m_attr.hour = widget["hour"].toBool();
|
hasHour = widget["hasHour"].toBool();
|
||||||
m_attr.min = widget["min"].toBool();
|
hasMin = widget["hasMin"].toBool();
|
||||||
m_attr.sec = widget["sec"].toBool();
|
hasSec = widget["hasSec"].toBool();
|
||||||
m_attr.weekly = widget["weekly"].toBool();
|
hasWeek = widget["hasWeek"].toBool();
|
||||||
m_attr.fullYear = widget["fullYear"].toBool();
|
hasAmPm = widget["hasAmPm"].toBool();
|
||||||
m_attr.hour12 = widget["12Hour"].toBool();
|
is12Hour = widget["is12Hour"].toBool();
|
||||||
m_attr.AmPm = widget["AmPm"].toBool();
|
isFullYear = widget["isFullYear"].toBool();
|
||||||
m_attr.dateStyle = widget["dateStyle"].toInt();
|
isMultiline = json["isMultiline"].toBool();
|
||||||
m_attr.timeStyle = widget["timeStyle"].toInt();
|
} else {
|
||||||
m_attr.multiline = widget["multiline"].toBool();
|
auto font = widget["font"];
|
||||||
isSingleMD = m_attr.dateStyle==1||m_attr.dateStyle==2||m_attr.dateStyle==4||m_attr.dateStyle==6||m_attr.dateStyle==8||m_attr.dateStyle==10||m_attr.dateStyle==12;
|
this->font = qfont(font["family"].toString(), font["size"].toInt(), font["bold"].toBool(), font["italics"].toBool());
|
||||||
|
this->font.setUnderline(font["underline"].toBool());
|
||||||
|
color = Tools::int2Color(font["color"].toInt());
|
||||||
|
hasYear = widget["year"].toBool();
|
||||||
|
hasMonth = widget["month"].toBool();
|
||||||
|
hasDay = widget["day"].toBool();
|
||||||
|
hasHour = widget["hour"].toBool();
|
||||||
|
hasMin = widget["min"].toBool();
|
||||||
|
hasSec = widget["sec"].toBool();
|
||||||
|
hasWeek = widget["weekly"].toBool();
|
||||||
|
hasAmPm = widget["AmPm"].toBool();
|
||||||
|
is12Hour = widget["12Hour"].toBool();
|
||||||
|
isFullYear = widget["fullYear"].toBool();
|
||||||
|
isMultiline = widget["multiline"].toBool();
|
||||||
|
}
|
||||||
|
timeZone = QTimeZone(widget["timeZone"].toString().toUtf8());
|
||||||
|
dateStyle = widget["dateStyle"].toInt();
|
||||||
|
isSingleHour = widget["timeStyle"].toInt();
|
||||||
|
isSingleMD = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDClock::init() {
|
void EDClock::init() {
|
||||||
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
|
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
|
||||||
datetime = cur.toTimeZone(QTimeZone(m_attr.timeZoneId));
|
datetime = cur.toTimeZone(timeZone);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -67,35 +70,35 @@ void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||||
QString text;
|
QString text;
|
||||||
QDate date = datetime.date();
|
QDate date = datetime.date();
|
||||||
QTime time = datetime.time();
|
QTime time = datetime.time();
|
||||||
QString spacer = m_attr.multiline ? "\n" : " ";
|
QString spacer = isMultiline ? "\n" : " ";
|
||||||
QString yearFmt = m_attr.fullYear ? "yyyy" : "yy";
|
QString yearFmt = isFullYear ? "yyyy" : "yy";
|
||||||
QString monthFmt = isSingleMD ? "M" : "MM";
|
QString monthFmt = isSingleMD ? "M" : "MM";
|
||||||
QString dateFmt = isSingleMD ? "d" : "dd";
|
QString dateFmt = isSingleMD ? "d" : "dd";
|
||||||
QString sep;
|
QString sep;
|
||||||
if(m_attr.dateStyle > 7) sep = "-";
|
if(dateStyle > 7) sep = "-";
|
||||||
else if(m_attr.dateStyle > 1) sep = "/";
|
else if(dateStyle > 1) sep = "/";
|
||||||
switch(m_attr.dateStyle) {
|
switch(dateStyle) {
|
||||||
case 0: case 1:
|
case 0: case 1:
|
||||||
if(m_attr.year) text += date.toString(yearFmt) + "年";
|
if(hasYear) text += date.toString(yearFmt) + "年";
|
||||||
if(m_attr.month) text += date.toString(monthFmt) + "月";
|
if(hasMonth) text += date.toString(monthFmt) + "月";
|
||||||
if(m_attr.day) text += date.toString(dateFmt) + "日";
|
if(hasDay) text += date.toString(dateFmt) + "日";
|
||||||
break;
|
break;
|
||||||
case 2: case 3: case 8: case 9:
|
case 2: case 3: case 8: case 9:
|
||||||
if(m_attr.month) text += date.toString(monthFmt) + sep;
|
if(hasMonth) text += date.toString(monthFmt) + sep;
|
||||||
if(m_attr.day) text += date.toString(dateFmt) + sep;
|
if(hasDay) text += date.toString(dateFmt) + sep;
|
||||||
if(m_attr.year) text += date.toString(yearFmt);
|
if(hasYear) text += date.toString(yearFmt);
|
||||||
if(text.endsWith(sep)) text.chop(1);
|
if(text.endsWith(sep)) text.chop(1);
|
||||||
break;
|
break;
|
||||||
case 4: case 5: case 10: case 11:
|
case 4: case 5: case 10: case 11:
|
||||||
if(m_attr.day) text += date.toString(dateFmt) + sep;
|
if(hasDay) text += date.toString(dateFmt) + sep;
|
||||||
if(m_attr.month) text += date.toString(monthFmt) + sep;
|
if(hasMonth) text += date.toString(monthFmt) + sep;
|
||||||
if(m_attr.year) text += date.toString(yearFmt);
|
if(hasYear) text += date.toString(yearFmt);
|
||||||
if(text.endsWith(sep)) text.chop(1);
|
if(text.endsWith(sep)) text.chop(1);
|
||||||
break;
|
break;
|
||||||
case 6: case 7: case 12: case 13:
|
case 6: case 7: case 12: case 13:
|
||||||
if(m_attr.year) text += date.toString(yearFmt) + sep;
|
if(hasYear) text += date.toString(yearFmt) + sep;
|
||||||
if(m_attr.month) text += date.toString(monthFmt) + sep;
|
if(hasMonth) text += date.toString(monthFmt) + sep;
|
||||||
if(m_attr.day) text += date.toString(dateFmt);
|
if(hasDay) text += date.toString(dateFmt);
|
||||||
if(text.endsWith(sep)) text.chop(1);
|
if(text.endsWith(sep)) text.chop(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -103,7 +106,7 @@ void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||||
}
|
}
|
||||||
if(! text.isEmpty()) text += spacer;
|
if(! text.isEmpty()) text += spacer;
|
||||||
|
|
||||||
if(m_attr.weekly) {
|
if(hasWeek) {
|
||||||
auto dayOfWeek = date.dayOfWeek();
|
auto dayOfWeek = date.dayOfWeek();
|
||||||
if(dayOfWeek==1) text += tr("MON");
|
if(dayOfWeek==1) text += tr("MON");
|
||||||
else if(dayOfWeek==2) text += tr("TUE");
|
else if(dayOfWeek==2) text += tr("TUE");
|
||||||
|
@ -115,18 +118,24 @@ void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||||
text += spacer;
|
text += spacer;
|
||||||
}
|
}
|
||||||
QString timeFmt;
|
QString timeFmt;
|
||||||
if(m_attr.hour12 && m_attr.AmPm) timeFmt += (time.hour()<12 ? tr("AM") : tr("PM")) + " ";
|
if(is12Hour && hasAmPm) timeFmt += (time.hour()<12 ? tr("AM") : tr("PM")) + " ";
|
||||||
if(m_attr.hour) timeFmt += (m_attr.timeStyle!=1 ? "hh:" : "h:");
|
if(hasHour) timeFmt += (isSingleHour ? "h:" : "hh:");
|
||||||
if(m_attr.min) timeFmt += "mm:";
|
if(hasMin) timeFmt += "mm:";
|
||||||
if(m_attr.sec) timeFmt += "ss";
|
if(hasSec) timeFmt += "ss";
|
||||||
if(timeFmt.endsWith(":")) timeFmt.chop(1);
|
if(timeFmt.endsWith(":")) timeFmt.chop(1);
|
||||||
if(! timeFmt.isEmpty()) text += time.toString(timeFmt);
|
if(! timeFmt.isEmpty()) text += time.toString(timeFmt);
|
||||||
text = text.trimmed();
|
text = text.trimmed();
|
||||||
|
auto lines = text.split("\n");
|
||||||
|
auto rect = innerRect();
|
||||||
|
if(lines.size() > 1) rect.setHeight(lineHeight = rect.height() / lines.size());
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setPen(m_attr.textColor);
|
painter->setPen(color);
|
||||||
m_attr.font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
painter->setFont(m_attr.font);
|
painter->setFont(font);
|
||||||
painter->drawText(innerRect(), text, QTextOption(Qt::AlignCenter));
|
for(auto &line : lines) {
|
||||||
|
painter->drawText(rect, line, QTextOption(Qt::AlignCenter));
|
||||||
|
rect.translate(0, rect.height());
|
||||||
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
EBase::paint(painter, option, widget);
|
EBase::paint(painter, option, widget);
|
||||||
}
|
}
|
||||||
|
@ -135,12 +144,12 @@ QWidget* EDClock::attrWgt() {
|
||||||
auto wgtAttr = new QWidget();
|
auto wgtAttr = new QWidget();
|
||||||
auto vBox = new QVBoxLayout(wgtAttr);
|
auto vBox = new QVBoxLayout(wgtAttr);
|
||||||
vBox->setContentsMargins(6, 0, 6, 0);
|
vBox->setContentsMargins(6, 0, 6, 0);
|
||||||
if(mMultiWin!=nullptr) vBox->setSpacing(3);
|
if(mMultiWin) vBox->setSpacing(3);
|
||||||
|
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout();
|
auto hBox = new QHBoxLayout();
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addWidget(new QLabel(translate("","Basic Properties")));
|
||||||
|
|
||||||
auto line = new QFrame();
|
auto line = new QFrame();
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
@ -156,9 +165,9 @@ QWidget* EDClock::attrWgt() {
|
||||||
auto edTimeZone = new QComboBox;
|
auto edTimeZone = new QComboBox;
|
||||||
auto zoneIds = QTimeZone::availableTimeZoneIds();
|
auto zoneIds = QTimeZone::availableTimeZoneIds();
|
||||||
for(auto &zoneId : zoneIds) edTimeZone->addItem(zoneId);
|
for(auto &zoneId : zoneIds) edTimeZone->addItem(zoneId);
|
||||||
edTimeZone->setCurrentText(m_attr.timeZoneId);
|
edTimeZone->setCurrentText(timeZone.id());
|
||||||
connect(edTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) {
|
connect(edTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) {
|
||||||
m_attr.timeZoneId = text.toUtf8();
|
timeZone = QTimeZone(text.toUtf8());
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(edTimeZone);
|
hBox->addWidget(edTimeZone);
|
||||||
|
@ -176,25 +185,25 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdYear = new QCheckBox(tr("Year"));
|
auto fdYear = new QCheckBox(tr("Year"));
|
||||||
fdYear->setChecked(m_attr.year);
|
fdYear->setChecked(hasYear);
|
||||||
connect(fdYear, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdYear, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.year = checked;
|
hasYear = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdYear);
|
hBox->addWidget(fdYear);
|
||||||
|
|
||||||
auto fdMonth = new QCheckBox(tr("Month"));
|
auto fdMonth = new QCheckBox(tr("Month"));
|
||||||
fdMonth->setChecked(m_attr.month);
|
fdMonth->setChecked(hasMonth);
|
||||||
connect(fdMonth, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdMonth, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.month = checked;
|
hasMonth = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdMonth);
|
hBox->addWidget(fdMonth);
|
||||||
|
|
||||||
auto fdDay = new QCheckBox(tr("Day"));
|
auto fdDay = new QCheckBox(tr("Day"));
|
||||||
fdDay->setChecked(m_attr.day);
|
fdDay->setChecked(hasDay);
|
||||||
connect(fdDay, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdDay, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.day = checked;
|
hasDay = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdDay);
|
hBox->addWidget(fdDay);
|
||||||
|
@ -205,25 +214,25 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdHour = new QCheckBox(tr("Hour"));
|
auto fdHour = new QCheckBox(tr("Hour"));
|
||||||
fdHour->setChecked(m_attr.hour);
|
fdHour->setChecked(hasHour);
|
||||||
connect(fdHour, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdHour, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.hour = checked;
|
hasHour = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdHour);
|
hBox->addWidget(fdHour);
|
||||||
|
|
||||||
auto fdMin = new QCheckBox(tr("Min."));
|
auto fdMin = new QCheckBox(tr("Min."));
|
||||||
fdMin->setChecked(m_attr.min);
|
fdMin->setChecked(hasMin);
|
||||||
connect(fdMin, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdMin, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.min = checked;
|
hasMin = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdMin);
|
hBox->addWidget(fdMin);
|
||||||
|
|
||||||
auto fdSec = new QCheckBox(tr("Sec."));
|
auto fdSec = new QCheckBox(tr("Sec."));
|
||||||
fdSec->setChecked(m_attr.sec);
|
fdSec->setChecked(hasSec);
|
||||||
connect(fdSec, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdSec, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.sec = checked;
|
hasSec = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdSec);
|
hBox->addWidget(fdSec);
|
||||||
|
@ -233,17 +242,17 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox = new QHBoxLayout();
|
hBox = new QHBoxLayout();
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
auto fdHasWeek = new QCheckBox(tr("Weekly"));
|
auto fdHasWeek = new QCheckBox(tr("Weekly"));
|
||||||
fdHasWeek->setChecked(m_attr.weekly);
|
fdHasWeek->setChecked(hasWeek);
|
||||||
connect(fdHasWeek, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdHasWeek, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.weekly = checked;
|
hasWeek = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdHasWeek);
|
hBox->addWidget(fdHasWeek);
|
||||||
|
|
||||||
auto fdFullYear = new QCheckBox(tr("Full Year"));
|
auto fdFullYear = new QCheckBox(tr("Full Year"));
|
||||||
fdFullYear->setChecked(m_attr.fullYear);
|
fdFullYear->setChecked(isFullYear);
|
||||||
connect(fdFullYear, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdFullYear, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.fullYear = checked;
|
isFullYear = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFullYear);
|
hBox->addWidget(fdFullYear);
|
||||||
|
@ -254,19 +263,19 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdIs12Hour = new QCheckBox(tr("12-Hour"));
|
auto fdIs12Hour = new QCheckBox(tr("12-Hour"));
|
||||||
fdIs12Hour->setChecked(m_attr.hour12);
|
fdIs12Hour->setChecked(is12Hour);
|
||||||
hBox->addWidget(fdIs12Hour);
|
hBox->addWidget(fdIs12Hour);
|
||||||
|
|
||||||
auto fdAmPm = new QCheckBox(tr("AM")+"/"+tr("PM"));
|
auto fdAmPm = new QCheckBox(tr("AM")+"/"+tr("PM"));
|
||||||
fdAmPm->setChecked(m_attr.AmPm);
|
fdAmPm->setChecked(hasAmPm);
|
||||||
connect(fdIs12Hour, &QCheckBox::toggled, this, [this, fdAmPm](bool checked) {
|
connect(fdIs12Hour, &QCheckBox::toggled, this, [this, fdAmPm](bool checked) {
|
||||||
m_attr.hour12 = checked;
|
is12Hour = checked;
|
||||||
fdAmPm->setVisible(checked);
|
fdAmPm->setVisible(checked);
|
||||||
if(! checked) fdAmPm->setChecked(false);
|
if(! checked) fdAmPm->setChecked(false);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
connect(fdAmPm, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdAmPm, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.AmPm = checked;
|
hasAmPm = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdAmPm);
|
hBox->addWidget(fdAmPm);
|
||||||
|
@ -282,24 +291,24 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Date Style")));
|
hBox->addWidget(new QLabel(tr("Date Style")));
|
||||||
|
|
||||||
auto fdDateFmt = new QComboBox();
|
auto fdDateFmt = new QComboBox;
|
||||||
fdDateFmt->addItem("1955年02月04日");
|
fdDateFmt->addItem("1970-02-24", 13);
|
||||||
fdDateFmt->addItem("1955年2月4日");
|
fdDateFmt->addItem("1970-2-24", 12);
|
||||||
fdDateFmt->addItem("2/24/1955");
|
fdDateFmt->addItem("1970年02月04日", 0);
|
||||||
fdDateFmt->addItem("02/24/1955");
|
fdDateFmt->addItem("1970年2月4日", 1);
|
||||||
fdDateFmt->addItem("24/2/1955");
|
fdDateFmt->addItem("1970/02/24", 7);
|
||||||
fdDateFmt->addItem("24/02/1955");
|
fdDateFmt->addItem("1970/2/24", 6);
|
||||||
fdDateFmt->addItem("1955/2/24");
|
fdDateFmt->addItem("02-24-1970", 9);
|
||||||
fdDateFmt->addItem("1955/02/24");
|
fdDateFmt->addItem("2-24-1970", 8);
|
||||||
fdDateFmt->addItem("2-24-1955");
|
fdDateFmt->addItem("02/24/1970", 3);
|
||||||
fdDateFmt->addItem("02-24-1955");
|
fdDateFmt->addItem("2/24/1970", 2);
|
||||||
fdDateFmt->addItem("24-2-1955");
|
fdDateFmt->addItem("24-02-1970", 11);
|
||||||
fdDateFmt->addItem("24-02-1955");
|
fdDateFmt->addItem("24-2-1970", 10);
|
||||||
fdDateFmt->addItem("1955-2-24");
|
fdDateFmt->addItem("24/02/1970", 5);
|
||||||
fdDateFmt->addItem("1955-02-24");
|
fdDateFmt->addItem("24/2/1970", 4);
|
||||||
fdDateFmt->setCurrentIndex(m_attr.dateStyle);
|
SetCurData(fdDateFmt, dateStyle);
|
||||||
connect(fdDateFmt, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int index) {
|
connect(fdDateFmt, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=](int index) {
|
||||||
m_attr.dateStyle = index;
|
dateStyle = fdDateFmt->itemData(index).toInt();
|
||||||
isSingleMD = index==1||index==2||index==4||index==6||index==8||index==10||index==12;
|
isSingleMD = index==1||index==2||index==4||index==6||index==8||index==10||index==12;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
@ -312,12 +321,12 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Time Style")));
|
hBox->addWidget(new QLabel(tr("Time Style")));
|
||||||
|
|
||||||
auto fdTimeFmt = new QComboBox();
|
auto fdTimeFmt = new QComboBox;
|
||||||
fdTimeFmt->addItem("HH:MM:SS");
|
fdTimeFmt->addItem("HH:MM:SS");
|
||||||
fdTimeFmt->addItem("H:MM:SS");
|
fdTimeFmt->addItem("H:MM:SS");
|
||||||
fdTimeFmt->setCurrentIndex(m_attr.timeStyle);
|
fdTimeFmt->setCurrentIndex(isSingleHour);
|
||||||
connect(fdTimeFmt, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int index) {
|
connect(fdTimeFmt, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int index) {
|
||||||
m_attr.timeStyle = index;
|
isSingleHour = index;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTimeFmt);
|
hBox->addWidget(fdTimeFmt);
|
||||||
|
@ -330,9 +339,9 @@ QWidget* EDClock::attrWgt() {
|
||||||
hBox->addWidget(new QLabel(tr("Display Style")));
|
hBox->addWidget(new QLabel(tr("Display Style")));
|
||||||
|
|
||||||
auto fdIsMultiline = new QCheckBox(tr("Multiline"));
|
auto fdIsMultiline = new QCheckBox(tr("Multiline"));
|
||||||
fdIsMultiline->setChecked(m_attr.multiline);
|
fdIsMultiline->setChecked(isMultiline);
|
||||||
connect(fdIsMultiline, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdIsMultiline, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.multiline = checked;
|
isMultiline = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdIsMultiline);
|
hBox->addWidget(fdIsMultiline);
|
||||||
|
@ -340,7 +349,7 @@ QWidget* EDClock::attrWgt() {
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
line = new QFrame();
|
line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
vBox->addWidget(line);
|
vBox->addWidget(line);
|
||||||
|
@ -350,23 +359,23 @@ QWidget* EDClock::attrWgt() {
|
||||||
|
|
||||||
auto fdFontFamily = new QFontComboBox();
|
auto fdFontFamily = new QFontComboBox();
|
||||||
fdFontFamily->setEditable(false);
|
fdFontFamily->setEditable(false);
|
||||||
fdFontFamily->setCurrentText(m_attr.font.family());
|
fdFontFamily->setCurrentText(font.family());
|
||||||
connect(fdFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &f) {
|
connect(fdFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &f) {
|
||||||
QFont font(f.family());
|
QFont ft(f.family());
|
||||||
font.setPixelSize(m_attr.font.pixelSize());
|
ft.setPixelSize(font.pixelSize());
|
||||||
font.setBold(m_attr.font.bold());
|
ft.setBold(font.bold());
|
||||||
font.setItalic(m_attr.font.italic());
|
ft.setItalic(font.italic());
|
||||||
font.setUnderline(m_attr.font.underline());
|
ft.setUnderline(font.underline());
|
||||||
m_attr.font = font;
|
font = ft;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontFamily);
|
hBox->addWidget(fdFontFamily);
|
||||||
|
|
||||||
auto fdFontSize = new QSpinBox();
|
auto fdFontSize = new QSpinBox();
|
||||||
fdFontSize->setRange(4, 9999);
|
fdFontSize->setRange(4, 9999);
|
||||||
fdFontSize->setValue(m_attr.font.pixelSize());
|
fdFontSize->setValue(font.pixelSize());
|
||||||
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
m_attr.font.setPixelSize(value);
|
font.setPixelSize(value);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontSize);
|
hBox->addWidget(fdFontSize);
|
||||||
|
@ -381,9 +390,9 @@ QWidget* EDClock::attrWgt() {
|
||||||
fdBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
fdBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdBold->setFixedSize(30, 30);
|
fdBold->setFixedSize(30, 30);
|
||||||
fdBold->setCheckable(true);
|
fdBold->setCheckable(true);
|
||||||
fdBold->setChecked(m_attr.font.bold());
|
fdBold->setChecked(font.bold());
|
||||||
connect(fdBold, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdBold, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.font.setBold(checked);
|
font.setBold(checked);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdBold);
|
hBox->addWidget(fdBold);
|
||||||
|
@ -392,9 +401,9 @@ QWidget* EDClock::attrWgt() {
|
||||||
fdItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
fdItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdItalic->setFixedSize(30, 30);
|
fdItalic->setFixedSize(30, 30);
|
||||||
fdItalic->setCheckable(true);
|
fdItalic->setCheckable(true);
|
||||||
fdItalic->setChecked(m_attr.font.italic());
|
fdItalic->setChecked(font.italic());
|
||||||
connect(fdItalic, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdItalic, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.font.setItalic(checked);
|
font.setItalic(checked);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdItalic);
|
hBox->addWidget(fdItalic);
|
||||||
|
@ -403,17 +412,17 @@ QWidget* EDClock::attrWgt() {
|
||||||
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontUnderline->setFixedSize(30, 30);
|
fdFontUnderline->setFixedSize(30, 30);
|
||||||
fdFontUnderline->setCheckable(true);
|
fdFontUnderline->setCheckable(true);
|
||||||
fdFontUnderline->setChecked(m_attr.font.underline());
|
fdFontUnderline->setChecked(font.underline());
|
||||||
connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
m_attr.font.setUnderline(checked);
|
font.setUnderline(checked);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontUnderline);
|
hBox->addWidget(fdFontUnderline);
|
||||||
|
|
||||||
auto fdColor = new LoColorSelector("T", m_attr.textColor);
|
auto fdColor = new LoColorSelector("T", color);
|
||||||
fdColor->setFixedWidth(30);
|
fdColor->setFixedWidth(30);
|
||||||
connect(fdColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
connect(fdColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||||
m_attr.textColor = color;
|
this->color = color;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdColor);
|
hBox->addWidget(fdColor);
|
||||||
|
@ -424,33 +433,30 @@ QWidget* EDClock::attrWgt() {
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EDClock::attrJson() const{
|
JObj EDClock::attrJson() const {
|
||||||
JObj oWidget;
|
JObj json;
|
||||||
oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId);
|
addBaseAttr(json);
|
||||||
oWidget["year"] = m_attr.year;
|
json["elementType"] = "DClock";
|
||||||
oWidget["month"] = m_attr.month;
|
json["timeZone"] = QString::fromUtf8(timeZone.id());
|
||||||
oWidget["day"] = m_attr.day;
|
json["hasYear"] = hasYear;
|
||||||
oWidget["hour"] = m_attr.hour;
|
json["hasMonth"] = hasMonth;
|
||||||
oWidget["min"] = m_attr.min;
|
json["hasDay"] = hasDay;
|
||||||
oWidget["sec"] = m_attr.sec;
|
json["hasHour"] = hasHour;
|
||||||
oWidget["weekly"] = m_attr.weekly;
|
json["hasMin"] = hasMin;
|
||||||
oWidget["fullYear"] = m_attr.fullYear;
|
json["hasSec"] = hasSec;
|
||||||
oWidget["12Hour"] = m_attr.hour12;
|
json["hasWeek"] = hasWeek;
|
||||||
oWidget["AmPm"] = m_attr.AmPm;
|
json["isFullYear"] = isFullYear;
|
||||||
oWidget["dateStyle"] = m_attr.dateStyle;
|
json["is12Hour"] = is12Hour;
|
||||||
oWidget["timeStyle"] = m_attr.timeStyle;
|
json["hasAmPm"] = hasAmPm;
|
||||||
oWidget["multiline"] = m_attr.multiline;
|
json["dateStyle"] = dateStyle;
|
||||||
oWidget["font"] = JObj{
|
json["timeStyle"] = isSingleHour;
|
||||||
{"family", m_attr.font.family()},
|
json["isMultiline"] = isMultiline;
|
||||||
{"size", m_attr.font.pixelSize()},
|
json["color"] = color.name(QColor::HexArgb);
|
||||||
{"bold", m_attr.font.bold()},
|
json["font"] = font.family();
|
||||||
{"italics", m_attr.font.italic()},
|
json["fontSize"] = font.pixelSize();
|
||||||
{"underline", m_attr.font.underline()},
|
json["fontBold"] = font.bold();
|
||||||
{"color", Tools::color2Int(m_attr.textColor)}
|
json["fontItalic"] = font.italic();
|
||||||
};
|
json["fontUnderline"] = font.underline();
|
||||||
JObj oRoot;
|
json["lineHeight"] = lineHeight;
|
||||||
addBaseAttr(oRoot);
|
return json;
|
||||||
oRoot["elementType"] = "DClock";
|
|
||||||
oRoot["widget"] = oWidget;
|
|
||||||
return oRoot;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,18 @@
|
||||||
#ifndef EDCLOCK_H
|
#ifndef EDCLOCK_H
|
||||||
#define EDCLOCK_H
|
#define EDCLOCK_H
|
||||||
|
|
||||||
|
#include "ebase.h"
|
||||||
|
#include "gutil/qgui.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "ebase.h"
|
|
||||||
|
|
||||||
class EDClock : public EBase {
|
class EDClock : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
struct Data {
|
|
||||||
QByteArray timeZoneId;
|
|
||||||
QFont font;
|
|
||||||
QColor textColor;
|
|
||||||
bool year;
|
|
||||||
bool month;
|
|
||||||
bool day;
|
|
||||||
bool hour;
|
|
||||||
bool min;
|
|
||||||
bool sec;
|
|
||||||
bool weekly;
|
|
||||||
bool fullYear;
|
|
||||||
bool hour12;
|
|
||||||
bool AmPm;
|
|
||||||
bool multiline;
|
|
||||||
int dateStyle;
|
|
||||||
int timeStyle;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit EDClock(EBase *multiWin = nullptr);
|
explicit EDClock(EBase *multiWin = nullptr);
|
||||||
explicit EDClock(const JObj &json, EBase *multiWin = nullptr);
|
explicit EDClock(const JObj &json, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
|
@ -39,10 +21,26 @@ public:
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() const override;
|
||||||
|
|
||||||
|
QTimeZone timeZone;
|
||||||
|
QFont font = qfont("Arial", 12);
|
||||||
|
QColor color{Qt::red};
|
||||||
|
int dateStyle = 0;
|
||||||
|
int isSingleHour = 0;
|
||||||
|
int lineHeight = 0;
|
||||||
|
bool hasYear = true;
|
||||||
|
bool hasMonth = true;
|
||||||
|
bool hasDay = true;
|
||||||
|
bool hasHour = true;
|
||||||
|
bool hasMin = true;
|
||||||
|
bool hasSec = true;
|
||||||
|
bool hasWeek = true;
|
||||||
|
bool hasAmPm = true;
|
||||||
|
bool isFullYear = true;
|
||||||
|
bool is12Hour = true;
|
||||||
|
bool isMultiline = true;
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
Data m_attr;
|
|
||||||
QString img_dir;
|
QString img_dir;
|
||||||
QDateTime datetime;
|
QDateTime datetime;
|
||||||
bool isSingleMD = false;
|
bool isSingleMD = false;
|
||||||
|
|
|
@ -238,7 +238,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addLabel(translate("","Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame;
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
|
|
@ -97,7 +97,7 @@ QWidget* EGif::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout();
|
auto hBox = new QHBoxLayout();
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addWidget(new QLabel(translate("","Basic Properties")));
|
||||||
|
|
||||||
auto line = new QFrame();
|
auto line = new QFrame();
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
@ -118,7 +118,7 @@ QWidget* EGif::attrWgt() {
|
||||||
bnSelectFile->setFixedWidth(30);
|
bnSelectFile->setFixedWidth(30);
|
||||||
bnSelectFile->setObjectName("bnSelectFile");
|
bnSelectFile->setObjectName("bnSelectFile");
|
||||||
connect(bnSelectFile, &QPushButton::clicked, wgtAttr, [=] {
|
connect(bnSelectFile, &QPushButton::clicked, wgtAttr, [=] {
|
||||||
auto file = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), gFileHome, EGif::filters());
|
auto file = QFileDialog::getOpenFileName(wgtAttr, translate("","Select File"), gFileHome, EGif::filters());
|
||||||
if(file.isEmpty()) return;
|
if(file.isEmpty()) return;
|
||||||
auto movie = new QMovie(file);
|
auto movie = new QMovie(file);
|
||||||
if(! movie->isValid()) {
|
if(! movie->isValid()) {
|
||||||
|
|
|
@ -139,7 +139,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
EBase *ele = 0;
|
EBase *ele = 0;
|
||||||
QListWidgetItem *item = 0;
|
QListWidgetItem *item = 0;
|
||||||
if(type==EBase::Image) {
|
if(type==EBase::Image) {
|
||||||
auto files = QFileDialog::getOpenFileNames(wgtAttr, tr("Select File"), gFileHome, EPhoto::filters());
|
auto files = QFileDialog::getOpenFileNames(wgtAttr, translate("","Select File"), gFileHome, EPhoto::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto ePhoto = EPhoto::create(files[i], mPageItem, this);
|
auto ePhoto = EPhoto::create(files[i], mPageItem, this);
|
||||||
if(ePhoto==0) continue;
|
if(ePhoto==0) continue;
|
||||||
|
@ -156,7 +156,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(type==EBase::Gif) {
|
} else if(type==EBase::Gif) {
|
||||||
auto files = QFileDialog::getOpenFileNames(wgtAttr, tr("Select File"), gFileHome, EGif::filters());
|
auto files = QFileDialog::getOpenFileNames(wgtAttr, translate("","Select File"), gFileHome, EGif::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto eGif = EGif::create(files[i], mPageItem, this);
|
auto eGif = EGif::create(files[i], mPageItem, this);
|
||||||
if(eGif==0) continue;
|
if(eGif==0) continue;
|
||||||
|
@ -173,7 +173,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(type==EBase::Video) {
|
} else if(type==EBase::Video) {
|
||||||
auto file = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), gFileHome, EVideo::filters());
|
auto file = QFileDialog::getOpenFileName(wgtAttr, translate("","Select File"), gFileHome, EVideo::filters());
|
||||||
if(! file.isEmpty()) {
|
if(! file.isEmpty()) {
|
||||||
auto eVideo = EVideo::create(file, mPageItem, this);
|
auto eVideo = EVideo::create(file, mPageItem, this);
|
||||||
if(eVideo==0) return;
|
if(eVideo==0) return;
|
||||||
|
|
|
@ -18,7 +18,7 @@ EPhoto *EPhoto::create(const QString &file, PageListItem *pageItem, EBase *multi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
QFileInfo info(file);
|
QFileInfo info(file);
|
||||||
return new EPhoto(img, info.absolutePath(), info.fileName(), pageItem, multiWin);
|
return new EPhoto(img, info.absolutePath(), info.fileName(), JObj(), pageItem, multiWin);
|
||||||
}
|
}
|
||||||
EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
|
@ -38,13 +38,16 @@ EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin
|
||||||
reader.setAutoTransform(true);
|
reader.setAutoTransform(true);
|
||||||
auto img = reader.read();
|
auto img = reader.read();
|
||||||
if(img.isNull()) return 0;
|
if(img.isNull()) return 0;
|
||||||
auto ins = new EPhoto(img, dir, name, pageItem, multiWin);
|
auto ins = new EPhoto(img, dir, name, json, pageItem, multiWin);
|
||||||
ins->setBaseAttr(json);
|
ins->setBaseAttr(json);
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
|
|
||||||
EPhoto::EPhoto(const QImage &img, const QString &dir, const QString &name, PageListItem *pageItem, EBase *multiWin) : EBase(multiWin), img(img), mDir(dir), mName(name), mPageItem(pageItem) {
|
EPhoto::EPhoto(const QImage &img, const QString &dir, const QString &name, const JObj &json, PageListItem *pageItem, EBase *multiWin) : EBase(multiWin), img(img), mDir(dir), mName(name), mPageItem(pageItem) {
|
||||||
mType = EBase::Image;
|
mType = EBase::Image;
|
||||||
|
direct = json["direct"].toString();
|
||||||
|
speed = json["speed"].toInt();
|
||||||
|
tailSpacing = json["tailSpacing"].toInt();
|
||||||
scaleImgIfNeed();
|
scaleImgIfNeed();
|
||||||
}
|
}
|
||||||
JObj EPhoto::attrJson() const {
|
JObj EPhoto::attrJson() const {
|
||||||
|
@ -53,6 +56,9 @@ JObj EPhoto::attrJson() const {
|
||||||
json["elementType"] = "Image";
|
json["elementType"] = "Image";
|
||||||
json["dir"] = mDir;
|
json["dir"] = mDir;
|
||||||
json["name"] = mName;
|
json["name"] = mName;
|
||||||
|
json["direct"] = direct;
|
||||||
|
json["speed"] = speed;
|
||||||
|
json["tailSpacing"] = tailSpacing;
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
void EPhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void EPhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
|
@ -93,7 +99,7 @@ QWidget* EPhoto::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addWidget(new QLabel(translate("","Basic Properties")));
|
||||||
|
|
||||||
auto line = new QFrame();
|
auto line = new QFrame();
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
@ -113,7 +119,7 @@ QWidget* EPhoto::attrWgt() {
|
||||||
bnSelectFile->setObjectName("bnSelectFile");
|
bnSelectFile->setObjectName("bnSelectFile");
|
||||||
connect(bnSelectFile, &QPushButton::clicked, wgtAttr, [=] {
|
connect(bnSelectFile, &QPushButton::clicked, wgtAttr, [=] {
|
||||||
QString home = mDir.startsWith(gProgItem->mProgDir) ? gFileHome : mDir;
|
QString home = mDir.startsWith(gProgItem->mProgDir) ? gFileHome : mDir;
|
||||||
QString file = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), home, EPhoto::filters());
|
QString file = QFileDialog::getOpenFileName(wgtAttr, translate("","Select File"), home, EPhoto::filters());
|
||||||
if(file.isEmpty()) return;
|
if(file.isEmpty()) return;
|
||||||
QImageReader reader(file);
|
QImageReader reader(file);
|
||||||
reader.setAutoTransform(true);
|
reader.setAutoTransform(true);
|
||||||
|
@ -132,6 +138,71 @@ QWidget* EPhoto::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(bnSelectFile);
|
hBox->addWidget(bnSelectFile);
|
||||||
|
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
auto label = hBox->addLabel(tr("Scroll")+": "+tr("Direction"));
|
||||||
|
label->setMinimumWidth(80);
|
||||||
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto edDirect = new QComboBox;
|
||||||
|
edDirect->addItem(tr("No"), "");
|
||||||
|
edDirect->addItem(tr("Right -> Left"), "left");
|
||||||
|
edDirect->addItem(tr("Bottom -> Top"), "top");
|
||||||
|
edDirect->addItem(tr("Left -> Right"), "right");
|
||||||
|
edDirect->addItem(tr("Top -> Bottom"), "bottom");
|
||||||
|
SetCurData(edDirect, direct);
|
||||||
|
connect(edDirect, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=] {
|
||||||
|
direct = edDirect->currentData().toString();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edDirect);
|
||||||
|
|
||||||
|
label = hBox->addLabel(tr("Speed"));
|
||||||
|
label->setMinimumWidth(80);
|
||||||
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto fd = new QComboBox;
|
||||||
|
fd->setEditable(true);
|
||||||
|
fd->setMinimumWidth(50);
|
||||||
|
fd->addItem("600");
|
||||||
|
fd->addItem("540");
|
||||||
|
fd->addItem("480");
|
||||||
|
fd->addItem("420");
|
||||||
|
fd->addItem("360");
|
||||||
|
fd->addItem("300");
|
||||||
|
fd->addItem("240");
|
||||||
|
fd->addItem("180");
|
||||||
|
fd->addItem("120");
|
||||||
|
fd->addItem("60");
|
||||||
|
fd->addItem("30");
|
||||||
|
fd->setMaxVisibleItems(fd->count());
|
||||||
|
auto text = QString::number(speed);
|
||||||
|
if(SetCurText(fd, text)==-1) {
|
||||||
|
SetCurText(fd, "60");
|
||||||
|
fd->setCurrentText(text);
|
||||||
|
}
|
||||||
|
connect(fd, &QComboBox::editTextChanged, this, [=](const QString &text) {
|
||||||
|
bool ok;
|
||||||
|
auto speed = text.toInt(&ok);
|
||||||
|
if(ok) this->speed = speed;
|
||||||
|
});
|
||||||
|
hBox->addWidget(fd);
|
||||||
|
hBox->addLabel("px/s");
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
// hBox = new HBox(vBox);
|
||||||
|
// label = hBox->addLabel(tr("Tail Spacing"));
|
||||||
|
// label->setMinimumWidth(80);
|
||||||
|
// label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
// auto edTailSpacing = new QSpinBox;
|
||||||
|
// edTailSpacing->setRange(0, 9999);
|
||||||
|
// edTailSpacing->setValue(tailSpacing);
|
||||||
|
// connect(edTailSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
|
// tailSpacing = value;
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(edTailSpacing);
|
||||||
|
// hBox->addStretch();
|
||||||
|
|
||||||
// hBox = new HBox(vBox);
|
// hBox = new HBox(vBox);
|
||||||
// hBox->addWidget(new QLabel(tr("Play Properties")));
|
// hBox->addWidget(new QLabel(tr("Play Properties")));
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ public:
|
||||||
static EPhoto *create(const QString &file, PageListItem *pageItem, EBase *multiWin = nullptr);
|
static EPhoto *create(const QString &file, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
static EPhoto *create(const JObj &, PageListItem *pageItem, EBase *multiWin = nullptr);
|
static EPhoto *create(const JObj &, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
explicit EPhoto(const QImage&, const QString &dir, const QString &name, PageListItem *pageItem, EBase *multiWin = nullptr);
|
explicit EPhoto(const QImage&, const QString &dir, const QString &name, const JObj &json, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
void scaleImgIfNeed();
|
void scaleImgIfNeed();
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ public:
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
|
|
||||||
QImage img;
|
QImage img;
|
||||||
QString mDir, mName;
|
QString mDir, mName, direct;
|
||||||
|
int speed = 0, tailSpacing = 0;
|
||||||
protected:
|
protected:
|
||||||
PageListItem *mPageItem;
|
PageListItem *mPageItem;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
#include <QCheckBox>
|
||||||
#if(QT_VERSION_MAJOR > 5)
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
#include <QStringConverter>
|
#include <QStringConverter>
|
||||||
#else
|
#else
|
||||||
|
@ -36,13 +37,15 @@ EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
text = widget["text"].toString();
|
text = widget["text"].toString();
|
||||||
align = (Qt::Alignment) widget["align"].toInt();
|
align = (Qt::Alignment) widget["align"].toInt();
|
||||||
backColor = widget["backColor"].toString("#00000000");
|
backColor = widget["backColor"].toString("#00000000");
|
||||||
|
lastFont = widget["lastFont"].toString("黑体");
|
||||||
auto play = json["play"];
|
auto play = json["play"];
|
||||||
if(play.isNull()) {
|
if(play.isNull()) {
|
||||||
playMode = json["playMode"].toString();
|
playMode = json["playMode"].toString();
|
||||||
if(playMode=="Scroll") {
|
if(playMode=="Scroll") {
|
||||||
direction = json["direction"].toString();
|
direction = json["direction"].toString();
|
||||||
speed = json["speed"].toInt();
|
speed = json["speed"].toInt();
|
||||||
headTailSpacing = json["headTailSpacing"].toInt();
|
tailSpacing = json["headTailSpacing"].toInt();
|
||||||
|
useNewFmt = json["useNewFmt"].toBool();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
playMode = playModes[play["style"].toInt()];
|
playMode = playModes[play["style"].toInt()];
|
||||||
|
@ -50,7 +53,7 @@ EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
QString ds[]{"left", "top", "right", "bottom"};
|
QString ds[]{"left", "top", "right", "bottom"};
|
||||||
direction = ds[rolling["rollingStyle"].toInt()];
|
direction = ds[rolling["rollingStyle"].toInt()];
|
||||||
speed = 1000/rolling["rollingSpeed"].toInt(33);
|
speed = 1000/rolling["rollingSpeed"].toInt(33);
|
||||||
headTailSpacing = rolling["headTailSpacing"].toInt();
|
tailSpacing = rolling["headTailSpacing"].toInt();
|
||||||
}
|
}
|
||||||
connect(this, &EText::sizeChanged, this, &EText::updImg);
|
connect(this, &EText::sizeChanged, this, &EText::updImg);
|
||||||
updImg();
|
updImg();
|
||||||
|
@ -79,7 +82,7 @@ QWidget* EText::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addLabel(tr("Basic Properties"));
|
hBox->addLabel(translate("","Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame;
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
@ -92,13 +95,14 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
auto fdFontFamily = new QFontComboBox;
|
auto fdFontFamily = new QFontComboBox;
|
||||||
fdFontFamily->setEditable(false);
|
fdFontFamily->setEditable(false);
|
||||||
fdFontFamily->setCurrentFont(QFont("黑体"));
|
fdFontFamily->setCurrentFont(QFont(lastFont));
|
||||||
connect(fdFontFamily, &QFontComboBox::currentFontChanged, fdText, [fdText](const QFont &f) {
|
connect(fdFontFamily, &QFontComboBox::currentFontChanged, fdText, [=](const QFont &f) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontFamilies({f.family()});
|
fmt.setFontFamilies({f.family()});
|
||||||
QTextCursor cursor = fdText->textCursor();
|
QTextCursor cursor = fdText->textCursor();
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
cursor.mergeCharFormat(fmt);
|
cursor.mergeCharFormat(fmt);
|
||||||
|
lastFont = f.family();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontFamily);
|
hBox->addWidget(fdFontFamily);
|
||||||
|
|
||||||
|
@ -107,7 +111,7 @@ QWidget* EText::attrWgt() {
|
||||||
auto fdFontSize = new QSpinBox;
|
auto fdFontSize = new QSpinBox;
|
||||||
fdFontSize->setRange(4, 9999);
|
fdFontSize->setRange(4, 9999);
|
||||||
fdFontSize->setValue(16);
|
fdFontSize->setValue(16);
|
||||||
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, fdText, [fdText](int value) {
|
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, fdText, [=](int value) {
|
||||||
if(value <= 0) return;
|
if(value <= 0) return;
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setProperty(QTextFormat::FontPixelSize, value);
|
fmt.setProperty(QTextFormat::FontPixelSize, value);
|
||||||
|
@ -329,8 +333,16 @@ QWidget* EText::attrWgt() {
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
connect(fdText, &QTextEdit::currentCharFormatChanged, this, [=](const QTextCharFormat &format) {
|
connect(fdText, &QTextEdit::currentCharFormatChanged, this, [=](const QTextCharFormat &format) {
|
||||||
|
auto ft = format.font();
|
||||||
|
auto families = ft.families();
|
||||||
|
if(! families.isEmpty()) {
|
||||||
|
fdFontFamily->blockSignals(true);
|
||||||
|
fdFontFamily->setCurrentFont(families[0]);
|
||||||
|
fdFontFamily->blockSignals(false);
|
||||||
|
lastFont = families[0];
|
||||||
|
}
|
||||||
fdFontSize->blockSignals(true);
|
fdFontSize->blockSignals(true);
|
||||||
fdFontSize->setValue(format.font().pixelSize());
|
fdFontSize->setValue(ft.pixelSize());
|
||||||
fdFontSize->blockSignals(false);
|
fdFontSize->blockSignals(false);
|
||||||
auto foreground = format.foreground();
|
auto foreground = format.foreground();
|
||||||
fdTextColor->blockSignals(true);
|
fdTextColor->blockSignals(true);
|
||||||
|
@ -382,7 +394,7 @@ QWidget* EText::attrWgt() {
|
||||||
auto btnImport = new QPushButton(tr("Import txt File"));
|
auto btnImport = new QPushButton(tr("Import txt File"));
|
||||||
btnImport->setProperty("ssType", "progManageTool");
|
btnImport->setProperty("ssType", "progManageTool");
|
||||||
connect(btnImport, &QPushButton::clicked, fdText, [=] {
|
connect(btnImport, &QPushButton::clicked, fdText, [=] {
|
||||||
auto filePath = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), gFileHome, "Txt(*.txt)");
|
auto filePath = QFileDialog::getOpenFileName(wgtAttr, translate("","Select File"), gFileHome, "Txt(*.txt)");
|
||||||
if(filePath.isEmpty()) return;
|
if(filePath.isEmpty()) return;
|
||||||
QFile qFile(filePath);
|
QFile qFile(filePath);
|
||||||
if(! qFile.open(QFile::ReadOnly)) {
|
if(! qFile.open(QFile::ReadOnly)) {
|
||||||
|
@ -446,25 +458,9 @@ QWidget* EText::attrWgt() {
|
||||||
vBox->setSpacing(3);
|
vBox->setSpacing(3);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
auto label = new QLabel(tr("Head-Tail Spacing"));
|
auto label = hBox->addLabel(tr("Direction"));
|
||||||
label->setMinimumWidth(100);
|
label->setMinimumWidth(80);
|
||||||
hBox->addWidget(label);
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
auto fdHeadTailSpacing = new QSpinBox;
|
|
||||||
fdHeadTailSpacing->setRange(0, 9999);
|
|
||||||
fdHeadTailSpacing->setValue(headTailSpacing);
|
|
||||||
connect(fdHeadTailSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
headTailSpacing = value;
|
|
||||||
updImg();
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdHeadTailSpacing);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
|
||||||
|
|
||||||
label = new QLabel(tr("Scroll Style"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto fdDirection = new QComboBox;
|
auto fdDirection = new QComboBox;
|
||||||
fdDirection->addItem(tr("Right -> Left"), "left");
|
fdDirection->addItem(tr("Right -> Left"), "left");
|
||||||
|
@ -477,13 +473,10 @@ QWidget* EText::attrWgt() {
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdDirection);
|
hBox->addWidget(fdDirection);
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
label = hBox->addLabel(tr("Speed"));
|
||||||
|
label->setMinimumWidth(80);
|
||||||
label = new QLabel(tr("Scroll Speed"));
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto fd = new QComboBox;
|
auto fd = new QComboBox;
|
||||||
fd->setEditable(true);
|
fd->setEditable(true);
|
||||||
|
@ -514,6 +507,29 @@ QWidget* EText::attrWgt() {
|
||||||
hBox->addLabel("px/s");
|
hBox->addLabel("px/s");
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
label = hBox->addLabel(tr("Tail Spacing"));
|
||||||
|
label->setMinimumWidth(80);
|
||||||
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto edTailSpacing = new QSpinBox;
|
||||||
|
edTailSpacing->setRange(0, 9999);
|
||||||
|
edTailSpacing->setValue(tailSpacing);
|
||||||
|
connect(edTailSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
|
tailSpacing = value;
|
||||||
|
updImg();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edTailSpacing);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
auto edNewFmt = new QCheckBox(tr("New Format")+" (Player 2.1.18)");
|
||||||
|
edNewFmt->setChecked(useNewFmt);
|
||||||
|
connect(edNewFmt, &QCheckBox::stateChanged, this, [this](int value) {
|
||||||
|
useNewFmt = value==Qt::Checked;
|
||||||
|
updImg();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edNewFmt);
|
||||||
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
}
|
}
|
||||||
auto stackBox = new QStackedLayout;
|
auto stackBox = new QStackedLayout;
|
||||||
|
@ -554,6 +570,7 @@ JObj EText::attrJson() const {
|
||||||
{"text", text},
|
{"text", text},
|
||||||
{"align", (int) align},
|
{"align", (int) align},
|
||||||
{"backColor", backColor.name(QColor::HexArgb)},
|
{"backColor", backColor.name(QColor::HexArgb)},
|
||||||
|
{"lastFont", lastFont},
|
||||||
{"files", files},
|
{"files", files},
|
||||||
{"idDir", QString("%1-%2-%3-%4-%5").arg(zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight)}
|
{"idDir", QString("%1-%2-%3-%4-%5").arg(zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight)}
|
||||||
};
|
};
|
||||||
|
@ -561,7 +578,8 @@ JObj EText::attrJson() const {
|
||||||
if(playMode=="Scroll") {
|
if(playMode=="Scroll") {
|
||||||
obj["direction"] = direction;
|
obj["direction"] = direction;
|
||||||
obj["speed"] = speed;
|
obj["speed"] = speed;
|
||||||
obj["headTailSpacing"] = headTailSpacing;
|
obj["headTailSpacing"] = tailSpacing;
|
||||||
|
obj["useNewFmt"] = useNewFmt;
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -633,13 +651,14 @@ void EText::updImg() {
|
||||||
}
|
}
|
||||||
emit updPageCnt();
|
emit updPageCnt();
|
||||||
} else if(playMode=="Scroll") {//生成一张大图
|
} else if(playMode=="Scroll") {//生成一张大图
|
||||||
if(direction=="left" || direction=="right") {
|
auto isHor = direction=="left" || direction=="right";
|
||||||
|
if(isHor) {
|
||||||
doc.setHtml(text.replace("<p ", "<span ").replace("</p>", "</span>").replace("<br />", " "));
|
doc.setHtml(text.replace("<p ", "<span ").replace("</p>", "</span>").replace("<br />", " "));
|
||||||
width = ceil(doc.idealWidth()) + headTailSpacing;
|
width = ceil(doc.idealWidth()) + tailSpacing;
|
||||||
} else {
|
} else {
|
||||||
doc.setTextWidth(width);
|
doc.setTextWidth(width);
|
||||||
doc.setHtml(text);
|
doc.setHtml(text);
|
||||||
height = doc.size().height() + headTailSpacing;
|
height = doc.size().height() + tailSpacing;
|
||||||
}
|
}
|
||||||
QImage img(width, height, QImage::Format_ARGB32);
|
QImage img(width, height, QImage::Format_ARGB32);
|
||||||
img.fill(backColor);
|
img.fill(backColor);
|
||||||
|
@ -647,7 +666,7 @@ void EText::updImg() {
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
doc.drawContents(&painter);
|
doc.drawContents(&painter);
|
||||||
}
|
}
|
||||||
if(direction=="left" || direction=="right") {
|
if(isHor) {
|
||||||
alignV(img);
|
alignV(img);
|
||||||
if(width < innerRect.width()) {
|
if(width < innerRect.width()) {
|
||||||
auto newWidth = width*2;
|
auto newWidth = width*2;
|
||||||
|
@ -662,19 +681,26 @@ void EText::updImg() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mImgs.clear();
|
mImgs.clear();
|
||||||
mImgs.append(img);
|
if(! useNewFmt) mImgs.append(img);
|
||||||
// if(img.width()<=8192) mImgs.append(img);
|
else if(isHor) {
|
||||||
// else {
|
if(img.width()<=4096) mImgs.append(img);
|
||||||
// for(int i=0; i<img.width(); i+=8192) {
|
else {
|
||||||
// QImage imgpart(8192, height, QImage::Format_ARGB32);
|
auto rem = img.width();
|
||||||
// imgpart.fill(m_attr.backColor);
|
do {
|
||||||
// {
|
mImgs.append(img.copy(img.width()-rem, 0, qMin(4096, rem), img.height()));
|
||||||
// QPainter painter(&imgpart);
|
rem -= 4096;
|
||||||
// painter.drawImage(-i, 0, img);
|
} while (rem>0);
|
||||||
// }
|
}
|
||||||
// mImgs.append(imgpart);
|
} else {
|
||||||
// }
|
if(img.height()<=4096) mImgs.append(img);
|
||||||
// }
|
else {
|
||||||
|
auto rem = img.height();
|
||||||
|
do {
|
||||||
|
mImgs.append(img.copy(0, img.height()-rem, img.width(), qMin(4096, rem)));
|
||||||
|
rem -= 4096;
|
||||||
|
} while (rem>0);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if(playMode=="Static") {//生成一张图
|
} else if(playMode=="Static") {//生成一张图
|
||||||
doc.setHtml(text);
|
doc.setHtml(text);
|
||||||
doc.setTextWidth(width);
|
doc.setTextWidth(width);
|
||||||
|
|
|
@ -18,10 +18,12 @@ public:
|
||||||
QString text;
|
QString text;
|
||||||
Qt::Alignment align;
|
Qt::Alignment align;
|
||||||
QColor backColor = Qt::transparent;
|
QColor backColor = Qt::transparent;
|
||||||
|
QString lastFont = "黑体";
|
||||||
QString playMode = "Flip";
|
QString playMode = "Flip";
|
||||||
QString direction = "left";
|
QString direction = "left";
|
||||||
int speed = 60;
|
int speed = 60;
|
||||||
int headTailSpacing = 10;
|
int tailSpacing = 10;
|
||||||
|
bool useNewFmt = false;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updImg();
|
void updImg();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "etimer.h"
|
#include "etimer.h"
|
||||||
#include "tools.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "base/lodateselector.h"
|
#include "base/calendarbutton.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
@ -44,8 +43,7 @@ ETimer::ETimer(const JObj &json, EBase *multiWin) : EBase(multiWin){
|
||||||
font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
||||||
font.setUnderline(json["fontUnderline"].toBool());
|
font.setUnderline(json["fontUnderline"].toBool());
|
||||||
textColor = json["textColor"].toString();
|
textColor = json["textColor"].toString();
|
||||||
auto color = json["backColor"].toString();
|
backColor = json["backColor"].toString("#00000000");
|
||||||
backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,17 +95,15 @@ QWidget* ETimer::attrWgt() {
|
||||||
|
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout();
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addLabel(translate("","Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame();
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
auto fdCntDown = new QRadioButton(tr("Count Down"));
|
auto fdCntDown = new QRadioButton(tr("Count Down"));
|
||||||
auto fdCntUp = new QRadioButton(tr("Count Up"));
|
auto fdCntUp = new QRadioButton(tr("Count Up"));
|
||||||
|
@ -125,28 +121,24 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addWidget(fdCntUp);
|
hBox->addWidget(fdCntUp);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Time")));
|
hBox->addLabel(tr("Target Time"));
|
||||||
|
|
||||||
auto fdTime = new QDateTimeEdit(this->targetTime);
|
auto edTime = new QDateTimeEdit(this->targetTime);
|
||||||
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
edTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
connect(edTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
||||||
this->targetTime = dateTime;
|
this->targetTime = dateTime;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTime);
|
hBox->addWidget(edTime);
|
||||||
|
|
||||||
auto wDateSelector = new LoDateSelector();
|
auto btnTime = new CalendarButton;
|
||||||
connect(wDateSelector, &LoDateSelector::sDateSelected, fdTime, &QDateTimeEdit::setDate);
|
connect(btnTime->calendar, &QCalendarWidget::clicked, edTime, &QDateTimeEdit::setDate);
|
||||||
hBox->addWidget(wDateSelector);
|
hBox->addWidget(btnTime);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdHasDay = new QCheckBox(tr("Day"));
|
auto fdHasDay = new QCheckBox(tr("Day"));
|
||||||
|
@ -190,9 +182,7 @@ QWidget* ETimer::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdIsMultiline);
|
hBox->addWidget(fdIsMultiline);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Text")));
|
hBox->addWidget(new QLabel(tr("Text")));
|
||||||
|
|
||||||
|
@ -204,9 +194,7 @@ QWidget* ETimer::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdText);
|
hBox->addWidget(fdText);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdFont = new QFontComboBox();
|
auto fdFont = new QFontComboBox();
|
||||||
|
@ -233,9 +221,7 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addWidget(fdFontSize);
|
hBox->addWidget(fdFontSize);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdFontBold = new QPushButton("B");
|
auto fdFontBold = new QPushButton("B");
|
||||||
|
@ -289,7 +275,6 @@ QWidget* ETimer::attrWgt() {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdBackColor);
|
hBox->addWidget(fdBackColor);
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
#include "base/lodateselector.h"
|
#include "base/calendarbutton.h"
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QFontComboBox>
|
#include <QFontComboBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -80,7 +80,7 @@ QWidget* ETimer2::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addLabel(tr("Basic Properties"));
|
hBox->addLabel(translate("","Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame;
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
@ -108,19 +108,19 @@ QWidget* ETimer2::attrWgt() {
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addLabel(tr("Time"));
|
hBox->addLabel(tr("Target Time"));
|
||||||
|
|
||||||
auto fdTime = new QDateTimeEdit(targetTime);
|
auto edTime = new QDateTimeEdit(targetTime);
|
||||||
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
edTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
connect(edTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
||||||
targetTime = dateTime;
|
targetTime = dateTime;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTime);
|
hBox->addWidget(edTime);
|
||||||
|
|
||||||
auto wDateSelector = new LoDateSelector;
|
auto btnCalendar = new CalendarButton;
|
||||||
connect(wDateSelector, &LoDateSelector::sDateSelected, fdTime, &QDateTimeEdit::setDate);
|
connect(btnCalendar->calendar, &QCalendarWidget::clicked, edTime, &QDateTimeEdit::setDate);
|
||||||
hBox->addWidget(wDateSelector);
|
hBox->addWidget(btnCalendar);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "base/ffutil.h"
|
#include "base/ffutil.h"
|
||||||
|
#include "gutil/qwaitingdlg.h"
|
||||||
|
#include "videosplitthread.h"
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
@ -47,6 +49,8 @@ EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin)
|
||||||
auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, pageItem, multiWin);
|
auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, pageItem, multiWin);
|
||||||
ins->setBaseAttr(ele);
|
ins->setBaseAttr(ele);
|
||||||
if(ins->_duration < 4) ins->_duration = dur;
|
if(ins->_duration < 4) ins->_duration = dur;
|
||||||
|
ins->useSW = ele["useSW"].toBool();
|
||||||
|
ins->isPreSplit = ele["isPreSplit"].toBool();
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1);
|
ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1);
|
||||||
return ins;
|
return ins;
|
||||||
|
@ -81,19 +85,17 @@ QWidget* EVideo::attrWgt() {
|
||||||
|
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout();
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addLabel(translate("","Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame();
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("File")));
|
hBox->addLabel(tr("File"));
|
||||||
|
|
||||||
auto fdFileName = new QLineEdit(mRawName);
|
auto fdFileName = new QLineEdit(mRawName);
|
||||||
fdFileName->setReadOnly(true);
|
fdFileName->setReadOnly(true);
|
||||||
|
@ -103,7 +105,7 @@ QWidget* EVideo::attrWgt() {
|
||||||
bnSelectFile->setFixedWidth(30);
|
bnSelectFile->setFixedWidth(30);
|
||||||
bnSelectFile->setObjectName("bnSelectFile");
|
bnSelectFile->setObjectName("bnSelectFile");
|
||||||
connect(bnSelectFile, &QPushButton::clicked, this, [=] {
|
connect(bnSelectFile, &QPushButton::clicked, this, [=] {
|
||||||
auto rawFile = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), gFileHome, EVideo::filters());
|
auto rawFile = QFileDialog::getOpenFileName(wgtAttr, translate("","Select File"), gFileHome, EVideo::filters());
|
||||||
if(rawFile.isEmpty()) return;
|
if(rawFile.isEmpty()) return;
|
||||||
QFileInfo rawInfo(rawFile);
|
QFileInfo rawInfo(rawFile);
|
||||||
int64_t dur;
|
int64_t dur;
|
||||||
|
@ -127,11 +129,9 @@ QWidget* EVideo::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(bnSelectFile);
|
hBox->addWidget(bnSelectFile);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
// hBox = new HBox(vBox);
|
||||||
|
|
||||||
// hBox = new QHBoxLayout();
|
|
||||||
// hBox->addSpacing(6);
|
// hBox->addSpacing(6);
|
||||||
// hBox->addWidget(new QLabel(tr("AspectRatioMode")));
|
// hBox->addLabel(tr("AspectRatioMode"));
|
||||||
|
|
||||||
// auto wAspectRatioMode = new QComboBox();
|
// auto wAspectRatioMode = new QComboBox();
|
||||||
// wAspectRatioMode->addItem(tr("IgnoreAspectRatio"));
|
// wAspectRatioMode->addItem(tr("IgnoreAspectRatio"));
|
||||||
|
@ -144,32 +144,46 @@ QWidget* EVideo::attrWgt() {
|
||||||
// hBox->addWidget(wAspectRatioMode);
|
// hBox->addWidget(wAspectRatioMode);
|
||||||
// hBox->addStretch();
|
// hBox->addStretch();
|
||||||
|
|
||||||
// vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Play Properties"));
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
line = new QFrame;
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
|
||||||
|
|
||||||
line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Play Times")));
|
hBox->addLabel(tr("Play Times"));
|
||||||
|
|
||||||
auto wPlayTimes = new QSpinBox();
|
auto edPlayTimes = new QSpinBox;
|
||||||
wPlayTimes->setRange(1, 99999);
|
edPlayTimes->setRange(1, 99999);
|
||||||
wPlayTimes->setValue(playTimes);
|
edPlayTimes->setValue(playTimes);
|
||||||
connect(wPlayTimes, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
connect(edPlayTimes, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
playTimes = value;
|
playTimes = value;
|
||||||
});
|
});
|
||||||
hBox->addWidget(wPlayTimes);
|
hBox->addWidget(edPlayTimes);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
|
auto edUseSW = new QCheckBox(tr("Use SW"));
|
||||||
|
edUseSW->setChecked(useSW);
|
||||||
|
connect(edUseSW, &QCheckBox::stateChanged, this, [this](int value) {
|
||||||
|
useSW = value==Qt::Checked;
|
||||||
|
});
|
||||||
|
hBox->addWidget(edUseSW);
|
||||||
|
|
||||||
|
auto edPreSplit = new QCheckBox(tr("Pre Split")+" ("+tr("No Effect")+")");
|
||||||
|
edPreSplit->setChecked(isPreSplit);
|
||||||
|
connect(edPreSplit, &QCheckBox::stateChanged, this, [this](int value) {
|
||||||
|
isPreSplit = value==Qt::Checked;
|
||||||
|
});
|
||||||
|
hBox->addWidget(edPreSplit);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
@ -183,19 +197,19 @@ bool EVideo::save(const QString &pageDir) {
|
||||||
else return false;
|
else return false;
|
||||||
QFile(oldFile).copy(saveFile);
|
QFile(oldFile).copy(saveFile);
|
||||||
mDir = pageDir;
|
mDir = pageDir;
|
||||||
// if(gProgItem->maxLen) {
|
if(gProgItem->maxLen && isPreSplit) {
|
||||||
// auto waitingDlg = new WaitingDlg(mPageItem->listWidget()->window(), "正在转码视频 ...");
|
auto waitingDlg = new WaitingDlg(mPageItem->listWidget()->window(), "正在转码视频 ...");
|
||||||
// auto thread = new VideoSplitThread(mWidth, mHeight, gProgItem->maxLen, gProgItem->isVer ? gProgItem->mWidth : gProgItem->mHeight, gProgItem->partLens, gProgItem->isVer, pos(), saveFile.toUtf8());
|
auto thread = new VideoSplitThread(mWidth, mHeight, gProgItem->maxLen, gProgItem->isVer ? gProgItem->mWidth : gProgItem->mHeight, gProgItem->partLens, gProgItem->isVer, pos(), saveFile.toUtf8());
|
||||||
// connect(thread, &VideoSplitThread::emErr, this, [=](QString err) {
|
connect(thread, &VideoSplitThread::emErr, this, [=](QString err) {
|
||||||
// waitingDlg->close();
|
waitingDlg->close();
|
||||||
// if(! err.isEmpty()) QMessageBox::critical(mPageItem->listWidget()->window(), "Video trans error", err+"\n"+saveFile);
|
if(! err.isEmpty()) QMessageBox::critical(mPageItem->listWidget()->window(), "Video trans error", err+"\n"+saveFile);
|
||||||
// });
|
});
|
||||||
// connect(thread, &VideoSplitThread::emProgress, this, [saveFile, waitingDlg](int progress) {
|
connect(thread, &VideoSplitThread::emProgress, this, [saveFile, waitingDlg](int progress) {
|
||||||
// waitingDlg->fdText->setText(QString("正在转码视频 %1%").arg(progress));
|
waitingDlg->fdText->setText(QString("正在转码视频 %1%").arg(progress));
|
||||||
// });
|
});
|
||||||
// thread->start();
|
thread->start();
|
||||||
// waitingDlg->exec();
|
waitingDlg->exec();
|
||||||
// }
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +220,17 @@ JObj EVideo::attrJson() const {
|
||||||
{"file", mName},
|
{"file", mName},
|
||||||
{"pathRaw", mRawDir},
|
{"pathRaw", mRawDir},
|
||||||
{"fileRaw", mRawName},
|
{"fileRaw", mRawName},
|
||||||
|
{"useSW", useSW},
|
||||||
|
{"isPreSplit", isPreSplit},
|
||||||
{"playTimes", playTimes}
|
{"playTimes", playTimes}
|
||||||
};
|
};
|
||||||
|
if(gProgItem->isVer) {
|
||||||
|
obj["outHeight"] = gProgItem->maxLen;
|
||||||
|
obj["outWidth"] = gProgItem->mWidth * (int)gProgItem->partLens.size();
|
||||||
|
} else {
|
||||||
|
obj["outWidth"] = gProgItem->maxLen;
|
||||||
|
obj["outHeight"] = gProgItem->mHeight * (int)gProgItem->partLens.size();
|
||||||
|
}
|
||||||
addBaseAttr(obj);
|
addBaseAttr(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +268,7 @@ QString EVideo::transcoding(QWidget *parent, QString rawFile, QString rawName, Q
|
||||||
});
|
});
|
||||||
connect(&process, &QProcess::errorOccurred, &msgBox, [=, &msgBox](QProcess::ProcessError error) {
|
connect(&process, &QProcess::errorOccurred, &msgBox, [=, &msgBox](QProcess::ProcessError error) {
|
||||||
msgBox.accept();
|
msgBox.accept();
|
||||||
QMessageBox::critical(parent, tr("Error"), QString(QMetaEnum::fromType<QProcess::ProcessError>().valueToKey(error))+" ("+QString::number(error)+")");
|
QMessageBox::critical(parent, translate("","Error"), QString(QMetaEnum::fromType<QProcess::ProcessError>().valueToKey(error))+" ("+QString::number(error)+")");
|
||||||
});
|
});
|
||||||
connect(&process, &QProcess::readyReadStandardOutput, &msgBox, [&process] {
|
connect(&process, &QProcess::readyReadStandardOutput, &msgBox, [&process] {
|
||||||
auto data = process.readAllStandardOutput();
|
auto data = process.readAllStandardOutput();
|
||||||
|
@ -273,7 +296,7 @@ QString EVideo::transcoding(QWidget *parent, QString rawFile, QString rawName, Q
|
||||||
process.start("ffmpeg", {"-y", "-i", rawFile, "-vcodec", "h264", "-s", QString::number(w)+"x"+QString::number(h), "-profile:v", "main", "-b:v", QString::number(w*h/150)+"k", outFile});
|
process.start("ffmpeg", {"-y", "-i", rawFile, "-vcodec", "h264", "-s", QString::number(w)+"x"+QString::number(h), "-profile:v", "main", "-b:v", QString::number(w*h/150)+"k", outFile});
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
if(err.right(32).contains("Conversion failed!")) {
|
if(err.right(32).contains("Conversion failed!")) {
|
||||||
QMessageBox::critical(parent, tr("Error"), err);
|
QMessageBox::critical(parent, translate("","Error"), err);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return outFile;
|
return outFile;
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
||||||
int playTimes = 1;
|
int playTimes = 1;
|
||||||
|
bool useSW = false, isPreSplit = false;
|
||||||
PageListItem *mPageItem;
|
PageListItem *mPageItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "eweb.h"
|
#include "eweb.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
|
#include "main.h"
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -41,7 +42,7 @@ QWidget* EWeb::attrWgt() {
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addLabel(tr("Basic Properties"));
|
hBox->addLabel(translate("","Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame;
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
|
|
@ -142,10 +142,17 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson) {
|
||||||
auto startTime = isWin ? 0 : ele["startTime"].toInt();
|
auto startTime = isWin ? 0 : ele["startTime"].toInt();
|
||||||
for(auto &ss : sources) {
|
for(auto &ss : sources) {
|
||||||
auto source = ss.toObj();
|
auto source = ss.toObj();
|
||||||
source["left"] = geometry["x"];
|
if(source["isPreSplit"].toBool()) {
|
||||||
source["top"] = geometry["y"];
|
source["left"] = 0;
|
||||||
source["width"] = geometry["w"];
|
source["top"] = 0;
|
||||||
source["height"] = geometry["h"];
|
source["width"] = ele["outWidth"];
|
||||||
|
source["height"] = ele["outHeight"];
|
||||||
|
} else {
|
||||||
|
source["left"] = geometry["x"];
|
||||||
|
source["top"] = geometry["y"];
|
||||||
|
source["width"] = geometry["w"];
|
||||||
|
source["height"] = geometry["h"];
|
||||||
|
}
|
||||||
source["rotate"] = ele["rotate"];
|
source["rotate"] = ele["rotate"];
|
||||||
source["opacity"] = ele["opacity"].toDouble(1);
|
source["opacity"] = ele["opacity"].toDouble(1);
|
||||||
source["playTime"] = startTime;
|
source["playTime"] = startTime;
|
||||||
|
@ -209,6 +216,7 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson) {
|
||||||
}
|
}
|
||||||
return JObj{
|
return JObj{
|
||||||
{"repeatTimes", pageJson["repeat"]},
|
{"repeatTimes", pageJson["repeat"]},
|
||||||
|
{"waitAudio", pageJson["waitAudio"]},
|
||||||
{"schedules", schedules},
|
{"schedules", schedules},
|
||||||
{"_program", JObj{
|
{"_program", JObj{
|
||||||
{"name", pageJson["name"].toString()},
|
{"name", pageJson["name"].toString()},
|
||||||
|
@ -226,11 +234,11 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
if(type=="Text") source = genText(ele, sources);
|
if(type=="Text") source = genText(ele, sources);
|
||||||
else if(type=="Image"||type=="Photo") source = genImage(ele);
|
else if(type=="Image"||type=="Photo") source = genImage(ele);
|
||||||
else if(type=="Video"||type=="Movie") {
|
else if(type=="Video"||type=="Movie") {
|
||||||
//genProg(ele, dstDir, mProgItem);
|
|
||||||
auto widget = ele["widget"];
|
auto widget = ele["widget"];
|
||||||
if(widget.isNull()) widget = ele;
|
if(widget.isNull()) widget = ele;
|
||||||
auto path = widget["path"].toString();
|
auto path = widget["path"].toString();
|
||||||
auto name = widget["file"].toString();
|
auto name = widget["file"].toString();
|
||||||
|
if(widget["isPreSplit"].toBool()) name += "-square.mp4";
|
||||||
auto srcFile = path + "/" + name;
|
auto srcFile = path + "/" + name;
|
||||||
if(! QFileInfo(srcFile).isFile() && ! QFileInfo(srcFile = srcPageDir + "/" + name).isFile()) continue;
|
if(! QFileInfo(srcFile).isFile() && ! QFileInfo(srcFile = srcPageDir + "/" + name).isFile()) continue;
|
||||||
auto id = Tools::fileMd5(srcFile);
|
auto id = Tools::fileMd5(srcFile);
|
||||||
|
@ -240,6 +248,8 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
source["id"] = id;
|
source["id"] = id;
|
||||||
source["md5"] = id;
|
source["md5"] = id;
|
||||||
source["name"] = name;
|
source["name"] = name;
|
||||||
|
source["useSW"] = ele["useSW"];
|
||||||
|
source["isPreSplit"] = ele["isPreSplit"];
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
source["timeSpan"] = play.isNull() ? ele["duration"].toInt() * ele["playTimes"].toInt() : play["playDuration"].toInt() * play["playTimes"].toInt();
|
source["timeSpan"] = play.isNull() ? ele["duration"].toInt() * ele["playTimes"].toInt() : play["playDuration"].toInt() * play["playTimes"].toInt();
|
||||||
} else if(type=="Gif") source = convertGif(ele);
|
} else if(type=="Gif") source = convertGif(ele);
|
||||||
|
@ -259,6 +269,8 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
||||||
source["entryEffect"] = ele["entryEffect"];
|
source["entryEffect"] = ele["entryEffect"];
|
||||||
source["exitEffect"] = ele["exitEffect"];
|
source["exitEffect"] = ele["exitEffect"];
|
||||||
|
if(source["entryEffect"].toStr().isEmpty()) source["entryEffect"] = "None"; //兼容旧播放器
|
||||||
|
if(source["exitEffect"].toStr().isEmpty()) source["exitEffect"] = "None"; //兼容旧播放器
|
||||||
source["entryEffectTimeSpan"] = ele["entryDur"];
|
source["entryEffectTimeSpan"] = ele["entryDur"];
|
||||||
source["exitEffectTimeSpan"] = ele["exitDur"];
|
source["exitEffectTimeSpan"] = ele["exitDur"];
|
||||||
if(ele["hasBlink"].toBool()) source["blink"] = ele["blink"];
|
if(ele["hasBlink"].toBool()) source["blink"] = ele["blink"];
|
||||||
|
@ -292,30 +304,47 @@ JObj GenTmpThread::genText(const JValue &ele, JArray &sources) {
|
||||||
|
|
||||||
auto isScroll = playMode=="Scroll";
|
auto isScroll = playMode=="Scroll";
|
||||||
if(isScroll) {
|
if(isScroll) {
|
||||||
JObj source;
|
if(filenames.size()>1) {
|
||||||
source["_type"] = "MultiPng";
|
JObj source;
|
||||||
source["playMode"] = playMode;
|
source["_type"] = "Scroll";
|
||||||
JArray arrayPics;
|
source["direct"] = direction;
|
||||||
for(auto &filename : filenames) {
|
source["speed"] = speed;
|
||||||
auto file = filePrefix + filename.toString();
|
JArray imgs;
|
||||||
QFile qFile(file);
|
for(auto &filename : filenames) {
|
||||||
if(! qFile.exists()) continue;
|
auto file = filePrefix + filename.toString();
|
||||||
auto id = Tools::fileMd5(file);
|
QFile qFile(file);
|
||||||
qFile.copy(dstDir+"/"+id);
|
if(! qFile.exists()) continue;
|
||||||
|
auto id = Tools::fileMd5(file);
|
||||||
|
qFile.copy(dstDir+"/"+id);
|
||||||
|
imgs.append(id);
|
||||||
|
}
|
||||||
|
source["imgs"] = imgs;
|
||||||
|
return source;
|
||||||
|
} else {
|
||||||
|
JObj source;
|
||||||
|
source["_type"] = "MultiPng";
|
||||||
|
source["playMode"] = playMode;
|
||||||
|
JArray arrayPics;
|
||||||
|
for(auto &filename : filenames) {
|
||||||
|
auto file = filePrefix + filename.toString();
|
||||||
|
QFile qFile(file);
|
||||||
|
if(! qFile.exists()) continue;
|
||||||
|
auto id = Tools::fileMd5(file);
|
||||||
|
qFile.copy(dstDir+"/"+id);
|
||||||
|
|
||||||
JObj arrayPic;
|
JObj arrayPic;
|
||||||
arrayPic["id"] = id;
|
arrayPic["id"] = id;
|
||||||
if(direction=="left") arrayPic["effect"] = "right to left";
|
if(direction=="left") arrayPic["effect"] = "right to left";
|
||||||
else if(direction=="top") arrayPic["effect"] = "bottom to top";
|
else if(direction=="top") arrayPic["effect"] = "bottom to top";
|
||||||
else if(direction=="right") arrayPic["effect"] = "left to right";
|
else if(direction=="right") arrayPic["effect"] = "left to right";
|
||||||
else if(direction=="bottom") arrayPic["effect"] = "top to bottom";
|
else if(direction=="bottom") arrayPic["effect"] = "top to bottom";
|
||||||
arrayPic["scrollSpeed"] = speed;
|
arrayPic["scrollSpeed"] = speed;
|
||||||
arrayPic["effectSpeed"] = 1000 / speed;
|
arrayPic["picDuration"] = 0;
|
||||||
arrayPic["picDuration"] = 0;
|
arrayPics.append(arrayPic);
|
||||||
arrayPics.append(arrayPic);
|
}
|
||||||
|
source["arrayPics"] = arrayPics;
|
||||||
|
return source;
|
||||||
}
|
}
|
||||||
source["arrayPics"] = arrayPics;
|
|
||||||
return source;
|
|
||||||
} else {
|
} else {
|
||||||
auto duration = ele["duration"].toInt();
|
auto duration = ele["duration"].toInt();
|
||||||
for(auto &filename : filenames) {
|
for(auto &filename : filenames) {
|
||||||
|
@ -353,6 +382,8 @@ JObj GenTmpThread::genImage(const JValue &ele) {
|
||||||
auto geometry = ele["geometry"];
|
auto geometry = ele["geometry"];
|
||||||
auto width = geometry["w"].toInt();
|
auto width = geometry["w"].toInt();
|
||||||
auto height = geometry["h"].toInt();
|
auto height = geometry["h"].toInt();
|
||||||
|
auto direct = ele["direct"].toStr();
|
||||||
|
auto speed = ele["speed"].toInt();
|
||||||
/*if(mProgItem->maxLen) {
|
/*if(mProgItem->maxLen) {
|
||||||
auto scaled = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
auto scaled = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
QImage square(gProgItem->isVer ? gProgItem->mWidth*gProgItem->partLens.size() : gProgItem->maxLen, gProgItem->isVer ? gProgItem->maxLen : gProgItem->mHeight*gProgItem->partLens.size(), QImage::Format_ARGB32);
|
QImage square(gProgItem->isVer ? gProgItem->mWidth*gProgItem->partLens.size() : gProgItem->maxLen, gProgItem->isVer ? gProgItem->maxLen : gProgItem->mHeight*gProgItem->partLens.size(), QImage::Format_ARGB32);
|
||||||
|
@ -387,26 +418,34 @@ JObj GenTmpThread::genImage(const JValue &ele) {
|
||||||
file.close();
|
file.close();
|
||||||
source["id"] = md5;
|
source["id"] = md5;
|
||||||
source["md5"] = md5;
|
source["md5"] = md5;
|
||||||
} else */if(img.width() > width*2 && img.height() > height*2) {
|
} else */
|
||||||
|
auto isScroll = ! direct.isEmpty() && speed > 0;
|
||||||
|
QString md5;
|
||||||
|
if((isScroll && (img.width() != width || img.height() != height)) || (img.width() > width*2 && img.height() > height*2)) {
|
||||||
QBuffer buf;
|
QBuffer buf;
|
||||||
img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(&buf, "PNG");
|
img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(&buf, "PNG");
|
||||||
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||||
cryptoHash.addData(buf.data());
|
cryptoHash.addData(buf.data());
|
||||||
auto md5 = QString::fromLatin1(cryptoHash.result().toHex());
|
md5 = QString::fromLatin1(cryptoHash.result().toHex());
|
||||||
QFile file(dstDir+"/"+md5);
|
QFile file(dstDir+"/"+md5);
|
||||||
if(! file.open(QFile::WriteOnly)) return source;
|
if(! file.open(QFile::WriteOnly)) return source;
|
||||||
file.write(buf.data());
|
file.write(buf.data());
|
||||||
file.close();
|
file.close();
|
||||||
source["id"] = md5;
|
|
||||||
source["md5"] = md5;
|
|
||||||
} else {
|
} else {
|
||||||
auto md5 = Tools::fileMd5(srcFile);
|
md5 = Tools::fileMd5(srcFile);
|
||||||
if(md5.isEmpty()) return source;
|
if(md5.isEmpty()) return source;
|
||||||
QFile::copy(srcFile, dstDir+"/"+md5);
|
QFile::copy(srcFile, dstDir+"/"+md5);
|
||||||
|
}
|
||||||
|
if(isScroll) {
|
||||||
|
source["_type"] = "Scroll";
|
||||||
|
source["direct"] = direct;
|
||||||
|
source["speed"] = speed;
|
||||||
|
source["imgs"] = JArray{md5};
|
||||||
|
} else {
|
||||||
|
source["_type"] = "Image";
|
||||||
source["id"] = md5;
|
source["id"] = md5;
|
||||||
source["md5"] = md5;
|
source["md5"] = md5;
|
||||||
}
|
}
|
||||||
source["_type"] = "Image";
|
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
source["timeSpan"] = play.isNull() ? ele["duration"] : play["playDuration"];
|
source["timeSpan"] = play.isNull() ? ele["duration"] : play["playDuration"];
|
||||||
return source;
|
return source;
|
||||||
|
@ -419,7 +458,7 @@ JObj GenTmpThread::convertGif(const JValue &json) {
|
||||||
QString srcFile = path + "/" + name;
|
QString srcFile = path + "/" + name;
|
||||||
QFileInfo srcInfo(srcFile);
|
QFileInfo srcInfo(srcFile);
|
||||||
if(! srcInfo.isFile()) return JObj();
|
if(! srcInfo.isFile()) return JObj();
|
||||||
QString id = Tools::fileMd5(srcFile);
|
auto id = Tools::fileMd5(srcFile);
|
||||||
if(id.isEmpty()) return JObj();
|
if(id.isEmpty()) return JObj();
|
||||||
QFile::copy(srcFile, dstDir+"/"+id);
|
QFile::copy(srcFile, dstDir+"/"+id);
|
||||||
JObj oRes;
|
JObj oRes;
|
||||||
|
@ -432,57 +471,79 @@ JObj GenTmpThread::convertGif(const JValue &json) {
|
||||||
return oRes;
|
return oRes;
|
||||||
}
|
}
|
||||||
JObj GenTmpThread::convertDClock(const JValue &json){
|
JObj GenTmpThread::convertDClock(const JValue &json){
|
||||||
JObj oRes;
|
JObj source;
|
||||||
oRes["_type"] = "DigitalClockNew";
|
source["_type"] = "DigitalClockNew";
|
||||||
oRes["name"] = "DigitalClockNew";
|
source["name"] = "DigitalClockNew";
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
oRes["timeZone"] = widget["timeZone"];
|
QFont font;
|
||||||
oRes["timezone"] = 8;//兼容旧播放器
|
QColor color;
|
||||||
oRes["year"] = widget["year"];
|
if(widget.isNull()) {
|
||||||
oRes["month"] = widget["month"];
|
widget = json;
|
||||||
oRes["day"] = widget["day"];
|
source["year"] = json["hasYear"];
|
||||||
oRes["hour"] = widget["hour"];
|
source["month"] = json["hasMonth"];
|
||||||
oRes["min"] = widget["min"];
|
source["day"] = json["hasDay"];
|
||||||
oRes["sec"] = widget["sec"];
|
source["hour"] = json["hasHour"];
|
||||||
oRes["weekly"] = widget["weekly"];
|
source["min"] = json["hasMin"];
|
||||||
oRes["fullYear"] = widget["fullYear"];
|
source["sec"] = json["hasSec"];
|
||||||
oRes["hour12"] = widget["12Hour"];
|
source["weekly"] = json["hasWeek"];
|
||||||
oRes["AmPm"] = widget["AmPm"];
|
source["fullYear"] = json["isFullYear"];
|
||||||
oRes["dateStyle"] = widget["dateStyle"];
|
source["hour12"] = json["is12Hour"];
|
||||||
oRes["timeStyle"] = widget["timeStyle"];
|
source["AmPm"] = json["hasAmPm"];
|
||||||
oRes["multiline"] = widget["multiline"];
|
source["multiline"] = json["isMultiline"];
|
||||||
|
color = json["color"].toString("#ffff0000");
|
||||||
auto fontVal = widget["font"];
|
font.setFamily(json["font"].toString());
|
||||||
auto textColor = Tools::int2Color(fontVal["color"].toInt());
|
font.setPixelSize(json["fontSize"].toInt());
|
||||||
QFont font(fontVal["family"].toString());
|
font.setBold(json["fontBold"].toBool());
|
||||||
font.setPixelSize(fontVal["size"].toInt());
|
font.setItalic(json["fontItalic"].toBool());
|
||||||
font.setBold(fontVal["bold"].toBool());
|
font.setUnderline(json["fontUnderline"].toBool());
|
||||||
font.setItalic(fontVal["italics"].toBool());
|
} else {
|
||||||
font.setUnderline(fontVal["underline"].toBool());
|
source["year"] = widget["year"];
|
||||||
|
source["month"] = widget["month"];
|
||||||
|
source["day"] = widget["day"];
|
||||||
|
source["hour"] = widget["hour"];
|
||||||
|
source["min"] = widget["min"];
|
||||||
|
source["sec"] = widget["sec"];
|
||||||
|
source["weekly"] = widget["weekly"];
|
||||||
|
source["fullYear"] = widget["fullYear"];
|
||||||
|
source["hour12"] = widget["12Hour"];
|
||||||
|
source["AmPm"] = widget["AmPm"];
|
||||||
|
source["multiline"] = widget["multiline"];
|
||||||
|
auto ft = widget["font"];
|
||||||
|
color = Tools::int2Color(ft["color"].toInt());
|
||||||
|
font.setFamily(ft["family"].toString());
|
||||||
|
font.setPixelSize(ft["size"].toInt());
|
||||||
|
font.setBold(ft["bold"].toBool());
|
||||||
|
font.setItalic(ft["italics"].toBool());
|
||||||
|
font.setUnderline(ft["underline"].toBool());
|
||||||
|
}
|
||||||
|
source["timeZone"] = widget["timeZone"];
|
||||||
|
source["timezone"] = 8;//兼容旧播放器
|
||||||
|
source["dateStyle"] = widget["dateStyle"];
|
||||||
|
source["timeStyle"] = widget["timeStyle"];
|
||||||
|
|
||||||
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
QFontMetrics metric(font);
|
QFontMetrics metric(font);
|
||||||
oRes["spaceWidth"] = metric.horizontalAdvance(" ");
|
source["spaceWidth"] = metric.horizontalAdvance(" ");
|
||||||
QColor color(textColor);
|
auto lineHeight = json["isMultiline"].toBool() ? json["lineHeight"].toInt() : 0;
|
||||||
JArray imgs;
|
JArray imgs;
|
||||||
for(int i=0; i<=9; i++) Tools::saveImg2(dstDir, metric, font, color, imgs, QString::number(i), QString::number(i));
|
for(int i=0; i<=9; i++) Tools::saveImg2(dstDir, metric, font, color, imgs, QString::number(i), QString::number(i), lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("MON"), "MON");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("MON"), "MON", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("TUE"), "TUE");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("TUE"), "TUE", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("WED"), "WED");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("WED"), "WED", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("THU"), "THU");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("THU"), "THU", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("FRI"), "FRI");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("FRI"), "FRI", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SAT"), "SAT");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SAT"), "SAT", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SUN"), "SUN");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SUN"), "SUN", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("AM"), "AM");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("AM"), "AM", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("PM"), "PM");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("PM"), "PM", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "年", "YEAR");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "年", "YEAR", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "月", "MONTH");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "月", "MONTH", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "日", "DAY");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "日", "DAY", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, ":", "maohao");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, ":", "maohao", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "/", "xiegang");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "/", "xiegang", lineHeight);
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "hengxian");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "hengxian", lineHeight);
|
||||||
oRes["arrayPics"] = imgs;
|
source["arrayPics"] = imgs;
|
||||||
return oRes;
|
return source;
|
||||||
}
|
}
|
||||||
JObj GenTmpThread::convertAClock(const JValue &json) {
|
JObj GenTmpThread::convertAClock(const JValue &json) {
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "pageeditor.h"
|
#include "pageeditor.h"
|
||||||
#include "tools.h"
|
#include "main.h"
|
||||||
#include "ebase.h"
|
#include "ebase.h"
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -164,7 +164,7 @@ void PageEditor::onDelete() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageEditor::onClean() {
|
void PageEditor::onClean() {
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"),tr("Clear all medias?"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::information(this, translate("","Tip"),tr("Clear all medias?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
if(res == QMessageBox::Ok) {
|
if(res == QMessageBox::Ok) {
|
||||||
auto eles = sortedEles();
|
auto eles = sortedEles();
|
||||||
foreach(auto ele, eles) {
|
foreach(auto ele, eles) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "base/ffutil.h"
|
#include "base/ffutil.h"
|
||||||
#include "base/lodateselector.h"
|
#include "base/calendarbutton.h"
|
||||||
#include "program/eaclock.h"
|
#include "program/eaclock.h"
|
||||||
#include "program/ebase.h"
|
#include "program/ebase.h"
|
||||||
#include "program/edclock.h"
|
#include "program/edclock.h"
|
||||||
|
@ -15,13 +15,13 @@
|
||||||
#include "program/etimer2.h"
|
#include "program/etimer2.h"
|
||||||
#include "program/evideo.h"
|
#include "program/evideo.h"
|
||||||
#include "program/eweb.h"
|
#include "program/eweb.h"
|
||||||
#include "tools.h"
|
|
||||||
#include <QDateEdit>
|
#include <QDateEdit>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
class PageScene : public QGraphicsScene {
|
class PageScene : public QGraphicsScene {
|
||||||
public:
|
public:
|
||||||
|
@ -259,6 +259,13 @@ QPushButton[ssName="weeklySelector"]:checked {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdLoop);
|
hBox->addWidget(fdLoop);
|
||||||
|
|
||||||
|
auto edWaitAudio = new QCheckBox(tr("Wait Audio"));
|
||||||
|
edWaitAudio->setChecked(mAttr["waitAudio"].toBool());
|
||||||
|
connect(edWaitAudio, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
|
mAttr["waitAudio"] = checked;
|
||||||
|
});
|
||||||
|
hBox->addWidget(edWaitAudio);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
@ -287,7 +294,7 @@ QPushButton[ssName="weeklySelector"]:checked {
|
||||||
|
|
||||||
mAudiosList = new QListWidget;
|
mAudiosList = new QListWidget;
|
||||||
connect(btnAdd, &QPushButton::clicked, mAttrWgt, [this, fdTtlDur] {
|
connect(btnAdd, &QPushButton::clicked, mAttrWgt, [this, fdTtlDur] {
|
||||||
auto files = QFileDialog::getOpenFileNames(mAttrWgt, tr("Select File"), gFileHome);
|
auto files = QFileDialog::getOpenFileNames(mAttrWgt, translate("","Select File"), gFileHome);
|
||||||
int durs = fdTtlDur->text().toInt();
|
int durs = fdTtlDur->text().toInt();
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
int64_t dur;
|
int64_t dur;
|
||||||
|
@ -435,9 +442,9 @@ QPushButton[ssName="weeklySelector"]:checked {
|
||||||
fdStart->setDate(QDate::fromString(validDate["start"].toString(), "yyyy-MM-dd"));
|
fdStart->setDate(QDate::fromString(validDate["start"].toString(), "yyyy-MM-dd"));
|
||||||
hBox->addWidget(fdStart);
|
hBox->addWidget(fdStart);
|
||||||
|
|
||||||
auto bnDateStart = new LoDateSelector();
|
auto bnDateStart = new CalendarButton;
|
||||||
bnDateStart->setEnabled(isDateValid);
|
bnDateStart->setEnabled(isDateValid);
|
||||||
connect(bnDateStart, &LoDateSelector::sDateSelected, fdStart, &QDateEdit::setDate);
|
connect(bnDateStart->calendar, &QCalendarWidget::clicked, fdStart, &QDateEdit::setDate);
|
||||||
hBox->addWidget(bnDateStart);
|
hBox->addWidget(bnDateStart);
|
||||||
|
|
||||||
hBox->addWidget(new QLabel("~"));
|
hBox->addWidget(new QLabel("~"));
|
||||||
|
@ -472,9 +479,9 @@ QPushButton[ssName="weeklySelector"]:checked {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdEnd);
|
hBox->addWidget(fdEnd);
|
||||||
|
|
||||||
auto bnDateEnd = new LoDateSelector();
|
auto bnDateEnd = new CalendarButton;
|
||||||
bnDateEnd->setEnabled(isDateValid);
|
bnDateEnd->setEnabled(isDateValid);
|
||||||
connect(bnDateEnd, &LoDateSelector::sDateSelected, fdEnd, &QDateEdit::setDate);
|
connect(bnDateEnd->calendar, &QCalendarWidget::clicked, fdEnd, &QDateEdit::setDate);
|
||||||
hBox->addWidget(bnDateEnd);
|
hBox->addWidget(bnDateEnd);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
|
|
||||||
ProgItem *gProgItem{0};
|
ProgItem *gProgItem = 0;
|
||||||
|
|
||||||
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
||||||
gProgItem = progItem;
|
gProgItem = progItem;
|
||||||
|
@ -75,7 +75,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
// saveThread = QThread::create([this](){
|
// saveThread = QThread::create([this](){
|
||||||
// save();
|
// save();
|
||||||
// });
|
// });
|
||||||
// dlgTip->lock(tr("Saving..."),tr("Success"),tr("Save failed"));
|
// dlgTip->lock(tr("Saving..."),translate("","Success"),tr("Save failed"));
|
||||||
// connect(saveThread, SIGNAL(finished()), dlgTip, SLOT(unlock()));//显示正在保存提示对话框
|
// connect(saveThread, SIGNAL(finished()), dlgTip, SLOT(unlock()));//显示正在保存提示对话框
|
||||||
// connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
// connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
||||||
// connect(saveThread, &QThread::finished, this, [this] {
|
// connect(saveThread, &QThread::finished, this, [this] {
|
||||||
|
@ -111,8 +111,8 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
ProgCreateDlg dlg(mProgItem->mName, mProgItem->mWidth, mProgItem->mHeight, mProgItem->mRemark, widthsStr, mProgItem->isVer, this);
|
ProgCreateDlg dlg(mProgItem->mName, mProgItem->mWidth, mProgItem->mHeight, mProgItem->mRemark, widthsStr, mProgItem->isVer, this);
|
||||||
dlg.edIsInsert->setChecked(mProgItem->isInsert);
|
dlg.edIsInsert->setChecked(mProgItem->isInsert);
|
||||||
if(dlg.exec() != QDialog::Accepted) return;
|
if(dlg.exec() != QDialog::Accepted) return;
|
||||||
mProgItem->mWidth = dlg.fdWidth->value();
|
mProgItem->mWidth = gProgWidth = dlg.fdWidth->value();
|
||||||
mProgItem->mHeight = dlg.fdHeight->value();
|
mProgItem->mHeight = gProgHeight = dlg.fdHeight->value();
|
||||||
mProgItem->mRemark = dlg.fdRemark->toPlainText();
|
mProgItem->mRemark = dlg.fdRemark->toPlainText();
|
||||||
mProgItem->isInsert = dlg.edIsInsert->isChecked();
|
mProgItem->isInsert = dlg.edIsInsert->isChecked();
|
||||||
mProgItem->partLens.clear();
|
mProgItem->partLens.clear();
|
||||||
|
@ -195,6 +195,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer")+"2");
|
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer")+"2");
|
||||||
action->setData(EBase::Timer2);
|
action->setData(EBase::Timer2);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
|
#ifndef leyide
|
||||||
action = new QAction(QIcon(":/res/program/demo-video.png"), tr("Demos"));
|
action = new QAction(QIcon(":/res/program/demo-video.png"), tr("Demos"));
|
||||||
connect(action, &QAction::triggered, this, [this] {
|
connect(action, &QAction::triggered, this, [this] {
|
||||||
auto file = QFileDialog::getOpenFileName(this, tr("Open Demo"), QApplication::applicationDirPath()+"/Demos");
|
auto file = QFileDialog::getOpenFileName(this, tr("Open Demo"), QApplication::applicationDirPath()+"/Demos");
|
||||||
|
@ -226,7 +227,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
|
#endif
|
||||||
toolBar->addSeparator();
|
toolBar->addSeparator();
|
||||||
|
|
||||||
action = new QAction(QIcon(":/res/program/preview.png"), tr("Play")+"/"+tr("Stop"));
|
action = new QAction(QIcon(":/res/program/preview.png"), tr("Play")+"/"+tr("Stop"));
|
||||||
|
@ -294,7 +295,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
if(mNewEleY+iNewHeight>mProgItem->mHeight) mNewEleY=0;
|
if(mNewEleY+iNewHeight>mProgItem->mHeight) mNewEleY=0;
|
||||||
auto type = data.toInt();
|
auto type = data.toInt();
|
||||||
if(type==EBase::Image) {
|
if(type==EBase::Image) {
|
||||||
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EPhoto::filters());
|
auto files = QFileDialog::getOpenFileNames(this, translate("","Select File"), gFileHome, EPhoto::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto ePhoto = EPhoto::create(files[i], mPageItem);
|
auto ePhoto = EPhoto::create(files[i], mPageItem);
|
||||||
if(ePhoto==0) continue;
|
if(ePhoto==0) continue;
|
||||||
|
@ -311,7 +312,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(type==EBase::Gif) {
|
} else if(type==EBase::Gif) {
|
||||||
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EGif::filters());
|
auto files = QFileDialog::getOpenFileNames(this, translate("","Select File"), gFileHome, EGif::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto eGif = EGif::create(files[i], mPageItem);
|
auto eGif = EGif::create(files[i], mPageItem);
|
||||||
if(eGif==0) continue;
|
if(eGif==0) continue;
|
||||||
|
@ -329,7 +330,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(type==EBase::Video) {
|
} else if(type==EBase::Video) {
|
||||||
auto file = QFileDialog::getOpenFileName(this, tr("Select File"), gFileHome, EVideo::filters());
|
auto file = QFileDialog::getOpenFileName(this, translate("","Select File"), gFileHome, EVideo::filters());
|
||||||
if(file.isEmpty()) return;
|
if(file.isEmpty()) return;
|
||||||
auto eVideo = EVideo::create(file, mPageItem);
|
auto eVideo = EVideo::create(file, mPageItem);
|
||||||
if(eVideo==nullptr) return;
|
if(eVideo==nullptr) return;
|
||||||
|
@ -419,7 +420,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
if(listPage->count() == 1) mPageEditor->onClean();
|
if(listPage->count() == 1) mPageEditor->onClean();
|
||||||
else if(listPage->count() > 1) {
|
else if(listPage->count() > 1) {
|
||||||
auto item = (PageListItem*) listPage->currentItem();
|
auto item = (PageListItem*) listPage->currentItem();
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"), tr("Are you sure you want to delete this program page?"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::information(this, translate("","Tip"), tr("Are you sure you want to delete this program page?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
if(res == QMessageBox::Ok) {
|
if(res == QMessageBox::Ok) {
|
||||||
delete item;
|
delete item;
|
||||||
if(listPage->count() > 0) listPage->setCurrentRow(0);
|
if(listPage->count() > 0) listPage->setCurrentRow(0);
|
||||||
|
@ -517,14 +518,14 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
scroll->setWidgetResizable(true);
|
scroll->setWidgetResizable(true);
|
||||||
scroll->setPalette(backTrans);
|
scroll->setPalette(backTrans);
|
||||||
mTabsAttr->addTab(scroll, tr("widget properties"));
|
mTabsAttr->addTab(scroll, tr("Widget Properties"));
|
||||||
|
|
||||||
scroll = new QScrollArea();
|
scroll = new QScrollArea();
|
||||||
scroll->setFrameShape(QFrame::NoFrame);
|
scroll->setFrameShape(QFrame::NoFrame);
|
||||||
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
scroll->setWidgetResizable(true);
|
scroll->setWidgetResizable(true);
|
||||||
scroll->setPalette(backTrans);
|
scroll->setPalette(backTrans);
|
||||||
mTabsAttr->addTab(scroll, tr("Page properties"));
|
mTabsAttr->addTab(scroll, tr("Program Properties"));
|
||||||
mTabsAttr->setCurrentIndex(0);
|
mTabsAttr->setCurrentIndex(0);
|
||||||
|
|
||||||
hBox->addWidget(mTabsAttr);
|
hBox->addWidget(mTabsAttr);
|
||||||
|
@ -578,7 +579,7 @@ bool ProgEditorWin::isProgChanged() {
|
||||||
void ProgEditorWin::closeEvent(QCloseEvent *event) {
|
void ProgEditorWin::closeEvent(QCloseEvent *event) {
|
||||||
mProgItem->onSetProgram();
|
mProgItem->onSetProgram();
|
||||||
if(isProgChanged()) {
|
if(isProgChanged()) {
|
||||||
auto res = QMessageBox::question(this, tr("Tip Info"), tr("Do you want to save the modifications?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
|
auto res = QMessageBox::question(this, translate("","Tip"), tr("Do you want to save the modifications?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
|
||||||
if(res == QMessageBox::Yes) onSave();
|
if(res == QMessageBox::Yes) onSave();
|
||||||
else if(res == QMessageBox::Cancel) event->ignore();
|
else if(res == QMessageBox::Cancel) event->ignore();
|
||||||
}
|
}
|
||||||
|
@ -592,18 +593,18 @@ bool ProgEditorWin::save() {
|
||||||
//停止每个幻灯片的元素
|
//停止每个幻灯片的元素
|
||||||
int cnt = listPage->count();
|
int cnt = listPage->count();
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
auto items = static_cast<PageListItem*>(listPage->item(i))->mScene->items();
|
auto items = ((PageListItem*) listPage->item(i))->mScene->items();
|
||||||
foreach(auto item, items) static_cast<EBase*>(item)->freeFiles();
|
for(auto item : items) ((EBase*) item)->freeFiles();
|
||||||
}
|
}
|
||||||
QDir progDir(mProgItem->mProgDir);
|
QDir progDir(mProgItem->mProgDir);
|
||||||
if(! progDir.exists() && ! progDir.mkdir(mProgItem->mProgDir)) {
|
if(! progDir.exists() && ! progDir.mkdir(mProgItem->mProgDir)) {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Create Dir failed")+": "+mProgItem->mProgDir);
|
QMessageBox::critical(this, translate("","Error"), tr("Failed to Create Forder")+": "+mProgItem->mProgDir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto pageNames = progDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
auto pageNames = progDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
for(QString &pageName : pageNames) if(! progDir.rename(pageName, pageName + PAGEDEL_SUFFIX)) {
|
for(QString &pageName : pageNames) if(! progDir.rename(pageName, pageName + PAGEDEL_SUFFIX)) {
|
||||||
rtn = 0;
|
rtn = 0;
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Rename fail when saving")+" "+pageName);
|
QMessageBox::critical(this, translate("","Error"), tr("Failed to Rename Forder")+": "+pageName);
|
||||||
}
|
}
|
||||||
//保存每个页面的元素和页面属性到page.json文档
|
//保存每个页面的元素和页面属性到page.json文档
|
||||||
mPageJsons.clear();
|
mPageJsons.clear();
|
||||||
|
@ -617,27 +618,27 @@ bool ProgEditorWin::save() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageNames = progDir.entryList(QStringList("*" PAGEDEL_SUFFIX));
|
pageNames = progDir.entryList(QStringList("*" PAGEDEL_SUFFIX));
|
||||||
foreach(QString pageName, pageNames) {
|
for(auto pageName : pageNames) {
|
||||||
if(! QDir(mProgItem->mProgDir + "/" + pageName).removeRecursively()) {
|
if(! QDir(mProgItem->mProgDir + "/" + pageName).removeRecursively()) {
|
||||||
rtn = 0;
|
rtn = 0;
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Remove Recursively fail when saving")+" "+pageName);
|
QMessageBox::critical(this, translate("","Error"), tr("Failed to Remove Recursively")+" "+pageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
auto items = static_cast<PageListItem*>(listPage->item(i))->mScene->items();
|
auto items = static_cast<PageListItem*>(listPage->item(i))->mScene->items();
|
||||||
foreach(auto item, items) static_cast<EBase*>(item)->loadFiles();
|
for(auto item : items) static_cast<EBase*>(item)->loadFiles();
|
||||||
}
|
}
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgEditorWin::onSave() {
|
void ProgEditorWin::onSave() {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("Saving..."), tr("Success"));
|
auto waitingDlg = new WaitingDlg(this, tr("Saving..."), translate("","Success"));
|
||||||
waitingDlg->setWindowFlag(Qt::WindowCloseButtonHint, 0);
|
waitingDlg->setWindowFlag(Qt::WindowCloseButtonHint, 0);
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
if(save()) waitingDlg->success();
|
if(save()) {
|
||||||
else waitingDlg->close();
|
waitingDlg->success();
|
||||||
waitingDlg->exec();
|
mProgItem->onSetProgram();
|
||||||
mProgItem->onSetProgram();
|
} else waitingDlg->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgEditorWin::onAddPage() {
|
void ProgEditorWin::onAddPage() {
|
||||||
|
@ -665,7 +666,7 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
||||||
#endif
|
#endif
|
||||||
setWindowTitle(tr("Solution Information"));
|
setWindowTitle(tr("Solution Info"));
|
||||||
auto vBox = new VBox(this);
|
auto vBox = new VBox(this);
|
||||||
vBox->setContentsMargins(6,0,6,6);
|
vBox->setContentsMargins(6,0,6,6);
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
|
|
|
@ -76,7 +76,7 @@ QPushButton:hover{background-color: #cccccc;}
|
||||||
|
|
||||||
auto fdPassword = new QLineEdit;
|
auto fdPassword = new QLineEdit;
|
||||||
fdPassword->setEchoMode(QLineEdit::Password);
|
fdPassword->setEchoMode(QLineEdit::Password);
|
||||||
fdPassword->setPlaceholderText(QObject::tr("Input password"));
|
fdPassword->setPlaceholderText(translate("","Input Password"));
|
||||||
hBox->addWidget(fdPassword);
|
hBox->addWidget(fdPassword);
|
||||||
|
|
||||||
auto fdDrives = new ListWgt;
|
auto fdDrives = new ListWgt;
|
||||||
|
@ -102,8 +102,8 @@ QPushButton:hover{background-color: #cccccc;}
|
||||||
dlg.accept();
|
dlg.accept();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(fdDrives->count() <= 0) QMessageBox::warning(&dlg, QObject::tr("Tip"), QObject::tr("No checked USB device"));
|
if(fdDrives->count() <= 0) QMessageBox::warning(&dlg, translate("","Tip"), QObject::tr("No checked USB device"));
|
||||||
else QMessageBox::warning(&dlg, QObject::tr("Tip"), QObject::tr("please select usb device in list"));
|
else QMessageBox::warning(&dlg, translate("","Tip"), QObject::tr("please select usb device in list"));
|
||||||
});
|
});
|
||||||
vBox->addWidget(btnBox);
|
vBox->addWidget(btnBox);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto btnRefresh = new QPushButton(tr("Refresh"));
|
auto btnRefresh = new QPushButton(translate("","Refresh"));
|
||||||
connect(btnRefresh, &QPushButton::clicked, this, [=] {
|
connect(btnRefresh, &QPushButton::clicked, this, [=] {
|
||||||
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
|
@ -122,26 +122,26 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
|
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
|
||||||
if(! item->isLocked) return;
|
if(! item->isLocked) return;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
auto pwd = QInputDialog::getText(this, translate("","Input Password"), translate("","Input Password"), QLineEdit::Password, QString(), &ok);
|
||||||
if(! ok) return;
|
if(! ok) return;
|
||||||
JObj json;
|
JObj json;
|
||||||
json.insert("_id", "VerifyPassword");
|
json.insert("_id", "VerifyPassword");
|
||||||
json.insert("_type", "VerifyPassword");
|
json.insert("_type", "VerifyPassword");
|
||||||
json.insert("pwd", pwd);
|
json.insert("pwd", pwd);
|
||||||
auto waitingDlg = new WaitingDlg(item->btnUnlock, tr("VerifyPassword")+" ...");
|
auto waitingDlg = new WaitingDlg(item->btnUnlock, tr("Verify Password")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
ConnReply(reply, waitingDlg) [=] {
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, QObject::tr("Error"), err);
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! json["result"].toBool()) {
|
if(! json["result"].toBool()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::warning(this, tr("Tip Info"), tr("password is wrong"));
|
QMessageBox::warning(this, translate("","Tip"), tr("password is wrong"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
|
@ -181,7 +181,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
table->addCol("id", "ID", 130).margin(4);
|
table->addCol("id", "ID", 130).margin(4);
|
||||||
table->addCol("online", tr("Online"), 40);
|
table->addCol("online", tr("Online"), 40);
|
||||||
table->addCol("ip", "IP", 100);
|
table->addCol("ip", "IP", 100);
|
||||||
table->addCol("size", tr("Screen Size"), 80).alignC(),
|
table->addCol("size", translate("","Screen Size"), 80).alignC(),
|
||||||
table->addCol("alias", tr("Alias"), 120);
|
table->addCol("alias", tr("Alias"), 120);
|
||||||
table->addCol("playerVer", "Player Ver", 70);
|
table->addCol("playerVer", "Player Ver", 70);
|
||||||
table->addCol("encrypt", tr("Security"), 40);
|
table->addCol("encrypt", tr("Security"), 40);
|
||||||
|
|
|
@ -41,6 +41,7 @@ void SendProgThread::run() {
|
||||||
req.insert("files", files);
|
req.insert("files", files);
|
||||||
req.insert("idList", JArray{"aaa"});
|
req.insert("idList", JArray{"aaa"});
|
||||||
req.insert("zVer", "xixun1");
|
req.insert("zVer", "xixun1");
|
||||||
|
//req.insert("isLauncher", true);
|
||||||
auto resNum = tcp.write(JToBytes(req));
|
auto resNum = tcp.write(JToBytes(req));
|
||||||
tcp.flush();
|
tcp.flush();
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten() || ! tcp.waitForReadyRead()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten() || ! tcp.waitForReadyRead()) {
|
||||||
|
@ -200,6 +201,17 @@ void SendProgThread::run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tcp.close();
|
tcp.close();
|
||||||
|
QString err;
|
||||||
|
auto json = JFrom(resp, &err);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
emit emErr(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
err = json["msg"].toStr();
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
emit emErr(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
emit emProgress(100);
|
emit emProgress(100);
|
||||||
emit emErr("OK");
|
emit emErr("OK");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <queue>
|
||||||
extern "C"{
|
extern "C"{
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
@ -17,105 +18,107 @@ VideoSplitThread::VideoSplitThread(int elew, int eleh, int maxLen, int sph, std:
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSplitThread::run() {
|
void VideoSplitThread::run() {
|
||||||
AVFormatContext *in_fmt = avformat_alloc_context(), *out_fmt = 0;
|
AVFormatContext *fmt_in = avformat_alloc_context(), *fmt_out = 0;
|
||||||
AVCodecContext *de_ctx = 0, *en_ctx = 0;
|
AVCodecContext *de_ctx = 0, *en_ctx = 0;
|
||||||
QString err;
|
QString err;
|
||||||
char buf[AV_ERROR_MAX_STRING_SIZE];
|
char buf[AV_ERROR_MAX_STRING_SIZE];
|
||||||
int ret;
|
int ret;
|
||||||
{
|
{
|
||||||
if((ret = avformat_open_input(&in_fmt, file.constData(), 0, 0)) < 0) {
|
if((ret = avformat_open_input(&fmt_in, file.constData(), 0, 0)) < 0) {
|
||||||
err = QString("Couldn't open input stream. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("Couldn't open input stream. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
if((ret = avformat_find_stream_info(in_fmt, nullptr)) < 0) {
|
if((ret = avformat_find_stream_info(fmt_in, 0)) < 0) {
|
||||||
err = QString("Couldn't find stream information. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("Couldn't find stream information. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
auto outfile = file+"-square.mp4";
|
auto outfile = file+"-square.mp4";
|
||||||
if((ret = avformat_alloc_output_context2(&out_fmt, 0, "mp4", outfile.constData())) < 0) {
|
if((ret = avformat_alloc_output_context2(&fmt_out, 0, "mp4", outfile.constData())) < 0) {
|
||||||
err = QString("avformat_alloc_output_context2 fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("avformat_alloc_output_context2 fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
int vi_idx = -1;
|
int video_idx = -1;
|
||||||
AVStream *out_vi_stream;
|
AVStream *stream_out_video;
|
||||||
for(uint ss=0; ss<in_fmt->nb_streams; ss++) {
|
for(uint ss=0; ss<fmt_in->nb_streams; ss++) {
|
||||||
AVStream *stream = in_fmt->streams[ss];
|
auto streamIn = fmt_in->streams[ss];
|
||||||
qDebug()<<"codec_type"<<av_get_media_type_string(stream->codecpar->codec_type);
|
qDebug() << streamIn->index << av_get_media_type_string(streamIn->codecpar->codec_type);
|
||||||
if(stream->codecpar->codec_type == AVMEDIA_TYPE_DATA) continue;
|
if(streamIn->codecpar->codec_type == AVMEDIA_TYPE_DATA) continue;
|
||||||
AVStream *out_stream = avformat_new_stream(out_fmt, 0);
|
auto streamOut = avformat_new_stream(fmt_out, 0);
|
||||||
if(vi_idx == -1 && stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
if((ret = avcodec_parameters_copy(streamOut->codecpar, streamIn->codecpar)) < 0) {
|
||||||
vi_idx = ss;
|
err = QString("avcodec_parameters_copy fail. ") + av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
out_vi_stream = out_stream;
|
goto free;
|
||||||
} else {
|
}
|
||||||
if((ret = avcodec_parameters_copy(out_stream->codecpar, stream->codecpar)) < 0) {
|
streamOut->time_base = streamIn->time_base;
|
||||||
err = QString("avcodec_parameters_copy fail. ") + av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
streamOut->start_time = streamIn->start_time;
|
||||||
goto free;
|
streamOut->duration = streamIn->duration;
|
||||||
}
|
if(video_idx == -1 && streamIn->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
video_idx = ss;
|
||||||
|
stream_out_video = streamOut;
|
||||||
}
|
}
|
||||||
out_stream->time_base = stream->time_base;
|
|
||||||
out_stream->start_time = stream->start_time;
|
|
||||||
out_stream->duration = stream->duration;
|
|
||||||
}
|
}
|
||||||
if(vi_idx == -1) {
|
if(video_idx == -1) {
|
||||||
err = "Didn't find a Video Stream";
|
err = "Didn't find a Video Stream";
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto codecpar = in_fmt->streams[vi_idx]->codecpar;
|
auto par_in_video = fmt_in->streams[video_idx]->codecpar;
|
||||||
|
|
||||||
auto decoder = avcodec_find_decoder(codecpar->codec_id);
|
auto decoder = avcodec_find_decoder(par_in_video->codec_id);
|
||||||
if(decoder==0) {
|
if(decoder==0) {
|
||||||
err = "Could not found Video Decoder";
|
err = "Could not found Video Decoder";
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
de_ctx = avcodec_alloc_context3(decoder);
|
de_ctx = avcodec_alloc_context3(decoder);
|
||||||
de_ctx->thread_count = 4;
|
de_ctx->thread_count = 4;
|
||||||
avcodec_parameters_to_context(de_ctx, codecpar);
|
avcodec_parameters_to_context(de_ctx, par_in_video);
|
||||||
if(avcodec_open2(de_ctx, decoder, 0) < 0) {
|
if(avcodec_open2(de_ctx, decoder, 0) < 0) {
|
||||||
err = "Could not open Video decode Ctx";
|
err = "Could not open Video decode Ctx";
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outPar = out_vi_stream->codecpar;
|
auto par_out_video = stream_out_video->codecpar;
|
||||||
outPar->codec_type = AVMEDIA_TYPE_VIDEO;
|
par_out_video->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
outPar->codec_id = AV_CODEC_ID_H264;
|
par_out_video->codec_id = AV_CODEC_ID_H264;
|
||||||
outPar->format = AV_PIX_FMT_YUV420P;
|
par_out_video->format = AV_PIX_FMT_YUV420P;
|
||||||
|
par_out_video->profile = 77;
|
||||||
|
par_out_video->level = 42;
|
||||||
if(isVer) {
|
if(isVer) {
|
||||||
outPar->height = maxLen;
|
par_out_video->height = maxLen;
|
||||||
outPar->width = mSPH*mWidths.size();
|
par_out_video->width = mSPH * (int)mWidths.size();
|
||||||
} else {
|
} else {
|
||||||
outPar->width = maxLen;
|
par_out_video->width = maxLen;
|
||||||
outPar->height = mSPH*mWidths.size();
|
par_out_video->height = mSPH * (int)mWidths.size();
|
||||||
}
|
}
|
||||||
|
qDebug().nospace()<<"out "<<par_out_video->width<<" x "<<par_out_video->height;
|
||||||
|
|
||||||
auto encoder = avcodec_find_encoder(outPar->codec_id);
|
auto encoder = avcodec_find_encoder(par_out_video->codec_id);
|
||||||
if(encoder==0) {
|
if(encoder==0) {
|
||||||
fprintf(stderr, "Codec not found\n");
|
fprintf(stderr, "Codec not found\n");
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
en_ctx = avcodec_alloc_context3(encoder);
|
en_ctx = avcodec_alloc_context3(encoder);
|
||||||
en_ctx->thread_count = 4;
|
en_ctx->thread_count = 4;
|
||||||
avcodec_parameters_to_context(en_ctx, outPar);
|
avcodec_parameters_to_context(en_ctx, par_out_video);
|
||||||
en_ctx->bit_rate = outPar->width * outPar->height * 6;
|
en_ctx->bit_rate = par_out_video->width * par_out_video->height * 6;
|
||||||
en_ctx->gop_size = de_ctx->gop_size;
|
en_ctx->gop_size = de_ctx->gop_size;
|
||||||
en_ctx->max_b_frames = 3;
|
en_ctx->max_b_frames = 0;
|
||||||
en_ctx->time_base = out_vi_stream->time_base;
|
en_ctx->time_base = stream_out_video->time_base;
|
||||||
|
|
||||||
if((ret = avcodec_open2(en_ctx, encoder, 0)) < 0) {
|
if((ret = avcodec_open2(en_ctx, encoder, 0)) < 0) {
|
||||||
err = QString("Open video encode ctx failed. ") + av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("Open video encode ctx failed. ") + av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
if(out_fmt->flags & AVFMT_NOFILE) qDebug()<<"AVFMT_NOFILE";
|
if(fmt_out->flags & AVFMT_NOFILE) qDebug()<<"AVFMT_NOFILE";
|
||||||
else if((ret = avio_open(&out_fmt->pb, outfile.constData(), AVIO_FLAG_WRITE)) < 0) {
|
else if((ret = avio_open(&fmt_out->pb, outfile.constData(), AVIO_FLAG_WRITE)) < 0) {
|
||||||
err = QString("avio_open fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("avio_open fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
if((ret = avformat_write_header(out_fmt, 0)) < 0) {
|
if((ret = avformat_write_header(fmt_out, 0)) < 0) {
|
||||||
err = QString("avformat_write_header fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("avformat_write_header fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
auto sws_ctx = sws_getContext(de_ctx->width, de_ctx->height, de_ctx->pix_fmt, mEleW, mEleH, AV_PIX_FMT_RGB32, SWS_FAST_BILINEAR, 0, 0, 0);
|
auto sws_ctx = sws_getContext(de_ctx->width, de_ctx->height, de_ctx->pix_fmt, mEleW, mEleH, AV_PIX_FMT_RGB32, SWS_FAST_BILINEAR, 0, 0, 0);
|
||||||
auto out_sws_ctx = sws_getContext(outPar->width, outPar->height, AV_PIX_FMT_RGB32, outPar->width, outPar->height, AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);
|
auto out_sws_ctx = sws_getContext(par_out_video->width, par_out_video->height, AV_PIX_FMT_RGB32, par_out_video->width, par_out_video->height, AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);
|
||||||
auto packet = av_packet_alloc();
|
auto packet = av_packet_alloc();
|
||||||
auto frm = av_frame_alloc();
|
auto frm = av_frame_alloc();
|
||||||
|
|
||||||
|
@ -123,20 +126,24 @@ void VideoSplitThread::run() {
|
||||||
uint8_t *img_data[4]{new uchar[img_linesize[0] * mEleH]};
|
uint8_t *img_data[4]{new uchar[img_linesize[0] * mEleH]};
|
||||||
QImage img(img_data[0], mEleW, mEleH, img_linesize[0], QImage::Format_ARGB32, imgCleanupHandler, img_data[0]);
|
QImage img(img_data[0], mEleW, mEleH, img_linesize[0], QImage::Format_ARGB32, imgCleanupHandler, img_data[0]);
|
||||||
|
|
||||||
int out_img_linesize[4]{(outPar->width*4+63)/64*64};
|
int out_img_linesize[4]{(par_out_video->width*4+63)/64*64};
|
||||||
uint8_t *out_img_data[4]{new uchar[out_img_linesize[0] * outPar->height]};
|
uint8_t *out_img_data[4]{new uchar[out_img_linesize[0] * par_out_video->height]};
|
||||||
QImage out_img(out_img_data[0], outPar->width, outPar->height, out_img_linesize[0], QImage::Format_ARGB32, imgCleanupHandler, out_img_data[0]);
|
QImage out_img(out_img_data[0], par_out_video->width, par_out_video->height, out_img_linesize[0], QImage::Format_ARGB32, imgCleanupHandler, out_img_data[0]);
|
||||||
QPainter painter(&out_img);
|
QPainter painter(&out_img);
|
||||||
while(1) {
|
while(1) {
|
||||||
if((ret = av_read_frame(in_fmt, packet)) < 0) {
|
if((ret = av_read_frame(fmt_in, packet)) < 0) {
|
||||||
if(ret!=AVERROR_EOF) {
|
if(ret!=AVERROR_EOF) {
|
||||||
err = QString("Read packet fail: ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("Read packet fail: ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = avcodec_send_packet(de_ctx, 0);
|
ret = avcodec_send_packet(de_ctx, 0);
|
||||||
} else {
|
} else {
|
||||||
if(packet->stream_index != vi_idx) {
|
if(packet->stream_index != video_idx) {
|
||||||
av_interleaved_write_frame(out_fmt, packet);
|
ret = av_interleaved_write_frame(fmt_out, packet);
|
||||||
|
if(ret < 0) {
|
||||||
|
err = QString("write_frame(A) failed. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
|
goto free2;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = avcodec_send_packet(de_ctx, packet);
|
ret = avcodec_send_packet(de_ctx, packet);
|
||||||
|
@ -171,40 +178,51 @@ void VideoSplitThread::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto pts = frm->pts;
|
auto pts = frm->pts;
|
||||||
|
auto pkt_dts = frm->pkt_dts;
|
||||||
auto dur = frm->pkt_duration;
|
auto dur = frm->pkt_duration;
|
||||||
av_frame_unref(frm);
|
av_frame_unref(frm);
|
||||||
frm->pts = pts;
|
frm->pts = pts;
|
||||||
|
frm->pkt_dts = pkt_dts;
|
||||||
frm->pkt_duration = dur;
|
frm->pkt_duration = dur;
|
||||||
frm->format = AV_PIX_FMT_YUV420P;
|
frm->format = AV_PIX_FMT_YUV420P;
|
||||||
frm->width = outPar->width;
|
frm->width = par_out_video->width;
|
||||||
frm->height = outPar->height;
|
frm->height = par_out_video->height;
|
||||||
if((ret = av_frame_get_buffer(frm, 0)) < 0) {
|
if((ret = av_frame_get_buffer(frm, 0)) < 0) {
|
||||||
err = QString("av_frame_get_buffer fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("av_frame_get_buffer fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free2;
|
goto free2;
|
||||||
}
|
}
|
||||||
sws_scale(out_sws_ctx, out_img_data, out_img_linesize, 0, outPar->height, frm->data, frm->linesize);
|
sws_scale(out_sws_ctx, out_img_data, out_img_linesize, 0, par_out_video->height, frm->data, frm->linesize);
|
||||||
ret = avcodec_send_frame(en_ctx, frm);
|
ret = avcodec_send_frame(en_ctx, frm);
|
||||||
int pro = frm->pts*100/out_vi_stream->duration;
|
int progress = frm->pts * 100 / stream_out_video->duration;
|
||||||
if(pro > lastPro) {
|
if(progress > lastProgress) {
|
||||||
lastPro = pro;
|
lastProgress = progress;
|
||||||
emit emProgress(pro);
|
emit emProgress(progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
err = QString("avcodec_send_frame fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
err = QString("avcodec_send_frame failed. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
goto free2;
|
goto free2;
|
||||||
}
|
}
|
||||||
while((ret = avcodec_receive_packet(en_ctx, packet)) != AVERROR(EAGAIN)) {
|
while((ret = avcodec_receive_packet(en_ctx, packet)) != AVERROR(EAGAIN)) {
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
if(ret!=AVERROR_EOF) err = QString("Receive frame fail: ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
if(ret!=AVERROR_EOF) err = QString("Receive frame fail: ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
else {
|
else {
|
||||||
av_interleaved_write_frame(out_fmt, 0);
|
ret = av_interleaved_write_frame(fmt_out, 0);
|
||||||
av_write_trailer(out_fmt);
|
if(ret < 0) {
|
||||||
|
err = QString("write_frame(0) failed. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
|
goto free2;
|
||||||
|
}
|
||||||
|
av_write_trailer(fmt_out);
|
||||||
emit emProgress(100);
|
emit emProgress(100);
|
||||||
}
|
}
|
||||||
goto free2;
|
goto free2;
|
||||||
} else {
|
} else {
|
||||||
av_interleaved_write_frame(out_fmt, packet);
|
packet->stream_index = video_idx;
|
||||||
|
ret = av_interleaved_write_frame(fmt_out, packet);
|
||||||
|
if(ret < 0) {
|
||||||
|
err = QString("write_frame(V) failed. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
|
||||||
|
goto free2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,8 +236,8 @@ void VideoSplitThread::run() {
|
||||||
free:
|
free:
|
||||||
avcodec_free_context(&de_ctx);
|
avcodec_free_context(&de_ctx);
|
||||||
avcodec_free_context(&en_ctx);
|
avcodec_free_context(&en_ctx);
|
||||||
avformat_close_input(&in_fmt);
|
avformat_close_input(&fmt_in);
|
||||||
avio_closep(&out_fmt->pb);
|
avio_closep(&fmt_out->pb);
|
||||||
if(out_fmt) avformat_free_context(out_fmt);
|
if(fmt_out) avformat_free_context(fmt_out);
|
||||||
emit emErr(err);
|
emit emErr(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ public slots:
|
||||||
stoped = true;
|
stoped = true;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int lastPro{0};
|
int lastProgress = 0;
|
||||||
std::atomic_bool stoped{false};
|
std::atomic_bool stoped = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEOSPLITTHREAD_H
|
#endif // VIDEOSPLITTHREAD_H
|
||||||
|
|
|
@ -1,37 +1,48 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>res/signal-0.png</file>
|
|
||||||
<file>res/signal-1.png</file>
|
|
||||||
<file>res/signal-2.png</file>
|
|
||||||
<file>res/signal-3.png</file>
|
|
||||||
<file>res/signal-4.png</file>
|
|
||||||
<file>res/signal-5.png</file>
|
|
||||||
<file>css.css</file>
|
<file>css.css</file>
|
||||||
<file>res/AdvParam.png</file>
|
<file>res/AdvParam.png</file>
|
||||||
<file>res/AppSetting.png</file>
|
<file>res/AppSetting.png</file>
|
||||||
<file>res/AppSettingTip.png</file>
|
<file>res/AppSettingTip.png</file>
|
||||||
<file>res/ArrowDropDown.png</file>
|
<file>res/ArrowDropDown.png</file>
|
||||||
<file>res/ArrowDropUp.png</file>
|
<file>res/ArrowDropUp.png</file>
|
||||||
|
<file>res/Calendar-gray.png</file>
|
||||||
|
<file>res/Calendar.png</file>
|
||||||
<file>res/CheckBoxChecked.png</file>
|
<file>res/CheckBoxChecked.png</file>
|
||||||
<file>res/CheckBoxUnchecked.png</file>
|
<file>res/CheckBoxUnchecked.png</file>
|
||||||
<file>res/DeviceNum_All.png</file>
|
|
||||||
<file>res/FlashArrow.png</file>
|
|
||||||
<file>res/Lock.png</file>
|
|
||||||
<file>res/offline.png</file>
|
|
||||||
<file>res/online.png</file>
|
|
||||||
<file>res/UnLock.png</file>
|
|
||||||
<file>res/info.png</file>
|
|
||||||
<file>res/deviceReadbackPic.png</file>
|
|
||||||
<file>res/DeviceManager_s.png</file>
|
<file>res/DeviceManager_s.png</file>
|
||||||
<file>res/DeviceManager_u.png</file>
|
<file>res/DeviceManager_u.png</file>
|
||||||
|
<file>res/DeviceNum_All.png</file>
|
||||||
<file>res/DeviceSetting_s.png</file>
|
<file>res/DeviceSetting_s.png</file>
|
||||||
<file>res/DeviceSetting_u.png</file>
|
<file>res/DeviceSetting_u.png</file>
|
||||||
|
<file>res/FlashArrow.png</file>
|
||||||
<file>res/GuangYingPin_s.png</file>
|
<file>res/GuangYingPin_s.png</file>
|
||||||
<file>res/GuangYingPin_u.png</file>
|
<file>res/GuangYingPin_u.png</file>
|
||||||
<file>res/Hdmi.png</file>
|
<file>res/Hdmi.png</file>
|
||||||
|
<file>res/Lock.png</file>
|
||||||
|
<file>res/Logo-citta.png</file>
|
||||||
|
<file>res/Logo-leyide.png</file>
|
||||||
<file>res/Logo.png</file>
|
<file>res/Logo.png</file>
|
||||||
<file>res/Logo-leyide.png</file>
|
<file>res/ProgramManager_s.png</file>
|
||||||
<file>res/Logo-citta.png</file>
|
<file>res/ProgramManager_u.png</file>
|
||||||
|
<file>res/UnLock.png</file>
|
||||||
|
<file>res/WndClose.png</file>
|
||||||
|
<file>res/WndMaximize.png</file>
|
||||||
|
<file>res/WndMinimize.png</file>
|
||||||
|
<file>res/bnBrightnessAdjustMent_s.png</file>
|
||||||
|
<file>res/bnNetConfig_s.png</file>
|
||||||
|
<file>res/bnPowerControl_s.png</file>
|
||||||
|
<file>res/bnVerifyClock_s.png</file>
|
||||||
|
<file>res/deviceReadbackPic.png</file>
|
||||||
|
<file>res/encrypt.png</file>
|
||||||
|
<file>res/groupbox-checked.png</file>
|
||||||
|
<file>res/groupbox-unchecked.png</file>
|
||||||
|
<file>res/info.png</file>
|
||||||
|
<file>res/loop.png</file>
|
||||||
|
<file>res/next.png</file>
|
||||||
|
<file>res/offline.png</file>
|
||||||
|
<file>res/online.png</file>
|
||||||
|
<file>res/previous.png</file>
|
||||||
<file>res/program/AClock.png</file>
|
<file>res/program/AClock.png</file>
|
||||||
<file>res/program/Add.png</file>
|
<file>res/program/Add.png</file>
|
||||||
<file>res/program/AddPlan.png</file>
|
<file>res/program/AddPlan.png</file>
|
||||||
|
@ -48,17 +59,7 @@
|
||||||
<file>res/program/Copy.png</file>
|
<file>res/program/Copy.png</file>
|
||||||
<file>res/program/Cut.png</file>
|
<file>res/program/Cut.png</file>
|
||||||
<file>res/program/DClock.png</file>
|
<file>res/program/DClock.png</file>
|
||||||
<file>res/program/DateSelect.png</file>
|
|
||||||
<file>res/program/DateSelect_e.png</file>
|
|
||||||
<file>res/program/DateSelect_enable.png</file>
|
|
||||||
<file>res/program/Delete.png</file>
|
<file>res/program/Delete.png</file>
|
||||||
<file>res/program/demo-video.png</file>
|
|
||||||
<file>res/program/TextAlignHC.png</file>
|
|
||||||
<file>res/program/TextAlignHL.png</file>
|
|
||||||
<file>res/program/TextAlignHR.png</file>
|
|
||||||
<file>res/program/TextAlignVB.png</file>
|
|
||||||
<file>res/program/TextAlignVC.png</file>
|
|
||||||
<file>res/program/TextAlignVT.png</file>
|
|
||||||
<file>res/program/Gif.png</file>
|
<file>res/program/Gif.png</file>
|
||||||
<file>res/program/GoDown.png</file>
|
<file>res/program/GoDown.png</file>
|
||||||
<file>res/program/GoUp.png</file>
|
<file>res/program/GoUp.png</file>
|
||||||
|
@ -79,6 +80,12 @@
|
||||||
<file>res/program/Setting.png</file>
|
<file>res/program/Setting.png</file>
|
||||||
<file>res/program/Temp.png</file>
|
<file>res/program/Temp.png</file>
|
||||||
<file>res/program/Text.png</file>
|
<file>res/program/Text.png</file>
|
||||||
|
<file>res/program/TextAlignHC.png</file>
|
||||||
|
<file>res/program/TextAlignHL.png</file>
|
||||||
|
<file>res/program/TextAlignHR.png</file>
|
||||||
|
<file>res/program/TextAlignVB.png</file>
|
||||||
|
<file>res/program/TextAlignVC.png</file>
|
||||||
|
<file>res/program/TextAlignVT.png</file>
|
||||||
<file>res/program/TileFull.png</file>
|
<file>res/program/TileFull.png</file>
|
||||||
<file>res/program/TileH.png</file>
|
<file>res/program/TileH.png</file>
|
||||||
<file>res/program/TileV.png</file>
|
<file>res/program/TileV.png</file>
|
||||||
|
@ -86,30 +93,22 @@
|
||||||
<file>res/program/Weather.png</file>
|
<file>res/program/Weather.png</file>
|
||||||
<file>res/program/Web.png</file>
|
<file>res/program/Web.png</file>
|
||||||
<file>res/program/Window.png</file>
|
<file>res/program/Window.png</file>
|
||||||
<file>res/program/preview.png</file>
|
|
||||||
<file>res/program/previewStop.png</file>
|
|
||||||
<file>res/program/bnExport_s.png</file>
|
<file>res/program/bnExport_s.png</file>
|
||||||
<file>res/program/bnExport_u.png</file>
|
<file>res/program/bnExport_u.png</file>
|
||||||
<file>res/program/bnSearch.png</file>
|
<file>res/program/bnSearch.png</file>
|
||||||
<file>res/program/bnSend_s.png</file>
|
<file>res/program/bnSend_s.png</file>
|
||||||
<file>res/program/bnSend_u.png</file>
|
<file>res/program/bnSend_u.png</file>
|
||||||
<file>res/ProgramManager_s.png</file>
|
<file>res/program/demo-video.png</file>
|
||||||
<file>res/ProgramManager_u.png</file>
|
<file>res/program/preview.png</file>
|
||||||
<file>res/WndClose.png</file>
|
<file>res/program/previewStop.png</file>
|
||||||
<file>res/WndMaximize.png</file>
|
|
||||||
<file>res/WndMinimize.png</file>
|
|
||||||
<file>res/bnBrightnessAdjustMent_s.png</file>
|
|
||||||
<file>res/bnNetConfig_s.png</file>
|
|
||||||
<file>res/bnPowerControl_s.png</file>
|
|
||||||
<file>res/bnVerifyClock_s.png</file>
|
|
||||||
<file>res/encrypt.png</file>
|
|
||||||
<file>res/groupbox-checked.png</file>
|
|
||||||
<file>res/groupbox-unchecked.png</file>
|
|
||||||
<file>res/loop.png</file>
|
|
||||||
<file>res/next.png</file>
|
|
||||||
<file>res/previous.png</file>
|
|
||||||
<file>res/random.png</file>
|
<file>res/random.png</file>
|
||||||
<file>res/reddot.png</file>
|
<file>res/reddot.png</file>
|
||||||
|
<file>res/signal-0.png</file>
|
||||||
|
<file>res/signal-1.png</file>
|
||||||
|
<file>res/signal-2.png</file>
|
||||||
|
<file>res/signal-3.png</file>
|
||||||
|
<file>res/signal-4.png</file>
|
||||||
|
<file>res/signal-5.png</file>
|
||||||
<file>res/splash.png</file>
|
<file>res/splash.png</file>
|
||||||
<file>res/test.png</file>
|
<file>res/test.png</file>
|
||||||
<file>res/video-pre.png</file>
|
<file>res/video-pre.png</file>
|
||||||
|
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.0 KiB |
|
@ -94,12 +94,12 @@ void Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont&
|
||||||
file.close();
|
file.close();
|
||||||
imgs.insert(name, md5);
|
imgs.insert(name, md5);
|
||||||
}
|
}
|
||||||
void Tools::saveImg2(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, JArray& imgs, const QString& str, const QString& name) {
|
void Tools::saveImg2(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, JArray& imgs, const QString& str, const QString& name, int height) {
|
||||||
JObj obj{
|
JObj obj{
|
||||||
{"name", name}
|
{"name", name}
|
||||||
};
|
};
|
||||||
if(! str.isEmpty()) {
|
if(! str.isEmpty()) {
|
||||||
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
QImage img(metric.horizontalAdvance(str), height ? height : metric.lineSpacing(), QImage::Format_ARGB32);
|
||||||
obj.insert("picWidth", img.width());
|
obj.insert("picWidth", img.width());
|
||||||
obj.insert("picHeight", img.height());
|
obj.insert("picHeight", img.height());
|
||||||
img.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
|
|