所有项目

This commit is contained in:
Gangphon 2025-05-06 18:28:05 +08:00
parent c57549264d
commit 5390821976
131 changed files with 16465 additions and 13578 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*/build/*
build-*
# QtCreator

View File

@ -10,7 +10,7 @@ RESOURCES += res.qrc
win32 {
EXE_SUFFIX = .exe
copy.files += $$files(ffmpeg/bin/*.dll)
# copy.files += $$files(ffmpeg/bin/*.dll)
# copy.files += 7z/7z.dll
# copy.files += 7z/7z.exe
@ -28,17 +28,17 @@ osx {
QMAKE_BUNDLE_DATA += copy
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
LIBS += -L$$PWD/ffmpeg$$DIR_SUFFIX/lib/\
-lavcodec \
-lavdevice \
-lavfilter \
-lavformat \
-lavutil \
-lswresample \
-lswscale
# INCLUDEPATH += $$PWD/ffmpeg$$DIR_SUFFIX/include
# LIBS += -L$$PWD/ffmpeg$$DIR_SUFFIX/lib/\
# -lavcodec \
# -lavdevice \
# -lavfilter \
# -lavformat \
# -lavutil \
# -lswresample \
# -lswscale
# 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
SOURCES += \
ffutil.cpp \
gutil/cu.cpp \
gutil/qaesencryption.cpp \
gutil/qcore.cpp \
@ -59,10 +58,11 @@ SOURCES += \
mainwindow.cpp \
mediapanel.cpp \
opendlg.cpp \
planpanel.cpp
outputpanel.cpp \
planpanel.cpp \
progresspanel.cpp
HEADERS += \
ffutil.h \
gutil/cu.h \
gutil/qaesencryption.h \
gutil/qcore.h \
@ -75,7 +75,9 @@ HEADERS += \
mainwindow.h \
mediapanel.h \
opendlg.h \
planpanel.h
outputpanel.h \
planpanel.h \
progresspanel.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin

View File

@ -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;
}

View File

@ -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

View File

@ -7,71 +7,54 @@
#include <QSpinBox>
#include <QtMath>
#include <QMouseEvent>
#include <QGraphicsVideoItem>
#include <QOpenGLWidget>
Layer::Layer(int idx, const QString &name, QWidget *parent) : QWidget(parent), idx(idx), name(name) {
mSidePen.setCapStyle(Qt::FlatCap);
mSidePen.setDashPattern(QVector<qreal>{1,3});
}
void Layer::paintEvent(QPaintEvent *event) {
void Layer::paintEvent(QPaintEvent *) {
QPainter painter(this);
if(isSelected) {
mSidePen.setColor(Qt::green);
painter.setPen(mSidePen);
if(gEditView->selected == this) {
painter.setPen(item ? Qt::cyan : Qt::green);
painter.drawRect(0, 0, width(), height());
m_rLT = QRectF(-HandleSize/2, -HandleSize/2, HandleSize, HandleSize);//左上角
m_rT = QRectF(width()/2 - HandleSize/2, -HandleSize/2, HandleSize, HandleSize);//上中
m_rRT = QRectF(width() - HandleSize/2, - HandleSize/2, HandleSize, HandleSize);//右上角
m_rL = QRectF(-HandleSize/2, height()/2 - HandleSize/2, HandleSize, HandleSize);
m_rR = QRectF(width() - HandleSize/2, height()/2 - HandleSize/2, HandleSize, HandleSize);
m_rLB = QRectF(-HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
m_rB = QRectF(width()/2 - HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
m_rRB = QRectF(width() - HandleSize/2, height() - HandleSize/2, HandleSize, HandleSize);
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);
painter.drawRect(hdlLT);
painter.drawRect(hdlT);
painter.drawRect(hdlRT);
painter.drawRect(hdlL);
painter.drawRect(hdlR);
painter.drawRect(hdlLB);
painter.drawRect(hdlB);
painter.drawRect(hdlRB);
} else {
mSidePen.setColor(Qt::darkGreen);
painter.setPen(mSidePen);
painter.setPen(item ? Qt::darkCyan : Qt::darkGreen);
painter.drawRect(0, 0, width(), height());
}
//磁条吸附时两化吸附的边
static QPen snapPen(Qt::green);
painter.setPen(snapPen);
QRectF rect(8, 8, width()-16, height()-16);
if(item) painter.drawText(rect, QString("%1\n%2×%3").arg(name).arg(sSize.width()).arg(sSize.height()), QTextOption(Qt::AlignCenter));
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());
else if(snapLR==2) painter.drawLine(width(), 0, width(), height());
if(snapTB==1) painter.drawLine(0, 0, width(), 0);
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) {
QWidget::mousePressEvent(e);
if(e->button() != Qt::LeftButton) return;
if(! isSelected) {
isSelected = true;
otherLayers.clear();
auto parent = this->parentWidget();
if(parent) {
auto children = parent->children();
for(auto child : children) if(child!=this) {
auto layer = dynamic_cast<Layer*>(child);
if(layer==0) continue;
layer->isSelected = false;
otherLayers.emplace_back(layer);
}
}
if(item) {
if(! gOutPanel->isVisible()) return;
if(gEditView->selected!=this) {
gOutPanel->enCurChanged = false;
gOutPanel->tree->setCurrentItem(item);
gOutPanel->enCurChanged = true;
}
} else if(gOutPanel->isVisible()) return;
gEditView->select(this);
setFrmSec(e->pos());
auto mousePos = e->globalPosition();
auto elePos = pos();
@ -91,8 +74,7 @@ void Layer::mouseReleaseEvent(QMouseEvent *event) {
QWidget::mouseReleaseEvent(event);
if(Qt::LeftButton == event->button()) {
mPressRel.setX(FLT_MAX);
clearSnap();
for(auto ele : otherLayers) ele->clearSnap();
for(auto layer : gEditView->layers) layer->clearSnap();
}
}
#define SnapSpace 6
@ -101,163 +83,167 @@ void Layer::mouseMoveEvent(QMouseEvent *e) {
setFrmSec(e->pos());
return;
}
if(! isSelected) return;
if(gEditView->selected != this) return;
if(mFrmSec==Qt::NoSection || mPressRel.x()>=FLT_MAX) return;
auto mousePos = e->globalPosition();
auto dstHor = mPressRel.x() + mousePos.x();
auto dstVer = mPressRel.y() + mousePos.y();
snapLR = snapTB = 0;
for(auto ele : otherLayers) ele->clearSnap();
bool posChanged = false, sizeChanged = false;
for(auto layer : gEditView->layers) layer->clearSnap();
if(mFrmSec==Qt::TitleBarArea) {
if(snapLR==0) for(auto ele : otherLayers) {//左右
if(fabs(dstHor - ele->x()) < SnapSpace) {
dstHor = ele->x();
if(snapLR==0) for(auto layer : gEditView->layers) if(layer!=this) {//左右
if(fabs(dstHor - layer->x()) < SnapSpace) {
dstHor = layer->x();
snapLR = 1;
ele->snapLR = 1;
ele->update();
layer->snapLR = 1;
layer->update();
break;
}
auto eleRight = ele->x() + ele->width();
auto eleRight = layer->x() + layer->width();
if(fabs(dstHor - eleRight) < SnapSpace) {
dstHor = eleRight;
snapLR = 1;
ele->snapLR = 2;
ele->update();
layer->snapLR = 2;
layer->update();
break;
}
auto right = dstHor + width();
if(fabs(right - ele->x()) < SnapSpace && ele->x() - width() >= 0) {
dstHor = ele->x() - width();
if(fabs(right - layer->x()) < SnapSpace && layer->x() - width() >= 0) {
dstHor = layer->x() - width();
snapLR = 2;
ele->snapLR = 1;
ele->update();
layer->snapLR = 1;
layer->update();
break;
}
if(fabs(right - eleRight) < SnapSpace && eleRight - width() >= 0) {
dstHor = eleRight - width();
snapLR = 2;
ele->snapLR = 2;
ele->update();
layer->snapLR = 2;
layer->update();
break;
}
}
if(snapTB==0) for(auto ele : otherLayers) {//上下
if(fabs(dstVer-ele->y()) < SnapSpace) {
dstVer = ele->y();
if(snapTB==0) for(auto layer : gEditView->layers) if(layer!=this) {//上下
if(fabs(dstVer-layer->y()) < SnapSpace) {
dstVer = layer->y();
snapTB = 1;
ele->snapTB = 1;
ele->update();
layer->snapTB = 1;
layer->update();
break;
}
auto eleBtm = ele->y() + ele->height();
auto eleBtm = layer->y() + layer->height();
if(fabs(dstVer - eleBtm) < SnapSpace) {
dstVer = eleBtm;
snapTB = 1;
ele->snapTB = 2;
ele->update();
layer->snapTB = 2;
layer->update();
break;
}
auto btm = dstVer + height();
if(fabs(btm - ele->y()) < SnapSpace && ele->y() - height() >= 0) {
dstVer = ele->y() - height();
if(fabs(btm - layer->y()) < SnapSpace && layer->y() - height() >= 0) {
dstVer = layer->y() - height();
snapTB = 2;
ele->snapTB = 1;
ele->update();
layer->snapTB = 1;
layer->update();
break;
}
if(fabs(btm - eleBtm) < SnapSpace && eleBtm - height() >= 0) {
dstVer = eleBtm - height();
snapTB = 2;
ele->snapTB = 2;
ele->update();
layer->snapTB = 2;
layer->update();
break;
}
}
move(dstHor, dstVer);
posChanged = true;
} else if(mFrmSec==Qt::BottomRightSection) {
if(dstHor < HandleSize) dstHor = HandleSize;
if(dstVer < HandleSize) dstVer = HandleSize;
resize(dstHor, dstVer);
sizeChanged = true;
} else if(mFrmSec==Qt::RightSection) {
if(dstHor < HandleSize) dstHor = HandleSize;
auto right = x() + dstHor;
for(Layer *ele : otherLayers) {//左右
if(fabs(right - ele->x()) < SnapSpace) {
dstHor = ele->x() - x();
for(Layer *layer : gEditView->layers) if(layer!=this) {//左右
if(fabs(right - layer->x()) < SnapSpace) {
dstHor = layer->x() - x();
snapLR = 2;
ele->snapLR = 1;
ele->update();
layer->snapLR = 1;
layer->update();
break;
}
auto eleRight = ele->x() + ele->width();
auto eleRight = layer->x() + layer->width();
if(fabs(right - eleRight) < SnapSpace) {
dstHor = eleRight - x();
snapLR = 2;
ele->snapLR = 2;
ele->update();
layer->snapLR = 2;
layer->update();
break;
}
}
resize(dstHor, mPressRel.y());
sizeChanged = true;
} else if(mFrmSec==Qt::BottomSection) {
if(dstVer < HandleSize) dstVer = HandleSize;
auto btm = y() + dstVer;
for(Layer *ele : otherLayers) {//上下
auto eleBtm = ele->y() + ele->height();
if(fabs(btm - ele->y()) < SnapSpace) {
dstVer = ele->y() - y();
for(Layer *layer : gEditView->layers) if(layer!=this) {//上下
auto eleBtm = layer->y() + layer->height();
if(fabs(btm - layer->y()) < SnapSpace) {
dstVer = layer->y() - y();
snapTB = 2;
ele->snapTB = 1;
ele->update();
layer->snapTB = 1;
layer->update();
break;
}
if(fabs(btm - eleBtm) < SnapSpace) {
dstVer = eleBtm - y();
snapTB = 2;
ele->snapTB = 2;
ele->update();
layer->snapTB = 2;
layer->update();
break;
}
}
resize(mPressRel.rx(), dstVer);
sizeChanged = true;
} else {
QRectF geo(x(), y(), width(), height());
if(mFrmSec==Qt::LeftSection) {
dstHor = qMin(dstHor, geo.right() - HandleSize);
if(dstHor > 8) for(auto ele : otherLayers) {//左右
if(fabs(dstHor - ele->x()) < SnapSpace) {
dstHor = ele->x();
if(dstHor > 8) for(auto layer : gEditView->layers) if(layer!=this) {//左右
if(fabs(dstHor - layer->x()) < SnapSpace) {
dstHor = layer->x();
snapLR = 1;
ele->snapLR = 1;
ele->update();
layer->snapLR = 1;
layer->update();
break;
}
auto eleRight = ele->x() + ele->width();
auto eleRight = layer->x() + layer->width();
if(fabs(dstHor - eleRight) < SnapSpace) {
dstHor = eleRight;
snapLR = 1;
ele->snapLR = 2;
ele->update();
layer->snapLR = 2;
layer->update();
break;
}
}
geo.setLeft(dstHor);
} else if(mFrmSec==Qt::TopSection) {
dstVer = qMin(dstVer, geo.bottom() - HandleSize);
if(dstVer > 8) for(Layer *ele : otherLayers) {//上下
if(fabs(dstVer - ele->y()) < SnapSpace) {
dstVer = ele->y();
if(dstVer > 8) for(Layer *layer : gEditView->layers) if(layer!=this) {//上下
if(fabs(dstVer - layer->y()) < SnapSpace) {
dstVer = layer->y();
snapTB = 1;
ele->snapTB = 1;
ele->update();
layer->snapTB = 1;
layer->update();
break;
}
auto eleBtm = ele->y() + ele->height();
auto eleBtm = layer->y() + layer->height();
if(fabs(dstVer - eleBtm) < SnapSpace) {
dstVer = eleBtm;
snapTB = 1;
ele->snapTB = 2;
ele->update();
layer->snapTB = 2;
layer->update();
break;
}
}
@ -279,10 +265,44 @@ void Layer::mouseMoveEvent(QMouseEvent *e) {
geo.setBottom(dstVer);
}
setGeometry(geo.toRect());
posChanged = true;
sizeChanged = true;
}
sPos = (pos()-gOrigin) / gScale;
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) cell->wgt->setPos(sPos);
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;
}
}
}
}
}
void Layer::leaveEvent(QEvent *) {
setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
@ -290,14 +310,14 @@ void Layer::leaveEvent(QEvent *) {
}
void Layer::setFrmSec(const QPointF &pos) {
if(m_rLT.contains(pos)) setFrmSecIfNeed(Qt::TopLeftSection, Qt::SizeFDiagCursor);
else if(m_rT.contains(pos)) setFrmSecIfNeed(Qt::TopSection, Qt::SizeVerCursor);
else if(m_rRT.contains(pos)) setFrmSecIfNeed(Qt::TopRightSection, Qt::SizeBDiagCursor);
else if(m_rL.contains(pos)) setFrmSecIfNeed(Qt::LeftSection, Qt::SizeHorCursor);
else if(m_rR.contains(pos)) setFrmSecIfNeed(Qt::RightSection, Qt::SizeHorCursor);
else if(m_rLB.contains(pos)) setFrmSecIfNeed(Qt::BottomLeftSection, Qt::SizeBDiagCursor);
else if(m_rB.contains(pos)) setFrmSecIfNeed(Qt::BottomSection, Qt::SizeVerCursor);
else if(m_rRB.contains(pos)) setFrmSecIfNeed(Qt::BottomRightSection, Qt::SizeFDiagCursor);
if(hdlLT.contains(pos)) setFrmSecIfNeed(Qt::TopLeftSection, Qt::SizeFDiagCursor);
else if(hdlT.contains(pos)) setFrmSecIfNeed(Qt::TopSection, Qt::SizeVerCursor);
else if(hdlRT.contains(pos)) setFrmSecIfNeed(Qt::TopRightSection, Qt::SizeBDiagCursor);
else if(hdlL.contains(pos)) setFrmSecIfNeed(Qt::LeftSection, Qt::SizeHorCursor);
else if(hdlR.contains(pos)) setFrmSecIfNeed(Qt::RightSection, Qt::SizeHorCursor);
else if(hdlLB.contains(pos)) setFrmSecIfNeed(Qt::BottomLeftSection, Qt::SizeBDiagCursor);
else if(hdlB.contains(pos)) setFrmSecIfNeed(Qt::BottomSection, Qt::SizeVerCursor);
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 setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
}
@ -313,3 +333,114 @@ void Layer::clearSnap() {
snapLR = snapTB = 0;
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);
}

View File

@ -2,25 +2,25 @@
#define LAYER_H
#include "main.h"
#include <QWidget>
#include <QPen>
#define HandleSize 10
class OutputView;
class Layer : public QWidget {
Q_OBJECT
public:
explicit Layer(int idx, const QString &name, QWidget *parent = 0);
inline void setGeo() {
explicit Layer(int idx, const QString &name, QWidget *parent = 0) : QWidget(parent), idx(idx), name(name) {}
inline void updateGeo() {
setGeometry(QRect(sPos*gScale+gOrigin, sSize*gScale));
}
void select();
QPoint sPos;
QSize sSize{1920, 1080};
int idx = 1, rowIdx = 0;
QString name;
char type = 'L';
bool isSelected = false;
TreeWidgetItem *item = 0;
OutputView *view = 0;
protected:
void paintEvent(QPaintEvent *) override;
@ -28,18 +28,41 @@ protected:
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) 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 setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
void clearSnap();
QPen mSidePen;
QRectF m_rL, m_rR, m_rT, m_rB, m_rLT, m_rRT, m_rRB, m_rLB;
QRectF hdlLT = QRectF(-HandleSize/2, -HandleSize/2, HandleSize, HandleSize), hdlT, hdlRT, hdlL, hdlR, hdlLB, hdlB, hdlRB;
QPointF mPressRel{FLT_MAX, FLT_MAX};
Qt::WindowFrameSection mFrmSec = Qt::NoSection;
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

View File

@ -4,26 +4,31 @@
#include "layer.h"
#include <QMessageBox>
#include <QToolBar>
#include <QLineEdit>
#include <QMouseEvent>
#include <QOpenGLWidget>
LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
gScene = new QGraphicsScene(this);
auto hBox = new HBox(this);
hBox->setContentsMargins(0, 0, 0, 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->setAlignment(Qt::AlignTop|Qt::AlignLeft);
gEditView->setTransformationAnchor(GraphicsView::NoAnchor);
gEditView->setTransformationAnchor(QGraphicsView::NoAnchor);
gEditView->setInteractive(false);
gEditView->setSceneRect({-gOrigin / gScale, QSizeF(1, 1)});
gEditView->setScene(gScene);
gEditView->setScene(gScene = new QGraphicsScene(this));
gEditView->scale(gScale, gScale);
auto origin = ((GraphicsView*)gEditView)->originWgt = new OriginWgt(gEditView);
origin->setGeometry(gOrigin.x()-10, gOrigin.y()-10, 20, 20);
gEditView->originWgt = new OriginWgt(gEditView);
gEditView->originWgt->setGeometry(gOrigin.x()-10, gOrigin.y()-10, 20, 20);
hBox->addWidget(gEditView);
@ -32,9 +37,9 @@ LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
toolBar->setStyleSheet("QToolBar{spacing: 2px;}");
toolBar->setIconSize({18, 18});
auto actScaleUp = new QAction(QIcon(":/res/program/ScaleUp.png"), tr("Zoom In"));
toolBar->addAction(actScaleUp);
connect(actScaleUp, &QAction::triggered, this, [this] {
auto actScaleAdd = new QAction(QIcon(":/res/program/ScaleUp.png"), tr("Zoom In"));
toolBar->addAction(actScaleAdd);
connect(actScaleAdd, &QAction::triggered, this, [this] {
if(gScale >= 8) return;
gScale *= 1.1;
scaleChanged();
@ -45,9 +50,9 @@ LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
edScale->setAlignment(Qt::AlignCenter);
toolBar->addWidget(edScale);
auto actScaleDown = new QAction(QIcon(":/res/program/ScaleDown.png"), tr("Zoom Out"));
toolBar->addAction(actScaleDown);
connect(actScaleDown, &QAction::triggered, this, [this] {
auto actScaleMinus = new QAction(QIcon(":/res/program/ScaleDown.png"), tr("Zoom Out"));
toolBar->addAction(actScaleMinus);
connect(actScaleMinus, &QAction::triggered, this, [this] {
if(gScale <= 0.01) return;
gScale *= 0.909090909090;
scaleChanged();
@ -65,15 +70,13 @@ LiveEditor::LiveEditor(QWidget *parent) : QWidget(parent) {
toolBar->addAction(actFull);
hBox->addWidget(toolBar);
}
void LiveEditor::scaleChanged() {
gEditView->setSceneRect({-gOrigin / gScale, QSizeF(1, 1)});
QTransform tran;
tran.scale(gScale, gScale);
gEditView->setTransform(tran);
for(auto child : gEditView->children()) {
auto layer = dynamic_cast<Layer *>(child);
if(layer) layer->setGeo();
}
for(auto layer : gEditView->layers) layer->updateGeo();
edScale->setText(QString::number(gScale));
}
@ -83,20 +86,40 @@ void LiveEditor::onTileFull() {
// element->setPos(0,0);
}
void GraphicsView::mousePressEvent(QMouseEvent *e) {
void EditView::select(Layer *layer) {
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);
if(e->button() != Qt::LeftButton) return;
pressRel = gOrigin - e->globalPosition().toPoint();
}
void GraphicsView::mouseReleaseEvent(QMouseEvent *event) {
void EditView::mouseReleaseEvent(QMouseEvent *event) {
QWidget::mouseReleaseEvent(event);
if(Qt::LeftButton == event->button()) {
pressRel.setX(INT_MAX);
}
}
void GraphicsView::mouseMoveEvent(QMouseEvent *e) {
void EditView::mouseMoveEvent(QMouseEvent *e) {
if(! (e->buttons() & Qt::LeftButton)) return;
if(pressRel.x()==INT_MAX) return;
auto mousePos = e->globalPosition().toPoint();

View File

@ -4,6 +4,17 @@
#include <QGraphicsView>
#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 {
public:
using QWidget::QWidget;
@ -14,23 +25,14 @@ public:
}
};
class Layer;
class LiveEditor : public QWidget {
Q_OBJECT
public:
explicit LiveEditor(QWidget *parent = 0);
Layer* selected();
void scaleChanged();
void onTileFull();
QLabel *edScale;
};
class GraphicsView : public QGraphicsView {
class EditView : public QGraphicsView {
Q_OBJECT
public:
using QGraphicsView::QGraphicsView;
void select(Layer *layer);
Layer* selected = 0;
std::vector<Layer*> layers;
OriginWgt *originWgt;
protected:
void mousePressEvent(QMouseEvent *) override;

View File

@ -10,9 +10,10 @@ QString gProgFile;
JObj gProg;
const QString UpdVerUrl;
QGraphicsScene *gScene;
QGraphicsView *gEditView;
EditView *gEditView;
double gScale = 0.1;
QPoint gOrigin{20, 20};
OutputPanel *gOutPanel;
TableWidget *gTable, *gTableH, *gTableV;
int gPlayinC = 0;
//Tick *gTick;
@ -107,6 +108,5 @@ int main(int argc, char *argv[]) {
//if(dlg.exec()!=QDialog::Accepted) return 0;
}
MainWindow w;
w.show();
return a.exec();
}

View File

@ -3,6 +3,8 @@
#include "gutil/qgui.h"
#include "gutil/qjson.h"
#include "liveeditor.h"
#include "outputpanel.h"
#include <QCoreApplication>
#include "QImageReader"
#include <QJsonDocument>
@ -15,9 +17,10 @@ extern QString gProgFile;
extern JObj gProg;
extern const QString UpdVerUrl;
extern QGraphicsScene *gScene;
extern QGraphicsView *gEditView;
extern EditView *gEditView;
extern double gScale;
extern QPoint gOrigin;
extern OutputPanel *gOutPanel;
extern TableWidget *gTable, *gTableH, *gTableV;
extern int gPlayinC;
//extern Tick *gTick;

View File

@ -1,6 +1,8 @@
#include "mainwindow.h"
#include "mediapanel.h"
#include "outputpanel.h"
#include "planpanel.h"
#include "progresspanel.h"
#include <QFileDialog>
#include <QLineEdit>
#include <QPushButton>
@ -14,32 +16,37 @@
#include <QToolBar>
#include <QDockWidget>
#include <QScrollArea>
#include <QTimer>
MainWindow::MainWindow() {
resize(1280, 800);
resize(1400, 840);
setWindowTitle("Compass");
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
setCentralWidget(liveEditor = new LiveEditor);
tabPorper = new QTabWidget;
tabPorper->setMinimumWidth(360);
tabPorper->setStyleSheet("QTabWidget::pane{border:none;}");
tab = new QTabWidget;
tab->setMinimumWidth(360);
tab->setStyleSheet("QTabWidget::pane{border:none;}");
auto scroll = new QScrollArea;
scroll->setFrameShape(QFrame::NoFrame);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scroll->setWidgetResizable(true);
tabPorper->addTab(scroll, tr("Properties"));
tab->addTab(scroll, tr("Layer Properties"));
auto mediapanel = new MediaPanel;
tabPorper->addTab(mediapanel, tr("Library"));
tabPorper->setCurrentIndex(1);
auto mediaPanel = new MediaPanel;
tab->addTab(mediaPanel, tr("Media Library"));
auto outputPanel = new OutputPanel;
tab->addTab(outputPanel, tr("Output"));
tab->setCurrentIndex(1);
auto dockProperties = new QDockWidget;
dockProperties->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
dockProperties->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dockProperties->setWidget(tabPorper);
dockProperties->setWidget(tab);
addDockWidget(Qt::RightDockWidgetArea, dockProperties);
auto dockPlan = new QDockWidget(tr("Plan"));
@ -51,7 +58,7 @@ MainWindow::MainWindow() {
auto dockProgress = new QDockWidget(tr("Progress"));
dockProgress->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
dockProgress->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
//dockProgress->setWidget(dockWidgetContents);
dockProgress->setWidget(new ProgressPanel);
addDockWidget(Qt::BottomDockWidgetArea, dockProgress);
splitDockWidget(dockPlan, dockProgress, Qt::Vertical);
@ -65,4 +72,11 @@ MainWindow::MainWindow() {
action = new QAction(QIcon(":/res/program/Setting.png"), tr("Setting"));
toolBar->addAction(action);
toolBar->addSeparator();
show();
dockProgress->setMaximumHeight(80);
QTimer::singleShot(68, [=] {
dockProgress->setMaximumHeight(200);
});
}

View File

@ -12,7 +12,7 @@ class MainWindow : public QMainWindow {
public:
MainWindow();
LiveEditor *liveEditor;
QTabWidget *tabPorper;
QTabWidget *tab;
};
#endif // MAINWINDOW_H

View File

@ -14,19 +14,18 @@
#include <QVideoSink>
#include <QVideoFrame>
MediaTree *gMediaTree;
MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
auto vBox = new VBox(this);
vBox->setContentsMargins(0, 0, 0, 0);
vBox->setSpacing(0);
auto hBox = new HBox(vBox);
hBox->setContentsMargins(6,6,6,6);
hBox->setSpacing(6);
bnNew = new QPushButton(translate("","New"));
bnNew->setMinimumSize(75, 30);
bnNew->setProperty("ssType", "progManageTool");
hBox->addWidget(bnNew);
connect(bnNew, &QPushButton::clicked, this, [this] {
auto bnAdd = new QPushButton("🞥");
bnAdd->setMaximumWidth(50);
hBox->addWidget(bnAdd);
connect(bnAdd, &QPushButton::clicked, this, [this] {
auto file = QFileDialog::getOpenFileName(this, 0, gFileHome);
if(file.isEmpty()) return;
QFileInfo info(file);
@ -38,7 +37,7 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
if(suffix.startsWith("mp")) {
auto player = new QMediaPlayer;
player->setSource(QUrl::fromLocalFile(file));
item = new MediaItem(file, tree);
item = new MediaItem(file, gMediaTree);
item->setText("type", "Video");
auto videoWgt = new QVideoWidget;
player->setVideoOutput(videoWgt);
@ -48,7 +47,8 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
player->stop();
player->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->profile = frame.toImage().scaledToHeight(60, Qt::SmoothTransformation);
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());
return;
}
item = new MediaItem(file, tree);
item = new MediaItem(file, gMediaTree);
item->setText("type", "Image");
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);
auto edProfile = new QLabel;
edProfile->setPixmap(QPixmap::fromImage(item->profile));
@ -82,11 +82,10 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
}
});
bnDelete = new QPushButton(tr("Delete"));
bnDelete->setMinimumSize(75, 30);
bnDelete->setProperty("ssType", "progManageTool");
hBox->addWidget(bnDelete);
connect(bnDelete, &QPushButton::clicked, this, [=] {
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();
@ -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();
auto fdSearch = new QLineEdit;
@ -128,33 +102,33 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
fdSearch->addAction(search, QLineEdit::LeadingPosition);
fdSearch->setClearButtonEnabled(true);
//fdSearch->setStyleSheet("border: 1px solid #888;");
connect(fdSearch, &QLineEdit::textChanged, this, [this](const QString &text) {
auto cnt = tree->topLevelItemCount();
connect(fdSearch, &QLineEdit::textChanged, this, [](const QString &text) {
auto cnt = gMediaTree->topLevelItemCount();
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)));
}
});
hBox->addWidget(fdSearch);
tree = new MediaTree;
tree->addCol("#", "", 20);
tree->addCol("profile", "", 42);
tree->addCol("name", "", 140);
tree->addCol("type", "", 45);
tree->addCol("size", "", 60);
tree->addCol("dur", "", 80);
tree->setDefs()->setHeaderAlignC();
tree->minRowHeight = 26;
tree->setSortingEnabled(true);
tree->setDragEnabled(true);
tree->setAcceptDrops(true);
tree->setDropIndicatorShown(true);
vBox->addWidget(tree);
gMediaTree = new MediaTree;
gMediaTree->addCol("#", "", 20);
gMediaTree->addCol("profile", "", 42);
gMediaTree->addCol("name", "", 140);
gMediaTree->addCol("type", "", 45);
gMediaTree->addCol("size", "", 60);
gMediaTree->addCol("dur", "", 80);
gMediaTree->setDefs()->setHeaderAlignC();
gMediaTree->minRowHeight = 26;
gMediaTree->setSortingEnabled(true);
gMediaTree->setDragEnabled(true);
gMediaTree->setAcceptDrops(true);
gMediaTree->setDropIndicatorShown(true);
vBox->addWidget(gMediaTree);
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if(mProgsDir.isEmpty()) return;
tree->clear();
gMediaTree->clear();
// for(auto &progName : progNames) {
// auto file = mProgsDir + "/" + progName + "/pro.json";
// QFile qFile(file);
@ -172,7 +146,7 @@ MediaPanel::MediaPanel(QWidget *parent) : QWidget(parent) {
// }
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();
}
@ -182,17 +156,10 @@ void MediaPanel::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi();
}
void MediaPanel::transUi() {
tree->headerItem()->setText("name"**tree, tr("Name"));
tree->headerItem()->setText("type"**tree, tr("Type"));
tree->headerItem()->setText("size"**tree, tr("Size"));
tree->headerItem()->setText("dur"**tree, 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) {
gMediaTree->headerItem()->setText("name"**gMediaTree, tr("Name"));
gMediaTree->headerItem()->setText("type"**gMediaTree, tr("Type"));
gMediaTree->headerItem()->setText("size"**gMediaTree, tr("Size"));
gMediaTree->headerItem()->setText("dur"**gMediaTree, tr("Duration"));
}
void MediaTree::dropEvent(QDropEvent *event) {
@ -201,7 +168,4 @@ void MediaTree::dropEvent(QDropEvent *event) {
return;
}
TreeWidget::dropEvent(event);
qDebug()<<" event"<<event;
qDebug()<<" source"<<event->source();
qDebug()<<" mimeData"<<event->mimeData();
}

View File

@ -16,26 +16,24 @@ protected:
void dropEvent(QDropEvent *event) override;
};
extern MediaTree *gMediaTree;
class MediaPanel : public QWidget {
Q_OBJECT
public:
explicit MediaPanel(QWidget *parent = 0);
MediaTree *tree;
protected:
void changeEvent(QEvent *) override;
void transUi();
private:
QString mProgsDir;
QPushButton *bnNew;
QPushButton *bnDelete;
QPushButton *bnRename;
};
class MediaItem : public TreeWidgetItem {
public:
explicit MediaItem(const QString &dir, TreeWidget *parent);
explicit MediaItem(const QString &file, TreeWidget *parent) : TreeWidgetItem(parent), file(file) {}
QString file;
QImage profile;

181
Compass/outputpanel.cpp Normal file
View File

@ -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"));
}

31
Compass/outputpanel.h Normal file
View File

@ -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

View File

@ -5,6 +5,7 @@
#include <QDropEvent>
#include <QMimeData>
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QGraphicsVideoItem>
#include <QMessageBox>
#include <QScrollBar>
@ -37,8 +38,8 @@ PlanPanel::PlanPanel(QWidget *parent) : QWidget{parent} {
auto hBox = new HBox(wgt);
hBox->setContentsMargins(0,0,0,0);
hBox->setSpacing(0);
auto btn = new QPushButton(">");
btn->setMaximumWidth(26);
auto btn = new QPushButton("");
btn->setMaximumWidth(24);
grp->addButton(btn);
hBox->addWidget(btn);
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);
grid->addWidget(gTableH, 0, 1);
gTableV = new PlanTableV(1, 1);
gTableV->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gTableV = new PlanTableV(0, 1);
gTableV->horizontalScrollBar()->hide();
gTableV->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
gTableV->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gTableV->horizontalHeader()->hide();
gTableV->verticalHeader()->hide();
@ -61,8 +63,10 @@ PlanPanel::PlanPanel(QWidget *parent) : QWidget{parent} {
grid->addWidget(gTableV, 1, 0);
gTable = new PlanTable(0, 50);
gTable->horizontalHeader()->setVisible(false);
gTable->verticalHeader()->setVisible(false);
gTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
gTable->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gTable->horizontalHeader()->hide();
gTable->verticalHeader()->hide();
gTable->setColWidth(CellWidth)->setRowHeight(CellHeight)->setRowResize(QHeaderView::Fixed);
gTable->setDragEnabled(true);
gTable->setAcceptDrops(true);
@ -94,7 +98,8 @@ void PlanPanel::addRow() {
gTableV->setCellWidget(r, 0, wgt);
auto layer = new Layer(r+1, "Layer", gEditView);
layer->setGeo();
gEditView->layers.push_back(layer);
layer->updateGeo();
layer->show();
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()));
}
void PlanTable::dragEnterEvent(QDragEnterEvent *event) {
if(event->source()==this || event->source()==gMediaTree) QTableWidget::dragEnterEvent(event);
}
void PlanTable::dropEvent(QDropEvent *event) {
MediaTree *tree;
if(event->source()==this) {
auto idxFrom = currentIndex();
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();
setData(idx.row(), idx.column(), cell);
event->accept();
} else if((tree = dynamic_cast<MediaTree*>(event->source()))) {
} else if(event->source()==gMediaTree) {
auto idx = indexAt(event->position().toPoint());
auto wgt = cellWidget(idx.row(), idx.column());
auto item = (MediaItem*) tree->currentItem();
auto item = (MediaItem*) gMediaTree->currentItem();
auto lb = (QLabel*) wgt->children().at(2);
qDebug()<<" currentIndex"<<idx;
lb->setText(item->text("name"**tree));
lb->setText(item->text("name"**gMediaTree));
lb = (QLabel*) wgt->children().at(1);
lb->setPixmap(QPixmap::fromImage(item->profile));
auto type = item->text("type"**tree);
auto type = item->text("type"**gMediaTree);
if(type=="Video") {
auto wgt = new QGraphicsVideoItem;
wgt->setAspectRatioMode(Qt::IgnoreAspectRatio);
auto player = new QMediaPlayer;
player->setSource(QUrl::fromLocalFile(item->file));
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));
} else if(type=="Image") {
QImageReader reader(item->file);

View File

@ -47,6 +47,7 @@ public:
using TableWidget::TableWidget;
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
};

52
Compass/progresspanel.cpp Normal file
View File

@ -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() {
}

19
Compass/progresspanel.h Normal file
View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

View File

@ -1,20 +1,19 @@
QT += core gui widgets
QT += multimedia
QT += network
QT += webenginewidgets
QT += concurrent
QT += serialport
QT += opengl
QT += webenginewidgets
greaterThan(QT_MAJOR_VERSION, 5) {
QT += openglwidgets
CONFIG += c++20
} else {
CONFIG += c++17
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAGS += /utf-8
}
CONFIG += c++17
CONFIG += lrelease
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.
#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\\\"
msvc {
contains(QT_ARCH, i386) {
@ -112,12 +111,12 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
RESOURCES += res.qrc
SOURCES += \
base/calendarbutton.cpp \
base/changepasswordform.cpp \
base/switchcontrol.cpp \
base/extendedgroupbox.cpp \
base/ffutil.cpp \
base/locolorselector.cpp \
base/lodateselector.cpp \
base/loqtitlebar.cpp \
base/loqtreewidget.cpp \
device/progressesdlg.cpp \
@ -181,11 +180,11 @@ SOURCES += \
program/videosplitthread.cpp
HEADERS += \
base/calendarbutton.h \
base/changepasswordform.h \
base/switchcontrol.h \
base/extendedgroupbox.h \
base/locolorselector.h \
base/lodateselector.h \
base/loqtitlebar.h \
base/loqtreewidget.h \
device/progressesdlg.h \

View File

@ -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);
}

View File

@ -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

View File

@ -1,4 +1,5 @@
#include "changepasswordform.h"
#include "main.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QLineEdit>
@ -48,7 +49,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
QString pwdOld = fdOld->text();
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();
return;
}
@ -56,24 +57,24 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
auto pwdRaw = settings.value("advUiPs");
QString pwd = pwdRaw.isNull() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toString().toLatin1()));
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();
return;
}
QString pwdNew = fdNew->text();
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();
return;
}
QString pwdAgn = fdAgn->text();
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();
return;
}
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();
});
vBox->addWidget(btnBox);

View File

@ -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();
});
}

View File

@ -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

View File

@ -1,5 +1,5 @@
#include "loqtitlebar.h"
#include <QApplication>
#include "main.h"
LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
bn_Minimize = new QPushButton(this);
@ -11,7 +11,7 @@ LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
bn_Minimize->setToolTip(tr("Minimize"));
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_Maximize, &QPushButton::clicked, this, [this](){
@ -24,7 +24,7 @@ LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
void LoQTitleBar::refreshLable() {
bn_Minimize->setToolTip(tr("Minimize"));
bn_Maximize->setToolTip(tr("Maximize"));
bn_Close->setToolTip(tr("Close"));
bn_Close->setToolTip(translate("","Close"));
}
bool LoQTitleBar::eventFilter(QObject *, QEvent *e) {
if(e->type()==QEvent::WindowStateChange) bn_Maximize->setToolTip(window()->isMaximized() ? tr("Restore") : tr("Maximize"));

View File

@ -6,7 +6,7 @@
BaseDlg::BaseDlg(QWidget *parent) : QDialog(parent) {
setWindowFlag(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
if(QSysInfo::productVersion()!="7" || ! QSysInfo::productType().startsWith("win")) setAttribute(Qt::WA_TranslucentBackground);
}
void BaseDlg::paintEvent(QPaintEvent *e) {

View File

@ -7,7 +7,7 @@
BaseWin::BaseWin(QWidget *parent) : QWidget(parent){
setWindowFlag(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
if(QSysInfo::productVersion()!="7" || ! QSysInfo::productType().startsWith("win")) setAttribute(Qt::WA_TranslucentBackground);
setMouseTracking(true);
auto layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout->setContentsMargins(8,8,8,8);
@ -40,7 +40,7 @@ void BaseWin::paintEvent(QPaintEvent *e) {
void BaseWin::mousePressEvent(QMouseEvent *e) {
if(e->button() != Qt::LeftButton) return;
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::RightSection ) mPressRel = QPoint(width() - e->globalX(), height() );
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(mFrmSec==Qt::NoSection || mPressRel.x()==INT_MAX) 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::RightSection ) resize(mPressRel.rx() + e->globalX(), mPressRel.ry() );
else if(mFrmSec==Qt::BottomSection ) resize(mPressRel.rx() , mPressRel.ry() + e->globalY());
else {
auto geo = geometry();
if(mFrmSec==Qt::LeftSection) geo.setLeft(mPressRel.rx() + e->globalX());
else if(mFrmSec==Qt::TopSection) geo.setTop(mPressRel.ry() + e->globalY());
else if(mFrmSec==Qt::TopLeftSection) geo.setTopLeft(mPressRel + e->globalPos());
if(mFrmSec==Qt::LeftSection) geo.setLeft(e->globalX() - mPressRel.rx());
else if(mFrmSec==Qt::TopSection) geo.setTop(e->globalY() - mPressRel.ry());
else if(mFrmSec==Qt::TopLeftSection) geo.setTopLeft(e->globalPos() - mPressRel);
else if(mFrmSec==Qt::TopRightSection) geo.setTopRight(mPressRel + e->globalPos());
else if(mFrmSec==Qt::BottomLeftSection) geo.setBottomLeft(mPressRel + e->globalPos());
setGeometry(geo);

File diff suppressed because it is too large Load Diff

View File

@ -55,21 +55,20 @@ private:
QLabel *lbTimingReboot;
QGroupBox *grpPlayer, *grpM80, *grpY50;
QGroupBox *grpPlayer, *grpY50, *grpG12, *grpM80;
QComboBox *fdM80Resolu, *fdDisMode;
QPushButton *btnM80Set, *btnY50Set;
QPushButton *btnM80Refresh;
QPushButton *btnM80Restore;
QPushButton *btnY50Set, *btnM80Set, *btnM80Refresh, *btnM80Restore;
QLabel *lbDisMode;
QLabel *lbScreenPos, *lbScreenOff;
QLabel *lbOffset, *lbCameraDis;
QLabel *lbOffset, *lbCameraDis, *lbLockCard, *lbLockPswd;
QPushButton *btnLock, *btnUnlock;
QGroupBox *grpHighForBusy;
QRadioButton *fdHighForBusy;
QRadioButton *fdTopLevelLH;
QPushButton *btnGetTopLevel;
QPushButton *btnLedSet;
QPushButton *btnLedSet = 0;
QPushButton *btnReceCardsGet, *btnBindTaxiIc;
QGroupBox *grpMinMaxBrightness;

View File

@ -87,7 +87,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnSensiSet->setProperty("ssType", "progManageTool");
connect(btnSensiSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -113,7 +113,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnSensiGet->setProperty("ssType", "progManageTool");
connect(btnSensiGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -128,12 +128,12 @@ CtrlBrightPanel::CtrlBrightPanel() {
fdSensi->setValue(json["sensitivity"].toInt());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
gFdResInfo->append(cardId+" "+tr("GetBrightnessSensitivity")+" "+err);
});
@ -170,7 +170,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnMinBrightSet->setProperty("ssType", "progManageTool");
connect(btnMinBrightSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
auto isAdaptToOld = fdAdaptToOld->isChecked();
@ -200,7 +200,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnMinBrightGet->setProperty("ssType", "progManageTool");
connect(btnMinBrightGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -218,13 +218,13 @@ CtrlBrightPanel::CtrlBrightPanel() {
fdMinBright->setValue(value);
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
auto brightLevel = card.BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
auto value = json["minBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
@ -267,14 +267,14 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnUpload->setProperty("ssType", "progManageTool");
connect(btnUpload, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QString sensorName;
if(fdRL2->isChecked()) sensorName = fdRL2->text();
else if(fdR68->isChecked()) sensorName = fdR68->text();
else {
QMessageBox::information(this, tr("Tip"), tr("NeedSelectSensorTypeTip"));
QMessageBox::information(this, translate("","Tip"), tr("NeedSelectSensorTypeTip"));
return;
}
QString xlsxFile = QFileDialog::getOpenFileName(this, tr("Open file dialog"), "/", "brightness files(*.xlsx)");
@ -285,7 +285,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
if(workbook->sheetCount() < 2) {
sheet = xlsx.currentWorksheet();
if(sheet==0) {
QMessageBox::information(this, tr("Tip"), tr("Not found current worksheet"));
QMessageBox::information(this, translate("","Tip"), tr("Not found current worksheet"));
return;
}
} else {
@ -299,7 +299,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
}
}
if(sheet==0) {
QMessageBox::information(this, tr("Tip"), "Not found sheet "+sensorName);
QMessageBox::information(this, translate("","Tip"), "Not found sheet "+sensorName);
return;
}
}
@ -307,7 +307,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
for(int j=0; j<255; j++) {
auto val = sheet->read(3, j+3).toString();
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;
}
values.append(val);
@ -335,14 +335,14 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnTableGet->setProperty("ssType", "progManageTool");
connect(btnTableGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QString strSensorType;
if(fdRL2->isChecked()) strSensorType = fdRL2->text();
else if(fdR68->isChecked()) strSensorType = fdR68->text();
else {
QMessageBox::information(this, tr("Tip"), tr("NeedSelectSensorTypeTip"));
QMessageBox::information(this, translate("","Tip"), tr("NeedSelectSensorTypeTip"));
return;
}
QJsonObject json;
@ -354,24 +354,24 @@ CtrlBrightPanel::CtrlBrightPanel() {
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card, strSensorType] {
Def_CtrlSingleGetReply
waitingDlg->close();
QStringList values = json["values"].toVariant().value<QStringList>();
if(values.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("no sensorBrightnessTable"));
auto values = json["values"];
if(values.empty()) {
QMessageBox::information(this, translate("","Tip"), tr("no sensorBrightnessTable"));
return;
}
QString tempFile = QCoreApplication::applicationDirPath()+"/files/bright-template.xlsx";
auto tempFile = QCoreApplication::applicationDirPath()+"/files/bright-template.xlsx";
QFile tempQFile(tempFile);
if(! tempQFile.exists()) {
QMessageBox::information(this, tr("Tip"), tempFile+" is not exist");
QMessageBox::information(this, translate("","Tip"), tempFile+" is not exist");
return;
}
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;
tempQFile.copy(savingFile);
QXlsx::Document xlsx(savingFile);
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();
});
}
@ -396,7 +396,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnCurBrightGet->setProperty("ssType", "progManageTool");
connect(btnCurBrightGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -406,12 +406,12 @@ CtrlBrightPanel::CtrlBrightPanel() {
auto waitingDlg = new WaitingDlg(this, tr("GetCurrentSensorBrightness"));
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
QJsonDocument json;
JValue json;
QByteArray data;
QString err = checkReplyForJson(reply, &json, &data);
auto err = errStrWithJson(reply, &json, &data);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Error"), err);
QMessageBox::critical(this, translate("","Error"), err);
return;
}
waitingDlg->success();
@ -420,11 +420,11 @@ CtrlBrightPanel::CtrlBrightPanel() {
fdCurBright->setText(QString::number(qRound(json["value"].toInt() * 100.0 / card.BrightnessLevel))+"%");
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [reply, card] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue 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))+"%";
gFdResInfo->append(card.id+" "+tr("GetCurrentSensorBrightness")+" "+err);
});
@ -471,7 +471,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnFixedSet->setProperty("ssType", "progManageTool");
connect(btnFixedSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
auto isAdaptToOld = fdAdaptToOld->isChecked();
@ -488,7 +488,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
if(isAdaptToOld) json.insert("brightness", (percent * card.BrightnessLevel + 50) / 100);
Def_CtrlSetMulti(tr("SetBrightness"))
}
@ -502,7 +502,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnFixedGet->setProperty("ssType", "progManageTool");
connect(btnFixedGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -512,12 +512,12 @@ CtrlBrightPanel::CtrlBrightPanel() {
auto waitingDlg = new WaitingDlg(this, tr("GetBrightness"));
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
QJsonDocument json;
JValue json;
QByteArray data;
QString err = checkReplyForJson(reply, &json, &data);
auto err = errStrWithJson(reply, &json, &data);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Error"), err);
QMessageBox::critical(this, translate("", "Error"), err);
return;
}
waitingDlg->success();
@ -531,11 +531,11 @@ CtrlBrightPanel::CtrlBrightPanel() {
}
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [reply, card] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
auto bright = json["brightnessPercentage"].toInt(-1);
if(bright==-1) bright = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
@ -736,7 +736,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnScheSet->setProperty("ssType", "progManageTool");
connect(btnScheSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
auto isAdaptToOld = fdAdaptToOld->isChecked();
@ -767,7 +767,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnScheGet->setProperty("ssType", "progManageTool");
connect(btnScheGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -818,13 +818,13 @@ void CtrlBrightPanel::init() {
mSensi = -1;
mTask = -1;
QJsonObject json;
JObj json;
json.insert("_id", "GetAutoBrightnessTask");
json.insert("_type", "GetAutoBrightnessTask");
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
mTask = restoreScheduleJson(json, card.BrightnessLevel);
if(mTask) radioSchedule->setChecked(true);
@ -832,13 +832,13 @@ void CtrlBrightPanel::init() {
else if(mSensi == 0) radioManual->setChecked(true);
});
json = QJsonObject();
json = JObj();
json.insert("_id", "GetBrightnessSensitivity");
json.insert("_type", "GetBrightnessSensitivity");
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
mSensi = json["sensitivity"].toInt();
fdSensi->setValue(mSensi);
@ -847,13 +847,13 @@ void CtrlBrightPanel::init() {
else radioManual->setChecked(true);
});
json = QJsonObject();
json = JObj();
json.insert("_id", "GetMinBrightness");
json.insert("_type", "GetMinBrightness");
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
auto value = json["minBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
@ -876,22 +876,22 @@ void CtrlBrightPanel::transUi() {
fdSensiTypeTip->setText(tr("BrightTip2"));
lbSensi->setText(tr("Sensitivity"));
lbMinBright->setText(tr("Minbrightness"));
btnMinBrightSet->setText(tr("Set"));
btnSensiSet->setText(tr("Set"));
btnUpload->setText(tr("Upload"));
btnMinBrightGet->setText(tr("Readback"));
btnSensiGet->setText(tr("Readback"));
btnTableGet->setText(tr("ReadbackTable"));
btnCurBrightGet->setText(tr("Refresh"));
btnMinBrightSet->setText(translate("","Set"));
btnSensiSet->setText(translate("","Set"));
btnUpload->setText(tr("Upload File"));
btnMinBrightGet->setText(translate("","Readback"));
btnSensiGet->setText(translate("","Readback"));
btnTableGet->setText(translate("","Readback"));
btnCurBrightGet->setText(translate("","Refresh"));
lbCurBright->setText(tr("Cur Brigntness")+": ");
lbFixedBright->setText(tr("Brightness value"));
btnFixedSet->setText(tr("Set"));
btnFixedGet->setText(tr("Readback"));
btnFixedSet->setText(translate("","Set"));
btnFixedGet->setText(translate("","Readback"));
lbDefBright->setText(tr("Default brightness"));
btnScheAdd->setText(tr("Add"));
btnScheClear->setText(tr("Clear"));
btnScheClear->setText(translate("","Clear"));
btnScheDel->setText(tr("Delete"));
btnScheImport->setText(tr("Import"));
btnScheExport->setText(tr("Export"));
@ -901,11 +901,11 @@ void CtrlBrightPanel::transUi() {
tableSche->setHeaderText("end", tr("End Time"));
btnScheSet->setText(tr("Apply"));
btnScheGet->setText(tr("Readback"));
btnScheGet->setText(translate("","Readback"));
fdScheTip->setText(tr("Default brightness tip"));
}
bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
bool CtrlBrightPanel::restoreScheduleJson(JValue &json, int max) {
tableSche->setRowCount(0);
auto taskBrightness = json["taskBrightness"];
auto brightness = json["defaultBrightnessPercentage"].toInt(-1);
@ -914,7 +914,7 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
auto jsitems = taskBrightness["items"].toArray();
auto brightnesses = json["brightnessPercentageList"].toArray();
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();
tableSche->insertRow(row);
@ -924,7 +924,7 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
auto slider = new QSlider(Qt::Horizontal);
slider->setRange(1, 100);
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);
auto lb = new QLabel(QString::number(slider->value())+"%");
@ -944,7 +944,7 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "end", timeEdit);
}
return jsitems.count() > 0;
return jsitems.size() > 0;
}
void CtrlBrightPanel::getScheduleJson(QJsonObject &json, int max) {
QJsonArray items, brightnesses;

View File

@ -2,10 +2,12 @@
#define CTRLBRIGHTPANEL_H
#include "gutil/qgui.h"
#include "gutil/qjson.h"
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QCheckBox>
#include <QCoreApplication>
class CtrlBrightPanel : public QWidget {
Q_OBJECT
@ -18,7 +20,7 @@ protected:
void transUi();
private:
bool restoreScheduleJson(QJsonDocument &, int);
bool restoreScheduleJson(JValue &, int);
void getScheduleJson(QJsonObject &, int);
QLabel *lbTitle;
QRadioButton *radioAuto;

View File

@ -51,12 +51,19 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
hBox->addSpacing(20);
fdHdmi2 = new QRadioButton("HDMI 2");
hBox->addWidget(fdHdmi2);
hBox->addStretch();
auto btnGroup = new QButtonGroup(this);
btnGroup->addButton(fdAsync, 0);
btnGroup->addButton(fdHdmi, 1);
btnGroup->addButton(fdHdmi2, 2);
hBox->addSpacing(20);
edAutoSwitch = new QCheckBox;
edAutoSwitch->setChecked(true);
hBox->addWidget(edAutoSwitch);
hBox->addStretch();
vBox->addSpacing(20);
hBox = new HBox(vBox);
@ -67,11 +74,11 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
btnSyncSet->setProperty("ssType", "progManageTool");
connect(btnSyncSet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
auto id = btnGroup->checkedId();
QJsonObject json;
JObj json;
json.insert("_id", "SyncSwitch");
json.insert("_type", "SyncSwitch");
json.insert("switchOn", (bool)id);
@ -83,7 +90,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
if(id) {
Def_CtrlSetMulti(tr("SyncSwitch"))
} 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->addSpacing(20);
@ -100,10 +126,10 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
btnSyncGet->setProperty("ssType", "progManageTool");
connect(btnSyncGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "IsSync");
json.insert("_type", "IsSync");
if(gSelCards.count() == 1) {
@ -113,21 +139,21 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
Def_CtrlSingleGetReply
waitingDlg->success();
auto switchOn = json["switchOn"];
if(switchOn.isUndefined()) switchOn = json["result"];
if(switchOn.isNull()) switchOn = json["result"];
if(! switchOn.toBool()) fdAsync->setChecked(true);
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
else fdHdmi->setChecked(true);
});
} else {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
auto switchOn = json["switchOn"];
if(switchOn.isUndefined()) switchOn = json["result"];
if(switchOn.isNull()) switchOn = json["result"];
if(! switchOn.toBool()) err = tr("Async");
else {
err = "HDMI";
@ -214,7 +240,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
if(! scheQFile.open(QIODevice::ReadOnly)) return;
auto data = scheQFile.readAll();
scheQFile.close();
restoreScheduleJson(QJsonDocument::fromJson(data).object());
restoreScheduleJson(JFrom(data).toObj());
});
hBox->addWidget(btnScheImport);
@ -249,7 +275,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
btnScheSet->setMinimumSize(QSize(60, 30));
connect(btnScheSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -277,7 +303,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
btnScheGet->setProperty("ssType", "progManageTool");
connect(btnScheGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -289,7 +315,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->success();
restoreScheduleJson(json["creenTask"].toObject());
restoreScheduleJson(json["creenTask"].toObj());
});
}
});
@ -317,21 +343,24 @@ void CtrlHdmiPanel::init() {
btnScheGet->setEnabled(isSingle);
if(! isSingle) {
fdHdmi2->setVisible(true);
edAutoSwitch->setVisible(true);
return;
}
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("_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] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
auto switchOn = json["switchOn"];
if(switchOn.isUndefined()) switchOn = json["result"];
if(switchOn.isNull()) switchOn = json["result"];
if(! switchOn.toBool()) fdAsync->setChecked(true);
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
else fdHdmi->setChecked(true);
@ -346,9 +375,11 @@ void CtrlHdmiPanel::transUi() {
fdManual->setText(tr("Manual"));
fdSchedule->setText(tr("Schedule"));
edAutoSwitch->setText(tr("Auto Switch"));
fdAsync->setText(tr("Async"));
btnSyncSet->setText(tr("Set"));
btnSyncGet->setText(tr("Readback"));
btnSyncSet->setText(translate("","Set"));
btnSyncGet->setText(translate("","Readback"));
tableSche->setHeaderText("start", tr("Start Time"));
tableSche->setHeaderText("end", tr("End Time"));
@ -362,19 +393,19 @@ void CtrlHdmiPanel::transUi() {
btnScheAdd->setText(tr("Add"));
btnScheSet->setText(tr("Apply"));
btnScheClear->setText(tr("Clear"));
btnScheClear->setText(translate("","Clear"));
btnScheDel->setText(tr("Delete"));
btnScheImport->setText(tr("Import"));
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"));
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);
auto oSchedules = oTaskSync["schedules"].toArray();
foreach(QJsonValue oSchedule, oSchedules) {
for(auto &oSchedule : oSchedules) {
int row = tableSche->rowCount();
tableSche->insertRow(row);

View File

@ -2,7 +2,8 @@
#define CTRLHDMIPANEL_H
#include "gutil/qgui.h"
#include <QLabel>
#include "gutil/qjson.h"
#include <QCheckBox>
#include <QRadioButton>
#include <QPushButton>
@ -10,7 +11,7 @@ class CtrlHdmiPanel : public QWidget {
Q_OBJECT
public:
CtrlHdmiPanel();
void restoreScheduleJson(QJsonObject oTaskSync);
void restoreScheduleJson(JObj oTaskSync);
QJsonObject getScheduleJson();
protected:
void showEvent(QShowEvent *event) override;
@ -21,6 +22,7 @@ protected:
private:
QLabel *lbHdmiCfg;
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
QCheckBox *edAutoSwitch;
QPushButton *btnSyncSet, *btnSyncGet;
TableWidget *tableSche;

View File

@ -23,7 +23,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
auto hBox = new HBox(vBox);
hBox->addStretch();
fdDhcp = new QRadioButton;
fdDhcp = new QRadioButton("DHCP");
fdDhcp->setChecked(true);
hBox->addWidget(fdDhcp, 0, Qt::AlignTop);
@ -103,7 +103,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
btnLanSet->setProperty("ssType", "progManageTool");
connect(btnLanSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QString ip = fdIP->text();
@ -137,7 +137,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
return;
}
}
QJsonObject json;
JObj json;
json.insert("_id", "SetEthernet");
json.insert("_type", "SetEthernet");
json.insert("dhcp", fdDhcp->isChecked());
@ -152,7 +152,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetEthernet"))
}
}
@ -166,10 +166,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
btnLanGet->setProperty("ssType", "progManageTool");
connect(btnLanGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetEthernet");
json.insert("_type", "GetEthernet");
if(gSelCards.count() == 1) {
@ -191,12 +191,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
fdDns->setText(json["dnsAddr"].toString());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = json["dhcp"].toBool() ? tr("DHCP IP") : tr("STATIC IP");
gFdResInfo->append(cardId+" "+tr("GetEthernet")+" "+err);
gFdResInfo->append(" IP: "+json["ipAddr"].toString());
@ -216,33 +216,20 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
label_5 = new QLabel;
label_5->setFont(ftTitle);
label_5->setAlignment(Qt::AlignCenter);
vBox->addWidget(label_5);
lbWifiCfg = new QLabel;
lbWifiCfg->setFont(ftTitle);
lbWifiCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbWifiCfg);
hBox = new HBox(vBox);
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);
{
auto vvv = new VBox(hBox);
auto hBox = new HBox(vvv);
hBox->addStretch();
hBox->addWidget(fdIsWifi = new QCheckBox);
hBox->addStretch();
auto aaaQButtonGroup = new QButtonGroup(fdIsWifi);
aaaQButtonGroup->addButton(fdIsWifi);
aaaQButtonGroup->addButton(fdIsHotspot);
vBox->addLayout(stackedWifi);
{
auto vvv = new VBox(stackedWifi);
hBox = new HBox(vvv);
lbWifiName = new QLabel;
@ -250,18 +237,18 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lbWifiName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbWifiName);
fdWifiName = new QComboBox;
fdWifiName->setEditable(true);
fdWifiName->setMinimumWidth(200);
fdWifiName->setSizeAdjustPolicy(QComboBox::AdjustToContents);
hBox->addWidget(fdWifiName);
edWifiName = new QComboBox;
edWifiName->setEditable(true);
edWifiName->setMinimumWidth(180);
edWifiName->setSizeAdjustPolicy(QComboBox::AdjustToContents);
hBox->addWidget(edWifiName);
btnScan = new QPushButton;
btnScan->setMinimumWidth(60);
btnScan->setProperty("ssType", "progManageTool");
connect(btnScan, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -274,10 +261,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
Def_CtrlSingleGetReply
waitingDlg->success();
auto wifis = json["wifiList"].toArray();
auto cur = fdWifiName->currentText();
fdWifiName->clear();
foreach(QJsonValue wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
if(! cur.isEmpty()) fdWifiName->setCurrentText(cur);
auto cur = edWifiName->currentText();
edWifiName->clear();
for(auto &wifi : wifis) edWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
if(! cur.isEmpty()) edWifiName->setCurrentText(cur);
});
}
});
@ -286,20 +273,107 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
hBox = new HBox(vvv);
lbWifiPassword = new QLabel;
lbWifiPassword->setMinimumWidth(80);
lbWifiPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbWifiPassword);
lbWifiPswd = new QLabel;
lbWifiPswd->setMinimumWidth(80);
lbWifiPswd->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbWifiPswd);
fdWifiPassword = new QLineEdit;
fdWifiPassword->setFixedWidth(200);
fdWifiPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
hBox->addWidget(fdWifiPassword);
edWifiPswd = new QLineEdit;
edWifiPswd->setFixedWidth(180);
edWifiPswd->setEchoMode(QLineEdit::PasswordEchoOnEdit);
hBox->addWidget(edWifiPswd);
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();
}
{
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);
lbHotspotName = new QLabel;
@ -307,22 +381,22 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lbHotspotName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbHotspotName);
fdHotspotName = new QLineEdit;
fdHotspotName->setFixedWidth(200);
hBox->addWidget(fdHotspotName);
edHotspotName = new QLineEdit;
edHotspotName->setFixedWidth(180);
hBox->addWidget(edHotspotName);
hBox->addStretch();
hBox = new HBox(vvv);
lbHotspotPassword = new QLabel;
lbHotspotPassword->setMinimumWidth(80);
lbHotspotPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbHotspotPassword);
lbHotspotPswd = new QLabel;
lbHotspotPswd->setMinimumWidth(80);
lbHotspotPswd->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbHotspotPswd);
fdHotspotPassword = new QLineEdit;
fdHotspotPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
fdHotspotPassword->setFixedWidth(200);
hBox->addWidget(fdHotspotPassword);
edHotspotPswd = new QLineEdit;
edHotspotPswd->setEchoMode(QLineEdit::PasswordEchoOnEdit);
edHotspotPswd->setFixedWidth(180);
hBox->addWidget(edHotspotPswd);
hBox->addStretch();
hBox = new HBox(vvv);
@ -331,133 +405,157 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lll->setMinimumWidth(80);
hBox->addWidget(lll);
fdIs2_4G = new QRadioButton("2.4G");
fdIs2_4G->setChecked(true);
hBox->addWidget(fdIs2_4G);
auto edIs2_4G = new QRadioButton("2.4G");
edIs2_4G->setChecked(true);
hBox->addWidget(edIs2_4G);
auto fdIs5G = new QRadioButton("5G");
hBox->addWidget(fdIs5G);
edIs5G = new QRadioButton("5G");
hBox->addWidget(edIs5G);
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();
}
hBox->addStretch();
fdIsWifi->setChecked(true);
hBox = new HBox(vBox);
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->setMinimumSize(QSize(60, 30));
btnWiFiGet->setMinimumSize(60, 30);
btnWiFiGet->setProperty("ssType", "progManageTool");
connect(btnWiFiGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "IsPortableHotSpot");
json.insert("_type", "IsPortableHotSpot");
JObj jsonG;
jsonG.insert("_id", "GetWifiSwitchState");
jsonG.insert("_type", "GetWifiSwitchState");
if(gSelCards.count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("IsPortableHotSpot")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
auto waitingDlg = new WaitingDlg(this, tr("Get AP or WiFi")+" ...");
waitingDlg->show();
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
waitingDlg->success();
fdWifiName->setCurrentText(json["wifi"].toString());
if(isG) {
fdIsWifi->setChecked(json["wifiEnable"].toBool());
fdIsAP->setChecked(json["apEnable"].toBool());
edWifiName->setCurrentText(json["wifiName"].toString());
edHotspotName->setText(json["hotSpotName"].toString());
edIs5G->setChecked(json["apBand"].toBool());
} else {
edWifiName->setCurrentText(json["wifi"].toString());
auto hotSpots = json["hotSpots"].toString();
fdHotspotName->setText(hotSpots);
if(hotSpots.isEmpty()) fdIsWifi->setChecked(true);
else fdIsHotspot->setChecked(true);
edHotspotName->setText(hotSpots);
fdIsWifi->setChecked(hotSpots.isEmpty());
fdIsAP->setChecked(! hotSpots.isEmpty());
}
});
} else {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
connect(reply, &QNetworkReply::finished, this, [=] {
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
err = tr("success");
err = translate("","Success");
if(isG) {
err = err+"\nWifi: "+(json["wifiEnable"].toBool()?"On":"Off")+" "+json["wifiName"].toString();
err = err+"\nAP: "+(json["apEnable"].toBool()?"On":"Off")+" "+json["hotSpotName"].toString()
+(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);
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -514,7 +612,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
btnSIMStatusGet->setProperty("ssType", "progManageTool");
connect(btnSIMStatusGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -526,7 +624,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->close();
QString str4GStatus = tr("状态:");
QString str4GStatus = tr("Status")+":";
auto state = json["state"].toInt();
if(state<2) str4GStatus += tr("未知");
else if(state==2) str4GStatus += tr("锁定状态需要用户的PIN码解锁");
@ -580,7 +678,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
}
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->addItem("");
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);
@ -702,7 +800,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
btnAPNCusSet->setProperty("ssType", "progManageTool");
connect(btnAPNCusSet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -740,10 +838,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
btnAPNCusGet->setProperty("ssType", "progManageTool");
connect(btnAPNCusGet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetCurrentAPN");
json.insert("_type", "GetCurrentAPN");
if(gSelCards.count() == 1) {
@ -765,12 +863,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
fdCus_mmsPort->setText(json["mmsport"].toString());
});
} else {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
err = json["apn"].toString();
auto user = json["user"].toString();
@ -804,10 +902,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
fdFightModel->setText(tr("OFF"), tr("ON"));
connect(fdFightModel, &SwitchControl::checkedChanged, this, [=](bool checked) {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "ContrFlightMode");
json.insert("_type", "ContrFlightMode");
json.insert("state", checked);
@ -818,7 +916,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("ContrFlightMode"))
}
}
@ -830,10 +928,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
btnFlightModelGet->setProperty("ssType", "progManageTool");
connect(btnFlightModelGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetFlightModeState");
json.insert("_type", "GetFlightModeState");
if(gSelCards.count() == 1) {
@ -846,12 +944,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
fdFightModel->update();
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = json["result"].toBool() ? "true" : "false";
gFdResInfo->append(cardId+" "+tr("GetFlightModeState")+" "+err);
});
@ -880,13 +978,13 @@ void CtrlNetworkPanel::init() {
if(! isSingle) return;
auto card = gSelCards[0];
QJsonObject json;
JObj json;
json.insert("_id", "GetEthernet");
json.insert("_type", "GetEthernet");
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
if(json["dhcp"].toBool()) {
@ -902,63 +1000,76 @@ void CtrlNetworkPanel::init() {
fdDns->setText(json["dnsAddr"].toString());
});
json = QJsonObject();
json = JObj();
json.insert("_id", "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, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
auto wifis = json["wifiList"].toArray();
fdWifiName->clear();
foreach(QJsonValue wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
edWifiName->clear();
for(JValue &wifi : wifis) edWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
{
QJsonObject json;
JObj json;
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
if(isG) {
json.insert("_id", "GetWifiSwitchState");
json.insert("_type", "GetWifiSwitchState");
} else {
json.insert("_id", "IsPortableHotSpot");
json.insert("_type", "IsPortableHotSpot");
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
}
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;
auto wifi = json["wifi"].toString();
fdWifiName->setCurrentText(wifi);
auto hotSpots = json["hotSpots"].toString();
fdHotspotName->setText(hotSpots);
if(hotSpots.isEmpty()) fdIsWifi->setChecked(true);
else fdIsHotspot->setChecked(true);
if(isG) {
fdIsWifi->setChecked(json["wifiEnable"].toBool());
fdIsAP->setChecked(json["apEnable"].toBool());
edWifiName->setCurrentText(json["wifiName"].toString());
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());
}
});
}
});
json = QJsonObject();
json = JObj();
json.insert("_id", "GetSwitchSimData");
json.insert("_type", "GetSwitchSimData");
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
bool b = json["enable"].toBool();
fdEnableCellular->setChecked(b);
fdMcc->setEnabled(b);
fdCarrierName->setEnabled(b);
auto enable = json["enable"].toBool();
fdEnableCellular->setChecked(enable);
fdMcc->setEnabled(enable);
fdCarrierName->setEnabled(enable);
});
json = QJsonObject();
json = JObj();
json.insert("_id", "GetAPNList");
json.insert("_type", "GetAPNList");
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
auto err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) return;
fdMcc->clear();
fdMcc->addItem("");
auto apns = json["apns"].toArray();
foreach(QJsonValue apn, apns) {
QString mcc = apn["mcc"].toString();
for(QJsonValue apn : apns) {
auto mcc = apn["mcc"].toString();
for(int i=0; i<fdMcc->count(); i++) if(mcc==fdMcc->itemText(i)) {
auto var = fdMcc->itemData(i);
fdMcc->setItemData(i, QVariant());
@ -973,13 +1084,13 @@ void CtrlNetworkPanel::init() {
getCurrentAPN(card.ip);
json = QJsonObject();
json = JObj();
json.insert("_id", "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, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
fdFightModel->setCheckedStatus(json["result"].toBool());
fdFightModel->update();
@ -992,27 +1103,27 @@ void CtrlNetworkPanel::changeEvent(QEvent *event) {
}
void CtrlNetworkPanel::transUi() {
lbLanCfg->setText(tr("Wire Enther(RJ45) Configuration"));
fdDhcp->setText(tr("DHCP"));
fdSpecifyIp->setText(tr("Specify IP"));
lbHotspotName->setText(tr("AP name"));
labelGateway->setText(tr("Gateway"));
lbWifiName->setText(tr("WiFi name"));
labelIpAddress->setText(tr("IP Address"));
lbHotspotPassword->setText(tr("Password"));
lbHotspotPswd->setText(tr("Password"));
labelDnsAddress->setText(tr("DNS Address"));
labelMaskAddress->setText(tr("Subnet mask"));
lbWifiPassword->setText(tr("Password"));
lbWifiPswd->setText(tr("Password"));
btnScan->setText(tr("Scan"));
btnWiFiSet->setText(tr("Set"));
btnLanSet->setText(tr("Set"));
btnWiFiGet->setText(tr("Readback"));
btnLanGet->setText(tr("Readback"));
fdIsWifi->setText(tr("WiFi Mode"));
fdIsHotspot->setText(tr("Ap Mode"));
label_5->setText(tr("WIFI Configuration"));
fdHotspotPassword->setPlaceholderText(tr("Input password"));
fdWifiPassword->setPlaceholderText(tr("Input password"));
fdHotspotName->setPlaceholderText(tr("Input ap name"));
btnWiFiSet->setText(translate("","Set"));
btnHotspotSet->setText(translate("","Set"));
btnLanSet->setText(translate("","Set"));
btnWiFiGet->setText(translate("","Readback"));
btnLanGet->setText(translate("","Readback"));
fdIsWifi->setText(tr("Enable WiFi"));
fdIsAP->setText(tr("Enable AP"));
lbWifiCfg->setText(tr("WiFi Config"));
edHotspotPswd->setPlaceholderText(translate("","Input Password"));
edWifiPswd->setPlaceholderText(translate("","Input Password"));
edHotspotName->setPlaceholderText(tr("Input ap name"));
lbCellularConfig->setText(tr("Cellular Config"));
lbCheckStatusTip->setText(tr("Through the check status button"));
fdEnableCellular->setText(tr("Enable Cellular Data"));
@ -1021,7 +1132,7 @@ void CtrlNetworkPanel::transUi() {
label_2->setText(tr("Country ID(mcc):"));
label_3->setText(tr("Carrier Name"));
fdCus_apn->setPlaceholderText(tr("APN(Required)"));
btnFlightModelGet->setText(tr("Readback"));
btnFlightModelGet->setText(translate("","Readback"));
btnSIMStatusGet->setText(tr("Get cellular network status information"));
label_10->setText(tr("Flight Mode"));
@ -1034,18 +1145,18 @@ void CtrlNetworkPanel::transUi() {
lbCus_proxy->setText(tr("Proxy"));
lbCus_mmsPort->setText(tr("MMS Port"));
lbCus_mmsProxy->setText(tr("MMS Proxy"));
btnAPNCusSet->setText(tr("Set"));
btnAPNCusGet->setText(tr("Readback"));
btnAPNCusSet->setText(translate("","Set"));
btnAPNCusGet->setText(translate("","Readback"));
}
void CtrlNetworkPanel::getCurrentAPN(QString &ip) {
QJsonObject json;
JObj json;
json.insert("_id", "GetCurrentAPN");
json.insert("_type", "GetCurrentAPN");
auto reply = NetReq("http://"+ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
fdCus_Name->setText(json["carrier"].toString());
fdCus_apn->setText(json["apn"].toString());

View File

@ -45,21 +45,17 @@ private:
QLabel *labelIpAddress, *labelMaskAddress, *labelGateway, *labelDnsAddress;
QLineEdit *fdIP, *fdMask, *fdGateWay, *fdDns;
QPushButton *btnLanSet, *btnLanGet;
QLabel *label_5;
QLabel *lbWifiName;
QComboBox *fdWifiName;
QRadioButton *fdIs2_4G;
QLabel *lbWifiPassword;
QLabel *lbWifiCfg, *lbWifiName;
QComboBox *edWifiName;
QRadioButton *edIs5G;
QLabel *lbWifiPswd;
QRadioButton *fdIsWifi, *fdIsHotspot;
QLineEdit *fdWifiPassword;
QCheckBox *fdIsWifi, *fdIsAP;
QLineEdit *edWifiPswd;
QPushButton *btnScan;
QPushButton *btnWiFiSet;
QPushButton *btnWiFiGet;
QLabel *lbHotspotName;
QLabel *lbHotspotPassword;
QLineEdit *fdHotspotName;
QLineEdit *fdHotspotPassword;
QPushButton *btnWiFiSet, *btnHotspotSet, *btnWiFiGet;
QLabel *lbHotspotName, *lbHotspotPswd;
QLineEdit *edHotspotName, *edHotspotPswd;
QFrame *line_3;
QLabel *lbCellularConfig;
QCheckBox *fdEnableCellular;

View File

@ -52,7 +52,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
fdScreen->setTextColor(QColor(100,100,100), QColor(0, 160, 230));
connect(fdScreen, &SwitchControl::checkedChanged, this, [this](bool checked) {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -82,7 +82,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
btnScreenGet->setProperty("ssType", "progManageTool");
connect(btnScreenGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -106,8 +106,8 @@ CtrlPowerPanel::CtrlPowerPanel() {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
err = json["on"].toBool() ? tr("On") : tr("Off");
auto item = findItem(card.id);
@ -194,7 +194,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
if(! scheQFile.open(QIODevice::ReadOnly)) return;
auto data = scheQFile.readAll();
scheQFile.close();
restoreScheduleJson(QJsonDocument::fromJson(data).object());
restoreScheduleJson(JFrom(data));
});
hBox->addWidget(pushButtonImport);
@ -229,7 +229,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
pushButtonApply->setMinimumSize(QSize(60, 30));
connect(pushButtonApply, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
if(tableSche->rowCount()==0) clearSche();
@ -259,7 +259,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
pushButtonClearSchedule->setProperty("ssType", "progManageTool");
connect(pushButtonClearSchedule, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
clearSche();
@ -272,7 +272,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
pushButtonReadback->setProperty("ssType", "progManageTool");
connect(pushButtonReadback, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -284,7 +284,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->success();
restoreScheduleJson(json["screenTask"].toObject());
restoreScheduleJson(json["screenTask"].toObj());
});
}
});
@ -318,10 +318,10 @@ void CtrlPowerPanel::init() {
json.insert("_type", "GetTimingScreenTask");
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
if(restoreScheduleJson(json["screenTask"].toObject())) fdSchedule->setChecked(true);
if(restoreScheduleJson(json["screenTask"].toObj())) fdSchedule->setChecked(true);
else fdManual->setChecked(true);
});
}
@ -337,7 +337,7 @@ void CtrlPowerPanel::transUi() {
lbScreen->setText(tr("Power"));
fdScreen->setText(tr("Off"), tr("On"));
btnScreenGet->setText(tr("Readback"));
btnScreenGet->setText(translate("","Readback"));
tableSche->setHeaderText("start", tr("Start Time"));
tableSche->setHeaderText("end", tr("End Time"));
@ -351,18 +351,18 @@ void CtrlPowerPanel::transUi() {
pushButtonAdd->setText(tr("Add"));
pushButtonApply->setText(tr("Apply"));
pushButtonClear->setText(tr("Clear"));
pushButtonClear->setText(translate("","Clear"));
pushButtonDelete->setText(tr("Delete"));
pushButtonImport->setText(tr("Import"));
pushButtonExport->setText(tr("Export"));
labelPowerScheduleTip->setText(tr("It is power off state outside the schedule time period"));
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);
auto schedules = oTaskSync["schedules"].toArray();
foreach(QJsonValue schedule, schedules) {
for(auto &schedule : schedules) {
int row = tableSche->rowCount();
tableSche->insertRow(row);
@ -389,7 +389,7 @@ bool CtrlPowerPanel::restoreScheduleJson(QJsonObject oTaskSync) {
}
}
}
return schedules.count() > 0;
return schedules.size() > 0;
}
QJsonObject CtrlPowerPanel::getScheduleJson() {
QJsonArray schedules;
@ -416,7 +416,7 @@ QJsonObject CtrlPowerPanel::getScheduleJson() {
};
}
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;
QJsonObject json;
json.insert("_id", "CleanTimingScreenTask");

View File

@ -2,6 +2,7 @@
#define CTRLPOWERPANEL_H
#include "gutil/qgui.h"
#include "gutil/qjson.h"
#include <QLabel>
#include <QRadioButton>
#include <QPushButton>
@ -11,7 +12,7 @@ class CtrlPowerPanel : public QWidget {
Q_OBJECT
public:
CtrlPowerPanel();
bool restoreScheduleJson(QJsonObject oTaskSync);
bool restoreScheduleJson(JValue oTaskSync);
QJsonObject getScheduleJson();
void clearSche();
protected:

View File

@ -61,26 +61,26 @@ CtrlPwdPanel::CtrlPwdPanel() {
btnPwdSet->setProperty("ssType", "progManageTool");
connect(btnPwdSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("InputOriginalPasswordTip"));
QMessageBox::information(this, translate("","Tip"), tr("InputOriginalPasswordTip"));
return;
}
if(fdNewPwd->text().isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("InputNewPasswordTip"));
QMessageBox::information(this, translate("","Tip"), tr("InputNewPasswordTip"));
return;
}
if(fdPwdAgain->text().isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("InputRepeatPasswordTip"));
QMessageBox::information(this, translate("","Tip"), tr("InputRepeatPasswordTip"));
return;
}
if(fdNewPwd->text() != fdPwdAgain->text()) {
QMessageBox::information(this, tr("Tip"), tr("InputRepeatPasswordNotSameTip"));
QMessageBox::information(this, translate("","Tip"), tr("InputRepeatPasswordNotSameTip"));
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;
QJsonObject json;
json.insert("_id", "SetControllerPassword");
@ -91,16 +91,16 @@ CtrlPwdPanel::CtrlPwdPanel() {
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
QString err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Error"), err);
QMessageBox::critical(this, translate("","Error"), err);
return;
}
if(json["result"].toInt()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Tip"), tr("OriginalPasswordErrorTip"));
QMessageBox::critical(this, translate("","Tip"), tr("OriginalPasswordErrorTip"));
return;
}
waitingDlg->success();
@ -121,12 +121,12 @@ CtrlPwdPanel::CtrlPwdPanel() {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
else {
err = tr("Success");
err = translate("","Success");
lbOldPwd->show();
fdOldPwd->show();
btnPwdClear->show();
@ -150,11 +150,11 @@ CtrlPwdPanel::CtrlPwdPanel() {
btnPwdClear->setProperty("ssType", "progManageTool");
connect(btnPwdClear, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("InputOriginalPasswordTip"));
QMessageBox::information(this, translate("","Tip"), tr("InputOriginalPasswordTip"));
return;
}
QJsonObject json;
@ -166,16 +166,16 @@ CtrlPwdPanel::CtrlPwdPanel() {
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Error"), err);
QMessageBox::critical(this, translate("","Error"), err);
return;
}
if(json["result"].toInt()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Tip"), tr("OriginalPasswordErrorTip"));
QMessageBox::critical(this, translate("","Tip"), tr("OriginalPasswordErrorTip"));
return;
}
waitingDlg->success();
@ -196,12 +196,12 @@ CtrlPwdPanel::CtrlPwdPanel() {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) {
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
else {
err = tr("Success");
err = translate("","Success");
lbOldPwd->hide();
fdOldPwd->hide();
btnPwdClear->hide();

View File

@ -238,7 +238,7 @@ CtrlTestPanel::CtrlTestPanel() {
btnAnycastReset->setProperty("ssType", "progManageTool");
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
SendAnycastCmd(0);
@ -253,7 +253,7 @@ CtrlTestPanel::CtrlTestPanel() {
btnAnycast->setProperty("ssType", "progManageTool");
connect(btnAnycast, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
SendAnycastCmd(fdAnycast->text().toInt());
@ -287,7 +287,7 @@ CtrlTestPanel::CtrlTestPanel() {
connect(pushButtonStartLine, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -323,7 +323,7 @@ CtrlTestPanel::CtrlTestPanel() {
});
connect(pushButtonStartGray, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -359,7 +359,7 @@ CtrlTestPanel::CtrlTestPanel() {
});
connect(pushButtonStartColor, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -395,7 +395,7 @@ CtrlTestPanel::CtrlTestPanel() {
});
connect(btnStopTest, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -458,7 +458,7 @@ void CtrlTestPanel::transUi() {
radioButton_Blue->setText(tr("Blue"));
radioButton_White->setText(tr("White"));
btnStopTest->setText(tr("Stop"));
btnAnycastClear->setText(tr("Clear"));
btnAnycastClear->setText(translate("","Clear"));
btnAnycastReset->setText(tr("Reset"));
btnAnycast->setText(tr("Anycast"));
}
@ -499,7 +499,7 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
tcp->close();
tcp->deleteLater();
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->startTimer(10000);
@ -516,7 +516,7 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
tcp->stopTimer();
tcp->close();
tcp->deleteLater();
gFdResInfo->append(cardId+" "+action+" "+tr("Success"));
gFdResInfo->append(cardId+" "+action+" "+translate("","Success"));
});
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
tcp->close();

View File

@ -25,7 +25,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
fdTimeZoneSet = new QPushButton;
connect(fdTimeZoneSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -59,7 +59,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnLangSet = new QPushButton;
connect(btnLangSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -83,10 +83,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnLangGet = new QPushButton;
connect(btnLangGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetLanguage");
json.insert("_type", "GetLanguage");
if(gSelCards.count() == 1) {
@ -99,12 +99,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
else fdIsEn->setChecked(true);
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = json["language"].toInt()==1 ? "中文" : "英文";
gFdResInfo->append(cardId+" 获取语言 "+err);
});
@ -131,7 +131,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnSyncTime->setMinimumSize(QSize(60, 30));
connect(btnSyncTime, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -162,10 +162,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnDateGet->setMinimumSize(QSize(0, 30));
connect(btnDateGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetControllerDate");
json.insert("_type", "GetControllerDate");
if(gSelCards.count() == 1) {
@ -177,12 +177,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
labelCurTime->setText(json["date"].toString());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = json["date"].toString();
gFdResInfo->append(cardId+" "+tr("GetControllerDate")+" "+err);
});
@ -284,7 +284,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnSyncSet->setMinimumSize(QSize(60, 30));
connect(btnSyncSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -320,10 +320,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
fdSyncGet->setMinimumSize(QSize(60, 30));
connect(fdSyncGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetingSyncMethod");
json.insert("_type", "GetingSyncMethod");
if(gSelCards.count() == 1) {
@ -335,13 +335,13 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
dealGetSync(json);
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
JValue json;
QByteArray data;
QString err = checkReplyForJson(reply, &json, &data);
auto err = errStrWithJson(reply, &json, &data);
if(err.isEmpty()) {
QString strOtherSyncItem = tr("screenSwitch") + ":" + (json["screenSwitch"].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));
connect(btnLoraMasterSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -424,8 +424,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [reply, card, isMaster] {
QString err = checkReplyForJson(reply);
gFdResInfo->append(card.id+" "+(isMaster ? tr("MasterSwitch ") : tr("SlaveSwitch "))+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));
QString err = errStrWithJson(reply);
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));
connect(btnLoraMasterGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "IsMasterSlave");
json.insert("_type", "IsMasterSlave");
if(gSelCards.count() == 1) {
@ -453,12 +453,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
fdSlave->setChecked(! isMaster);
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = json["result"].toBool() ? tr("Master") : tr("Slave");
gFdResInfo->append(cardId+" "+tr("Lora identity")+" "+err);
});
@ -494,10 +494,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnNtpSet->setMinimumSize(QSize(60, 30));
connect(btnNtpSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "SetNtpServer");
json.insert("_type", "SetNtpServer");
json.insert("ntpServer", fdNtpServer->text());
@ -508,7 +508,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetNtpServer"))
}
}
@ -519,10 +519,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
btnNtpGet->setMinimumSize(QSize(60, 30));
connect(btnNtpGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
JObj json;
json.insert("_id", "GetNtpServer");
json.insert("_type", "GetNtpServer");
if(gSelCards.count() == 1) {
@ -534,12 +534,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() {
fdNtpServer->setText(json["ntpServer"].toString());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = json["ntpServer"].toString();
gFdResInfo->append(cardId+" "+tr("GetNtpServer")+" "+err);
});
@ -598,35 +598,35 @@ void CtrlVerifyClockPanel::init() {
if(! isSingle) return;
auto card = gSelCards[0];
QJsonObject json;
JObj json;
json.insert("_id", "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] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
dealGetSync(json);
});
json = QJsonObject();
json = JObj();
json.insert("_id", "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] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
fdTimezone->setCurrentText(json["timezone"].toString());
});
json = QJsonObject();
json = JObj();
json.insert("_id", "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] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
if(json["language"].toInt()==1) fdIsCn->setChecked(true);
else fdIsEn->setChecked(true);
@ -637,21 +637,21 @@ void CtrlVerifyClockPanel::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi();
}
void CtrlVerifyClockPanel::transUi() {
btnDateGet->setText(tr("Readback"));
btnLangGet->setText(tr("Readback"));
btnLangSet->setText(tr("Set"));
btnLoraMasterGet->setText(tr("Readback"));
btnLoraMasterSet->setText(tr("Set"));
btnNtpGet->setText(tr("Readback"));
btnNtpSet->setText(tr("Set"));
btnDateGet->setText(translate("","Readback"));
btnLangGet->setText(translate("","Readback"));
btnLangSet->setText(translate("","Set"));
btnLoraMasterGet->setText(translate("","Readback"));
btnLoraMasterSet->setText(translate("","Set"));
btnNtpGet->setText(translate("","Readback"));
btnNtpSet->setText(translate("","Set"));
btnSyncTime->setText(tr("Verify to Computer time"));
checkBoxBrightness->setText(tr("Brightness"));
checkBoxScreenSwitch->setText(tr("Screen on/off"));
checkBoxVolume->setText(tr("Volume"));
fdIsLan->setText(tr("LAN"));
fdNtpServer->setPlaceholderText(tr("NTP Server address"));
fdSyncGet->setText(tr("Readback"));
fdTimeZoneSet->setText(tr("Set"));
fdSyncGet->setText(translate("","Readback"));
fdTimeZoneSet->setText(translate("","Set"));
groupBox->setTitle(tr("Enable Synchronous playing"));
groupBox_5->setTitle(tr("Cur time of controller"));
groupNTP->setTitle(tr("NTP Server"));
@ -665,11 +665,11 @@ void CtrlVerifyClockPanel::transUi() {
lbLang->setText(tr("Language:"));
lineEditIdCode->setPlaceholderText(tr("identification code"));
lineEdit_3->setPlaceholderText(tr("Sync time interval"));
btnSyncSet->setText(tr("Set"));
btnSyncSet->setText(translate("","Set"));
fdMaster->setText(tr("Master"));
fdSlave->setText(tr("Slave"));
}
void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
void CtrlVerifyClockPanel::dealGetSync(JValue &json) {
QString strType = json["time"].toString().toLower();
if(strType=="serial" || strType=="lan") {
if(strType=="serial") fdIsLora->setChecked(true);

View File

@ -1,6 +1,7 @@
#ifndef CTRLVERIFYCLOCKPANEL_H
#define CTRLVERIFYCLOCKPANEL_H
#include "gutil/qjson.h"
#include <QComboBox>
#include <QRadioButton>
#include <QGroupBox>
@ -18,7 +19,7 @@ protected:
void init();
void changeEvent(QEvent *) override;
void transUi();
void dealGetSync(QJsonDocument &json);
void dealGetSync(JValue &json);
protected slots:
void OnRadioButton();
void OnRadioButton2();

View File

@ -66,7 +66,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
fdVolumeSet->setProperty("ssType", "progManageTool");
connect(fdVolumeSet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -93,7 +93,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
fdVolumeGet->setProperty("ssType", "progManageTool");
connect(fdVolumeGet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -108,12 +108,12 @@ CtrlVolumePanel::CtrlVolumePanel() {
fdVolume->setValue(json["volume"].toInt());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(err.isEmpty()) err = QString::number(json["volume"].toInt());
gFdResInfo->append(cardId+" "+tr("GetVolume")+" "+err);
});
@ -218,7 +218,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
if(! scheQFile.open(QIODevice::ReadOnly)) return;
auto data = scheQFile.readAll();
scheQFile.close();
restoreScheduleJson(QJsonDocument::fromJson(data).object());
restoreScheduleJson(JFrom(data));
});
hBox->addWidget(btnScheImport);
@ -263,7 +263,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
btnScheSet->setProperty("ssType", "progManageTool");
connect(btnScheSet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -291,7 +291,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
btnScheGet->setProperty("ssType", "progManageTool");
connect(btnScheGet, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QJsonObject json;
@ -303,7 +303,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
Def_CtrlSingleGetReply
waitingDlg->success();
restoreScheduleJson(json["taskVolume"].toObject());
restoreScheduleJson(json["taskVolume"]);
});
}
});
@ -334,10 +334,10 @@ void CtrlVolumePanel::init() {
QJsonObject json;
json.insert("_id", "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] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
fdVolume->setValue(json["volume"].toInt());
});
@ -345,12 +345,12 @@ void CtrlVolumePanel::init() {
json = QJsonObject();
json.insert("_id", "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] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
if(restoreScheduleJson(json["taskVolume"].toObject())) fdSchedule->setChecked(true);
if(restoreScheduleJson(json["taskVolume"].toObj())) fdSchedule->setChecked(true);
else fdManual->setChecked(true);
});
}
@ -365,12 +365,12 @@ void CtrlVolumePanel::transUi() {
fdSchedule->setText(tr("Schedule"));
lbVolume->setText(tr("Volume"));
fdVolumeSet->setText(tr("Set"));
fdVolumeGet->setText(tr("Readback"));
fdVolumeSet->setText(translate("","Set"));
fdVolumeGet->setText(translate("","Readback"));
lbDefBright->setText(tr("Default volume"));
btnScheAdd->setText(tr("Add"));
btnScheClear->setText(tr("Clear"));
btnScheClear->setText(translate("","Clear"));
btnScheDel->setText(tr("Delete"));
btnScheImport->setText(tr("Import"));
btnScheExport->setText(tr("Export"));
@ -387,16 +387,16 @@ void CtrlVolumePanel::transUi() {
tableSche->setHeaderText("6", tr("SAT"));
btnScheSet->setText(tr("Apply"));
btnScheGet->setText(tr("Readback"));
btnScheGet->setText(translate("","Readback"));
fdScheTip->setText(tr("Default volume tip"));
}
bool CtrlVolumePanel::restoreScheduleJson(QJsonObject json) {
bool CtrlVolumePanel::restoreScheduleJson(JValue json) {
tableSche->setRowCount(0);
auto items = json["items"].toArray();
fdDefBright->setValue(items.size()==0 ? 10 : json["defaultVolume"].toInt());
for(int i=0; i<items.size(); i++) {
auto schedule = items.at(i)["schedules"][0];
for(int i=0; i<(int)items.size(); i++) {
auto schedule = items[i]["schedules"][0];
int row = tableSche->rowCount();
tableSche->insertRow(row);
@ -405,7 +405,7 @@ bool CtrlVolumePanel::restoreScheduleJson(QJsonObject json) {
auto slider = new QSlider(Qt::Horizontal);
slider->setRange(0, 15);
slider->setValue(items.at(i)["volume"].toInt());
slider->setValue(items[i]["volume"].toInt());
hBox->addWidget(slider);
auto lb = new QLabel;
@ -437,7 +437,7 @@ bool CtrlVolumePanel::restoreScheduleJson(QJsonObject json) {
}
}
}
return items.count() > 0;
return items.size() > 0;
}
QJsonObject CtrlVolumePanel::getScheduleJson() {
QJsonArray items;

View File

@ -2,6 +2,7 @@
#define CTRLVOLUMEPANEL_H
#include "gutil/qgui.h"
#include "gutil/qjson.h"
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
@ -17,7 +18,7 @@ protected:
void transUi();
private:
bool restoreScheduleJson(QJsonObject);
bool restoreScheduleJson(JValue);
QJsonObject getScheduleJson();
QLabel *lbVolumeControl;

View File

@ -35,22 +35,22 @@ ProgressesDlg::ProgressesDlg(QWidget *parent) : QDialog(parent) {
}
void ProgressesItem::sendProgress(const QString &id) {
QJsonObject json;
JObj json;
json.insert("_id", 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) [=] {
if(treeWidget()==0) return;
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
setRes(id+" "+tr("Error")+": "+err, Qt::red);
setRes(id+" "+translate("","Error")+": "+err, Qt::red);
return;
}
auto progre = json["progress"].toInt();
if(progre >= 100) {
fdProgress->setValue(100);
setRes("FPGA "+tr("Install Success"), Qt::darkGreen);
setRes("MCU "+tr("Install Success"), Qt::darkGreen);
} else if(progre == -1) {
fdProgress->setValue(100);
setRes(tr("Same version, needn't update"), Qt::darkGreen);

View File

@ -142,7 +142,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
else items.append(item);
}
if(items.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
return;
}
QByteArray fileData;
@ -153,7 +153,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
fileData = file.readAll();
file.close();
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;
}
} else if(! fileId.isEmpty()) {
@ -170,15 +170,15 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
fileData = reply->readAll();
if(! err.isEmpty()) {
if(! fileData.isEmpty()) err += "\n"+fileData;
QMessageBox::critical(this, tr("Error"), err);
QMessageBox::critical(this, translate("","Error"), err);
return;
}
if(fileData.isEmpty()) {
QMessageBox::critical(this, tr("Error"), tr("Online file is empty"));
QMessageBox::critical(this, translate("","Error"), tr("Online file is empty"));
return;
}
} else {
QMessageBox::critical(this, tr("Error"), tr("File is empty"));
QMessageBox::critical(this, translate("","Error"), tr("File is empty"));
return;
}
auto nameBytes = fileName.toUtf8();
@ -193,7 +193,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
item->setResult(tr("Uploading")+" ...");
item->fdProgress->setValue(0);
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) {
if(bytesTotal==0) return;
item->fdProgress->setValue(bytesSent*100/bytesTotal);
@ -219,14 +219,14 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
json.insert("_type", "SynchronousHardwareVersion");
}
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) [=] {
if(item->treeWidget()==0) return;
QJsonDocument json;
auto err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
item->isUpdating = false;
item->setResult(tr("Install error")+": "+err, Qt::red);
item->setResult(translate("","Install")+" "+translate("","Error")+": "+err, Qt::red);
return;
}
if(isApk || ! json["hasProgress"].toBool()) {
@ -264,7 +264,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
connect(btnUninstall, &QPushButton::clicked, this, [this, fdApk] {
auto strApkName = fdApk->currentText();
if(strApkName.isEmpty()) {
QMessageBox::information(this, tr("Tip"), "APK is Empty");
QMessageBox::information(this, translate("","Tip"), "APK is Empty");
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) {
auto item = (UpdateApkItem *) table->topLevelItem(i);
item->setResult(tr("Uninstalling")+" ...");
QJsonObject json;
JObj json;
json.insert("_id", "UninstallSoftware");
json.insert("_type", "UninstallSoftware");
json.insert("packageName", strApkName);
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
ConnReply(reply, item) [reply, item, strApkName] {
QString err = checkReplyForJson(reply, "error");
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").post(json);
ConnReply(reply, item) [=] {
auto err = errStrWithJson(reply, "error");
if(! err.isEmpty()) {
item->setResult(tr("Uninstall error")+": "+err, Qt::red);
item->setResult(translate("","Uninstall")+" "+translate("","Error")+": "+err, Qt::red);
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"));
connect(btnCheck, &QPushButton::clicked, this, [this, fdApk] {
QString strApkName = fdApk->currentText();
auto strApkName = fdApk->currentText();
int cnt = table->topLevelItemCount();
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("id") == Qt::Checked) {
auto item = (UpdateApkItem *) table->topLevelItem(i);
@ -322,7 +322,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
hBox->addStretch();
auto btnRefresh = new QPushButton(tr("Refresh"));
auto btnRefresh = new QPushButton(translate("","Refresh"));
connect(btnRefresh, &QPushButton::clicked, this, [=] {
table->clear();
table->fdCheckAll->setCheckState(Qt::Unchecked);
@ -369,7 +369,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
if(! item->isLocked) return;
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;
QJsonObject json;
json.insert("_id", "VerifyPassword");
@ -379,16 +379,16 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
waitingDlg->show();
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
ConnReply(reply, waitingDlg) [=] {
QJsonDocument json;
auto err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(this, tr("Error"), err);
QMessageBox::critical(this, translate("","Error"), err);
return;
}
if(! json["result"].toBool()) {
waitingDlg->close();
QMessageBox::warning(this, tr("Tip Info"), tr("password is wrong"));
QMessageBox::warning(this, translate("","Tip"), tr("password is wrong"));
return;
}
waitingDlg->success();
@ -495,11 +495,11 @@ void UpgradeApkDialog::sendProgress(UpdateApkItem *item) {
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(30000).post(json);
ConnReply(reply, item) [=] {
if(item->treeWidget()==0) return;
QJsonDocument json;
auto err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
item->isUpdating = false;
item->setResult("GetFpgaUpdateProgress "+tr("Error")+": "+err, Qt::red);
item->setResult("GetFpgaUpdateProgress "+translate("","Error")+": "+err, Qt::red);
return;
}
auto progre = json["progress"].toInt();
@ -532,9 +532,9 @@ void UpgradeApkDialog::keyPressEvent(QKeyEvent *event) {
void UpdateApkItem::OnCheckFpgaVersions() {
QJsonObject json;
json.insert("_id", "CheckHardwareVersions");
json.insert("_type", "CheckHardwareVersions");
JObj json;
json["_id"] = "CheckHardwareVersions";
json["_type"] = "CheckHardwareVersions";
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
ConnReply(reply, fdProgress) [=] {
if(treeWidget()==0) return;
@ -553,9 +553,9 @@ void UpdateApkItem::OnCheckFpgaVersions() {
});
}
void UpdateApkItem::OnCheckSoftVersions(int repeat) {
QJsonObject json;
json.insert("_id", "CheckSoftVersions");
json.insert("_type", "CheckSoftVersions");
JObj json;
json["_id"] = "CheckSoftVersions";
json["_type"] = "CheckSoftVersions";
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
ConnReply(reply, fdProgress) [=] {
if(treeWidget()==0) return;

View File

@ -23,15 +23,15 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) {
JObj json;
json.insert("_id", "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();
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, waitingDlg) [=] {
waitingDlg->close();
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
QMessageBox::critical(treeWidget(), DevicePanel::tr("Error"), err);
QMessageBox::critical(treeWidget(), translate("","Error"), err);
return;
}
ImgDlg dlg(QByteArray::fromBase64(json["data"].toString().toLatin1()), treeWidget());
@ -55,7 +55,7 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) {
QObject::connect(btnUnlock, &QPushButton::clicked, btnUnlock, [this] {
if(! mCard.isLocked) return;
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;
JObj json;
json.insert("_id", "VerifyPassword");
@ -65,16 +65,16 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) {
waitingDlg->show();
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(60000).post(json);
ConnReply(reply, waitingDlg) [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(treeWidget(), DevicePanel::tr("Error"), err);
QMessageBox::critical(treeWidget(), translate("","Error"), err);
return;
}
if(! json["result"].toBool()) {
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;
}
waitingDlg->success();

View File

@ -120,7 +120,7 @@ QComboBox QAbstractItemView::item {
QComboBox QAbstractItemView::item:selected {background-color: #09c;}
)rrr");
btnRefresh = new QPushButton(tr("Refresh"), areaFlash);
btnRefresh = new QPushButton(translate("","Refresh"), areaFlash);
btnRefresh->setGeometry(0, 0, 75, areaFlash->height());
connect(btnRefresh, &QPushButton::clicked, this, [this] {
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("Firmware Version")).append(": ").append(item->mCard.firmwareVer).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;
json.insert("_id", "CheckSoftVersions");
json.insert("_type", "CheckSoftVersions");
@ -289,7 +289,7 @@ QPushButton:hover {background-color: #08b;}
auto bnSearch = new QPushButton(tr("Search"));
connect(bnSearch, &QPushButton::clicked, fdIP, [this] {
QString ipsStr = fdIP->toPlainText();
auto ipsStr = fdIP->toPlainText();
if(ipsStr.isEmpty()) {
QMessageBox::warning(this, tr("Attention"), tr("Please input IP address!"));
return;
@ -299,8 +299,11 @@ QPushButton:hover {background-color: #08b;}
QMessageBox::warning(this, tr("Attention"), tr("Please input IP address!"));
return;
}
QByteArray 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;
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;
QCoreApplication::processEvents();
}
specifyIPDlg->accept();
});
hBox->addWidget(bnSearch);
@ -312,8 +315,8 @@ QPushButton:hover {background-color: #08b;}
transUi();
sendGetInfo();
mUdpTimer.start(30000);
auto cnt = sendGetInfo();
if(cnt<=100) mUdpTimer.start(30000);
}
DevicePanel::~DevicePanel() {
@ -321,7 +324,7 @@ DevicePanel::~DevicePanel() {
mUdpTimer.stop();
}
void DevicePanel::sendGetInfo() {
int DevicePanel::sendGetInfo() {
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,
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);
if(! can) continue;
auto addrEntries = face.addressEntries();
for(QNetworkAddressEntry &addrEntry : addrEntries) {
for(auto &addrEntry : addrEntries) {
auto ip = addrEntry.ip();
if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue;
auto broadcast = addrEntry.broadcast();
@ -341,10 +344,18 @@ void DevicePanel::sendGetInfo() {
}
}
auto ipstr = fdIP->toPlainText();
int cnt = 0;
if(! ipstr.isEmpty()) {
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) {
@ -352,13 +363,13 @@ void DevicePanel::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi();
}
void DevicePanel::transUi() {
btnRefresh->setText(tr("Refresh"));
btnRefresh->setText(translate("","Refresh"));
bnSpecifyIP->setItemText(0,tr("Specify IP"));
label_3->setText(tr("All"));
mDeviceTable->setHeaderText("online", tr("Online"));
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("brightness", tr("Screen Brightness"));
mDeviceTable->setHeaderText("power", tr("Power Status"));
@ -388,7 +399,7 @@ void DevicePanel::transCtrl() {
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 fdCardNumInfo->setText(tr("Multi screen operation")+". "+tr("selected num")+": "+QString::number(gSelCards.count()));
btnClear->setText(tr("Clear"));
btnClear->setText(translate("","Clear"));
}
}
void DevicePanel::newCtrl() {
@ -465,7 +476,7 @@ void DevicePanel::newCtrl() {
fdInfo->setMaximumWidth(360);
vBox2->addWidget(fdInfo);
btnClear = new QPushButton(tr("Clear"));
btnClear = new QPushButton(translate("","Clear"));
btnClear->setMinimumHeight(30);
btnClear->setProperty("ssType", "progManageTool");
connect(btnClear, &QPushButton::clicked, fdInfo, &QTextEdit::clear);

View File

@ -19,7 +19,7 @@ public:
explicit DevicePanel(QSettings &, QWidget *parent = nullptr);
~DevicePanel();
void sendGetInfo();
int sendGetInfo();
void newCtrl();
void init(DeviceItem *item);

View File

@ -121,6 +121,9 @@ public:
iterator end() const noexcept {
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;
}
};

View File

@ -33,13 +33,13 @@ inline QString byteSizeStr(double size) {
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) {
QTimer timer;
timer.setSingleShot(true);
inline int wait(int msec, QObject *context = 0, QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents) {
QEventLoop loop;
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
timer.start(msec);
loop.exec(flags);
QTimer::singleShot(msec, &loop, &QEventLoop::quit);
if(context) QObject::connect(context, &QObject::destroyed, &loop, [&] {
loop.exit(1);
});
return loop.exec(flags);
}
template <typename Func>

View File

@ -33,7 +33,7 @@ QString errStrWithData(QNetworkReply *reply, JValue *outJson) {
auto data = reply->readAll();
QString 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 "";
}
@ -49,7 +49,7 @@ QString errStrWithData(QNetworkReply *reply, QJsonDocument *outJson) {
auto data = reply->readAll();
QJsonParseError 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 "";
}

View File

@ -96,7 +96,7 @@ QString errStr(QNetworkReply *);
QString errStrWithData(QNetworkReply *, JValue * = 0);
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;
QEventLoop loop;
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);

View File

@ -3,6 +3,49 @@
#include <QTimerEvent>
#include <QPainter>
#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) {
setAttribute(Qt::WA_DeleteOnClose);
@ -39,6 +82,7 @@ void WaitingDlg::timerEvent(QTimerEvent *event) {
} else if(closeTimerId==event->timerId()) {
killTimer(closeTimerId);
closeTimerId = 0;
accept();
close();
} else QDialog::timerEvent(event);
}
@ -53,7 +97,7 @@ void WaitingDlg::showLater() {
showTimerId = startTimer(200);
}
void WaitingDlg::success() {
fdText->setText(sucText.isEmpty() ? tr("Success") : sucText);
fdText->setText(sucText.isEmpty() ? QCoreApplication::translate("","Success") : sucText);
mIndicator->success();
if(showTimerId) {
killTimer(showTimerId);

View File

@ -9,15 +9,33 @@ class WaitingIndicator : public QWidget {
Q_OBJECT
public:
using QWidget::QWidget;
QColor mColor{0x0088ff};
QColor mColor = 0x0088ff;
public slots:
void success();
protected:
void timerEvent(QTimerEvent * event) override;
void paintEvent(QPaintEvent * event) override;
int angle{0};
int timerId{0};
int angle = 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 {

View File

@ -51,6 +51,12 @@ int main(int argc, char *argv[]) {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
auto config = QSslConfiguration::defaultConfiguration();
config.setProtocol(QSsl::AnyProtocol);
config.setPeerVerifyMode(QSslSocket::VerifyNone);
config.setPeerVerifyDepth(1);
QSslConfiguration::setDefaultConfiguration(config);
QApplication::setOrganizationName("Sysolution");
QApplication::setOrganizationDomain("ledok.cn");
QApplication::setApplicationName("LedOK Express");
@ -108,14 +114,14 @@ QString checkReply(QNetworkReply *reply, QJsonDocument *outJson) {
auto err = errStr(reply);
if(! err.isEmpty()) {
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;
}
if(outJson) {
auto data = reply->readAll();
QJsonParseError 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 "";
}
@ -124,47 +130,47 @@ QString errStrWithJson(QNetworkReply *reply, JValue *outJson, QByteArray *outDat
auto data = reply->readAll();
if(outData) *outData = data;
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;
}
QString error;
auto json = JFrom(data, &error);
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+translate("","Device replied")+": "+data;
if(! json["success"].toBool()) return translate("","Fail")+". "+translate("","Device replied")+": "+data;
if(outJson) *outJson = json;
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) {
auto err = errStr(reply);
auto data = reply->readAll();
if(outData) *outData = data;
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;
}
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()) return QCoreApplication::translate("Def","Fail")+". "+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 translate("","Fail")+". "+translate("","Device replied")+": "+data;
if(outJson) outJson->swap(json);
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) {
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 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;
}

View File

@ -2,12 +2,14 @@
#define MAIN_H
#include "gutil/qjson.h"
#include "program/progitem.h"
#include <QCoreApplication>
#include <QJsonDocument>
#include <QNetworkReply>
#include <QOpenGLWidget>
#include <QTextEdit>
#define PAGEDEL_SUFFIX "@D$E$L&20111005&"
#define PAGEDEL_SUFFIX "~temp~temp~temp"
#define RECTF_INVALID QRectF(-9999, -9999, 0, 0)
struct LedCard {
@ -63,6 +65,7 @@ QString programsDir();
extern Tick *gTick;
extern QString gFileHome;
extern QString gApkHome;
extern int gProgWidth, gProgHeight;
class DevicePanel;
extern DevicePanel *gDevicePanel;
extern QList<LedCard> gSelCards;
@ -76,6 +79,10 @@ extern bool gShowIP;
extern bool gShowAlias;
extern bool gShowLora;
extern QTextEdit *gFdResInfo;
extern ProgItem *gProgItem;
extern quint64 dirFileSize(const QString &path);
extern bool copyDir(const QString &source, const QString &destination, bool override);
extern unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize);
@ -95,6 +102,9 @@ enum _ENUM_CONTRL_WIDGET {
class DeviceItem;
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) {
auto aparts = a.split(".");
auto bparts = b.split(".");
@ -110,40 +120,40 @@ inline int verCompare(const QString& a, const QString& b) {
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
QString errStrWithJson(QNetworkReply *, QString errField);
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
QString checkReplyForJson(QNetworkReply *, QString errField);
void MergeFmt(QTextEdit *textEdit, const QTextCharFormat &fmt);
#define Def_CtrlReqPre \
waitingDlg->show();\
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);
#define Def_CtrlSetReqAfter \
QString err = checkReplyForJson(reply);\
auto err = errStrWithJson(reply);\
if(! err.isEmpty()) {\
waitingDlg->close();\
QMessageBox::critical(this, tr("Error"), err);\
QMessageBox::critical(this, translate("","Error"), err);\
return;\
}\
waitingDlg->success();
#define Def_CtrlSingleGetReply \
QJsonDocument json;\
QString err = checkReplyForJson(reply, &json);\
JValue json;\
auto err = errStrWithJson(reply, &json);\
if(! err.isEmpty()) {\
waitingDlg->close();\
QMessageBox::critical(this, tr("Error"), err);\
QMessageBox::critical(this, translate("","Error"), err);\
return;\
}
#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, [=] {\
QString err = checkReplyForJson(reply);\
gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\
auto err = errStrWithJson(reply);\
gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?translate("","Success"):err));\
});
class LocalObj : public QObject {

View File

@ -22,6 +22,7 @@
extern QPoint gPlayPos;
QString gApkHome;
int gProgWidth = 512, gProgHeight = 256;
bool gVideoCompress = false;
bool gVideoTranscoding = false;
bool gTextAntialiasing = false;
@ -350,7 +351,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
fdUpdLog->setReadOnly(true);
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) [=] {
auto err = errStr(reply);
if(! err.isEmpty()) {
@ -391,7 +392,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
auto err = errStr(reply);
if(! err.isEmpty()) {
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr("Error")+": "+err);
msgBox.setText(translate("","Error")+": "+err);
return;
}
msgBox.accept();
@ -409,7 +410,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
});
menu_setting->addAction(act_upd);
auto reply = NetReq(UpdVerUrl).timeout(60000).get();
auto reply = NetReq(UpdVerUrl).get();
ConnReply(reply, this) [=] {
auto err = errStr(reply);
if(! err.isEmpty()) {
@ -567,11 +568,11 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
fdDetectCard->setCursor(Qt::PointingHandCursor);
fdDetectCard->setProperty("ssType", "progManageTool");
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;
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
foreach(QNetworkInterface interfaces, networkinterfaces) {//networkinterfaces负责提供主机的IP地址和网络接口的列表
foreach(QNetworkAddressEntry entry, interfaces.addressEntries()) {//QNetworkAddressEntry存储了一个IP地址子网掩码和广播地址
for(QNetworkInterface &interfaces : networkinterfaces) {//networkinterfaces负责提供主机的IP地址和网络接口的列表
for(QNetworkAddressEntry &entry : interfaces.addressEntries()) {//QNetworkAddressEntry存储了一个IP地址子网掩码和广播地址
entry.setBroadcast(QHostAddress::Broadcast);
QHostAddress broadcastAddress("255.255.255.255");
entry.setBroadcast(QHostAddress::Broadcast);
@ -617,6 +618,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
hBox->addLabel("V" APP_VERSION" - " __DATE__);
gApkHome = settings.value("ApkHome").toString();
gProgWidth = settings.value("ProgWidth", 512).toInt();
gProgHeight = settings.value("ProgHeight", 256).toInt();
gVideoCompress = settings.value("VideoCompress").toBool();
gVideoTranscoding = settings.value("VideoTranscoding").toBool();
gTextAntialiasing = settings.value("TextAntialiasing").toBool();
@ -680,6 +683,8 @@ MainWindow::~MainWindow() {
settings.setValue("MainIsMax", isMaximized());
settings.setValue("PlayPos", gPlayPos);
if(! gApkHome.isEmpty()) settings.setValue("ApkHome", gApkHome);
settings.setValue("ProgWidth", gProgWidth);
settings.setValue("ProgHeight", gProgHeight);
if(mDevicePanel->fdIP) {
auto ipstr = mDevicePanel->fdIP->toPlainText();
if(! ipstr.isEmpty()) settings.setValue("SpecifyIP", ipstr);

View File

@ -383,8 +383,8 @@ mGuangYingPinWidget::mGuangYingPinWidget(QWidget *parent) : QWidget(parent) {
}
connect(grp, &QButtonGroup::idClicked, this, [=](int id) {
if(groupBox_com->isChecked()) {
if(pushButtonMainOpen->text()==tr("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(pushButtonMainOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortName->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);
});
@ -609,13 +609,13 @@ void mGuangYingPinWidget::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi();
}
void mGuangYingPinWidget::transUi() {
pushButtonSend->setText(tr("Send"));
pushButtonSend->setText(translate("","Send"));
pushButtonMainOpen->setText(tr("Open"));
pushButtonAuxOpen->setText(tr("Open"));
pushButtonBrightnessSet->setText(tr("Set"));
pushButtonBrightnessSet->setText(translate("","Set"));
pushButtonScreenOn->setText(tr("Screen On"));
pushButtonScreenOff->setText(tr("Screen Off"));
pushButtonRefresh->setText(tr("Refresh"));
pushButtonRefresh->setText(translate("","Refresh"));
groupBoxMain->setTitle(tr("Main"));
groupBoxAux->setTitle(tr("Auxiliary"));
groupBoxParam->setTitle(tr("Param configuration"));
@ -636,7 +636,7 @@ void mGuangYingPinWidget::transUi() {
label_BrightNess->setText(tr("Brightness"));
label_ComStatus->setText(tr("State:Off"));
label_ComStatusAux->setText(tr("State:Off"));
pushButtonClearLog->setText(tr("Clear"));
pushButtonClearLog->setText(translate("","Clear"));
checkBoxDebug->setText(tr("Debug"));
groupBox_Network->setTitle(tr("Network"));
groupBox_com->setTitle(tr("Com"));
@ -650,24 +650,24 @@ void mGuangYingPinWidget::OnAnsyProgramCustom(void)
{
int id = spinBox_ProgramIndex->value();
if(groupBox_com->isChecked()) {
if(pushButtonMainOpen->text()==tr("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(pushButtonMainOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortName->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(checkBoxDebug->isChecked()) textEditReadBuf->append("OnAnsyProgramCustom");
}
void mGuangYingPinWidget::OnAnsyProgramCustomByChanged(int id) {
if(groupBox_com->isChecked()) {
if(pushButtonMainOpen->text()==tr("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(pushButtonMainOpen->text()==translate("","Close")) Set_program_buf_and_send(comboBox_SPortName->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);
}
void mGuangYingPinWidget::OnBrightnessSetByChanged(int icurValue)
{
if(pushButtonMainOpen->text()==tr("Close"))
if(pushButtonMainOpen->text()==translate("","Close"))
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);
}
@ -686,9 +686,9 @@ void mGuangYingPinWidget::OnBrightnessSet(void)
{
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());
if(pushButtonAuxOpen->text()==tr("Close"))
if(pushButtonAuxOpen->text()==translate("","Close"))
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),spinBox_BrightnessValue->value());
}
@ -701,9 +701,9 @@ void mGuangYingPinWidget::OnScreenOn(void)
{
if(groupBox_com->isChecked())
{
if(pushButtonMainOpen->text()==tr("Close"))
if(pushButtonMainOpen->text()==translate("","Close"))
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);
}
if(groupBox_Network->isChecked())
@ -715,9 +715,9 @@ void mGuangYingPinWidget::OnScreenOff(void)
{
if(groupBox_com->isChecked())
{
if(pushButtonMainOpen->text()==tr("Close"))
if(pushButtonMainOpen->text()==translate("","Close"))
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);
}
if(groupBox_Network->isChecked())
@ -854,13 +854,13 @@ void mGuangYingPinWidget::MWOnoffPort(void)
comboBox_SPortDataBit->setEnabled(false);
comboBox_SPortOEBit->setEnabled(false);
comboBox_SPortStopBit->setEnabled(false);
pushButtonMainOpen->setText(tr("Close"));
pushButtonMainOpen->setText(translate("","Close"));
//发送设置使能
graphicsView_ComStatus->setStyleSheet("background-color: rgb(0, 255, 0);");
label_ComStatus->setText(tr("State:On"));
}
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_SPortOEBitAux->setEnabled(false);
comboBox_SPortStopBitAux->setEnabled(false);
pushButtonAuxOpen->setText(tr("Close"));
pushButtonAuxOpen->setText(translate("","Close"));
//发送设置使能
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(0, 255, 0);");
label_ComStatusAux->setText(tr("State:On"));
}
else {
QMessageBox::information(this, tr("Tip"), tr("OpenPort COM failed"));
QMessageBox::information(this, translate("","Tip"), tr("OpenPort COM failed"));
}
}

View File

@ -1,4 +1,5 @@
#include "playwin.h"
#include "main.h"
#include "eledigiclock.h"
#include "eleanaclock.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);
dlg.exec();
});
act = menu->addAction(tr("Close"));
act = menu->addAction(translate("","Close"));
connect(act, &QAction::triggered, this, [this] {
if(self==this) self = nullptr;
close();

View File

@ -12,6 +12,7 @@
#include <QFileDialog>
#include <QLineEdit>
#include <QProcess>
#include <QInputDialog>
ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
setAttribute(Qt::WA_DeleteOnClose);
@ -29,11 +30,11 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
vBox->addLayout(hBox);
bnNew = new QPushButton(tr("New"));
bnNew->setFixedSize(88, 38);
bnNew->setMinimumSize(75, 30);
bnNew->setProperty("ssType", "progManageTool");
hBox->addWidget(bnNew);
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(checkIfNameRepeated(dlg.fdName->text())) return;
std::vector<int> widths;
@ -58,7 +59,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
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->save();//保存pro.json
if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
@ -71,70 +72,67 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
});
bnEdit = new QPushButton(tr("Edit"));
bnEdit->setFixedSize(QSize(88, 38));
bnEdit->setMinimumSize(75, 30);
bnEdit->setProperty("ssType", "progManageTool");
bnEdit->setEnabled(false);
hBox->addWidget(bnEdit);
connect(bnEdit, SIGNAL(clicked(bool)), this, SLOT(onEditClicked(bool)));
bnDelete = new QPushButton(tr("Delete"));
bnDelete->setFixedSize(QSize(88, 38));
bnDelete->setMinimumSize(75, 30);
bnDelete->setProperty("ssType", "progManageTool");
bnDelete->setEnabled(false);
hBox->addWidget(bnDelete);
connect(bnDelete, SIGNAL(clicked(bool)), this, SLOT(onDeleteClicked(bool)));
bnImport = new QPushButton(tr("Import"));
bnImport->setFixedSize(88, 38);
bnImport->setMinimumSize(75, 30);
bnImport->setProperty("ssType", "progManageTool");
hBox->addWidget(bnImport);
connect(bnImport, &QPushButton::clicked, this, [this] {
auto dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(dir.isEmpty()) return;
QString progsDir = programsDir();
auto progsDir = programsDir();
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;
}
QStringList progDirs;
if(QFileInfo::exists(dir + "/pro.json")) progDirs.append(dir);
PathPairList pathPairs;
if(QFileInfo::exists(dir + "/pro.json")) pathPairs.append({dir, progsDir+"/"+QFileInfo(dir).fileName()});
else {
QStringList subdirNames = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(QString &subdirName : subdirNames) {
auto subdir = dir + "/" + subdirName;
if(! QFileInfo::exists(subdir + "/pro.json")) continue;
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;
}
progDirs.append(subdir);
pathPairs.append({subdir, progsDir+"/"+subdirName});
}
if(progDirs.isEmpty()) return;
if(pathPairs.isEmpty()) return;
}
ProgPortDlg dlg(this, tr("Import"));
dlg.table->setRowCount(progDirs.count());
for(int i=0; i<progDirs.count(); i++) {
dlg.table->setItem(i, 0, new QTableWidgetItem(QFileInfo(progDirs[i]).fileName()));
dlg.table->setRowCount(pathPairs.count());
for(int i=0; i<pathPairs.count(); i++) {
dlg.table->setItem(i, 0, new QTableWidgetItem(QFileInfo(pathPairs[i].first).fileName()));
dlg.table->setCellWidget(i, 1, new QProgressBar);
}
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]));
auto thread = new CopyDirThread();
thread->dirSrcs = progDirs;
thread->dirDst = progsDir;
for(int i=0; i<pathPairs.count(); i++) ((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(pathPairs[i].first));
auto thread = new CopyDirThread;
thread->paths = pathPairs;
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
});
thread->start();
});
dlg.exec();
mProgTree->clear();
addProFiles();
});
bnExport = new QPushButton(tr("Export"));
bnExport->setFixedSize(QSize(88, 38));
bnExport->setMinimumSize(75, 30);
bnExport->setEnabled(false);
bnExport->setProperty("ssType", "progManageTool");
hBox->addWidget(bnExport);
@ -151,16 +149,15 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
dlg.table->setCellWidget(i, 1, new QProgressBar);
}
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;
auto progsDir = programsDir();
auto thread = new CopyDirThread();
auto thread = new CopyDirThread;
for(int i=0; i<progNames.count(); i++) {
auto dir = progsDir+"/"+progNames[i];
((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) {
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
});
@ -169,15 +166,75 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
dlg.exec();
});
bnSend = new QPushButton(tr("Send"));
bnSend->setFixedSize(QSize(88, 38));
bnRename = new QPushButton(tr("Rename"));
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->setEnabled(false);
bnSend->hide();
hBox->addWidget(bnSend);
btnPlay = new QPushButton(tr("Play")+"/"+tr("Stop"));
btnPlay->setFixedSize(QSize(88, 38));
btnPlay->setMinimumSize(75, 30);
btnPlay->setProperty("ssType", "progManageTool");
hBox->addWidget(btnPlay);
connect(btnPlay, &QPushButton::clicked, this, [this] {
@ -251,7 +308,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
auto str = ((ProgItem*)item)->mProgDir;
QProcess::execute("explorer", {str.replace('/','\\')});
#endif
#ifdef Q_OS_MACOS
#ifdef Q_OS_MAC
QProcess::execute("open", {"-R", ((ProgItem*)item)->mProgDir});
#endif
});
@ -269,16 +326,14 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
QDir oldProgsQDir(oldProgsDir);
if(oldProgsQDir.exists()) {
CopyDirThread thread;
thread.dirDst = mProgsDir;
auto names = oldProgsQDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(auto &name : names) if(! name.endsWith("_tmp")) thread.dirSrcs.append(oldProgsDir + "/" + name);
if(! thread.dirSrcs.isEmpty()) thread.move();
for(auto &name : names) if(! name.endsWith("_tmp")) thread.paths.append({oldProgsDir+"/"+name, mProgsDir+"/"+name});
if(! thread.paths.isEmpty()) thread.move();
oldProgsQDir.removeRecursively();
}
}
}
//查找根路径下的项目文件夹查找文件夹下的节目pro.json信息包括节目名称大小像素备注等信息
if(! mProgsDir.isEmpty()) addProFiles();
addProFiles();
QSettings settings;
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);
@ -302,12 +357,15 @@ void ProgPanel::transUi() {
bnDelete->setText(tr("Delete"));
bnImport->setText(tr("Import"));
bnExport->setText(tr("Export"));
bnSend->setText(tr("Send"));
bnRename->setText(tr("Rename"));
bnSend->setText(translate("","Send"));
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
}
void ProgPanel::addProFiles() {
if(mProgsDir.isEmpty()) return;
auto progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
mProgTree->clear();
for(auto &progName : progNames) {
auto file = mProgsDir + "/" + progName + "/pro.json";
QFile qFile(file);
@ -365,7 +423,7 @@ bool ProgPanel::checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip){
return false;
}
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) {
for(int i=0; i<mProgTree->topLevelItemCount(); i++) if(mProgTree->item(i)->checkState("check") == Qt::Checked) {
auto item = (ProgItem*) mProgTree->topLevelItem(i--);

View File

@ -28,7 +28,7 @@ private:
QPushButton *bnNew;
QPushButton *bnEdit;
QPushButton *bnDelete;
QPushButton *bnImport, *bnExport;
QPushButton *bnImport, *bnExport, *bnRename, *bnCopy;
QPushButton *bnSend, *btnPlay;
};

View File

@ -6,9 +6,9 @@ CopyDirThread::CopyDirThread() {
}
void CopyDirThread::run() {
for(; i<dirSrcs.size(); i++) {
for(auto &path : paths) {
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() {
for(; i<dirSrcs.size(); i++) {
for(auto &path : paths) {
copiedSize = 0;
moveDir(dirSrcs[i], dirDst+"/"+QFileInfo(dirSrcs[i]).fileName());
moveDir(path.first, path.second);
}
}

View File

@ -3,19 +3,20 @@
#include <QThread>
using PathPairList = QList<std::pair<QString, QString>>;
class CopyDirThread : public QThread {
Q_OBJECT
public:
CopyDirThread();
QStringList dirSrcs;
QString dirDst;
PathPairList paths;
void run();
void move();
protected:
bool copyDir(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
bool moveDir(const QString &fromDir, const QString &toDir);
int i{0};
int i = 0;
int copiedSize = 0;
signals:
void sigProgress(int, int);

View File

@ -201,7 +201,7 @@ QWidget* EAClock::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new HBox(vBox);
hBox->addWidget(new QLabel(tr("Basic Properties")));
hBox->addWidget(new QLabel(translate("","Basic Properties")));
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);

View File

@ -1,6 +1,6 @@
#include "ebase.h"
#include "gutil/qgui.h"
#include "tools.h"
#include "main.h"
#include <QDirIterator>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
@ -20,11 +20,11 @@ int borderImgMaxWidth = 0;
int borderImgMaxHeight = 0;
struct Initer {
Initer() {
auto names = QDir(QApplication::applicationDirPath()+"/borders").entryList(QDir::Files);
auto names = QDir(QCoreApplication::applicationDirPath()+"/borders").entryList(QDir::Files);
for(auto &name : names) {
BorderImg bdImg;
bdImg.name = name;
bdImg.img = QPixmap(QApplication::applicationDirPath()+"/borders/"+bdImg.name);
bdImg.img = QPixmap(QCoreApplication::applicationDirPath()+"/borders/"+bdImg.name);
borderImgs.append(bdImg);
if(bdImg.img.width() > borderImgMaxWidth) borderImgMaxWidth = bdImg.img.width();
if(bdImg.img.height() > borderImgMaxHeight) borderImgMaxHeight = bdImg.img.height();

View File

@ -1,8 +1,8 @@
#include "edclock.h"
#include "base/locolorselector.h"
#include "main.h"
#include "tools.h"
#include "gutil/qgui.h"
#include "tools.h"
#include <QCheckBox>
#include <QFontComboBox>
#include <QSpinBox>
@ -11,22 +11,7 @@
EDClock::EDClock(EBase *multiWin) : EBase(multiWin) {
mType = EBase::DClock;
m_attr.timeZoneId = QTimeZone::systemTimeZoneId();
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;
timeZone = QTimeZone::systemTimeZone();
init();
}
@ -34,31 +19,49 @@ EDClock::EDClock(const JObj &json, EBase *multiWin) : EBase(multiWin) {
mType = EBase::DClock;
setBaseAttr(json);
auto widget = json["widget"];
if(widget.isNull()) {
widget = json;
font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
font.setUnderline(json["fontUnderline"].toBool());
color = json["color"].toStr("#ffff0000");
hasYear = widget["hasYear"].toBool();
hasMonth = widget["hasMonth"].toBool();
hasDay = widget["hasDay"].toBool();
hasHour = widget["hasHour"].toBool();
hasMin = widget["hasMin"].toBool();
hasSec = widget["hasSec"].toBool();
hasWeek = widget["hasWeek"].toBool();
hasAmPm = widget["hasAmPm"].toBool();
is12Hour = widget["is12Hour"].toBool();
isFullYear = widget["isFullYear"].toBool();
isMultiline = json["isMultiline"].toBool();
} else {
auto font = widget["font"];
m_attr.font = qfont(font["family"].toString(), font["size"].toInt(), font["bold"].toBool(), font["italics"].toBool());
m_attr.font.setUnderline(font["underline"].toBool());
m_attr.textColor = Tools::int2Color(font["color"].toInt());
m_attr.timeZoneId = widget["timeZone"].toString().toUtf8();
m_attr.year = widget["year"].toBool();
m_attr.month = widget["month"].toBool();
m_attr.day = widget["day"].toBool();
m_attr.hour = widget["hour"].toBool();
m_attr.min = widget["min"].toBool();
m_attr.sec = widget["sec"].toBool();
m_attr.weekly = widget["weekly"].toBool();
m_attr.fullYear = widget["fullYear"].toBool();
m_attr.hour12 = widget["12Hour"].toBool();
m_attr.AmPm = widget["AmPm"].toBool();
m_attr.dateStyle = widget["dateStyle"].toInt();
m_attr.timeStyle = widget["timeStyle"].toInt();
m_attr.multiline = widget["multiline"].toBool();
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();
}
void EDClock::init() {
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
datetime = cur.toTimeZone(QTimeZone(m_attr.timeZoneId));
datetime = cur.toTimeZone(timeZone);
update();
});
}
@ -67,35 +70,35 @@ void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
QString text;
QDate date = datetime.date();
QTime time = datetime.time();
QString spacer = m_attr.multiline ? "\n" : " ";
QString yearFmt = m_attr.fullYear ? "yyyy" : "yy";
QString spacer = isMultiline ? "\n" : " ";
QString yearFmt = isFullYear ? "yyyy" : "yy";
QString monthFmt = isSingleMD ? "M" : "MM";
QString dateFmt = isSingleMD ? "d" : "dd";
QString sep;
if(m_attr.dateStyle > 7) sep = "-";
else if(m_attr.dateStyle > 1) sep = "/";
switch(m_attr.dateStyle) {
if(dateStyle > 7) sep = "-";
else if(dateStyle > 1) sep = "/";
switch(dateStyle) {
case 0: case 1:
if(m_attr.year) text += date.toString(yearFmt) + "";
if(m_attr.month) text += date.toString(monthFmt) + "";
if(m_attr.day) text += date.toString(dateFmt) + "";
if(hasYear) text += date.toString(yearFmt) + "";
if(hasMonth) text += date.toString(monthFmt) + "";
if(hasDay) text += date.toString(dateFmt) + "";
break;
case 2: case 3: case 8: case 9:
if(m_attr.month) text += date.toString(monthFmt) + sep;
if(m_attr.day) text += date.toString(dateFmt) + sep;
if(m_attr.year) text += date.toString(yearFmt);
if(hasMonth) text += date.toString(monthFmt) + sep;
if(hasDay) text += date.toString(dateFmt) + sep;
if(hasYear) text += date.toString(yearFmt);
if(text.endsWith(sep)) text.chop(1);
break;
case 4: case 5: case 10: case 11:
if(m_attr.day) text += date.toString(dateFmt) + sep;
if(m_attr.month) text += date.toString(monthFmt) + sep;
if(m_attr.year) text += date.toString(yearFmt);
if(hasDay) text += date.toString(dateFmt) + sep;
if(hasMonth) text += date.toString(monthFmt) + sep;
if(hasYear) text += date.toString(yearFmt);
if(text.endsWith(sep)) text.chop(1);
break;
case 6: case 7: case 12: case 13:
if(m_attr.year) text += date.toString(yearFmt) + sep;
if(m_attr.month) text += date.toString(monthFmt) + sep;
if(m_attr.day) text += date.toString(dateFmt);
if(hasYear) text += date.toString(yearFmt) + sep;
if(hasMonth) text += date.toString(monthFmt) + sep;
if(hasDay) text += date.toString(dateFmt);
if(text.endsWith(sep)) text.chop(1);
break;
default:
@ -103,7 +106,7 @@ void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
}
if(! text.isEmpty()) text += spacer;
if(m_attr.weekly) {
if(hasWeek) {
auto dayOfWeek = date.dayOfWeek();
if(dayOfWeek==1) text += tr("MON");
else if(dayOfWeek==2) text += tr("TUE");
@ -115,18 +118,24 @@ void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
text += spacer;
}
QString timeFmt;
if(m_attr.hour12 && m_attr.AmPm) timeFmt += (time.hour()<12 ? tr("AM") : tr("PM")) + " ";
if(m_attr.hour) timeFmt += (m_attr.timeStyle!=1 ? "hh:" : "h:");
if(m_attr.min) timeFmt += "mm:";
if(m_attr.sec) timeFmt += "ss";
if(is12Hour && hasAmPm) timeFmt += (time.hour()<12 ? tr("AM") : tr("PM")) + " ";
if(hasHour) timeFmt += (isSingleHour ? "h:" : "hh:");
if(hasMin) timeFmt += "mm:";
if(hasSec) timeFmt += "ss";
if(timeFmt.endsWith(":")) timeFmt.chop(1);
if(! timeFmt.isEmpty()) text += time.toString(timeFmt);
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->setPen(m_attr.textColor);
m_attr.font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
painter->setFont(m_attr.font);
painter->drawText(innerRect(), text, QTextOption(Qt::AlignCenter));
painter->setPen(color);
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
painter->setFont(font);
for(auto &line : lines) {
painter->drawText(rect, line, QTextOption(Qt::AlignCenter));
rect.translate(0, rect.height());
}
painter->restore();
EBase::paint(painter, option, widget);
}
@ -135,12 +144,12 @@ QWidget* EDClock::attrWgt() {
auto wgtAttr = new QWidget();
auto vBox = new QVBoxLayout(wgtAttr);
vBox->setContentsMargins(6, 0, 6, 0);
if(mMultiWin!=nullptr) vBox->setSpacing(3);
if(mMultiWin) vBox->setSpacing(3);
addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Basic Properties")));
hBox->addWidget(new QLabel(translate("","Basic Properties")));
auto line = new QFrame();
line->setFrameShape(QFrame::HLine);
@ -156,9 +165,9 @@ QWidget* EDClock::attrWgt() {
auto edTimeZone = new QComboBox;
auto zoneIds = QTimeZone::availableTimeZoneIds();
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) {
m_attr.timeZoneId = text.toUtf8();
timeZone = QTimeZone(text.toUtf8());
update();
});
hBox->addWidget(edTimeZone);
@ -176,25 +185,25 @@ QWidget* EDClock::attrWgt() {
hBox->addSpacing(6);
auto fdYear = new QCheckBox(tr("Year"));
fdYear->setChecked(m_attr.year);
fdYear->setChecked(hasYear);
connect(fdYear, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.year = checked;
hasYear = checked;
update();
});
hBox->addWidget(fdYear);
auto fdMonth = new QCheckBox(tr("Month"));
fdMonth->setChecked(m_attr.month);
fdMonth->setChecked(hasMonth);
connect(fdMonth, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.month = checked;
hasMonth = checked;
update();
});
hBox->addWidget(fdMonth);
auto fdDay = new QCheckBox(tr("Day"));
fdDay->setChecked(m_attr.day);
fdDay->setChecked(hasDay);
connect(fdDay, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.day = checked;
hasDay = checked;
update();
});
hBox->addWidget(fdDay);
@ -205,25 +214,25 @@ QWidget* EDClock::attrWgt() {
hBox->addSpacing(6);
auto fdHour = new QCheckBox(tr("Hour"));
fdHour->setChecked(m_attr.hour);
fdHour->setChecked(hasHour);
connect(fdHour, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.hour = checked;
hasHour = checked;
update();
});
hBox->addWidget(fdHour);
auto fdMin = new QCheckBox(tr("Min."));
fdMin->setChecked(m_attr.min);
fdMin->setChecked(hasMin);
connect(fdMin, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.min = checked;
hasMin = checked;
update();
});
hBox->addWidget(fdMin);
auto fdSec = new QCheckBox(tr("Sec."));
fdSec->setChecked(m_attr.sec);
fdSec->setChecked(hasSec);
connect(fdSec, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.sec = checked;
hasSec = checked;
update();
});
hBox->addWidget(fdSec);
@ -233,17 +242,17 @@ QWidget* EDClock::attrWgt() {
hBox = new QHBoxLayout();
hBox->addSpacing(6);
auto fdHasWeek = new QCheckBox(tr("Weekly"));
fdHasWeek->setChecked(m_attr.weekly);
fdHasWeek->setChecked(hasWeek);
connect(fdHasWeek, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.weekly = checked;
hasWeek = checked;
update();
});
hBox->addWidget(fdHasWeek);
auto fdFullYear = new QCheckBox(tr("Full Year"));
fdFullYear->setChecked(m_attr.fullYear);
fdFullYear->setChecked(isFullYear);
connect(fdFullYear, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.fullYear = checked;
isFullYear = checked;
update();
});
hBox->addWidget(fdFullYear);
@ -254,19 +263,19 @@ QWidget* EDClock::attrWgt() {
hBox->addSpacing(6);
auto fdIs12Hour = new QCheckBox(tr("12-Hour"));
fdIs12Hour->setChecked(m_attr.hour12);
fdIs12Hour->setChecked(is12Hour);
hBox->addWidget(fdIs12Hour);
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) {
m_attr.hour12 = checked;
is12Hour = checked;
fdAmPm->setVisible(checked);
if(! checked) fdAmPm->setChecked(false);
update();
});
connect(fdAmPm, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.AmPm = checked;
hasAmPm = checked;
update();
});
hBox->addWidget(fdAmPm);
@ -282,24 +291,24 @@ QWidget* EDClock::attrWgt() {
hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Date Style")));
auto fdDateFmt = new QComboBox();
fdDateFmt->addItem("1955年02月04日");
fdDateFmt->addItem("1955年2月4日");
fdDateFmt->addItem("2/24/1955");
fdDateFmt->addItem("02/24/1955");
fdDateFmt->addItem("24/2/1955");
fdDateFmt->addItem("24/02/1955");
fdDateFmt->addItem("1955/2/24");
fdDateFmt->addItem("1955/02/24");
fdDateFmt->addItem("2-24-1955");
fdDateFmt->addItem("02-24-1955");
fdDateFmt->addItem("24-2-1955");
fdDateFmt->addItem("24-02-1955");
fdDateFmt->addItem("1955-2-24");
fdDateFmt->addItem("1955-02-24");
fdDateFmt->setCurrentIndex(m_attr.dateStyle);
connect(fdDateFmt, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int index) {
m_attr.dateStyle = index;
auto fdDateFmt = new QComboBox;
fdDateFmt->addItem("1970-02-24", 13);
fdDateFmt->addItem("1970-2-24", 12);
fdDateFmt->addItem("1970年02月04日", 0);
fdDateFmt->addItem("1970年2月4日", 1);
fdDateFmt->addItem("1970/02/24", 7);
fdDateFmt->addItem("1970/2/24", 6);
fdDateFmt->addItem("02-24-1970", 9);
fdDateFmt->addItem("2-24-1970", 8);
fdDateFmt->addItem("02/24/1970", 3);
fdDateFmt->addItem("2/24/1970", 2);
fdDateFmt->addItem("24-02-1970", 11);
fdDateFmt->addItem("24-2-1970", 10);
fdDateFmt->addItem("24/02/1970", 5);
fdDateFmt->addItem("24/2/1970", 4);
SetCurData(fdDateFmt, dateStyle);
connect(fdDateFmt, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=](int index) {
dateStyle = fdDateFmt->itemData(index).toInt();
isSingleMD = index==1||index==2||index==4||index==6||index==8||index==10||index==12;
update();
});
@ -312,12 +321,12 @@ QWidget* EDClock::attrWgt() {
hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Time Style")));
auto fdTimeFmt = new QComboBox();
auto fdTimeFmt = new QComboBox;
fdTimeFmt->addItem("HH: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) {
m_attr.timeStyle = index;
isSingleHour = index;
update();
});
hBox->addWidget(fdTimeFmt);
@ -330,9 +339,9 @@ QWidget* EDClock::attrWgt() {
hBox->addWidget(new QLabel(tr("Display Style")));
auto fdIsMultiline = new QCheckBox(tr("Multiline"));
fdIsMultiline->setChecked(m_attr.multiline);
fdIsMultiline->setChecked(isMultiline);
connect(fdIsMultiline, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.multiline = checked;
isMultiline = checked;
update();
});
hBox->addWidget(fdIsMultiline);
@ -340,7 +349,7 @@ QWidget* EDClock::attrWgt() {
vBox->addLayout(hBox);
line = new QFrame();
line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
@ -350,23 +359,23 @@ QWidget* EDClock::attrWgt() {
auto fdFontFamily = new QFontComboBox();
fdFontFamily->setEditable(false);
fdFontFamily->setCurrentText(m_attr.font.family());
fdFontFamily->setCurrentText(font.family());
connect(fdFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &f) {
QFont font(f.family());
font.setPixelSize(m_attr.font.pixelSize());
font.setBold(m_attr.font.bold());
font.setItalic(m_attr.font.italic());
font.setUnderline(m_attr.font.underline());
m_attr.font = font;
QFont ft(f.family());
ft.setPixelSize(font.pixelSize());
ft.setBold(font.bold());
ft.setItalic(font.italic());
ft.setUnderline(font.underline());
font = ft;
update();
});
hBox->addWidget(fdFontFamily);
auto fdFontSize = new QSpinBox();
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) {
m_attr.font.setPixelSize(value);
font.setPixelSize(value);
update();
});
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->setFixedSize(30, 30);
fdBold->setCheckable(true);
fdBold->setChecked(m_attr.font.bold());
fdBold->setChecked(font.bold());
connect(fdBold, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.font.setBold(checked);
font.setBold(checked);
update();
});
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->setFixedSize(30, 30);
fdItalic->setCheckable(true);
fdItalic->setChecked(m_attr.font.italic());
fdItalic->setChecked(font.italic());
connect(fdItalic, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.font.setItalic(checked);
font.setItalic(checked);
update();
});
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->setFixedSize(30, 30);
fdFontUnderline->setCheckable(true);
fdFontUnderline->setChecked(m_attr.font.underline());
fdFontUnderline->setChecked(font.underline());
connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.font.setUnderline(checked);
font.setUnderline(checked);
update();
});
hBox->addWidget(fdFontUnderline);
auto fdColor = new LoColorSelector("T", m_attr.textColor);
auto fdColor = new LoColorSelector("T", color);
fdColor->setFixedWidth(30);
connect(fdColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
m_attr.textColor = color;
this->color = color;
update();
});
hBox->addWidget(fdColor);
@ -425,32 +434,29 @@ QWidget* EDClock::attrWgt() {
}
JObj EDClock::attrJson() const {
JObj oWidget;
oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId);
oWidget["year"] = m_attr.year;
oWidget["month"] = m_attr.month;
oWidget["day"] = m_attr.day;
oWidget["hour"] = m_attr.hour;
oWidget["min"] = m_attr.min;
oWidget["sec"] = m_attr.sec;
oWidget["weekly"] = m_attr.weekly;
oWidget["fullYear"] = m_attr.fullYear;
oWidget["12Hour"] = m_attr.hour12;
oWidget["AmPm"] = m_attr.AmPm;
oWidget["dateStyle"] = m_attr.dateStyle;
oWidget["timeStyle"] = m_attr.timeStyle;
oWidget["multiline"] = m_attr.multiline;
oWidget["font"] = JObj{
{"family", m_attr.font.family()},
{"size", m_attr.font.pixelSize()},
{"bold", m_attr.font.bold()},
{"italics", m_attr.font.italic()},
{"underline", m_attr.font.underline()},
{"color", Tools::color2Int(m_attr.textColor)}
};
JObj oRoot;
addBaseAttr(oRoot);
oRoot["elementType"] = "DClock";
oRoot["widget"] = oWidget;
return oRoot;
JObj json;
addBaseAttr(json);
json["elementType"] = "DClock";
json["timeZone"] = QString::fromUtf8(timeZone.id());
json["hasYear"] = hasYear;
json["hasMonth"] = hasMonth;
json["hasDay"] = hasDay;
json["hasHour"] = hasHour;
json["hasMin"] = hasMin;
json["hasSec"] = hasSec;
json["hasWeek"] = hasWeek;
json["isFullYear"] = isFullYear;
json["is12Hour"] = is12Hour;
json["hasAmPm"] = hasAmPm;
json["dateStyle"] = dateStyle;
json["timeStyle"] = isSingleHour;
json["isMultiline"] = isMultiline;
json["color"] = color.name(QColor::HexArgb);
json["font"] = font.family();
json["fontSize"] = font.pixelSize();
json["fontBold"] = font.bold();
json["fontItalic"] = font.italic();
json["fontUnderline"] = font.underline();
json["lineHeight"] = lineHeight;
return json;
}

View File

@ -1,36 +1,18 @@
#ifndef EDCLOCK_H
#define EDCLOCK_H
#include "ebase.h"
#include "gutil/qgui.h"
#include <QPainter>
#include <QTextDocument>
#include <QTimeZone>
#include <QDate>
#include <QTime>
#include <QTimer>
#include "ebase.h"
class EDClock : public EBase {
Q_OBJECT
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(const JObj &json, EBase *multiWin = nullptr);
@ -39,10 +21,26 @@ public:
QWidget* attrWgt() 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:
void init();
Data m_attr;
QString img_dir;
QDateTime datetime;
bool isSingleMD = false;

View File

@ -238,7 +238,7 @@ QWidget* EEnviron::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new HBox(vBox);
hBox->addWidget(new QLabel(tr("Basic Properties")));
hBox->addLabel(translate("","Basic Properties"));
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);

View File

@ -97,7 +97,7 @@ QWidget* EGif::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Basic Properties")));
hBox->addWidget(new QLabel(translate("","Basic Properties")));
auto line = new QFrame();
line->setFrameShape(QFrame::HLine);
@ -118,7 +118,7 @@ QWidget* EGif::attrWgt() {
bnSelectFile->setFixedWidth(30);
bnSelectFile->setObjectName("bnSelectFile");
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;
auto movie = new QMovie(file);
if(! movie->isValid()) {

View File

@ -139,7 +139,7 @@ QWidget* EMultiWin::attrWgt() {
EBase *ele = 0;
QListWidgetItem *item = 0;
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++) {
auto ePhoto = EPhoto::create(files[i], mPageItem, this);
if(ePhoto==0) continue;
@ -156,7 +156,7 @@ QWidget* EMultiWin::attrWgt() {
}
}
} 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++) {
auto eGif = EGif::create(files[i], mPageItem, this);
if(eGif==0) continue;
@ -173,7 +173,7 @@ QWidget* EMultiWin::attrWgt() {
}
}
} 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()) {
auto eVideo = EVideo::create(file, mPageItem, this);
if(eVideo==0) return;

View File

@ -18,7 +18,7 @@ EPhoto *EPhoto::create(const QString &file, PageListItem *pageItem, EBase *multi
return 0;
}
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) {
auto widget = json["widget"];
@ -38,13 +38,16 @@ EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin
reader.setAutoTransform(true);
auto img = reader.read();
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);
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;
direct = json["direct"].toString();
speed = json["speed"].toInt();
tailSpacing = json["tailSpacing"].toInt();
scaleImgIfNeed();
}
JObj EPhoto::attrJson() const {
@ -53,6 +56,9 @@ JObj EPhoto::attrJson() const {
json["elementType"] = "Image";
json["dir"] = mDir;
json["name"] = mName;
json["direct"] = direct;
json["speed"] = speed;
json["tailSpacing"] = tailSpacing;
return json;
}
void EPhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
@ -93,7 +99,7 @@ QWidget* EPhoto::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new HBox(vBox);
hBox->addWidget(new QLabel(tr("Basic Properties")));
hBox->addWidget(new QLabel(translate("","Basic Properties")));
auto line = new QFrame();
line->setFrameShape(QFrame::HLine);
@ -113,7 +119,7 @@ QWidget* EPhoto::attrWgt() {
bnSelectFile->setObjectName("bnSelectFile");
connect(bnSelectFile, &QPushButton::clicked, wgtAttr, [=] {
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;
QImageReader reader(file);
reader.setAutoTransform(true);
@ -132,6 +138,71 @@ QWidget* EPhoto::attrWgt() {
});
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->addWidget(new QLabel(tr("Play Properties")));

View File

@ -11,7 +11,7 @@ public:
static EPhoto *create(const QString &file, 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();
@ -24,7 +24,8 @@ public:
QWidget* attrWgt() override;
QImage img;
QString mDir, mName;
QString mDir, mName, direct;
int speed = 0, tailSpacing = 0;
protected:
PageListItem *mPageItem;
};

View File

@ -10,6 +10,7 @@
#include <QFileDialog>
#include <QStackedLayout>
#include <QTextBlock>
#include <QCheckBox>
#if(QT_VERSION_MAJOR > 5)
#include <QStringConverter>
#else
@ -36,13 +37,15 @@ EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
text = widget["text"].toString();
align = (Qt::Alignment) widget["align"].toInt();
backColor = widget["backColor"].toString("#00000000");
lastFont = widget["lastFont"].toString("黑体");
auto play = json["play"];
if(play.isNull()) {
playMode = json["playMode"].toString();
if(playMode=="Scroll") {
direction = json["direction"].toString();
speed = json["speed"].toInt();
headTailSpacing = json["headTailSpacing"].toInt();
tailSpacing = json["headTailSpacing"].toInt();
useNewFmt = json["useNewFmt"].toBool();
}
} else {
playMode = playModes[play["style"].toInt()];
@ -50,7 +53,7 @@ EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
QString ds[]{"left", "top", "right", "bottom"};
direction = ds[rolling["rollingStyle"].toInt()];
speed = 1000/rolling["rollingSpeed"].toInt(33);
headTailSpacing = rolling["headTailSpacing"].toInt();
tailSpacing = rolling["headTailSpacing"].toInt();
}
connect(this, &EText::sizeChanged, this, &EText::updImg);
updImg();
@ -79,7 +82,7 @@ QWidget* EText::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new HBox(vBox);
hBox->addLabel(tr("Basic Properties"));
hBox->addLabel(translate("","Basic Properties"));
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
@ -92,13 +95,14 @@ QWidget* EText::attrWgt() {
auto fdFontFamily = new QFontComboBox;
fdFontFamily->setEditable(false);
fdFontFamily->setCurrentFont(QFont("黑体"));
connect(fdFontFamily, &QFontComboBox::currentFontChanged, fdText, [fdText](const QFont &f) {
fdFontFamily->setCurrentFont(QFont(lastFont));
connect(fdFontFamily, &QFontComboBox::currentFontChanged, fdText, [=](const QFont &f) {
QTextCharFormat fmt;
fmt.setFontFamilies({f.family()});
QTextCursor cursor = fdText->textCursor();
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
cursor.mergeCharFormat(fmt);
lastFont = f.family();
});
hBox->addWidget(fdFontFamily);
@ -107,7 +111,7 @@ QWidget* EText::attrWgt() {
auto fdFontSize = new QSpinBox;
fdFontSize->setRange(4, 9999);
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;
QTextCharFormat fmt;
fmt.setProperty(QTextFormat::FontPixelSize, value);
@ -329,8 +333,16 @@ QWidget* EText::attrWgt() {
updImg();
});
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->setValue(format.font().pixelSize());
fdFontSize->setValue(ft.pixelSize());
fdFontSize->blockSignals(false);
auto foreground = format.foreground();
fdTextColor->blockSignals(true);
@ -382,7 +394,7 @@ QWidget* EText::attrWgt() {
auto btnImport = new QPushButton(tr("Import txt File"));
btnImport->setProperty("ssType", "progManageTool");
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;
QFile qFile(filePath);
if(! qFile.open(QFile::ReadOnly)) {
@ -446,25 +458,9 @@ QWidget* EText::attrWgt() {
vBox->setSpacing(3);
auto hBox = new HBox(vBox);
auto label = new QLabel(tr("Head-Tail Spacing"));
label->setMinimumWidth(100);
hBox->addWidget(label);
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 label = hBox->addLabel(tr("Direction"));
label->setMinimumWidth(80);
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
auto fdDirection = new QComboBox;
fdDirection->addItem(tr("Right -> Left"), "left");
@ -477,13 +473,10 @@ QWidget* EText::attrWgt() {
updImg();
});
hBox->addWidget(fdDirection);
hBox->addStretch();
hBox = new HBox(vBox);
label = new QLabel(tr("Scroll Speed"));
label->setMinimumWidth(100);
hBox->addWidget(label);
label = hBox->addLabel(tr("Speed"));
label->setMinimumWidth(80);
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
auto fd = new QComboBox;
fd->setEditable(true);
@ -514,6 +507,29 @@ QWidget* EText::attrWgt() {
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;
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();
}
auto stackBox = new QStackedLayout;
@ -554,6 +570,7 @@ JObj EText::attrJson() const {
{"text", text},
{"align", (int) align},
{"backColor", backColor.name(QColor::HexArgb)},
{"lastFont", lastFont},
{"files", files},
{"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") {
obj["direction"] = direction;
obj["speed"] = speed;
obj["headTailSpacing"] = headTailSpacing;
obj["headTailSpacing"] = tailSpacing;
obj["useNewFmt"] = useNewFmt;
}
return obj;
}
@ -633,13 +651,14 @@ void EText::updImg() {
}
emit updPageCnt();
} 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 />", " "));
width = ceil(doc.idealWidth()) + headTailSpacing;
width = ceil(doc.idealWidth()) + tailSpacing;
} else {
doc.setTextWidth(width);
doc.setHtml(text);
height = doc.size().height() + headTailSpacing;
height = doc.size().height() + tailSpacing;
}
QImage img(width, height, QImage::Format_ARGB32);
img.fill(backColor);
@ -647,7 +666,7 @@ void EText::updImg() {
QPainter painter(&img);
doc.drawContents(&painter);
}
if(direction=="left" || direction=="right") {
if(isHor) {
alignV(img);
if(width < innerRect.width()) {
auto newWidth = width*2;
@ -662,19 +681,26 @@ void EText::updImg() {
}
}
mImgs.clear();
mImgs.append(img);
// if(img.width()<=8192) mImgs.append(img);
// else {
// for(int i=0; i<img.width(); i+=8192) {
// QImage imgpart(8192, height, QImage::Format_ARGB32);
// imgpart.fill(m_attr.backColor);
// {
// QPainter painter(&imgpart);
// painter.drawImage(-i, 0, img);
// }
// mImgs.append(imgpart);
// }
// }
if(! useNewFmt) mImgs.append(img);
else if(isHor) {
if(img.width()<=4096) mImgs.append(img);
else {
auto rem = img.width();
do {
mImgs.append(img.copy(img.width()-rem, 0, qMin(4096, rem), img.height()));
rem -= 4096;
} while (rem>0);
}
} 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") {//生成一张图
doc.setHtml(text);
doc.setTextWidth(width);

View File

@ -18,10 +18,12 @@ public:
QString text;
Qt::Alignment align;
QColor backColor = Qt::transparent;
QString lastFont = "黑体";
QString playMode = "Flip";
QString direction = "left";
int speed = 60;
int headTailSpacing = 10;
int tailSpacing = 10;
bool useNewFmt = false;
public slots:
void updImg();

View File

@ -1,7 +1,6 @@
#include "etimer.h"
#include "tools.h"
#include "main.h"
#include "base/lodateselector.h"
#include "base/calendarbutton.h"
#include "base/locolorselector.h"
#include "gutil/qgui.h"
#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.setUnderline(json["fontUnderline"].toBool());
textColor = json["textColor"].toString();
auto color = json["backColor"].toString();
backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
backColor = json["backColor"].toString("#00000000");
init();
}
@ -97,17 +95,15 @@ QWidget* ETimer::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Basic Properties")));
auto hBox = new HBox(vBox);
hBox->addLabel(translate("","Basic Properties"));
auto line = new QFrame();
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addStretch();
auto fdCntDown = new QRadioButton(tr("Count Down"));
auto fdCntUp = new QRadioButton(tr("Count Up"));
@ -125,28 +121,24 @@ QWidget* ETimer::attrWgt() {
hBox->addWidget(fdCntUp);
hBox->addStretch();
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Time")));
hBox->addLabel(tr("Target Time"));
auto fdTime = new QDateTimeEdit(this->targetTime);
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
auto edTime = new QDateTimeEdit(this->targetTime);
edTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
connect(edTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
this->targetTime = dateTime;
update();
});
hBox->addWidget(fdTime);
hBox->addWidget(edTime);
auto wDateSelector = new LoDateSelector();
connect(wDateSelector, &LoDateSelector::sDateSelected, fdTime, &QDateTimeEdit::setDate);
hBox->addWidget(wDateSelector);
auto btnTime = new CalendarButton;
connect(btnTime->calendar, &QCalendarWidget::clicked, edTime, &QDateTimeEdit::setDate);
hBox->addWidget(btnTime);
hBox->addStretch();
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
auto fdHasDay = new QCheckBox(tr("Day"));
@ -190,9 +182,7 @@ QWidget* ETimer::attrWgt() {
});
hBox->addWidget(fdIsMultiline);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Text")));
@ -204,9 +194,7 @@ QWidget* ETimer::attrWgt() {
});
hBox->addWidget(fdText);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
auto fdFont = new QFontComboBox();
@ -233,9 +221,7 @@ QWidget* ETimer::attrWgt() {
hBox->addWidget(fdFontSize);
hBox->addStretch();
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
auto fdFontBold = new QPushButton("B");
@ -289,7 +275,6 @@ QWidget* ETimer::attrWgt() {
update();
});
hBox->addWidget(fdBackColor);
vBox->addLayout(hBox);
vBox->addStretch();
return wgtAttr;

View File

@ -2,7 +2,7 @@
#include "main.h"
#include "gutil/qgui.h"
#include "base/locolorselector.h"
#include "base/lodateselector.h"
#include "base/calendarbutton.h"
#include <QButtonGroup>
#include <QFontComboBox>
#include <QMessageBox>
@ -80,7 +80,7 @@ QWidget* ETimer2::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new HBox(vBox);
hBox->addLabel(tr("Basic Properties"));
hBox->addLabel(translate("","Basic Properties"));
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
@ -108,19 +108,19 @@ QWidget* ETimer2::attrWgt() {
hBox = new HBox(vBox);
hBox->addSpacing(6);
hBox->addLabel(tr("Time"));
hBox->addLabel(tr("Target Time"));
auto fdTime = new QDateTimeEdit(targetTime);
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
auto edTime = new QDateTimeEdit(targetTime);
edTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
connect(edTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
targetTime = dateTime;
update();
});
hBox->addWidget(fdTime);
hBox->addWidget(edTime);
auto wDateSelector = new LoDateSelector;
connect(wDateSelector, &LoDateSelector::sDateSelected, fdTime, &QDateTimeEdit::setDate);
hBox->addWidget(wDateSelector);
auto btnCalendar = new CalendarButton;
connect(btnCalendar->calendar, &QCalendarWidget::clicked, edTime, &QDateTimeEdit::setDate);
hBox->addWidget(btnCalendar);
hBox->addStretch();

View File

@ -2,6 +2,8 @@
#include "tools.h"
#include "main.h"
#include "base/ffutil.h"
#include "gutil/qwaitingdlg.h"
#include "videosplitthread.h"
#include <QLineEdit>
#include <QMessageBox>
#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);
ins->setBaseAttr(ele);
if(ins->_duration < 4) ins->_duration = dur;
ins->useSW = ele["useSW"].toBool();
ins->isPreSplit = ele["isPreSplit"].toBool();
auto play = ele["play"];
ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1);
return ins;
@ -81,19 +85,17 @@ QWidget* EVideo::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Basic Properties")));
auto hBox = new HBox(vBox);
hBox->addLabel(translate("","Basic Properties"));
auto line = new QFrame();
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("File")));
hBox->addLabel(tr("File"));
auto fdFileName = new QLineEdit(mRawName);
fdFileName->setReadOnly(true);
@ -103,7 +105,7 @@ QWidget* EVideo::attrWgt() {
bnSelectFile->setFixedWidth(30);
bnSelectFile->setObjectName("bnSelectFile");
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;
QFileInfo rawInfo(rawFile);
int64_t dur;
@ -127,11 +129,9 @@ QWidget* EVideo::attrWgt() {
});
hBox->addWidget(bnSelectFile);
vBox->addLayout(hBox);
// hBox = new QHBoxLayout();
// hBox = new HBox(vBox);
// hBox->addSpacing(6);
// hBox->addWidget(new QLabel(tr("AspectRatioMode")));
// hBox->addLabel(tr("AspectRatioMode"));
// auto wAspectRatioMode = new QComboBox();
// wAspectRatioMode->addItem(tr("IgnoreAspectRatio"));
@ -144,32 +144,46 @@ QWidget* EVideo::attrWgt() {
// hBox->addWidget(wAspectRatioMode);
// hBox->addStretch();
// vBox->addLayout(hBox);
hBox = new HBox(vBox);
hBox->addLabel(tr("Play Properties"));
hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Play Properties")));
line = new QFrame();
line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox = new HBox(vBox);
hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Play Times")));
hBox->addLabel(tr("Play Times"));
auto wPlayTimes = new QSpinBox();
wPlayTimes->setRange(1, 99999);
wPlayTimes->setValue(playTimes);
connect(wPlayTimes, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
auto edPlayTimes = new QSpinBox;
edPlayTimes->setRange(1, 99999);
edPlayTimes->setValue(playTimes);
connect(edPlayTimes, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int 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();
vBox->addLayout(hBox);
vBox->addStretch();
return wgtAttr;
}
@ -183,19 +197,19 @@ bool EVideo::save(const QString &pageDir) {
else return false;
QFile(oldFile).copy(saveFile);
mDir = pageDir;
// if(gProgItem->maxLen) {
// 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());
// connect(thread, &VideoSplitThread::emErr, this, [=](QString err) {
// waitingDlg->close();
// if(! err.isEmpty()) QMessageBox::critical(mPageItem->listWidget()->window(), "Video trans error", err+"\n"+saveFile);
// });
// connect(thread, &VideoSplitThread::emProgress, this, [saveFile, waitingDlg](int progress) {
// waitingDlg->fdText->setText(QString("正在转码视频 %1%").arg(progress));
// });
// thread->start();
// waitingDlg->exec();
// }
if(gProgItem->maxLen && isPreSplit) {
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());
connect(thread, &VideoSplitThread::emErr, this, [=](QString err) {
waitingDlg->close();
if(! err.isEmpty()) QMessageBox::critical(mPageItem->listWidget()->window(), "Video trans error", err+"\n"+saveFile);
});
connect(thread, &VideoSplitThread::emProgress, this, [saveFile, waitingDlg](int progress) {
waitingDlg->fdText->setText(QString("正在转码视频 %1%").arg(progress));
});
thread->start();
waitingDlg->exec();
}
return true;
}
@ -206,8 +220,17 @@ JObj EVideo::attrJson() const {
{"file", mName},
{"pathRaw", mRawDir},
{"fileRaw", mRawName},
{"useSW", useSW},
{"isPreSplit", isPreSplit},
{"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);
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) {
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] {
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});
msgBox.exec();
if(err.right(32).contains("Conversion failed!")) {
QMessageBox::critical(parent, tr("Error"), err);
QMessageBox::critical(parent, translate("","Error"), err);
return "";
}
return outFile;

View File

@ -38,6 +38,7 @@ public:
protected:
int aspectRatioMode = Qt::IgnoreAspectRatio;
int playTimes = 1;
bool useSW = false, isPreSplit = false;
PageListItem *mPageItem;
};

View File

@ -1,5 +1,6 @@
#include "eweb.h"
#include "gutil/qgui.h"
#include "main.h"
#include <QSpinBox>
#include <QLineEdit>
#include <QPainter>
@ -41,7 +42,7 @@ QWidget* EWeb::attrWgt() {
addBaseAttrWgt(vBox);
auto hBox = new HBox(vBox);
hBox->addLabel(tr("Basic Properties"));
hBox->addLabel(translate("","Basic Properties"));
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);

View File

@ -142,10 +142,17 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson) {
auto startTime = isWin ? 0 : ele["startTime"].toInt();
for(auto &ss : sources) {
auto source = ss.toObj();
if(source["isPreSplit"].toBool()) {
source["left"] = 0;
source["top"] = 0;
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["opacity"] = ele["opacity"].toDouble(1);
source["playTime"] = startTime;
@ -209,6 +216,7 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson) {
}
return JObj{
{"repeatTimes", pageJson["repeat"]},
{"waitAudio", pageJson["waitAudio"]},
{"schedules", schedules},
{"_program", JObj{
{"name", pageJson["name"].toString()},
@ -226,11 +234,11 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
if(type=="Text") source = genText(ele, sources);
else if(type=="Image"||type=="Photo") source = genImage(ele);
else if(type=="Video"||type=="Movie") {
//genProg(ele, dstDir, mProgItem);
auto widget = ele["widget"];
if(widget.isNull()) widget = ele;
auto path = widget["path"].toString();
auto name = widget["file"].toString();
if(widget["isPreSplit"].toBool()) name += "-square.mp4";
auto srcFile = path + "/" + name;
if(! QFileInfo(srcFile).isFile() && ! QFileInfo(srcFile = srcPageDir + "/" + name).isFile()) continue;
auto id = Tools::fileMd5(srcFile);
@ -240,6 +248,8 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
source["id"] = id;
source["md5"] = id;
source["name"] = name;
source["useSW"] = ele["useSW"];
source["isPreSplit"] = ele["isPreSplit"];
auto play = ele["play"];
source["timeSpan"] = play.isNull() ? ele["duration"].toInt() * ele["playTimes"].toInt() : play["playDuration"].toInt() * play["playTimes"].toInt();
} 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"];
source["entryEffect"] = ele["entryEffect"];
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["exitEffectTimeSpan"] = ele["exitDur"];
if(ele["hasBlink"].toBool()) source["blink"] = ele["blink"];
@ -292,6 +304,23 @@ JObj GenTmpThread::genText(const JValue &ele, JArray &sources) {
auto isScroll = playMode=="Scroll";
if(isScroll) {
if(filenames.size()>1) {
JObj source;
source["_type"] = "Scroll";
source["direct"] = direction;
source["speed"] = speed;
JArray imgs;
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);
imgs.append(id);
}
source["imgs"] = imgs;
return source;
} else {
JObj source;
source["_type"] = "MultiPng";
source["playMode"] = playMode;
@ -310,12 +339,12 @@ JObj GenTmpThread::genText(const JValue &ele, JArray &sources) {
else if(direction=="right") arrayPic["effect"] = "left to right";
else if(direction=="bottom") arrayPic["effect"] = "top to bottom";
arrayPic["scrollSpeed"] = speed;
arrayPic["effectSpeed"] = 1000 / speed;
arrayPic["picDuration"] = 0;
arrayPics.append(arrayPic);
}
source["arrayPics"] = arrayPics;
return source;
}
} else {
auto duration = ele["duration"].toInt();
for(auto &filename : filenames) {
@ -353,6 +382,8 @@ JObj GenTmpThread::genImage(const JValue &ele) {
auto geometry = ele["geometry"];
auto width = geometry["w"].toInt();
auto height = geometry["h"].toInt();
auto direct = ele["direct"].toStr();
auto speed = ele["speed"].toInt();
/*if(mProgItem->maxLen) {
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);
@ -387,26 +418,34 @@ JObj GenTmpThread::genImage(const JValue &ele) {
file.close();
source["id"] = 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;
img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(&buf, "PNG");
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
cryptoHash.addData(buf.data());
auto md5 = QString::fromLatin1(cryptoHash.result().toHex());
md5 = QString::fromLatin1(cryptoHash.result().toHex());
QFile file(dstDir+"/"+md5);
if(! file.open(QFile::WriteOnly)) return source;
file.write(buf.data());
file.close();
source["id"] = md5;
source["md5"] = md5;
} else {
auto md5 = Tools::fileMd5(srcFile);
md5 = Tools::fileMd5(srcFile);
if(md5.isEmpty()) return source;
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["md5"] = md5;
}
source["_type"] = "Image";
auto play = ele["play"];
source["timeSpan"] = play.isNull() ? ele["duration"] : play["playDuration"];
return source;
@ -419,7 +458,7 @@ JObj GenTmpThread::convertGif(const JValue &json) {
QString srcFile = path + "/" + name;
QFileInfo srcInfo(srcFile);
if(! srcInfo.isFile()) return JObj();
QString id = Tools::fileMd5(srcFile);
auto id = Tools::fileMd5(srcFile);
if(id.isEmpty()) return JObj();
QFile::copy(srcFile, dstDir+"/"+id);
JObj oRes;
@ -432,57 +471,79 @@ JObj GenTmpThread::convertGif(const JValue &json) {
return oRes;
}
JObj GenTmpThread::convertDClock(const JValue &json){
JObj oRes;
oRes["_type"] = "DigitalClockNew";
oRes["name"] = "DigitalClockNew";
JObj source;
source["_type"] = "DigitalClockNew";
source["name"] = "DigitalClockNew";
auto widget = json["widget"];
oRes["timeZone"] = widget["timeZone"];
oRes["timezone"] = 8;//兼容旧播放器
oRes["year"] = widget["year"];
oRes["month"] = widget["month"];
oRes["day"] = widget["day"];
oRes["hour"] = widget["hour"];
oRes["min"] = widget["min"];
oRes["sec"] = widget["sec"];
oRes["weekly"] = widget["weekly"];
oRes["fullYear"] = widget["fullYear"];
oRes["hour12"] = widget["12Hour"];
oRes["AmPm"] = widget["AmPm"];
oRes["dateStyle"] = widget["dateStyle"];
oRes["timeStyle"] = widget["timeStyle"];
oRes["multiline"] = widget["multiline"];
auto fontVal = widget["font"];
auto textColor = Tools::int2Color(fontVal["color"].toInt());
QFont font(fontVal["family"].toString());
font.setPixelSize(fontVal["size"].toInt());
font.setBold(fontVal["bold"].toBool());
font.setItalic(fontVal["italics"].toBool());
font.setUnderline(fontVal["underline"].toBool());
QFont font;
QColor color;
if(widget.isNull()) {
widget = json;
source["year"] = json["hasYear"];
source["month"] = json["hasMonth"];
source["day"] = json["hasDay"];
source["hour"] = json["hasHour"];
source["min"] = json["hasMin"];
source["sec"] = json["hasSec"];
source["weekly"] = json["hasWeek"];
source["fullYear"] = json["isFullYear"];
source["hour12"] = json["is12Hour"];
source["AmPm"] = json["hasAmPm"];
source["multiline"] = json["isMultiline"];
color = json["color"].toString("#ffff0000");
font.setFamily(json["font"].toString());
font.setPixelSize(json["fontSize"].toInt());
font.setBold(json["fontBold"].toBool());
font.setItalic(json["fontItalic"].toBool());
font.setUnderline(json["fontUnderline"].toBool());
} else {
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);
QFontMetrics metric(font);
oRes["spaceWidth"] = metric.horizontalAdvance(" ");
QColor color(textColor);
source["spaceWidth"] = metric.horizontalAdvance(" ");
auto lineHeight = json["isMultiline"].toBool() ? json["lineHeight"].toInt() : 0;
JArray imgs;
for(int i=0; i<=9; i++) Tools::saveImg2(dstDir, metric, font, color, imgs, QString::number(i), QString::number(i));
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("MON"), "MON");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("TUE"), "TUE");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("WED"), "WED");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("THU"), "THU");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("FRI"), "FRI");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SAT"), "SAT");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SUN"), "SUN");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("AM"), "AM");
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("PM"), "PM");
Tools::saveImg2(dstDir, metric, font, color, imgs, "", "YEAR");
Tools::saveImg2(dstDir, metric, font, color, imgs, "", "MONTH");
Tools::saveImg2(dstDir, metric, font, color, imgs, "", "DAY");
Tools::saveImg2(dstDir, metric, font, color, imgs, ":", "maohao");
Tools::saveImg2(dstDir, metric, font, color, imgs, "/", "xiegang");
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "hengxian");
oRes["arrayPics"] = imgs;
return oRes;
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", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("TUE"), "TUE", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("WED"), "WED", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("THU"), "THU", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("FRI"), "FRI", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SAT"), "SAT", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("SUN"), "SUN", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("AM"), "AM", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("PM"), "PM", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, "", "YEAR", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, "", "MONTH", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, "", "DAY", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, ":", "maohao", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, "/", "xiegang", lineHeight);
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "hengxian", lineHeight);
source["arrayPics"] = imgs;
return source;
}
JObj GenTmpThread::convertAClock(const JValue &json) {
auto widget = json["widget"];

View File

@ -1,5 +1,5 @@
#include "pageeditor.h"
#include "tools.h"
#include "main.h"
#include "ebase.h"
#include <QKeyEvent>
#include <QMessageBox>
@ -164,7 +164,7 @@ void PageEditor::onDelete() {
}
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) {
auto eles = sortedEles();
foreach(auto ele, eles) {

View File

@ -2,7 +2,7 @@
#include "main.h"
#include "gutil/qgui.h"
#include "base/ffutil.h"
#include "base/lodateselector.h"
#include "base/calendarbutton.h"
#include "program/eaclock.h"
#include "program/ebase.h"
#include "program/edclock.h"
@ -15,13 +15,13 @@
#include "program/etimer2.h"
#include "program/evideo.h"
#include "program/eweb.h"
#include "tools.h"
#include <QDateEdit>
#include <QDir>
#include <QGraphicsView>
#include <QLineEdit>
#include <QMessageBox>
#include <QSpinBox>
#include <QFileDialog>
class PageScene : public QGraphicsScene {
public:
@ -259,6 +259,13 @@ QPushButton[ssName="weeklySelector"]:checked {
});
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();
vBox->addLayout(hBox);
@ -287,7 +294,7 @@ QPushButton[ssName="weeklySelector"]:checked {
mAudiosList = new QListWidget;
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();
for(int i=0; i<files.count(); i++) {
int64_t dur;
@ -435,9 +442,9 @@ QPushButton[ssName="weeklySelector"]:checked {
fdStart->setDate(QDate::fromString(validDate["start"].toString(), "yyyy-MM-dd"));
hBox->addWidget(fdStart);
auto bnDateStart = new LoDateSelector();
auto bnDateStart = new CalendarButton;
bnDateStart->setEnabled(isDateValid);
connect(bnDateStart, &LoDateSelector::sDateSelected, fdStart, &QDateEdit::setDate);
connect(bnDateStart->calendar, &QCalendarWidget::clicked, fdStart, &QDateEdit::setDate);
hBox->addWidget(bnDateStart);
hBox->addWidget(new QLabel(""));
@ -472,9 +479,9 @@ QPushButton[ssName="weeklySelector"]:checked {
});
hBox->addWidget(fdEnd);
auto bnDateEnd = new LoDateSelector();
auto bnDateEnd = new CalendarButton;
bnDateEnd->setEnabled(isDateValid);
connect(bnDateEnd, &LoDateSelector::sDateSelected, fdEnd, &QDateEdit::setDate);
connect(bnDateEnd->calendar, &QCalendarWidget::clicked, fdEnd, &QDateEdit::setDate);
hBox->addWidget(bnDateEnd);
hBox->addStretch();

View File

@ -28,7 +28,7 @@
#include <QUdpSocket>
#include <QMovie>
ProgItem *gProgItem{0};
ProgItem *gProgItem = 0;
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
gProgItem = progItem;
@ -75,7 +75,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
// saveThread = QThread::create([this](){
// 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()), saveThread, SLOT(deleteLater()));
// 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);
dlg.edIsInsert->setChecked(mProgItem->isInsert);
if(dlg.exec() != QDialog::Accepted) return;
mProgItem->mWidth = dlg.fdWidth->value();
mProgItem->mHeight = dlg.fdHeight->value();
mProgItem->mWidth = gProgWidth = dlg.fdWidth->value();
mProgItem->mHeight = gProgHeight = dlg.fdHeight->value();
mProgItem->mRemark = dlg.fdRemark->toPlainText();
mProgItem->isInsert = dlg.edIsInsert->isChecked();
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->setData(EBase::Timer2);
toolBar->addAction(action);
#ifndef leyide
action = new QAction(QIcon(":/res/program/demo-video.png"), tr("Demos"));
connect(action, &QAction::triggered, this, [this] {
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);
#endif
toolBar->addSeparator();
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;
auto type = data.toInt();
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++) {
auto ePhoto = EPhoto::create(files[i], mPageItem);
if(ePhoto==0) continue;
@ -311,7 +312,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
}
}
} 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++) {
auto eGif = EGif::create(files[i], mPageItem);
if(eGif==0) continue;
@ -329,7 +330,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
}
}
} 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;
auto eVideo = EVideo::create(file, mPageItem);
if(eVideo==nullptr) return;
@ -419,7 +420,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
if(listPage->count() == 1) mPageEditor->onClean();
else if(listPage->count() > 1) {
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) {
delete item;
if(listPage->count() > 0) listPage->setCurrentRow(0);
@ -517,14 +518,14 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scroll->setWidgetResizable(true);
scroll->setPalette(backTrans);
mTabsAttr->addTab(scroll, tr("widget properties"));
mTabsAttr->addTab(scroll, tr("Widget Properties"));
scroll = new QScrollArea();
scroll->setFrameShape(QFrame::NoFrame);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scroll->setWidgetResizable(true);
scroll->setPalette(backTrans);
mTabsAttr->addTab(scroll, tr("Page properties"));
mTabsAttr->addTab(scroll, tr("Program Properties"));
mTabsAttr->setCurrentIndex(0);
hBox->addWidget(mTabsAttr);
@ -578,7 +579,7 @@ bool ProgEditorWin::isProgChanged() {
void ProgEditorWin::closeEvent(QCloseEvent *event) {
mProgItem->onSetProgram();
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();
else if(res == QMessageBox::Cancel) event->ignore();
}
@ -592,18 +593,18 @@ bool ProgEditorWin::save() {
//停止每个幻灯片的元素
int cnt = listPage->count();
for(int i=0; i<cnt; i++) {
auto items = static_cast<PageListItem*>(listPage->item(i))->mScene->items();
foreach(auto item, items) static_cast<EBase*>(item)->freeFiles();
auto items = ((PageListItem*) listPage->item(i))->mScene->items();
for(auto item : items) ((EBase*) item)->freeFiles();
}
QDir progDir(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;
}
auto pageNames = progDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(QString &pageName : pageNames) if(! progDir.rename(pageName, pageName + PAGEDEL_SUFFIX)) {
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文档
mPageJsons.clear();
@ -617,27 +618,27 @@ bool ProgEditorWin::save() {
}
}
pageNames = progDir.entryList(QStringList("*" PAGEDEL_SUFFIX));
foreach(QString pageName, pageNames) {
for(auto pageName : pageNames) {
if(! QDir(mProgItem->mProgDir + "/" + pageName).removeRecursively()) {
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++) {
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;
}
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->show();
if(save()) waitingDlg->success();
else waitingDlg->close();
waitingDlg->exec();
if(save()) {
waitingDlg->success();
mProgItem->onSetProgram();
} else waitingDlg->close();
}
void ProgEditorWin::onAddPage() {
@ -665,7 +666,7 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
#ifdef Q_OS_WIN
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
#endif
setWindowTitle(tr("Solution Information"));
setWindowTitle(tr("Solution Info"));
auto vBox = new VBox(this);
vBox->setContentsMargins(6,0,6,6);
auto hBox = new HBox(vBox);

View File

@ -76,7 +76,7 @@ QPushButton:hover{background-color: #cccccc;}
auto fdPassword = new QLineEdit;
fdPassword->setEchoMode(QLineEdit::Password);
fdPassword->setPlaceholderText(QObject::tr("Input password"));
fdPassword->setPlaceholderText(translate("","Input Password"));
hBox->addWidget(fdPassword);
auto fdDrives = new ListWgt;
@ -102,8 +102,8 @@ QPushButton:hover{background-color: #cccccc;}
dlg.accept();
return;
}
if(fdDrives->count() <= 0) QMessageBox::warning(&dlg, QObject::tr("Tip"), QObject::tr("No checked USB device"));
else QMessageBox::warning(&dlg, QObject::tr("Tip"), QObject::tr("please select usb device in list"));
if(fdDrives->count() <= 0) QMessageBox::warning(&dlg, translate("","Tip"), QObject::tr("No checked USB device"));
else QMessageBox::warning(&dlg, translate("","Tip"), QObject::tr("please select usb device in list"));
});
vBox->addWidget(btnBox);

View File

@ -78,7 +78,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
hBox->addStretch();
auto btnRefresh = new QPushButton(tr("Refresh"));
auto btnRefresh = new QPushButton(translate("","Refresh"));
connect(btnRefresh, &QPushButton::clicked, this, [=] {
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) {
@ -122,7 +122,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
if(! item->isLocked) return;
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;
JObj json;
json.insert("_id", "VerifyPassword");
@ -130,18 +130,18 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
json.insert("pwd", pwd);
auto waitingDlg = new WaitingDlg(item->btnUnlock, tr("Verify Password")+" ...");
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) [=] {
QJsonDocument json;
auto err = checkReplyForJson(reply, &json);
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(this, QObject::tr("Error"), err);
QMessageBox::critical(this, translate("","Error"), err);
return;
}
if(! json["result"].toBool()) {
waitingDlg->close();
QMessageBox::warning(this, tr("Tip Info"), tr("password is wrong"));
QMessageBox::warning(this, translate("","Tip"), tr("password is wrong"));
return;
}
waitingDlg->success();
@ -181,7 +181,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
table->addCol("id", "ID", 130).margin(4);
table->addCol("online", tr("Online"), 40);
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("playerVer", "Player Ver", 70);
table->addCol("encrypt", tr("Security"), 40);

View File

@ -41,6 +41,7 @@ void SendProgThread::run() {
req.insert("files", files);
req.insert("idList", JArray{"aaa"});
req.insert("zVer", "xixun1");
//req.insert("isLauncher", true);
auto resNum = tcp.write(JToBytes(req));
tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten() || ! tcp.waitForReadyRead()) {
@ -200,6 +201,17 @@ void SendProgThread::run() {
return;
}
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 emErr("OK");
}

View File

@ -2,6 +2,7 @@
#include <QImage>
#include <QPainter>
#include <QDebug>
#include <queue>
extern "C"{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
@ -17,105 +18,107 @@ VideoSplitThread::VideoSplitThread(int elew, int eleh, int maxLen, int sph, std:
}
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;
QString err;
char buf[AV_ERROR_MAX_STRING_SIZE];
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);
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);
goto free;
}
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);
goto free;
}
int vi_idx = -1;
AVStream *out_vi_stream;
for(uint ss=0; ss<in_fmt->nb_streams; ss++) {
AVStream *stream = in_fmt->streams[ss];
qDebug()<<"codec_type"<<av_get_media_type_string(stream->codecpar->codec_type);
if(stream->codecpar->codec_type == AVMEDIA_TYPE_DATA) continue;
AVStream *out_stream = avformat_new_stream(out_fmt, 0);
if(vi_idx == -1 && stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
vi_idx = ss;
out_vi_stream = out_stream;
} else {
if((ret = avcodec_parameters_copy(out_stream->codecpar, stream->codecpar)) < 0) {
int video_idx = -1;
AVStream *stream_out_video;
for(uint ss=0; ss<fmt_in->nb_streams; ss++) {
auto streamIn = fmt_in->streams[ss];
qDebug() << streamIn->index << av_get_media_type_string(streamIn->codecpar->codec_type);
if(streamIn->codecpar->codec_type == AVMEDIA_TYPE_DATA) continue;
auto streamOut = avformat_new_stream(fmt_out, 0);
if((ret = avcodec_parameters_copy(streamOut->codecpar, streamIn->codecpar)) < 0) {
err = QString("avcodec_parameters_copy fail. ") + av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
goto free;
}
streamOut->time_base = streamIn->time_base;
streamOut->start_time = streamIn->start_time;
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";
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) {
err = "Could not found Video Decoder";
goto free;
}
de_ctx = avcodec_alloc_context3(decoder);
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) {
err = "Could not open Video decode Ctx";
goto free;
}
auto outPar = out_vi_stream->codecpar;
outPar->codec_type = AVMEDIA_TYPE_VIDEO;
outPar->codec_id = AV_CODEC_ID_H264;
outPar->format = AV_PIX_FMT_YUV420P;
auto par_out_video = stream_out_video->codecpar;
par_out_video->codec_type = AVMEDIA_TYPE_VIDEO;
par_out_video->codec_id = AV_CODEC_ID_H264;
par_out_video->format = AV_PIX_FMT_YUV420P;
par_out_video->profile = 77;
par_out_video->level = 42;
if(isVer) {
outPar->height = maxLen;
outPar->width = mSPH*mWidths.size();
par_out_video->height = maxLen;
par_out_video->width = mSPH * (int)mWidths.size();
} else {
outPar->width = maxLen;
outPar->height = mSPH*mWidths.size();
par_out_video->width = maxLen;
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) {
fprintf(stderr, "Codec not found\n");
goto free;
}
en_ctx = avcodec_alloc_context3(encoder);
en_ctx->thread_count = 4;
avcodec_parameters_to_context(en_ctx, outPar);
en_ctx->bit_rate = outPar->width * outPar->height * 6;
avcodec_parameters_to_context(en_ctx, par_out_video);
en_ctx->bit_rate = par_out_video->width * par_out_video->height * 6;
en_ctx->gop_size = de_ctx->gop_size;
en_ctx->max_b_frames = 3;
en_ctx->time_base = out_vi_stream->time_base;
en_ctx->max_b_frames = 0;
en_ctx->time_base = stream_out_video->time_base;
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);
goto free;
}
if(out_fmt->flags & AVFMT_NOFILE) qDebug()<<"AVFMT_NOFILE";
else if((ret = avio_open(&out_fmt->pb, outfile.constData(), AVIO_FLAG_WRITE)) < 0) {
if(fmt_out->flags & AVFMT_NOFILE) qDebug()<<"AVFMT_NOFILE";
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);
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);
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 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 frm = av_frame_alloc();
@ -123,20 +126,24 @@ void VideoSplitThread::run() {
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]);
int out_img_linesize[4]{(outPar->width*4+63)/64*64};
uint8_t *out_img_data[4]{new uchar[out_img_linesize[0] * outPar->height]};
QImage out_img(out_img_data[0], outPar->width, outPar->height, out_img_linesize[0], QImage::Format_ARGB32, imgCleanupHandler, out_img_data[0]);
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] * par_out_video->height]};
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);
while(1) {
if((ret = av_read_frame(in_fmt, packet)) < 0) {
if((ret = av_read_frame(fmt_in, packet)) < 0) {
if(ret!=AVERROR_EOF) {
err = QString("Read packet fail: ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
break;
}
ret = avcodec_send_packet(de_ctx, 0);
} else {
if(packet->stream_index != vi_idx) {
av_interleaved_write_frame(out_fmt, packet);
if(packet->stream_index != video_idx) {
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;
}
ret = avcodec_send_packet(de_ctx, packet);
@ -171,40 +178,51 @@ void VideoSplitThread::run() {
}
}
auto pts = frm->pts;
auto pkt_dts = frm->pkt_dts;
auto dur = frm->pkt_duration;
av_frame_unref(frm);
frm->pts = pts;
frm->pkt_dts = pkt_dts;
frm->pkt_duration = dur;
frm->format = AV_PIX_FMT_YUV420P;
frm->width = outPar->width;
frm->height = outPar->height;
frm->width = par_out_video->width;
frm->height = par_out_video->height;
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);
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);
int pro = frm->pts*100/out_vi_stream->duration;
if(pro > lastPro) {
lastPro = pro;
emit emProgress(pro);
int progress = frm->pts * 100 / stream_out_video->duration;
if(progress > lastProgress) {
lastProgress = progress;
emit emProgress(progress);
}
}
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;
}
while((ret = avcodec_receive_packet(en_ctx, packet)) != AVERROR(EAGAIN)) {
if(ret < 0) {
if(ret!=AVERROR_EOF) err = QString("Receive frame fail: ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
else {
av_interleaved_write_frame(out_fmt, 0);
av_write_trailer(out_fmt);
ret = av_interleaved_write_frame(fmt_out, 0);
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);
}
goto free2;
} 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:
avcodec_free_context(&de_ctx);
avcodec_free_context(&en_ctx);
avformat_close_input(&in_fmt);
avio_closep(&out_fmt->pb);
if(out_fmt) avformat_free_context(out_fmt);
avformat_close_input(&fmt_in);
avio_closep(&fmt_out->pb);
if(fmt_out) avformat_free_context(fmt_out);
emit emErr(err);
}

View File

@ -24,8 +24,8 @@ public slots:
stoped = true;
}
private:
int lastPro{0};
std::atomic_bool stoped{false};
int lastProgress = 0;
std::atomic_bool stoped = false;
};
#endif // VIDEOSPLITTHREAD_H

View File

@ -1,37 +1,48 @@
<RCC>
<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>res/AdvParam.png</file>
<file>res/AppSetting.png</file>
<file>res/AppSettingTip.png</file>
<file>res/ArrowDropDown.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/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_u.png</file>
<file>res/DeviceNum_All.png</file>
<file>res/DeviceSetting_s.png</file>
<file>res/DeviceSetting_u.png</file>
<file>res/FlashArrow.png</file>
<file>res/GuangYingPin_s.png</file>
<file>res/GuangYingPin_u.png</file>
<file>res/Hdmi.png</file>
<file>res/Logo.png</file>
<file>res/Logo-leyide.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/ProgramManager_s.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/Add.png</file>
<file>res/program/AddPlan.png</file>
@ -48,17 +59,7 @@
<file>res/program/Copy.png</file>
<file>res/program/Cut.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/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/GoDown.png</file>
<file>res/program/GoUp.png</file>
@ -79,6 +80,12 @@
<file>res/program/Setting.png</file>
<file>res/program/Temp.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/TileH.png</file>
<file>res/program/TileV.png</file>
@ -86,30 +93,22 @@
<file>res/program/Weather.png</file>
<file>res/program/Web.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_u.png</file>
<file>res/program/bnSearch.png</file>
<file>res/program/bnSend_s.png</file>
<file>res/program/bnSend_u.png</file>
<file>res/ProgramManager_s.png</file>
<file>res/ProgramManager_u.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/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/program/demo-video.png</file>
<file>res/program/preview.png</file>
<file>res/program/previewStop.png</file>
<file>res/random.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/test.png</file>
<file>res/video-pre.png</file>

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
LedOK/res/exclam.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -94,12 +94,12 @@ void Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont&
file.close();
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{
{"name", name}
};
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("picHeight", img.height());
img.fill(Qt::transparent);

Some files were not shown because too many files have changed in this diff Show More