This commit is contained in:
gangphon 2023-04-18 14:14:46 +08:00
parent d441f6fbc1
commit f2f5742ba5
454 changed files with 44213 additions and 52971 deletions

View File

@ -17,7 +17,7 @@ CONFIG += embed_translations
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
TARGET = $$quote(LedOK Express) TARGET = $$quote(LedOK Express)
VERSION = 1.3.0 VERSION = 1.3.5
DEFINES += APP_VERSION=\\\"$$VERSION\\\" DEFINES += APP_VERSION=\\\"$$VERSION\\\"
msvc { msvc {
QMAKE_CXXFLAGS += -execution-charset:utf-8 QMAKE_CXXFLAGS += -execution-charset:utf-8
@ -25,6 +25,15 @@ msvc {
CONFIG += force_debug_info CONFIG += force_debug_info
CONFIG += separate_debug_info CONFIG += separate_debug_info
# QMAKE_LFLAGS_RELEASE += /MAP
# QMAKE_CFLAGS_RELEASE += /Zi
# QMAKE_LFLAGS_RELEASE += /debug /opt:ref
# QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
# QMAKE_LFLAGS_RELEASE += $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
LIBS += -lDbgHelp
} }
win* { win* {
LIBS += -lwinmm LIBS += -lwinmm
@ -46,7 +55,6 @@ SOURCES += \
base/switchcontrol.cpp \ base/switchcontrol.cpp \
base/taesclass.cpp \ base/taesclass.cpp \
base/updateledset3dialog.cpp \ base/updateledset3dialog.cpp \
base/updaterdialog.cpp \
base/x_checkboxdelegate.cpp \ base/x_checkboxdelegate.cpp \
base/x_spinboxdelegate.cpp \ base/x_spinboxdelegate.cpp \
base/x_timeeditdelegate.cpp \ base/x_timeeditdelegate.cpp \
@ -57,18 +65,22 @@ SOURCES += \
base/lodateselector.cpp \ base/lodateselector.cpp \
base/loqtitlebar.cpp \ base/loqtitlebar.cpp \
base/loqtreewidget.cpp \ base/loqtreewidget.cpp \
base/table.cpp \
base/waitingdlg.cpp \ base/waitingdlg.cpp \
basedlg.cpp \ basedlg.cpp \
basewin.cpp \ basewin.cpp \
cfg.cpp \ cfg.cpp \
communication/hpptclient.cpp \ communication/hpptclient.cpp \
communication/taserialthread.cpp \ communication/taserialthread.cpp \
device/ctrlhdmipanel.cpp \
device/ctrlnetworkpanel.cpp \
device/ctrlpwdpanel.cpp \
devicectrlpanel.cpp \ devicectrlpanel.cpp \
deviceitem.cpp \ deviceitem.cpp \
devicepanel.cpp \ devicepanel.cpp \
ffplayer.cpp \ ffplayer.cpp \
globaldefine.cpp \ globaldefine.cpp \
gutil/qgui.cpp \
gutil/qnetwork.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
mguangyingpinwidget.cpp \ mguangyingpinwidget.cpp \
@ -87,55 +99,45 @@ SOURCES += \
player/posdlg.cpp \ player/posdlg.cpp \
progpanel.cpp \ progpanel.cpp \
synctimer.cpp \ synctimer.cpp \
tcpsocket.cpp \
test.cpp \ test.cpp \
tipdialog.cpp \
tools.cpp \ tools.cpp \
wDevicesManager/controlencryptwidget.cpp \ device/controlpowerschedule.cpp \
wDevicesManager/controlhdmischedule.cpp \ device/controlpowerwidget.cpp \
wDevicesManager/controlhdmiwidget.cpp \ device/controltestwidget.cpp \
wDevicesManager/controlnetconfigwidget.cpp \ device/controlvolumeschedule.cpp \
wDevicesManager/controlpowermanual.cpp \ device/controlvolumewidget.cpp \
wDevicesManager/controlpowerschedule.cpp \ device/ctrladvancedpanel.cpp \
wDevicesManager/controlpowerwidget.cpp \ device/ctrlbrightpanel.cpp \
wDevicesManager/controltestwidget.cpp \ device/ctrlverifyclockpanel.cpp \
wDevicesManager/controlvolumemanual.cpp \ device/ledcard.cpp \
wDevicesManager/controlvolumeschedule.cpp \ device/upgradeapkdialog.cpp \
wDevicesManager/controlvolumewidget.cpp \ device/wupgradeapkitem.cpp \
wDevicesManager/ctrladvancedpanel.cpp \ program/copydirthread.cpp \
wDevicesManager/ctrlbrightpanel.cpp \ program/eaclock.cpp \
wDevicesManager/ctrlverifyclockpanel.cpp \ program/eaudio.cpp \
wDevicesManager/ledcard.cpp \ program/ebase.cpp \
wDevicesManager/threadupgradeapk.cpp \ program/edclock.cpp \
wDevicesManager/upgradeapkdialog.cpp \ program/eenviron.cpp \
wDevicesManager/wupgradeapkitem.cpp \ program/egif.cpp \
wProgramManager/eaclock.cpp \ program/emultiwin.cpp \
wProgramManager/eaudio.cpp \ program/ephoto.cpp \
wProgramManager/ebase.cpp \ program/etext.cpp \
wProgramManager/edclock.cpp \ program/etimer.cpp \
wProgramManager/eenviron.cpp \ program/evideo.cpp \
wProgramManager/egif.cpp \ program/eweb.cpp \
wProgramManager/emultiwin.cpp \ program/gentmpthread.cpp \
wProgramManager/ephoto.cpp \ program/pageeditor.cpp \
wProgramManager/etext.cpp \ program/pagelistitem.cpp \
wProgramManager/etimer.cpp \ program/progcreatedlg.cpp \
wProgramManager/evideo.cpp \ program/progeditorwin.cpp \
wProgramManager/eweb.cpp \ program/progitem.cpp \
wProgramManager/gentmpthread.cpp \ program/sendprogramdialog.cpp \
wProgramManager/pageeditor.cpp \ program/sendprogthread.cpp \
wProgramManager/pagelistitem.cpp \ program/usbdetectdialog.cpp \
wProgramManager/progcreatedlg.cpp \ program/videosplitthread.cpp \
wProgramManager/progeditorwin.cpp \ program/wplanitem.cpp \
wProgramManager/progitem.cpp \ program/wplanlist.cpp \
wProgramManager/sendprogramdialog.cpp \ program/wprogrampublishitem.cpp \
wProgramManager/sendprogthread.cpp \
wProgramManager/threadexportprogrampro.cpp \
wProgramManager/usbdetectdialog.cpp \
wProgramManager/videosplitthread.cpp \
wProgramManager/wexportprogramitem.cpp \
wProgramManager/wplanitem.cpp \
wProgramManager/wplanlist.cpp \
wProgramManager/wprogrampublishitem.cpp \
HEADERS += \ HEADERS += \
base/aboutdlg.h \ base/aboutdlg.h \
@ -148,7 +150,6 @@ HEADERS += \
base/switchcontrol.h \ base/switchcontrol.h \
base/taesclass.h \ base/taesclass.h \
base/updateledset3dialog.h \ base/updateledset3dialog.h \
base/updaterdialog.h \
base/x_checkboxdelegate.h \ base/x_checkboxdelegate.h \
base/x_spinboxdelegate.h \ base/x_spinboxdelegate.h \
base/x_timeeditdelegate.h \ base/x_timeeditdelegate.h \
@ -158,19 +159,22 @@ HEADERS += \
base/lodateselector.h \ base/lodateselector.h \
base/loqtitlebar.h \ base/loqtitlebar.h \
base/loqtreewidget.h \ base/loqtreewidget.h \
base/table.h \
base/waitingdlg.h \ base/waitingdlg.h \
basedlg.h \ basedlg.h \
basewin.h \ basewin.h \
cfg.h \ cfg.h \
communication/hpptclient.h \ communication/hpptclient.h \
communication/taserialthread.h \ communication/taserialthread.h \
device/ctrlhdmipanel.h \
device/ctrlnetworkpanel.h \
device/ctrlpwdpanel.h \
devicectrlpanel.h \ devicectrlpanel.h \
deviceitem.h \ deviceitem.h \
devicepanel.h \ devicepanel.h \
ffplayer.h \ ffplayer.h \
globaldefine.h \ globaldefine.h \
gqt.h \ gutil/qgui.h \
gutil/qnetwork.h \
mainwindow.h \ mainwindow.h \
mguangyingpinwidget.h \ mguangyingpinwidget.h \
passwordindlg.h \ passwordindlg.h \
@ -188,73 +192,54 @@ HEADERS += \
player/posdlg.h \ player/posdlg.h \
progpanel.h \ progpanel.h \
synctimer.h \ synctimer.h \
tcpsocket.h \
tipdialog.h \
tools.h \ tools.h \
wDevicesManager/controlencryptwidget.h \ device/controlpowerschedule.h \
wDevicesManager/controlhdmischedule.h \ device/controlpowerwidget.h \
wDevicesManager/controlhdmiwidget.h \ device/controltestwidget.h \
wDevicesManager/controlnetconfigwidget.h \ device/controlvolumeschedule.h \
wDevicesManager/controlpowermanual.h \ device/controlvolumewidget.h \
wDevicesManager/controlpowerschedule.h \ device/ctrladvancedpanel.h \
wDevicesManager/controlpowerwidget.h \ device/ctrlbrightpanel.h \
wDevicesManager/controltestwidget.h \ device/ctrlverifyclockpanel.h \
wDevicesManager/controlvolumemanual.h \ device/ledcard.h \
wDevicesManager/controlvolumeschedule.h \ device/upgradeapkdialog.h \
wDevicesManager/controlvolumewidget.h \ device/wupgradeapkitem.h \
wDevicesManager/ctrladvancedpanel.h \ program/copydirthread.h \
wDevicesManager/ctrlbrightpanel.h \ program/eaclock.h \
wDevicesManager/ctrlverifyclockpanel.h \ program/eaudio.h \
wDevicesManager/ledcard.h \ program/ebase.h \
wDevicesManager/threadupgradeapk.h \ program/edclock.h \
wDevicesManager/upgradeapkdialog.h \ program/eenviron.h \
wDevicesManager/wupgradeapkitem.h \ program/egif.h \
wProgramManager/eaclock.h \ program/emultiwin.h \
wProgramManager/eaudio.h \ program/ephoto.h \
wProgramManager/ebase.h \ program/etext.h \
wProgramManager/edclock.h \ program/etimer.h \
wProgramManager/eenviron.h \ program/evideo.h \
wProgramManager/egif.h \ program/eweb.h \
wProgramManager/emultiwin.h \ program/gentmpthread.h \
wProgramManager/ephoto.h \ program/pageeditor.h \
wProgramManager/etext.h \ program/pagelistitem.h \
wProgramManager/etimer.h \ program/progcreatedlg.h \
wProgramManager/evideo.h \ program/progeditorwin.h \
wProgramManager/eweb.h \ program/progitem.h \
wProgramManager/gentmpthread.h \ program/sendprogramdialog.h \
wProgramManager/pageeditor.h \ program/sendprogthread.h \
wProgramManager/pagelistitem.h \ program/usbdetectdialog.h \
wProgramManager/progcreatedlg.h \ program/videosplitthread.h \
wProgramManager/progeditorwin.h \ program/wplanitem.h \
wProgramManager/progitem.h \ program/wplanlist.h \
wProgramManager/sendprogramdialog.h \ program/wprogrampublishitem.h \
wProgramManager/sendprogthread.h \
wProgramManager/threadexportprogrampro.h \
wProgramManager/usbdetectdialog.h \
wProgramManager/videosplitthread.h \
wProgramManager/wexportprogramitem.h \
wProgramManager/wplanitem.h \
wProgramManager/wplanlist.h \
wProgramManager/wprogrampublishitem.h \
FORMS += \ FORMS += \
base/pixbmpshowdialog.ui \ base/pixbmpshowdialog.ui \
base/updateledset3dialog.ui \ base/updateledset3dialog.ui \
base/updaterdialog.ui \
base/x_uimsgboxok.ui \ base/x_uimsgboxok.ui \
mguangyingpinwidget.ui \ mguangyingpinwidget.ui \
tipdialog.ui \ device/controlpowerschedule.ui \
wDevicesManager/controlencryptwidget.ui \ device/controltestwidget.ui \
wDevicesManager/controlhdmischedule.ui \ device/controlvolumeschedule.ui \
wDevicesManager/controlpowermanual.ui \ program/wplanitem.ui \
wDevicesManager/controlpowerschedule.ui \
wDevicesManager/controlpowerwidget.ui \
wDevicesManager/controltestwidget.ui \
wDevicesManager/controlvolumemanual.ui \
wDevicesManager/controlvolumeschedule.ui \
wDevicesManager/controlvolumewidget.ui \
wDevicesManager/upgradeapkdialog.ui \
wProgramManager/wplanitem.ui \
TRANSLATIONS += \ TRANSLATIONS += \
translations/app_zh_CN.ts \ translations/app_zh_CN.ts \
@ -268,9 +253,7 @@ EXTRA_TRANSLATIONS += \
translations/qt_ja.ts \ translations/qt_ja.ts \
translations/qt_en.ts translations/qt_en.ts
RESOURCES += \ RESOURCES += res.qrc
res.qrc \
qss.qrc
win32:RC_ICONS = res/Logo.ico win32:RC_ICONS = res/Logo.ico
osx:ICON = res/Logo.icns osx:ICON = res/Logo.icns
@ -308,6 +291,10 @@ copy.files += 7z/7z.exe
copy.path = $$OUT_PWD copy.path = $$OUT_PWD
copy2.path = $$OUT_PWD/release copy2.path = $$OUT_PWD/release
copy3.files += $$quote(y50 param)
copy3.path = $$OUT_PWD/release
CONFIG += file_copies CONFIG += file_copies
COPIES += copy COPIES += copy
COPIES += copy2 COPIES += copy2
COPIES += copy3

View File

@ -6,6 +6,10 @@ extern "C"{
#include <libswscale/swscale.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) { QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id) {
AVFormatContext *fmt_ctx = avformat_alloc_context(); AVFormatContext *fmt_ctx = avformat_alloc_context();
QString err; QString err;
@ -44,9 +48,12 @@ QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id
avcodec_free_context(&vcCtx); avcodec_free_context(&vcCtx);
goto free; 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, nullptr, nullptr, nullptr); 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 packet = av_packet_alloc();
auto frm = av_frame_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) { while(1) {
if(av_read_frame(fmt_ctx, packet) < 0) break; if(av_read_frame(fmt_ctx, packet) < 0) break;
if(packet->stream_index != vi_idx) continue; if(packet->stream_index != vi_idx) continue;
@ -54,10 +61,9 @@ QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id
if(res < 0) break; if(res < 0) break;
while((res = avcodec_receive_frame(vcCtx, frm)) != AVERROR(EAGAIN)) { while((res = avcodec_receive_frame(vcCtx, frm)) != AVERROR(EAGAIN)) {
if(res < 0) goto free2; if(res < 0) goto free2;
img = QImage(vcCtx->width, vcCtx->height, QImage::Format_ARGB32); dst[0] = new uchar[dstStride[3]];
uint8_t *dst[4]{img.bits()};
int dstStride[4]{img.bytesPerLine()};
sws_scale(sws_ctx, frm->data, frm->linesize, 0, vcCtx->height, dst, dstStride); 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; goto free2;
} }
} }
@ -71,188 +77,6 @@ QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id
avformat_close_input(&fmt_ctx); avformat_close_input(&fmt_ctx);
return err; return err;
} }
QString videoTrans(int sw, int sh, int dw, int dh, int cnt, QPointF pos, QByteArray file) {
AVFormatContext *in_fmt = avformat_alloc_context(), *out_fmt = 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(), nullptr, nullptr)) < 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) {
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) {
err = QString("avformat_alloc_output_context2 fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
goto free;
}
int vi_idx = -1;
for(uint ss=0; ss<in_fmt->nb_streams; ss++) {
AVStream *stream = in_fmt->streams[ss];
AVStream *out_stream = avformat_new_stream(out_fmt, 0);
if((ret = avcodec_parameters_copy(out_stream->codecpar, stream->codecpar)) < 0) {
err = QString("avcodec_parameters_copy fail. ") + av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
goto free;
}
out_stream->time_base = stream->time_base;
out_stream->start_time = stream->start_time;
out_stream->duration = stream->duration;
out_stream->avg_frame_rate = stream->avg_frame_rate;
out_stream->sample_aspect_ratio = {1,1};
if(vi_idx == -1 && stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) vi_idx = ss;
}
if(vi_idx == -1) {
err = "Didn't find a Video Stream";
goto free;
}
auto codecpar = in_fmt->streams[vi_idx]->codecpar;
qDebug()<<"codec_id"<<codecpar->codec_id<<avcodec_get_name(codecpar->codec_id);
auto decoder = avcodec_find_decoder(codecpar->codec_id);
if(decoder==0) {
err = "Could not found Video Decoder";
goto free;
}
de_ctx = avcodec_alloc_context3(decoder);
avcodec_parameters_to_context(de_ctx, codecpar);
if(avcodec_open2(de_ctx, decoder, 0) < 0) {
err = "Could not open Video decode Ctx";
goto free;
}
auto out_codecpar = out_fmt->streams[vi_idx]->codecpar;
out_codecpar->codec_id = AV_CODEC_ID_H264;
out_codecpar->format = AV_PIX_FMT_YUV420P;
out_codecpar->width = dw;
out_codecpar->height = dh;
out_codecpar->sample_aspect_ratio = {1,1};
out_fmt->streams[vi_idx]->sample_aspect_ratio = {1,1};
auto encoder = avcodec_find_encoder(out_codecpar->codec_id);
if(encoder==0) {
fprintf(stderr, "Codec not found\n");
goto free;
}
en_ctx = avcodec_alloc_context3(encoder);
avcodec_parameters_to_context(en_ctx, out_codecpar);
en_ctx->bit_rate = dw*dh*6;
en_ctx->gop_size = de_ctx->gop_size;
en_ctx->max_b_frames = 3;
en_ctx->framerate = de_ctx->framerate;
en_ctx->time_base = out_fmt->streams[vi_idx]->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) {
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) {
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, sw, sh, AV_PIX_FMT_0RGB, SWS_FAST_BILINEAR, 0, 0, 0);
auto out_sws_ctx = sws_getContext(dw, dh, AV_PIX_FMT_0RGB, dw, dh, AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);
auto packet = av_packet_alloc();
auto frm = av_frame_alloc();
auto out_frm = av_frame_alloc();
QImage img(sw, sh, QImage::Format_RGB32);
uint8_t *img_data[4]{img.bits(), 0, 0, 0};
int img_linesize[4]{img.bytesPerLine(), 0, 0, 0};
QImage out_img(dw, dh, QImage::Format_RGB32);
uint8_t *out_img_data[4]{out_img.bits(), 0, 0, 0};
int out_img_linesize[4]{out_img.bytesPerLine(), 0, 0, 0};
QPainter painter(&out_img);
while(1) {
if((ret = av_read_frame(in_fmt, 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);
continue;
}
ret = avcodec_send_packet(de_ctx, packet);
}
if(ret < 0) {
err = QString("avcodec_send_packet fail. ")+av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, ret);
break;
}
while((ret = avcodec_receive_frame(de_ctx, frm)) != 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);
goto free2;
}
ret = avcodec_send_frame(en_ctx, 0);
} else {
sws_scale(sws_ctx, frm->data, frm->linesize, 0, de_ctx->height, img_data, img_linesize);
painter.drawImage(pos, img);
auto apos = pos;
for(int i=1; i<cnt; i++) {
apos.rx() -= dw;
apos.ry() += dh/cnt;
painter.drawImage(apos, img);
}
av_frame_unref(out_frm);
av_frame_copy_props(out_frm, frm);
out_frm->format = AV_PIX_FMT_YUV420P;
out_frm->width = dw;
out_frm->height = dh;
out_frm->sample_aspect_ratio = {1,1};
if((ret = av_frame_get_buffer(out_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, dh, out_frm->data, out_frm->linesize);
ret = avcodec_send_frame(en_ctx, out_frm);
}
if(ret < 0) {
err = QString("avcodec_send_frame fail. ")+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);
}
goto free2;
} else {
av_interleaved_write_frame(out_fmt, packet);
}
}
}
}
free2:
av_frame_free(&frm);
av_frame_free(&out_frm);
av_packet_free(&packet);
sws_freeContext(sws_ctx);
sws_freeContext(out_sws_ctx);
}
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);
return err;
}
QString audioInfo(QByteArray url, int64_t *dur) { QString audioInfo(QByteArray url, int64_t *dur) {
AVFormatContext *fmt_ctx = avformat_alloc_context(); AVFormatContext *fmt_ctx = avformat_alloc_context();
QString err; QString err;

View File

@ -7,7 +7,6 @@ extern "C"{
} }
QString videoInfo(QByteArray url, QImage &, int64_t *dur, AVCodecID *); QString videoInfo(QByteArray url, QImage &, int64_t *dur, AVCodecID *);
QString videoTrans(int sw, int sh, int dw, int dh, int cnt, QPointF pos, QByteArray file);
QString audioInfo(QByteArray url, int64_t *dur); QString audioInfo(QByteArray url, int64_t *dur);
#endif // FFUTIL_H #endif // FFUTIL_H

View File

@ -13,9 +13,12 @@ LoColorSelector::LoColorSelector(const QString &text, const QColor &color, QWidg
} }
void LoColorSelector::init() { void LoColorSelector::init() {
connect(this, &QPushButton::clicked, this, [this]{ connect(this, &QPushButton::clicked, this, [this]{
QColorDialog colorDlg(this->color, this); QColorDialog colorDlg(this);
colorDlg.setOption(QColorDialog::ShowAlphaChannel); colorDlg.setOption(QColorDialog::ShowAlphaChannel);
colorDlg.setOption(QColorDialog::DontUseNativeDialog); colorDlg.setOption(QColorDialog::DontUseNativeDialog);
auto color = this->color;
color.setAlpha(255);
colorDlg.setCurrentColor(color);
auto btn = new QPushButton(tr("Transparent")); auto btn = new QPushButton(tr("Transparent"));
connect(btn, &QPushButton::clicked, &colorDlg, [&colorDlg] { connect(btn, &QPushButton::clicked, &colorDlg, [&colorDlg] {
@ -25,10 +28,8 @@ void LoColorSelector::init() {
static_cast<QBoxLayout *>(colorDlg.layout()->itemAt(0)->layout()->itemAt(0)->layout())->insertWidget(2, btn); static_cast<QBoxLayout *>(colorDlg.layout()->itemAt(0)->layout()->itemAt(0)->layout())->insertWidget(2, btn);
if(colorDlg.exec() != QColorDialog::Accepted) return; if(colorDlg.exec() != QColorDialog::Accepted) return;
QColor color = colorDlg.selectedColor(); color = colorDlg.selectedColor();
if(color == this->color) return;
if(! color.isValid()) return; if(! color.isValid()) return;
if(color.alpha()==0 && this->color.alpha()==0) color.setAlpha(255);
setColor(color); setColor(color);
emit sColorChanged(color); emit sColorChanged(color);
}); });

View File

@ -7,13 +7,13 @@ LoDateSelector::LoDateSelector(QWidget *parent) : QPushButton(parent) {
setStyleSheet(R"rrr( setStyleSheet(R"rrr(
LoDateSelector { LoDateSelector {
background-color: transparent; background-color: transparent;
image: url(:/res/ProgramManager/EditProgram/DateSelect_enable.png); image: url(:/res/program/DateSelect_enable.png);
padding: 0; padding: 0;
max-width: 32px; max-width: 32px;
max-height: 32px; max-height: 32px;
} }
LoDateSelector:!enabled{ LoDateSelector:!enabled{
image: url(:/res/ProgramManager/EditProgram/DateSelect_e.png); image: url(:/res/program/DateSelect_e.png);
} }
LoDateSelector:pressed { LoDateSelector:pressed {
margin-top: 1px; margin-top: 1px;

View File

@ -19,13 +19,7 @@ void CheckableHeader::paintSection(QPainter *painter, const QRect &rect, int log
LoQTreeWidget::LoQTreeWidget(QWidget *parent) : QTreeWidget(parent), m_checkState(CheckNone) { LoQTreeWidget::LoQTreeWidget(QWidget *parent) : QTreeWidget(parent), m_checkState(CheckNone) {
fdIsSelAll = new QCheckBox(); fdIsSelAll = new QCheckBox();
fdIsSelAll->setStyleSheet(R"rrr( fdIsSelAll->setStyleSheet("QCheckBox{margin-left: 5px;}");
QCheckBox::indicator {
width: 24px;
height: 24px;
margin-left: 10px;
}
)rrr");
m_header = new CheckableHeader(Qt::Horizontal, fdIsSelAll); m_header = new CheckableHeader(Qt::Horizontal, fdIsSelAll);
setHeader(m_header); setHeader(m_header);
setProperty("ssType", "topList"); setProperty("ssType", "topList");

View File

@ -8,7 +8,7 @@
SoftConfigDialog::SoftConfigDialog(QWidget *parent) : BaseDlg(parent) { SoftConfigDialog::SoftConfigDialog(QWidget *parent) : BaseDlg(parent) {
resize(400, 300); resize(400, 300);
setWindowTitle(tr("Software Configuration")); setWindowTitle(tr("Software Config"));
auto vbox = new QVBoxLayout(this); auto vbox = new QVBoxLayout(this);
auto pushButton = new QPushButton("X"); auto pushButton = new QPushButton("X");

View File

@ -1,18 +0,0 @@
#include "table.h"
int Table::sizeHintForColumn(int column) const {
auto item = horizontalHeaderItem(column);
if(!item) return QTableWidget::sizeHintForColumn(column);
int width = item->data(0x99).toInt();
if(!width) return QTableWidget::sizeHintForColumn(column);
auto header = horizontalHeader();
if(header->sectionResizeMode(column)!=QHeaderView::ResizeToContents) return QTableWidget::sizeHintForColumn(column);
int colCnt = columnCount();
int remainWidth = header->width(), stretchWidth = width;
for(int cc=0; cc<colCnt; cc++) if(cc!=column && (item = horizontalHeaderItem(cc))) {
if(header->sectionResizeMode(cc)==QHeaderView::ResizeToContents) stretchWidth += item->data(0x99).toInt();
else remainWidth -= item->data(0x99).toInt();
}
if(remainWidth<=0) return QTableWidget::sizeHintForColumn(column);
return width * remainWidth / stretchWidth;
}

View File

@ -1,67 +0,0 @@
#ifndef TABLE_H
#define TABLE_H
#include <QTableWidget>
#include <QHeaderView>
struct ColAttr {
QString field;
QString text;
int width{0};
};
class Table : public QTableWidget {
Q_OBJECT
public:
explicit Table(QWidget *parent = nullptr) : QTableWidget{parent} {}
Table(std::initializer_list<ColAttr> colAttrs, QWidget *parent = nullptr) : QTableWidget{0, (int)colAttrs.size(), parent} {
int i = 0;
for(typename std::initializer_list<ColAttr>::const_iterator it = colAttrs.begin(); it != colAttrs.end(); ++it) {
auto item = horizontalHeaderItem(i);
if(!item) {
item = new QTableWidgetItem();
item->setData(0x99, it->width);
setHorizontalHeaderItem(i, item);
}
item->setText(it->text);
if(it->width>0) horizontalHeader()->resizeSection(i, it->width);
mFieldMap.insert(it->field, i++);
}
}
Table *setDefs() {
setSelectionBehavior(QTableWidget::SelectRows);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setAlternatingRowColors(true);
horizontalHeader()->setBackgroundRole(QPalette::Window);
return this;
}
auto item(int row, QString column) {
auto col = mFieldMap[column];
return QTableWidget::item(row, col);
}
void setItem(int row, QString column, QTableWidgetItem *item) {
auto col = mFieldMap[column];
QTableWidget::setItem(row, col, item);
}
void setValue(int row, QString column, const QString &text) {
auto col = mFieldMap[column];
QTableWidget::setItem(row, col, new QTableWidgetItem(text));
}
auto cellWidget(int row, QString column) {
auto col = mFieldMap[column];
return QTableWidget::cellWidget(row, col);
}
void setCellWidget(int row, QString column, QWidget *widget) {
auto col = mFieldMap[column];
QTableWidget::setCellWidget(row, col, widget);
}
QMap<QString,int> mFieldMap;
protected:
int sizeHintForColumn(int column) const override;
};
#endif // TABLE_H

View File

@ -1,38 +0,0 @@
#include "updaterdialog.h"
#include "cfg.h"
#include "ui_updaterdialog.h"
UpdaterDialog::UpdaterDialog(QWidget *parent) : BaseDlg(parent), ui(new Ui::UpdaterDialog) {
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
ui->pushButton_2->setVisible(false);
ui->label_2->setText(tr("CurVersion")+":"+APP_VERSION);
QSimpleUpdater *m_updater = QSimpleUpdater::getInstance();
connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(OnCheckForUpdates()));
connect(m_updater, SIGNAL(checkingFinished(QString)), this, SLOT(updateChangelog(QString)));
m_updater->setModuleVersion(UpdVerUrl, APP_VERSION);
m_updater->setNotifyOnUpdate(UpdVerUrl, false);
m_updater->setNotifyOnFinish(UpdVerUrl, false);
m_updater->checkForUpdates(UpdVerUrl);
}
UpdaterDialog::~UpdaterDialog(){
delete ui;
}
void UpdaterDialog::OnCheckForUpdates(){
QSimpleUpdater::getInstance()->setNotifyOnUpdate(UpdVerUrl, true);
QSimpleUpdater::getInstance()->setNotifyOnFinish(UpdVerUrl, false);
QSimpleUpdater::getInstance()->setMandatoryUpdate(UpdVerUrl, true);
QSimpleUpdater::getInstance()->checkForUpdates(UpdVerUrl);
}
void UpdaterDialog::updateChangelog(QString){
if(QSimpleUpdater::getInstance()->getUpdateAvailable(UpdVerUrl)){
QString strtip = tr("LatestVersion:") + QSimpleUpdater::getInstance()->getLatestVersion(UpdVerUrl) + "\r\n"
+ tr("Update log:") + "\r\n" + QSimpleUpdater::getInstance()->getChangelog(UpdVerUrl);
ui->textEdit->setText(strtip);
ui->pushButton_2->setVisible(true);
} else {
ui->textEdit->setText(tr("The current version is already the latest version") + "\r\n\r\n"
+ tr("Update log:") + "\r\n" + QSimpleUpdater::getInstance()->getChangelog(UpdVerUrl));
}
}

View File

@ -1,26 +0,0 @@
#ifndef UPDATERDIALOG_H
#define UPDATERDIALOG_H
#include <basedlg.h>
#include <QSimpleUpdater.h>
namespace Ui {
class UpdaterDialog;
}
class UpdaterDialog : public BaseDlg
{
Q_OBJECT
public:
explicit UpdaterDialog(QWidget *parent = nullptr);
~UpdaterDialog();
private:
Ui::UpdaterDialog *ui;
protected slots:
void OnCheckForUpdates() ;
void updateChangelog(QString);
};
#endif // UPDATERDIALOG_H

View File

@ -1,193 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UpdaterDialog</class>
<widget class="QDialog" name="UpdaterDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>400</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Software Update</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>24</height>
</size>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="styleSheet">
<string notr="true">border-top: 2px solid gray; </string>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">image: url(:/res/Logo.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>V1.0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="pushButton_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>UpdaterDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>364</x>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>78</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,6 +1,7 @@
#include "waitingdlg.h" #include "waitingdlg.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QTimerEvent> #include <QTimerEvent>
#include <QPushButton>
WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : BaseDlg{parent}, sucText(sucText) { WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : BaseDlg{parent}, sucText(sucText) {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -11,8 +12,18 @@ WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : BaseDlg
setPalette(pal); setPalette(pal);
auto vBox = new QVBoxLayout(this); auto vBox = new QVBoxLayout(this);
vBox->setContentsMargins(6, 3, 6, 6);
vBox->addStretch(); vBox->addStretch();
btnAbort = new QPushButton("X");
btnAbort->setStyleSheet(R"rrr(
QPushButton {border-radius: 4px; padding: 2px 6px; background: transparent;}
QPushButton:hover {background: rgba(0,0,0,0.2);}
QPushButton:pressed {background: rgba(0,0,0,0.3);}
)rrr");
connect(btnAbort, &QPushButton::clicked, this, &QDialog::reject);
vBox->addWidget(btnAbort, 0, Qt::AlignRight);
mIndicator = new CustomProgressIndicator(this); mIndicator = new CustomProgressIndicator(this);
mIndicator->setDisplayModel(1); mIndicator->setDisplayModel(1);
mIndicator->setColor(QColor(0x0088dd)); mIndicator->setColor(QColor(0x0088dd));

View File

@ -10,12 +10,12 @@ class WaitingDlg : public BaseDlg {
public: public:
explicit WaitingDlg(QWidget *parent = nullptr, QString text = 0, QString sucText = 0); explicit WaitingDlg(QWidget *parent = nullptr, QString text = 0, QString sucText = 0);
QPushButton *btnAbort;
QLabel *fdText; QLabel *fdText;
QString sucText; QString sucText;
CustomProgressIndicator *mIndicator; CustomProgressIndicator *mIndicator;
public slots: public slots:
void success(); void success();
protected: protected:
void timerEvent(QTimerEvent *) override; void timerEvent(QTimerEvent *) override;
private: private:

View File

@ -48,7 +48,7 @@ bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){
MSG *msg = (MSG*)message; MSG *msg = (MSG*)message;
if(msg->message==WM_NCACTIVATE){ if(msg->message==WM_NCACTIVATE){
isActive = msg->wParam; isActive = msg->wParam;
repaint(); update();
} }
} }
return false; return false;

View File

@ -122,7 +122,7 @@ bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *){
MSG *msg = (MSG*)message; MSG *msg = (MSG*)message;
if(msg->message==WM_NCACTIVATE){ if(msg->message==WM_NCACTIVATE){
isActive = msg->wParam; isActive = msg->wParam;
repaint(); update();
} }
} }
return false; return false;

176
LedOK/css.css Normal file
View File

@ -0,0 +1,176 @@
QLineEdit,QComboBox,QAbstractSpinBox {
border: 1px solid #aaa;
border-radius: 3px;
padding: 2px;
}
QGroupBox {
border: 1px solid #aaa;
border-radius: 3px;
margin-top: 0.5em;
padding-top: 0.4em;
}
QGroupBox::title {
subcontrol-origin: margin;
left: 0.5em;
}
QComboBox::drop-down,
QAbstractSpinBox::up-button,
QAbstractSpinBox::down-button {
border: 0;
}
QComboBox::down-arrow,
QAbstractSpinBox::down-arrow {
image: url(:/res/ArrowDropDown.png);
}
QComboBox::down-arrow:on,
QAbstractSpinBox::up-arrow {
image: url(:/res/ArrowDropUp.png);
}
QAbstractSpinBox::up-arrow:pressed {
top: -1px;
}
QAbstractSpinBox::down-arrow:pressed {
top: 1px;
}
QCheckBox::indicator, QTreeWidget::indicator {
border-image: url(:/res/CheckBoxUnchecked.png); width: 1em; height: 1em; margin-left: 0.25em;
}
QCheckBox::indicator:checked, QTreeWidget::indicator:checked {
border-image: url(:/res/CheckBoxChecked.png);
}
QCheckBox::indicator:disabled {
background-color: #666;
}
ExtendedGroupBox::indicator {
border-image: url(:/res/groupbox-unchecked.png);
}
ExtendedGroupBox::indicator:checked {
border-image: url(:/res/groupbox-checked.png);
}
QScrollArea {
border : 0;
}
QScrollBar:vertical {
width: 12px;
}
QScrollBar:horizontal {
height: 12px;
}
QMenu {
background-color: #eee;
border: 2px solid #ccc;
}
QMenu::item {
background-color: transparent;
}
QMenu::item:selected {
background-color: #8CD;
}
QListWidget {
selection-background-color: #8ce;
}
LoColorSelector {
border: 1px solid #aaa;
border-radius: 4px;
background-color: transparent;
padding: 3px 6px;
max-height: 30px;
}
QTreeWidget[ssType="topList"]::item {
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
height: 40px;
}
QTreeWidget[ssType="topList"] QHeaderView::section {
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
border-left: 0;
border-right: 0;
height: 36px;
}
QTreeWidget[ssType="topList"]::item:hover {
background-color: #ddd;
}
QPushButton[ssType="progManageTool"] {
border-radius: 4px;
background-color: #19c;
color: #000;
padding: 3px 6px;
}
QPushButton[ssType="progManageTool"]:hover {
background-color: #08b;
color: #fff;
}
QPushButton[ssType="progManageTool"]:pressed {
background-color: #07a;
}
QPushButton[ssType="progManageTool"]:disabled {
background-color: #bbb;
color: #777;
}
LoQTitleBar QPushButton {
border-radius: 4px;
icon-size: 20px;
width: 32px;
height: 28px;
}
LoQTitleBar QPushButton:press,
LoQTitleBar QPushButton:hover {
background-color: #C1C1C1;
}
LoQTitleBar QPushButton::menu-indicator {
image: none;
}
QToolButton[ss="MainTab"],
QToolButton[ss="CtrlTab"] {
border: none;
}
QToolButton[ss="MainTab"]:checked,
QToolButton[ss="MainTab"]:hover {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ddd, stop: 1.0 #8cd);
font-size: 15px;
color: #04d;
}
QToolButton[ss="CtrlTab"]:checked,
QToolButton[ss="CtrlTab"]:hover {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eee, stop: 1.0 #ade);
font-size: 15px;
color: #04d;
}
QPushButton#bnSelectFile {
border-radius: 4px;
background-color: #19c;
border: 1px solid #888;
padding: 3px 6px;
}
QPushButton#bnSelectFile:pressed {
background: transparent;
}
QPushButton[style="multiTool"] {
border-radius: 4px;
padding: 3px 6px;
}
QPushButton[style="multiTool"]:hover {
background-color: rgba(226,226,226,1);
}

View File

@ -23,7 +23,7 @@ ControlPowerSchedule::ControlPowerSchedule(QWidget *parent,QList<LedCard *> *lis
ui->setupUi(this); ui->setupUi(this);
ui->labelPowerScheduleTip->setVisible(false); ui->labelPowerScheduleTip->setVisible(false);
refreshLable(); refreshLable();
setStyleSheet(Tools::styleSheet()); setStyleSheet(css);
ui->pushButtonAdd->setProperty("ssType", "progManageTool"); ui->pushButtonAdd->setProperty("ssType", "progManageTool");
ui->pushButtonAdd->setFlat(true); ui->pushButtonAdd->setFlat(true);
ui->pushButtonDelete->setProperty("ssType", "progManageTool"); ui->pushButtonDelete->setProperty("ssType", "progManageTool");
@ -149,7 +149,6 @@ void ControlPowerSchedule::OnProHttpResponse(QString url, QString postMD5, QByte
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType == "GetTimingScreenTask") if(strType == "GetTimingScreenTask")
{ {
JieXiJsonTaskPower(jsonObject["screenTask"].toObject()); JieXiJsonTaskPower(jsonObject["screenTask"].toObject());
@ -185,7 +184,6 @@ void ControlPowerSchedule::OnProHttpResponseAll(QString url, QString postMD5, QB
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType == "GetTimingScreenTask") if(strType == "GetTimingScreenTask")
{ {
emit sigHaveSchedule(JieXiJsonTaskPower(jsonObject["screenTask"].toObject())); emit sigHaveSchedule(JieXiJsonTaskPower(jsonObject["screenTask"].toObject()));

View File

@ -2,7 +2,7 @@
#define CONTROLPOWERSCHEDULE_H #define CONTROLPOWERSCHEDULE_H
#include <QWidget> #include <QWidget>
#include <wDevicesManager/ledcard.h> #include <device/ledcard.h>
#include <communication/hpptclient.h> #include <communication/hpptclient.h>
#include <base/loemptydialog.h> #include <base/loemptydialog.h>
#include <QStandardItemModel> #include <QStandardItemModel>
@ -18,10 +18,10 @@ class ControlPowerSchedule : public QWidget
public: public:
explicit ControlPowerSchedule(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr); explicit ControlPowerSchedule(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
~ControlPowerSchedule(); ~ControlPowerSchedule();
void refreshLable();
private: private:
Ui::ControlPowerSchedule *ui; Ui::ControlPowerSchedule *ui;
protected slots: protected slots:
void refreshLable();
void OnClickAdd(); void OnClickAdd();
void OnClickImport(); void OnClickImport();
void OnClickExport(); void OnClickExport();

View File

@ -0,0 +1,155 @@
#include "controlpowerwidget.h"
#include "gutil/qgui.h"
#include "globaldefine.h"
#include "base/waitingdlg.h"
#include "tools.h"
#include <QMessageBox>
ControlPowerWidget::ControlPowerWidget(QWidget *parent, QList<LedCard *> *list) : QWidget(parent) {
auto vBox = new VBox(this);
lbScreenCfg = new QLabel;
lbScreenCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbScreenCfg);
auto hBox = new HBox(vBox);
hBox->addStretch();
fdManual = new QRadioButton;
hBox->addWidget(fdManual);
hBox->addSpacing(40);
fdSchedule = new QRadioButton;
hBox->addWidget(fdSchedule);
hBox->addStretch();
auto stack = new QStackedLayout(vBox);
{
auto vBox = new VBox(stack);
vBox->addSpacing(20);
auto hBox = new HBox(vBox);
hBox->addStretch();
lbScreen = new QLabel;
hBox->addWidget(lbScreen);
fdScreen = new SwitchControl;
fdScreen->setMinimumSize(QSize(80, 33));
fdScreen->setSliderColor(QColor(0, 0, 0), QColor(0, 160, 230));
fdScreen->setBgColor(QColor(200,200,200), QColor(0x00cc00));
fdScreen->setTextColor(QColor(100,100,100), QColor(0, 160, 230));
connect(fdScreen, &SwitchControl::checkedChanged, this, [this](bool checked) {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "SetScreenOn");
json.insert("_type", "SetScreenOn");
json.insert("on", checked);
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, (checked ? tr("SetScreenOn") : tr("SetScreenOff"))+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
Def_CtrlSetReqAfter
});
} else {
if(checked) foreach(auto card, *gSelCards) {
Def_CtrlSetMulti(tr("SetScreenOn"))
}
else foreach(auto card, *gSelCards) {
Def_CtrlSetMulti(tr("SetScreenOff"))
}
}
});
hBox->addWidget(fdScreen);
hBox->addStretch();
btnScreenGet = new QPushButton;
btnScreenGet->setMinimumSize(QSize(60, 30));
btnScreenGet->setProperty("ssType", "progManageTool");
connect(btnScreenGet, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "IsScreenOn");
json.insert("_type", "IsScreenOn");
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("IsScreenOn")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->success();
fdScreen->setCheckedStatus(json["on"].toBool());
});
} else {
foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = json["on"].toBool() ? tr("On") : tr("Off");
gFdResInfo->append(cardId+" "+tr("IsScreenOn")+" "+err);
});
}
}
});
vBox->addWidget(btnScreenGet, 0, Qt::AlignCenter);
vBox->addStretch();
}
m_pSchedule = new ControlPowerSchedule(this, list);
connect(m_pSchedule, &ControlPowerSchedule::sigHaveSchedule, this, [=](bool b) {
if(b) fdSchedule->setChecked(true);
else fdManual->setChecked(true);
});
stack->addWidget(m_pSchedule);
connect(fdSchedule, &QRadioButton::toggled, stack, &QStackedLayout::setCurrentIndex);
fdManual->setChecked(true);
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
if(isVisible()) init();
});
transUi();
}
void ControlPowerWidget::showEvent(QShowEvent *event) {
QWidget::showEvent(event);
init();
}
void ControlPowerWidget::init() {
bool isSingle = gSelCards->count()==1;
if(! isSingle) return;
auto card = gSelCards->at(0);
QJsonObject json;
json.insert("_id", "IsScreenOn");
json.insert("_type", "IsScreenOn");
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) return;
fdScreen->setCheckedStatus(json["on"].toBool());
});
}
void ControlPowerWidget::changeEvent(QEvent *event) {
QWidget::changeEvent(event);
if(event->type() == QEvent::LanguageChange) transUi();
}
void ControlPowerWidget::transUi() {
lbScreenCfg->setText(tr("Power Configuration"));
fdManual->setText(tr("Manual"));
fdSchedule->setText(tr("Schedule"));
lbScreen->setText(tr("Power"));
fdScreen->setText(tr("Off"), tr("On"));
btnScreenGet->setText(tr("Readback"));
m_pSchedule->refreshLable();
}

View File

@ -0,0 +1,29 @@
#ifndef CONTROLPOWERWIDGET_H
#define CONTROLPOWERWIDGET_H
#include <device/controlpowerschedule.h>
#include <QRadioButton>
#include <base/switchcontrol.h>
class ControlPowerWidget : public QWidget {
Q_OBJECT
public:
explicit ControlPowerWidget(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
protected:
void showEvent(QShowEvent *event) override;
void init();
void changeEvent(QEvent *) override;
void transUi();
private:
ControlPowerSchedule *m_pSchedule=nullptr;
QLabel *lbScreenCfg;
QRadioButton *fdManual;
QRadioButton *fdSchedule;
QLabel *lbScreen;
SwitchControl *fdScreen;
QPushButton *btnScreenGet;
};
#endif // CONTROLPOWERWIDGET_H

View File

@ -17,7 +17,7 @@ ControlTestWidget::ControlTestWidget(QWidget *parent,QList<LedCard *> *list) :
m_pLedlist=list; m_pLedlist=list;
ui->setupUi(this); ui->setupUi(this);
refreshLable(); refreshLable();
setStyleSheet(Tools::styleSheet()); setStyleSheet(css);
ui->pushButtonStartLine->setProperty("ssType", "progManageTool"); ui->pushButtonStartLine->setProperty("ssType", "progManageTool");
ui->pushButtonStartGray->setProperty("ssType", "progManageTool"); ui->pushButtonStartGray->setProperty("ssType", "progManageTool");
ui->pushButtonStartColor->setProperty("ssType", "progManageTool"); ui->pushButtonStartColor->setProperty("ssType", "progManageTool");
@ -501,14 +501,8 @@ void ControlTestWidget::OnProHttpResponse(QString url, QString postMD5, QByteArr
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType == "TestScreen")
{
}
MACRO_ASKTIME_STOP MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK MACRO_POSTING_DLG_UNLOCK
} }
} }
} }
@ -534,15 +528,8 @@ void ControlTestWidget::OnProHttpResponseAll(QString url, QString postMD5, QByte
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType == "TestScreen")
{
}
MACRO_ASKTIME_STOP MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK MACRO_POSTING_DLG_UNLOCK
} }
} }
} }

View File

@ -2,7 +2,7 @@
#define CONTROLTESTWIDGET_H #define CONTROLTESTWIDGET_H
#include <QWidget> #include <QWidget>
#include <wDevicesManager/ledcard.h> #include <device/ledcard.h>
#include <communication/hpptclient.h> #include <communication/hpptclient.h>
#include <base/loemptydialog.h> #include <base/loemptydialog.h>
namespace Ui { namespace Ui {

View File

@ -21,7 +21,7 @@ ControlVolumeSchedule::ControlVolumeSchedule(QWidget *parent,QList<LedCard *> *l
m_pLedlist=list; m_pLedlist=list;
ui->setupUi(this); ui->setupUi(this);
refreshLable(); refreshLable();
setStyleSheet(Tools::styleSheet()); setStyleSheet(css);
ui->pushButtonAdd->setProperty("ssType", "progManageTool"); ui->pushButtonAdd->setProperty("ssType", "progManageTool");
ui->pushButtonAdd->setFlat(true); ui->pushButtonAdd->setFlat(true);
ui->pushButtonDelete->setProperty("ssType", "progManageTool"); ui->pushButtonDelete->setProperty("ssType", "progManageTool");
@ -146,7 +146,6 @@ void ControlVolumeSchedule::OnProHttpResponse(QString url, QString postMD5, QByt
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType == "GetAutoVolumeTask") if(strType == "GetAutoVolumeTask")
{ {
JieXiJsonTaskVolume(jsonObject["taskVolume"].toObject()); JieXiJsonTaskVolume(jsonObject["taskVolume"].toObject());
@ -182,7 +181,6 @@ void ControlVolumeSchedule::OnProHttpResponseAll(QString url, QString postMD5, Q
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType == "GetAutoVolumeTask") if(strType == "GetAutoVolumeTask")
{ {
emit sigHaveSchedule(JieXiJsonTaskVolume(jsonObject["taskVolume"].toObject())); emit sigHaveSchedule(JieXiJsonTaskVolume(jsonObject["taskVolume"].toObject()));

View File

@ -2,7 +2,7 @@
#define CONTROLVOLUMESCHEDULE_H #define CONTROLVOLUMESCHEDULE_H
#include <QWidget> #include <QWidget>
#include <wDevicesManager/ledcard.h> #include <device/ledcard.h>
#include <communication/hpptclient.h> #include <communication/hpptclient.h>
#include <base/loemptydialog.h> #include <base/loemptydialog.h>
#include <QStandardItemModel> #include <QStandardItemModel>
@ -19,8 +19,8 @@ class ControlVolumeSchedule : public QWidget
public: public:
explicit ControlVolumeSchedule(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr); explicit ControlVolumeSchedule(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
~ControlVolumeSchedule(); ~ControlVolumeSchedule();
protected slots:
void refreshLable(); void refreshLable();
protected slots:
void OnClickAdd(); void OnClickAdd();
void OnClickImport(); void OnClickImport();
void OnClickExport(); void OnClickExport();

View File

@ -0,0 +1,154 @@
#include "controlvolumewidget.h"
#include "gutil/qgui.h"
#include "globaldefine.h"
#include "base/waitingdlg.h"
#include "tools.h"
#include <QMessageBox>
ControlVolumeWidget::ControlVolumeWidget(QWidget *parent,QList<LedCard *> *list) : QWidget(parent) {
auto vBox = new VBox(this);
lbVolumeControl = new QLabel;
lbVolumeControl->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbVolumeControl);
auto hBox = new HBox(vBox);
hBox->addStretch();
fdManual = new QRadioButton;
hBox->addWidget(fdManual);
hBox->addSpacing(40);
fdSchedule = new QRadioButton;
hBox->addWidget(fdSchedule);
hBox->addStretch();
auto stack = new QStackedLayout(vBox);
{
auto vBox = new VBox(stack);
vBox->addSpacing(20);
auto hBox = new HBox(vBox);
hBox->addStretch();
lbVolume = new QLabel;
hBox->addWidget(lbVolume);
fdVolume = new QSlider(Qt::Horizontal);
fdVolume->setTickPosition(QSlider::TicksAbove);
fdVolume->setRange(0, 15);
connect(fdVolume, &QSlider::sliderReleased, this, [=] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "SetVolume");
json.insert("_type", "SetVolume");
json.insert("volume", fdVolume->value());
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("SetVolume")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, *gSelCards) {
Def_CtrlSetMulti(tr("SetVolume"))
}
}
});
hBox->addWidget(fdVolume);
auto lbCurVol = new QLabel;
lbCurVol->setMinimumWidth(30);
connect(fdVolume, &QSlider::valueChanged, lbCurVol, (void(QLabel::*)(int))&QLabel::setNum);
hBox->addWidget(lbCurVol);
hBox->addStretch();
fdVolumeGet = new QPushButton;
fdVolumeGet->setMinimumSize(QSize(60, 30));
fdVolumeGet->setProperty("ssType", "progManageTool");
connect(fdVolumeGet, &QPushButton::clicked, this, [=] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "GetVolume");
json.insert("_type", "GetVolume");
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("GetVolume")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->success();
fdVolume->setValue(json["volume"].toInt());
});
} else {
foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = QString::number(json["volume"].toInt());
gFdResInfo->append(cardId+" "+tr("GetVolume")+" "+err);
});
}
}
});
vBox->addWidget(fdVolumeGet, 0, Qt::AlignCenter);
vBox->addStretch();
}
m_pSchedule = new ControlVolumeSchedule(this, list);
connect(m_pSchedule, &ControlVolumeSchedule::sigHaveSchedule, this, [=](bool b) {
if(b) fdSchedule->setChecked(true);
else fdManual->setChecked(true);
});
stack->addWidget(m_pSchedule);
connect(fdSchedule, &QRadioButton::toggled, stack, &QStackedLayout::setCurrentIndex);
fdManual->setChecked(true);
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
if(isVisible()) init();
});
transUi();
}
void ControlVolumeWidget::showEvent(QShowEvent *event) {
QWidget::showEvent(event);
init();
}
void ControlVolumeWidget::init() {
bool isSingle = gSelCards->count()==1;
if(! isSingle) return;
auto card = gSelCards->at(0);
QJsonObject json;
json.insert("_id", "GetVolume");
json.insert("_type", "GetVolume");
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) return;
fdVolume->setValue(json["volume"].toInt());
});
}
void ControlVolumeWidget::changeEvent(QEvent *event) {
QWidget::changeEvent(event);
if(event->type() == QEvent::LanguageChange) transUi();
}
void ControlVolumeWidget::transUi() {
lbVolumeControl->setText(tr("Volume Control"));
fdManual->setText(tr("Manual"));
fdSchedule->setText(tr("Schedule"));
lbVolume->setText(tr("Volume"));
fdVolumeGet->setText(tr("Readback"));
m_pSchedule->refreshLable();
}

View File

@ -0,0 +1,31 @@
#ifndef CONTROLVOLUMEWIDGET_H
#define CONTROLVOLUMEWIDGET_H
#include <QWidget>
#include <device/controlvolumeschedule.h>
#include "QStackedWidget"
#include <QRadioButton>
class ControlVolumeWidget : public QWidget {
Q_OBJECT
public:
explicit ControlVolumeWidget(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
protected:
void showEvent(QShowEvent *event) override;
void init();
void changeEvent(QEvent *) override;
void transUi();
private:
ControlVolumeSchedule *m_pSchedule;
QLabel *lbVolumeControl;
QRadioButton *fdManual;
QRadioButton *fdSchedule;
QLabel *lbVolume;
QSlider *fdVolume;
QPushButton *fdVolumeGet;
};
#endif // CONTROLVOLUMEWIDGET_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
#ifndef CTRLADVANCEDPANEL_H
#define CTRLADVANCEDPANEL_H
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QTextEdit>
#include <QJsonObject>
#include <QGroupBox>
#include <QRadioButton>
#include <QCheckBox>
#include <QFile>
#include <QThread>
class CtrlAdvancedPanel : public QWidget {
Q_OBJECT
public:
explicit CtrlAdvancedPanel(QWidget *parent = nullptr);
protected:
void showEvent(QShowEvent *event) override;
void init();
void changeEvent(QEvent *) override;
void transUi();
void keyReleaseEvent(QKeyEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
private:
bool isPassed{false};
QLabel *lbTitle;
QLabel *lbScreenWidth;
QLineEdit *fdScreenWidth;
QLabel *lbScreenHeight;
QLineEdit *fdScreenHeight;
QPushButton *btnScreenSet;
QLabel *lbAlias;
QLineEdit *fdAlias;
QPushButton *btnAliasSet;
QLabel *labelWebServer;
QComboBox *fdWebServerAddr;
QLabel *lbCompanyId;
QLineEdit *fdCompanyId;
QPushButton *btnWebServerSet;
QLabel *label;
QComboBox *fdRealtimeServer;
QPushButton *btnRealtimeServerSet;
QPushButton *btnRealtimeClear;
QPushButton *btnWareUpdate;
QLabel *lbWareTip;
QPushButton *btnApkCheck;
QComboBox *fdPkg;
QPushButton *fdUninstall;
QPushButton *btnIsRunning;
QPushButton *btnRestart;
QPushButton *btnClearProg;
QPushButton *btnGetLog;
QPushButton *btnSetBack, *btnPlayerBackSet, *btnPlayerBackClear;
QLabel *lbTimingReboot;
QPushButton *btnTimingRebootSet, *btnTimingRebootGet;
QGroupBox *grpM80, *grpY50;
QComboBox *fdM80Resolu, *fdDisMode;
QPushButton *btnM80Set, *btnY50Set;
QPushButton *btnM80Refresh;
QPushButton *btnM80Restore;
QLabel *lbDisMode;
QPushButton *btnDisModeSet, *btnDisModeGet;
QLabel *lbScreenPos, *lbScreenOff;
QPushButton *btnScreenOffSet, *btnScreenOffGet;
QGroupBox *grpHighForBusy;
QRadioButton *fdHighForBusy;
QRadioButton *fdTopLevelLH;
QPushButton *btnHighForBusySet;
QPushButton *btnGetTopLevel;
QPushButton *btnLedSet3;
QPushButton *btnLedSet4;
QPushButton *btnBindTaxiIc;
QGroupBox *grpMinMaxBrightness;
QLabel *lbMinBright;
QLineEdit *fdMinBright;
QPushButton *btnMinBrightGet;
QPushButton *btnMinBrightSet;
QLabel *label_3;
QLineEdit *fdMaxBright;
QPushButton *btnMaxBrightGet;
QPushButton *btnMaxBrightSet;
QGroupBox *grpBoxHiddenSettings;
QPushButton *btnSysUpd, *btnMcuUpd, *btnMcuGet;
QLabel *lbRotate, *lbBaudCfg, *lbBaudModel, *lbUart, *lbBaud;
QPushButton *btnBaudSet, *btnBaudGet;
QCheckBox *fdIsOpenADB;
QLabel *lbCustomJson;
QTextEdit *fdCustomJson;
QPushButton *btnSendCustomJson;
QLabel *lbTraficProtocol, *lbCardMode, *lbTraficPort;
QComboBox *fdServerType;
QPushButton *btnTraficProtSet, *btnTraficProtGet, *btnTraficSet, *btnTraficGet;
};
class PlayerBackSendThread : public QThread {
Q_OBJECT
public:
PlayerBackSendThread(const QString &file, const QString &ip);
QString file, ip;
QString err;
protected:
void run();
signals:
void emErr(QString);
};
#endif // CTRLADVANCEDPANEL_H

View File

@ -3,53 +3,58 @@
#include "globaldefine.h" #include "globaldefine.h"
#include "deviceitem.h" #include "deviceitem.h"
#include "tools.h" #include "tools.h"
#include "base/x_timeeditdelegate.h"
#include "xlsxdocument.h" #include "xlsxdocument.h"
#include "xlsxworkbook.h" #include "xlsxworkbook.h"
#include <QBoxLayout>
#include <QMessageBox> #include <QMessageBox>
#include <QMetaEnum> #include <QMetaEnum>
#include <QJsonArray> #include <QJsonArray>
#include <QButtonGroup>
#include <QThread> #include <QThread>
#include <QHeaderView>
#include <QSettings> #include <QSettings>
#include <QTimeEdit> #include <QTimeEdit>
CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) { CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
auto vBox = new QVBoxLayout(this); auto vBox = new VBox(this);
vBox->setContentsMargins(0,0,0,0); vBox->setContentsMargins(0,0,0,0);
vBox->addSpacing(8); vBox->addSpacing(8);
lbBrightCfg = new QLabel; lbBrightCfg = new QLabel;
auto font = lbBrightCfg->font();
font.setPixelSize(font.pixelSize()+2);
font.setBold(true);
lbBrightCfg->setFont(font);
lbBrightCfg->setAlignment(Qt::AlignCenter); lbBrightCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbBrightCfg); vBox->addWidget(lbBrightCfg);
vBox->addSpacing(9);
auto hBox = new QHBoxLayout(); auto hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
radioAuto = new QRadioButton(); radioAuto = new QRadioButton;
radioAuto->setChecked(true); radioAuto->setChecked(true);
hBox->addWidget(radioAuto); hBox->addWidget(radioAuto);
hBox->addSpacing(40); hBox->addSpacing(40);
radioManual = new QRadioButton(); radioManual = new QRadioButton;
hBox->addWidget(radioManual); hBox->addWidget(radioManual);
hBox->addSpacing(40); hBox->addSpacing(40);
radioSchedule = new QRadioButton(); radioSchedule = new QRadioButton;
hBox->addWidget(radioSchedule); hBox->addWidget(radioSchedule);
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox); fdAdaptToOld = new QCheckBox;
hBox->addWidget(fdAdaptToOld);
auto line = new QFrame; auto line = new QFrame;
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line); vBox->addWidget(line);
auto autoPanel = new QWidget(); auto stack = new QStackedLayout(vBox);
{ {
auto vBox = new QVBoxLayout(autoPanel); auto vBox = new VBox(stack);
fdBrightTip = new QLabel; fdBrightTip = new QLabel;
fdBrightTip->setAlignment(Qt::AlignCenter); fdBrightTip->setAlignment(Qt::AlignCenter);
@ -89,9 +94,9 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
json.insert("_type", "SetBrightnessSensitivity"); json.insert("_type", "SetBrightnessSensitivity");
json.insert("sensitivity", fdSensi->value()); json.insert("sensitivity", fdSensi->value());
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("SetBrightnessSensitivity")); auto waitingDlg = new WaitingDlg(this, tr("SetBrightnessSensitivity")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] { connect(reply, &QNetworkReply::finished, card, [reply, waitingDlg] {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
@ -114,7 +119,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
json.insert("_id", "GetBrightnessSensitivity"); json.insert("_id", "GetBrightnessSensitivity");
json.insert("_type", "GetBrightnessSensitivity"); json.insert("_type", "GetBrightnessSensitivity");
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("GetBrightnessSensitivity")); auto waitingDlg = new WaitingDlg(this, tr("GetBrightnessSensitivity")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
@ -124,11 +129,12 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt()); if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
gFdResInfo->append(card->m_strCardId+" "+tr("GetBrightnessSensitivity")+" "+err); gFdResInfo->append(cardId+" "+tr("GetBrightnessSensitivity")+" "+err);
}); });
} }
} }
@ -166,20 +172,22 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController")); QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return; return;
} }
auto isAdaptToOld = fdAdaptToOld->isChecked();
QJsonObject json; QJsonObject json;
json.insert("_id", "SetMinBrightness"); json.insert("_id", "SetMinBrightness");
json.insert("_type", "SetMinBrightness"); json.insert("_type", "SetMinBrightness");
auto brightPercent = fdMinBright->value(); auto brightPercent = fdMinBright->value();
if(! isAdaptToOld) json.insert("minBrightnessPercentage", brightPercent);
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
json.insert("brightness", (brightPercent * gSelCards->at(0)->BrightnessLevel + 50) / 100); if(isAdaptToOld) json.insert("brightness", (brightPercent * gSelCards->at(0)->BrightnessLevel + 50) / 100);
auto waitingDlg = new WaitingDlg(this, tr("SetMinBrightness")); auto waitingDlg = new WaitingDlg(this, tr("SetMinBrightness")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] { connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
json.insert("brightness", (brightPercent * card->BrightnessLevel + 50) / 100); if(isAdaptToOld) json.insert("brightness", (brightPercent * card->BrightnessLevel + 50) / 100);
Def_CtrlSetMulti(tr("SetMinBrightness")); Def_CtrlSetMulti(tr("SetMinBrightness"));
} }
} }
@ -198,20 +206,30 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
json.insert("_id", "GetMinBrightness"); json.insert("_id", "GetMinBrightness");
json.insert("_type", "GetMinBrightness"); json.insert("_type", "GetMinBrightness");
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")); auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] { auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, brightLevel] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
fdMinBright->setValue(qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel)); auto value = json["minBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
fdMinBright->setValue(value);
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [reply, cardId, brightLevel] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
gFdResInfo->append(card->m_strCardId+" "+tr("GetMinBrightness")+" "+(err.isEmpty()?QString::number(qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel))+"%":err)); if(err.isEmpty()) {
auto value = json["minBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
err = QString::number(value)+"%";
}
gFdResInfo->append(cardId+" "+tr("GetMinBrightness")+" "+err);
}); });
} }
} }
@ -387,7 +405,14 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
auto waitingDlg = new WaitingDlg(this, tr("GetCurrentSensorBrightness")); auto waitingDlg = new WaitingDlg(this, tr("GetCurrentSensorBrightness"));
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] { connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
Def_CtrlSingleGetReply QJsonDocument json;
QByteArray data;
QString err = checkReplyForJson(reply, &json, &data);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
waitingDlg->success(); waitingDlg->success();
if(json["is485"].toBool()) fdR68->setChecked(true); if(json["is485"].toBool()) fdR68->setChecked(true);
else fdRL2->setChecked(true); else fdRL2->setChecked(true);
@ -400,7 +425,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = QString::number(qRound(json["value"].toInt() * 100.0 / card->BrightnessLevel))+"%"; if(err.isEmpty()) err = QString::number(qRound(json["value"].toInt() * 100.0 / card->BrightnessLevel))+"%";
gFdResInfo->append(card->m_strCardId+" "+tr("GetBrightnessSensitivity")+" "+err); gFdResInfo->append(card->m_strCardId+" "+tr("GetCurrentSensorBrightness")+" "+err);
}); });
} }
} }
@ -411,9 +436,8 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
vBox->addLayout(hBox); vBox->addLayout(hBox);
vBox->addStretch(); vBox->addStretch();
} }
auto manualPanel = new QWidget;
{ {
auto vBox = new QVBoxLayout(manualPanel); auto vBox = new VBox(stack);
auto hBox = new QHBoxLayout; auto hBox = new QHBoxLayout;
hBox->addStretch(); hBox->addStretch();
@ -449,12 +473,14 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController")); QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return; return;
} }
auto isAdaptToOld = fdAdaptToOld->isChecked();
QJsonObject json; QJsonObject json;
json.insert("_id", "SetBrightness"); json.insert("_id", "SetBrightness");
json.insert("_type", "SetBrightness"); json.insert("_type", "SetBrightness");
auto percent = fdFixedBright->value(); auto percent = fdFixedBright->value();
if(! isAdaptToOld) json.insert("brightnessPercentage", percent);
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
json.insert("brightness", (percent * gSelCards->at(0)->BrightnessLevel + 50) / 100); if(isAdaptToOld) json.insert("brightness", (percent * gSelCards->at(0)->BrightnessLevel + 50) / 100);
auto waitingDlg = new WaitingDlg(this, tr("SetBrightness")); auto waitingDlg = new WaitingDlg(this, tr("SetBrightness"));
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] { connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
@ -462,7 +488,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
json.insert("brightness", (percent * card->BrightnessLevel + 50) / 100); if(isAdaptToOld) json.insert("brightness", (percent * card->BrightnessLevel + 50) / 100);
Def_CtrlSetMulti(tr("SetBrightness")) Def_CtrlSetMulti(tr("SetBrightness"))
} }
} }
@ -484,10 +510,18 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
auto waitingDlg = new WaitingDlg(this, tr("GetBrightness")); auto waitingDlg = new WaitingDlg(this, tr("GetBrightness"));
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] { connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
Def_CtrlSingleGetReply QJsonDocument json;
QByteArray data;
QString err = checkReplyForJson(reply, &json, &data);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
waitingDlg->success(); waitingDlg->success();
card->brightness = json["brightness"].toInt(); card->bright = json["brightnessPercentage"].toInt(-1);
fdFixedBright->setValue(qRound(card->brightness * 100.0 / card->BrightnessLevel)); if(card->bright==-1) card->bright = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
fdFixedBright->setValue(card->bright);
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
@ -495,7 +529,12 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
connect(reply, &QNetworkReply::finished, this, [reply, card] { connect(reply, &QNetworkReply::finished, this, [reply, card] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
gFdResInfo->append(card->m_strCardId+" "+tr("Brightness")+" "+(err.isEmpty()?QString::number(qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel))+"%":err)); if(err.isEmpty()) {
auto value = json["brightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
err = QString::number(value)+"%";
}
gFdResInfo->append(card->m_strCardId+" "+tr("Brightness")+" "+err);
}); });
} }
} }
@ -507,23 +546,20 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
vBox->addLayout(hBox); vBox->addLayout(hBox);
vBox->addStretch(); vBox->addStretch();
} }
auto schedulePanel = new QWidget;
{ {
auto hBox = new QHBoxLayout(schedulePanel); auto hBox = new HBox(stack);
hBox->addStretch(); hBox->addStretch();
auto vBox = new QVBoxLayout; auto vBox = new VBox(hBox);
hBox->addLayout(vBox);
hBox->addStretch(); hBox->addStretch();
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
fdScheTip = new QLabel; fdScheTip = new QLabel;
fdScheTip->setWordWrap(true); fdScheTip->setWordWrap(true);
hBox->addWidget(fdScheTip); hBox->addWidget(fdScheTip);
vBox->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
btnScheAdd = new QPushButton; btnScheAdd = new QPushButton;
btnScheAdd->setMinimumSize(60, 30); btnScheAdd->setMinimumSize(60, 30);
@ -609,7 +645,40 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
if(! scheQFile.open(QIODevice::ReadOnly)) return; if(! scheQFile.open(QIODevice::ReadOnly)) return;
auto data = scheQFile.readAll(); auto data = scheQFile.readAll();
scheQFile.close(); scheQFile.close();
restoreScheduleJson(QJsonDocument::fromJson(data).object()); auto json = QJsonDocument::fromJson(data);
tableSche->setRowCount(0);
fdDefBright->setValue(json["defaultBrightness"].toInt());
auto jsitems = json["items"].toArray();
foreach(auto jsitem, jsitems) {
auto schedule = jsitem["schedules"][0];
int row = tableSche->rowCount();
tableSche->insertRow(row);
auto cellWgt = new QWidget;
auto hBox = new QHBoxLayout(cellWgt);
auto slider = new QSlider(Qt::Horizontal);
slider->setRange(1, 100);
slider->setValue(jsitem["brightness"].toInt());
hBox->addWidget(slider);
auto lb = new QLabel(QString::number(slider->value())+"%");
connect(slider, &QSlider::valueChanged, lb, [lb](int value) {
lb->setText(QString::number(value)+"%");
});
hBox->addWidget(lb);
tableSche->setCellWidget(row, "bright", cellWgt);
auto timeEdit = new QTimeEdit(QTime::fromString(schedule["startTime"].toString(), "HH:mm"));
timeEdit->setDisplayFormat("HH:mm");
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "start", timeEdit);
timeEdit = new QTimeEdit(QTime::fromString(schedule["endTime"].toString(), "HH:mm"));
timeEdit->setDisplayFormat("HH:mm");
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "end", timeEdit);
}
}); });
hBox->addWidget(btnScheImport); hBox->addWidget(btnScheImport);
@ -625,23 +694,30 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
settings.setValue("CtrlScheduleDir", QFileInfo(scheFile).absolutePath()); settings.setValue("CtrlScheduleDir", QFileInfo(scheFile).absolutePath());
QFile scheQFile(scheFile); QFile scheQFile(scheFile);
if(! scheQFile.open(QIODevice::WriteOnly)) return; if(! scheQFile.open(QIODevice::WriteOnly)) return;
scheQFile.write(QJsonDocument(getScheduleJson()).toJson()); QJsonArray items;
for(int i=0; i<tableSche->rowCount(); i++) items.append(QJsonObject{
{"brightness", static_cast<QSlider*>(tableSche->cellWidget(i, "bright")->layout()->itemAt(0)->widget())->value()},
{"schedules", QJsonArray{QJsonObject{
{"startTime", static_cast<QTimeEdit*>(tableSche->cellWidget(i, "start"))->text()},
{"endTime", static_cast<QTimeEdit*>(tableSche->cellWidget(i, "end"))->text()}
}}}
});
scheQFile.write(QJsonDocument(QJsonObject{{"defaultBrightness", fdDefBright->value()}, {"items", items}}).toJson());
scheQFile.close(); scheQFile.close();
}); });
hBox->addWidget(btnScheExport); hBox->addWidget(btnScheExport);
vBox->addLayout(hBox);
tableSche = new Table({ tableSche = new Table({
{"bright", tr("BrightnessValue"), 300}, {"bright", "", 300},
{"start", tr("Start Time"), 100}, {"start", "", 100},
{"end", tr("End Time"), 100} {"end", "", 100}
}); });
tableSche->setDefs(); tableSche->setDefs();
tableSche->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); tableSche->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
vBox->addWidget(tableSche); vBox->addWidget(tableSche);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
btnScheSet = new QPushButton; btnScheSet = new QPushButton;
@ -652,11 +728,13 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController")); QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return; return;
} }
auto isAdaptToOld = fdAdaptToOld->isChecked();
QJsonObject json; QJsonObject json;
json.insert("_id", "SetAutoBrightnessTask"); json.insert("_id", "SetAutoBrightnessTask");
json.insert("_type", "SetAutoBrightnessTask"); json.insert("_type", "SetAutoBrightnessTask");
if(! isAdaptToOld) getScheduleJson(json, 0);
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
json.insert("taskBrightness", getScheduleJson(gSelCards->at(0)->BrightnessLevel)); if(isAdaptToOld) getScheduleJson(json, gSelCards->at(0)->BrightnessLevel);
auto waitingDlg = new WaitingDlg(this, tr("SetAutoBrightnessTask")); auto waitingDlg = new WaitingDlg(this, tr("SetAutoBrightnessTask"));
Def_CtrlReqPre; Def_CtrlReqPre;
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] { connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
@ -664,7 +742,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
json.insert("taskBrightness", getScheduleJson(card->BrightnessLevel)); if(isAdaptToOld) getScheduleJson(json, card->BrightnessLevel);
Def_CtrlSetMulti(tr("SetAutoBrightnessTask")) Def_CtrlSetMulti(tr("SetAutoBrightnessTask"))
} }
} }
@ -690,27 +768,22 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] { connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
restoreScheduleJson(json["taskBrightness"].toObject(), card->BrightnessLevel); restoreScheduleJson(json, card->BrightnessLevel);
}); });
} }
}); });
hBox->addWidget(btnScheGet); hBox->addWidget(btnScheGet);
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox);
} }
auto stackBox = new QStackedLayout(vBox); stack->setCurrentIndex(0);
stackBox->addWidget(autoPanel);
stackBox->addWidget(manualPanel);
stackBox->addWidget(schedulePanel);
stackBox->setCurrentIndex(0);
auto group = new QButtonGroup; auto group = new QButtonGroup;
group->addButton(radioAuto, 0); group->addButton(radioAuto, 0);
group->addButton(radioManual, 1); group->addButton(radioManual, 1);
group->addButton(radioSchedule, 2); group->addButton(radioSchedule, 2);
connect(group, &QButtonGroup::idToggled, stackBox, [stackBox](int idx, bool checked) { connect(group, &QButtonGroup::idToggled, stack, [=](int idx, bool checked) {
if(checked) stackBox->setCurrentIndex(idx); if(checked) stack->setCurrentIndex(idx);
}); });
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] { connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
@ -740,11 +813,8 @@ void CtrlBrightPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply, card] { connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err); mTask = restoreScheduleJson(json, card->BrightnessLevel);
return;
}
mTask = restoreScheduleJson(json["taskBrightness"].toObject(), card->BrightnessLevel);
if(mTask) radioSchedule->setChecked(true); if(mTask) radioSchedule->setChecked(true);
else if(mSensi > 0) radioAuto->setChecked(true); else if(mSensi > 0) radioAuto->setChecked(true);
else if(mSensi == 0) radioManual->setChecked(true); else if(mSensi == 0) radioManual->setChecked(true);
@ -757,10 +827,7 @@ void CtrlBrightPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply] { connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
mSensi = json["sensitivity"].toInt(); mSensi = json["sensitivity"].toInt();
fdSensi->setValue(mSensi); fdSensi->setValue(mSensi);
if(mTask != 0) return; if(mTask != 0) return;
@ -775,11 +842,10 @@ void CtrlBrightPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply, card] { connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err); auto value = json["minBrightnessPercentage"].toInt(-1);
return; if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
} fdMinBright->setValue(value);
fdMinBright->setValue(qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel));
}); });
json = QJsonObject(); json = QJsonObject();
@ -789,12 +855,10 @@ void CtrlBrightPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply, card] { connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err); card->bright = json["brightnessPercentage"].toInt(-1);
return; if(card->bright==-1) card->bright = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
} fdFixedBright->setValue(card->bright);
card->brightness = json["brightness"].toInt();
fdFixedBright->setValue(qRound(card->brightness * 100.0 / card->BrightnessLevel));
}); });
} }
@ -807,6 +871,7 @@ void CtrlBrightPanel::transUi() {
radioAuto->setText(tr("Auto")); radioAuto->setText(tr("Auto"));
radioManual->setText(tr("Manual")); radioManual->setText(tr("Manual"));
radioSchedule->setText(tr("Schedule")); radioSchedule->setText(tr("Schedule"));
fdAdaptToOld->setText(tr("Adapt to Old Devices"));
fdBrightTip->setText(tr("BrightTip1")); fdBrightTip->setText(tr("BrightTip1"));
fdSensiTypeTip->setText(tr("BrightTip2")); fdSensiTypeTip->setText(tr("BrightTip2"));
@ -831,17 +896,26 @@ void CtrlBrightPanel::transUi() {
btnScheDel->setText(tr("Delete")); btnScheDel->setText(tr("Delete"));
btnScheImport->setText(tr("Import")); btnScheImport->setText(tr("Import"));
btnScheExport->setText(tr("Export")); btnScheExport->setText(tr("Export"));
tableSche->setHeaderText("bright", tr("BrightnessValue"));
tableSche->setHeaderText("start", tr("Start Time"));
tableSche->setHeaderText("end", tr("End Time"));
btnScheSet->setText(tr("Apply")); btnScheSet->setText(tr("Apply"));
btnScheGet->setText(tr("Readback")); btnScheGet->setText(tr("Readback"));
fdScheTip->setText(tr("Default brightness tip")); fdScheTip->setText(tr("Default brightness tip"));
} }
bool CtrlBrightPanel::restoreScheduleJson(QJsonObject obj, int max) { bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
tableSche->setRowCount(0); tableSche->setRowCount(0);
fdDefBright->setValue(qRound(obj["defaultBrightness"].toInt() * 100.0 / max)); auto taskBrightness = json["taskBrightness"];
auto jsitems = obj["items"].toArray(); auto brightness = json["defaultBrightnessPercentage"].toInt(-1);
foreach(auto jsitem, jsitems) { if(brightness==-1) brightness = qRound(taskBrightness["defaultBrightness"].toInt() * 100.0 / max);
auto schedule = jsitem["schedules"][0]; fdDefBright->setValue(brightness);
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];
int row = tableSche->rowCount(); int row = tableSche->rowCount();
tableSche->insertRow(row); tableSche->insertRow(row);
@ -850,7 +924,8 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonObject obj, int max) {
auto slider = new QSlider(Qt::Horizontal); auto slider = new QSlider(Qt::Horizontal);
slider->setRange(1, 100); slider->setRange(1, 100);
slider->setValue(qRound(jsitem["brightness"].toInt() * 100.0 / max)); if(brightnesses.size() > i) slider->setValue(brightnesses[i].toInt());
else slider->setValue(qRound(jsitems.at(i)["brightness"].toInt() * 100.0 / max));
hBox->addWidget(slider); hBox->addWidget(slider);
auto lb = new QLabel(QString::number(slider->value())+"%"); auto lb = new QLabel(QString::number(slider->value())+"%");
@ -872,31 +947,36 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonObject obj, int max) {
} }
return jsitems.count() > 0; return jsitems.count() > 0;
} }
QJsonObject CtrlBrightPanel::getScheduleJson(int max) { void CtrlBrightPanel::getScheduleJson(QJsonObject &json, int max) {
QJsonObject obj; QJsonArray items, brightnesses;
obj["createDate"] = QJsonValue::Null;
obj["createBy"] = "alahover";
obj["name"] = "TimingBrightness";
auto def = (fdDefBright->value() * max + 50) / 100;
obj["defaultBrightness"] = def;
obj["brightness"] = def;
QJsonArray jsItems;
for(int i=0; i<tableSche->rowCount(); i++) { for(int i=0; i<tableSche->rowCount(); i++) {
QJsonObject item; QJsonObject item;
item["brightness"] = (static_cast<QSlider*>(tableSche->cellWidget(i, "bright")->layout()->itemAt(0)->widget())->value() * max + 50) / 100; auto brightness = static_cast<QSlider*>(tableSche->cellWidget(i, "bright")->layout()->itemAt(0)->widget())->value();
QJsonObject schedule; if(max==0) brightnesses.append(brightness);
schedule["timeType"] = "Range"; else item.insert("brightness", (brightness * max + 50) / 100);
schedule["startTime"] = static_cast<QTimeEdit*>(tableSche->cellWidget(i, "start"))->text(); item.insert("schedules", QJsonArray{QJsonObject{
schedule["endTime"] = static_cast<QTimeEdit*>(tableSche->cellWidget(i, "end"))->text(); {"timeType", "Range"},
schedule["dateType"] = "All"; {"startTime", static_cast<QTimeEdit*>(tableSche->cellWidget(i, "start"))->text()},
schedule["startDate"] = QJsonValue::Null; {"endTime", static_cast<QTimeEdit*>(tableSche->cellWidget(i, "end"))->text()},
schedule["endDate"] = QJsonValue::Null; {"dateType", "All"},
schedule["monthFilter"] = QJsonArray(); {"filterType", "None"},
schedule["filterType"] = "None"; {"monthFilter", QJsonArray()},
schedule["weekFilter"] = QJsonArray(); {"weekFilter", QJsonArray()}
item["schedules"] = QJsonArray{schedule}; }});
jsItems.append(item); items.append(item);
} }
obj["items"] = jsItems; QJsonObject taskBrightness{
return obj; {"createBy", "alahover"},
{"name", "TimingBrightness"},
{"items", items}
};
if(max==0) {
json.insert("defaultBrightnessPercentage", fdDefBright->value());
json.insert("brightnessPercentageList", brightnesses);
} else {
auto def = (fdDefBright->value() * max + 50) / 100;
taskBrightness.insert("defaultBrightness", def);
taskBrightness.insert("brightness", def);
}
json.insert("taskBrightness", taskBrightness);
} }

View File

@ -1,15 +1,12 @@
#ifndef CTRLBRIGHTPANEL_H #ifndef CTRLBRIGHTPANEL_H
#define CTRLBRIGHTPANEL_H #define CTRLBRIGHTPANEL_H
#include "ledcard.h" #include "gutil/qgui.h"
#include "base/table.h"
#include <QButtonGroup>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QCheckBox>
#include <QSlider> #include <QSlider>
#include <QStackedLayout>
#include <QStyledItemDelegate>
class CtrlBrightPanel : public QWidget { class CtrlBrightPanel : public QWidget {
Q_OBJECT Q_OBJECT
@ -22,12 +19,13 @@ protected:
void transUi(); void transUi();
private: private:
bool restoreScheduleJson(QJsonObject, int = 100); bool restoreScheduleJson(QJsonDocument &, int);
QJsonObject getScheduleJson(int = 100); void getScheduleJson(QJsonObject &, int);
QLabel *lbBrightCfg; QLabel *lbBrightCfg;
QRadioButton *radioAuto; QRadioButton *radioAuto;
QRadioButton *radioManual; QRadioButton *radioManual;
QRadioButton *radioSchedule; QRadioButton *radioSchedule;
QCheckBox *fdAdaptToOld;
char mSensi{-1}; char mSensi{-1};
char mTask{-1}; char mTask{-1};

View File

@ -0,0 +1,424 @@
#include "ctrlhdmipanel.h"
#include "gutil/qgui.h"
#include "tools.h"
#include "globaldefine.h"
#include "base/waitingdlg.h"
#include <QMessageBox>
#include <QButtonGroup>
#include <QTimeEdit>
#include <QJsonArray>
CtrlHdmiPanel::CtrlHdmiPanel(QWidget *parent) : QWidget(parent) {
auto vBox = new QVBoxLayout(this);
lbHdmiCfg = new QLabel;
lbHdmiCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbHdmiCfg);
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
auto hBox = new QHBoxLayout();
hBox->addStretch();
fdManual = new QRadioButton;
hBox->addWidget(fdManual);
hBox->addSpacing(40);
fdSchedule = new QRadioButton;
hBox->addWidget(fdSchedule);
hBox->addStretch();
vBox->addLayout(hBox);
auto stacked = new QStackedLayout;
vBox->addLayout(stacked);
{
auto vBox = new VBox(stacked);
vBox->addSpacing(20);
auto hBox = new HBox(vBox);
hBox->addStretch();
fdAsync = new QRadioButton;
hBox->addWidget(fdAsync);
hBox->addSpacing(20);
fdHdmi = new QRadioButton("HDMI");
hBox->addWidget(fdHdmi);
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);
connect(btnGroup, &QButtonGroup::idToggled, this, [this](int id, bool checked) {
if(! checked) return;
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "SyncSwitch");
json.insert("_type", "SyncSwitch");
json.insert("switchOn", (bool)id);
if(id) json.insert("number", id);
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, checked ? tr("SyncSwitch") : tr("AnSyncSwitch"));
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, *gSelCards) {
if(checked){
Def_CtrlSetMulti(tr("SyncSwitch"))
} else {
Def_CtrlSetMulti(tr("AnSyncSwitch"))
}
}
}
});
vBox->addSpacing(20);
hBox = new HBox(vBox);
hBox->addStretch();
btnGetSync = new QPushButton;
btnGetSync->setMinimumSize(60, 30);
btnGetSync->setProperty("ssType", "progManageTool");
connect(btnGetSync, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "IsSync");
json.insert("_type", "IsSync");
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("IsSync"));
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->success();
auto switchOn = json["switchOn"];
if(switchOn.isUndefined()) 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 = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) {
auto switchOn = json["switchOn"];
if(switchOn.isUndefined()) switchOn = json["result"];
if(! switchOn.toBool()) err = tr("Async");
else {
err = "HDMI";
auto number = json["number"].toInt();
if(number) err += " "+QString::number(number);
}
}
gFdResInfo->append(cardId+" "+err);
});
}
}
});
hBox->addWidget(btnGetSync);
hBox->addStretch();
vBox->addStretch();
}
{
auto vBox = new VBox(stacked);
auto hBox = new HBox(vBox);
hBox->setSpacing(10);
tableSche = new Table({
{"start", "", 100},
{"end", "", 100},
{"0", "", 60},
{"1", "", 60},
{"2", "", 60},
{"3", "", 60},
{"4", "", 60},
{"5", "", 60},
{"6", "", 60}
});
tableSche->setDefs();
tableSche->setStyleSheet("Table {selection-background-color: #8ce;}");
btnScheAdd = new QPushButton;
btnScheAdd->setMinimumSize(QSize(60, 30));
btnScheAdd->setProperty("ssType", "progManageTool");
connect(btnScheAdd, &QPushButton::clicked, this, [this] {
int row = tableSche->appendRow();
auto timeEdit = new QTimeEdit(QTime(0, 0));
timeEdit->setDisplayFormat("HH:mm");
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "start", timeEdit);
timeEdit = new QTimeEdit(QTime(1, 0));
timeEdit->setDisplayFormat("HH:mm");
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "end", timeEdit);
for(int i=0; i<7; i++) {
auto fd = new QCheckBox;
fd->setChecked(true);
tableSche->setCellWidget(row, QString::number(i), fd);
}
});
hBox->addWidget(btnScheAdd);
btnScheDel = new QPushButton;
btnScheDel->setMinimumSize(QSize(60, 30));
btnScheDel->setProperty("ssType", "progManageTool");
connect(btnScheDel, &QPushButton::clicked, this, [this] {
auto selected = tableSche->selectedRanges();
if(! selected.isEmpty()) tableSche->model()->removeRows(selected[0].topRow(), selected[0].rowCount());
});
hBox->addWidget(btnScheDel);
btnScheClear = new QPushButton;
btnScheClear->setMinimumSize(QSize(60, 30));
btnScheClear->setProperty("ssType", "progManageTool");
connect(btnScheClear, &QPushButton::clicked, tableSche, &Table::clearRows);
hBox->addWidget(btnScheClear);
hBox->addStretch();
btnScheImport = new QPushButton;
btnScheImport->setMinimumSize(QSize(0, 30));
btnScheImport->setProperty("ssType", "progManageTool");
connect(btnScheImport, &QPushButton::clicked, this, [this] {
auto dir = QSettings().value("CtrlScheduleDir").toString();
if(dir.isEmpty()) dir = "/";
QString scheFile = QFileDialog::getOpenFileName(this, tr("Import File"), dir, tr("Sync Schedule")+" (*.syncs)");
if(scheFile.isEmpty()) return;
QFile scheQFile(scheFile);
if(! scheQFile.open(QIODevice::ReadOnly)) return;
auto data = scheQFile.readAll();
scheQFile.close();
restoreScheduleJson(QJsonDocument::fromJson(data).object());
});
hBox->addWidget(btnScheImport);
btnScheExport = new QPushButton;
btnScheExport->setMinimumSize(QSize(0, 30));
btnScheExport->setProperty("ssType", "progManageTool");
connect(btnScheExport, &QPushButton::clicked, this, [this] {
QSettings settings;
auto dir = settings.value("CtrlScheduleDir").toString();
if(dir.isEmpty()) dir = "/";
QString scheFile = QFileDialog::getSaveFileName(this, tr("Save File"), dir, tr("Sync Schedule")+" (*.syncs)");
if(scheFile.isEmpty()) return;
settings.setValue("CtrlScheduleDir", QFileInfo(scheFile).absolutePath());
QFile scheQFile(scheFile);
if(! scheQFile.open(QIODevice::WriteOnly)) return;
scheQFile.write(QJsonDocument(getScheduleJson()).toJson());
scheQFile.close();
});
hBox->addWidget(btnScheExport);
labelSyncScheduleTip = new QLabel;
labelSyncScheduleTip->setWordWrap(true);
vBox->addWidget(labelSyncScheduleTip);
vBox->addWidget(tableSche);
hBox = new HBox(vBox);
hBox->addStretch();
btnScheSet = new QPushButton;
btnScheSet->setProperty("ssType", "progManageTool");
btnScheSet->setMinimumSize(QSize(60, 30));
connect(btnScheSet, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "SetTimingHdmiInTask");
json.insert("_type", "SetTimingHdmiInTask");
if(gSelCards->count() == 1) {
json.insert("HdmiInTask", getScheduleJson());
auto waitingDlg = new WaitingDlg(this, tr("SetTimingHdmiInTask"));
Def_CtrlReqPre;
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, *gSelCards) {
json.insert("HdmiInTask", getScheduleJson());
Def_CtrlSetMulti(tr("SetTimingHdmiInTask"))
}
}
});
hBox->addWidget(btnScheSet);
hBox->addStretch();
btnScheGet = new QPushButton;
btnScheGet->setMinimumSize(QSize(0, 30));
btnScheGet->setProperty("ssType", "progManageTool");
connect(btnScheGet, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "GetTimingHdmiInTask");
json.insert("_type", "GetTimingHdmiInTask");
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("GetTimingHdmiInTask"));
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
Def_CtrlSingleGetReply
waitingDlg->success();
restoreScheduleJson(json["creenTask"].toObject());
});
}
});
hBox->addWidget(btnScheGet);
hBox->addStretch();
}
auto m_buttonGroup = new QButtonGroup;
m_buttonGroup->addButton(fdManual, 0);
m_buttonGroup->addButton(fdSchedule, 1);
connect(m_buttonGroup,SIGNAL(buttonClicked(int)),stacked,SLOT(setCurrentIndex(int)));
fdManual->setChecked(true);
stacked->setCurrentIndex(0);
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
if(isVisible()) init();
});
transUi();
}
void CtrlHdmiPanel::showEvent(QShowEvent *event) {
QWidget::showEvent(event);
init();
}
void CtrlHdmiPanel::init() {
bool isSingle = gSelCards->count()==1;
btnScheGet->setEnabled(isSingle);
if(! isSingle) {
fdHdmi2->setVisible(true);
return;
}
auto card = gSelCards->at(0);
fdHdmi2->setVisible(card->m_strCardId.startsWith("m8s", Qt::CaseInsensitive));
QJsonObject json;
json.insert("_id", "IsSync");
json.insert("_type", "IsSync");
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) return;
auto switchOn = json["switchOn"];
if(switchOn.isUndefined()) switchOn = json["result"];
if(! switchOn.toBool()) fdAsync->setChecked(true);
else if(json["number"].toInt()==2) fdHdmi2->setChecked(true);
else fdHdmi->setChecked(true);
});
}
void CtrlHdmiPanel::changeEvent(QEvent *event) {
QWidget::changeEvent(event);
if(event->type() == QEvent::LanguageChange) transUi();
}
void CtrlHdmiPanel::transUi() {
lbHdmiCfg->setText(tr("HDMI Configuration"));
fdManual->setText(tr("Manual"));
fdSchedule->setText(tr("Schedule"));
fdAsync->setText(tr("Async"));
btnGetSync->setText(tr("Readback"));
tableSche->setHeaderText("start", tr("Start Time"));
tableSche->setHeaderText("end", tr("End Time"));
tableSche->setHeaderText("0", tr("SUN"));
tableSche->setHeaderText("1", tr("MON"));
tableSche->setHeaderText("2", tr("TUE"));
tableSche->setHeaderText("3", tr("WED"));
tableSche->setHeaderText("4", tr("THU"));
tableSche->setHeaderText("5", tr("FRI"));
tableSche->setHeaderText("6", tr("SAT"));
btnScheAdd->setText(tr("Add"));
btnScheSet->setText(tr("Apply"));
btnScheClear->setText(tr("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"));
}
void CtrlHdmiPanel::restoreScheduleJson(QJsonObject oTaskSync) {
tableSche->setRowCount(0);
auto oSchedules = oTaskSync["schedules"].toArray();
foreach(auto oSchedule, oSchedules) {
int row = tableSche->rowCount();
tableSche->insertRow(row);
auto timeEdit = new QTimeEdit(QTime::fromString(oSchedule["startTime"].toString()+":00"));
timeEdit->setDisplayFormat("HH:mm");
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "start", timeEdit);
timeEdit = new QTimeEdit(QTime::fromString(oSchedule["endTime"].toString()+":00"));
timeEdit->setDisplayFormat("HH:mm");
timeEdit->setAlignment(Qt::AlignCenter);
tableSche->setCellWidget(row, "end", timeEdit);
if(oSchedule["filterType"].toString()=="None") for(int i=0; i<7; i++) {
auto fd = new QCheckBox;
fd->setChecked(true);
tableSche->setCellWidget(row, QString::number(i), fd);
} else if(oSchedule["filterType"].toString()=="Week") {
auto weekFilter = oSchedule["weekFilter"].toArray();
for(int i=0; i<7; i++) {
auto fd = new QCheckBox;
if(weekFilter.contains(i)) fd->setChecked(true);
tableSche->setCellWidget(row, QString::number(i), fd);
}
}
}
}
QJsonObject CtrlHdmiPanel::getScheduleJson() {
QJsonArray schedules;
for(int i=0; i<tableSche->rowCount(); i++) {
QJsonObject schedule;
schedule["timeType"] = "Range";
schedule["startTime"] = static_cast<QTimeEdit*>(tableSche->cellWidget(i, "start"))->text();
schedule["endTime"] = static_cast<QTimeEdit*>(tableSche->cellWidget(i, "end"))->text();
schedule["dateType"] = "All";
schedule["monthFilter"] = QJsonArray();
QJsonArray weekFilter;
for(int d=0; d<7; d++) if(static_cast<QCheckBox*>(tableSche->cellWidget(i, QString::number(d)))->isChecked()) weekFilter.append(d);
if(weekFilter.size()>=7) {
schedule["filterType"] = "None";
weekFilter = QJsonArray();
} else schedule["filterType"] = "Week";
schedule["weekFilter"] = weekFilter;
schedules.append(schedule);
}
return QJsonObject{
{"createBy", "alahover"},
{"name", "TimingScreen"},
{"schedules", schedules}
};
}

View File

@ -0,0 +1,38 @@
#ifndef CTRLHDMIPANEL_H
#define CTRLHDMIPANEL_H
#include "base/switchcontrol.h"
#include "gutil/qgui.h"
#include <QLabel>
#include <QRadioButton>
#include <QPushButton>
class CtrlHdmiPanel : public QWidget {
Q_OBJECT
public:
explicit CtrlHdmiPanel(QWidget *parent = nullptr);
void restoreScheduleJson(QJsonObject oTaskSync);
QJsonObject getScheduleJson();
protected:
void showEvent(QShowEvent *event) override;
void init();
void changeEvent(QEvent *) override;
void transUi();
private:
QLabel *lbHdmiCfg;
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
QPushButton *btnGetSync;
Table *tableSche;
QPushButton *btnScheAdd;
QPushButton *btnScheDel;
QPushButton *btnScheClear;
QPushButton *btnScheImport;
QPushButton *btnScheExport;
QLabel *labelSyncScheduleTip;
QPushButton *btnScheSet;
QPushButton *btnScheGet;
};
#endif // CTRLHDMIPANEL_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,88 @@
#ifndef CTRLNETWORKPANEL_H
#define CTRLNETWORKPANEL_H
#include <device/ledcard.h>
#include <communication/hpptclient.h>
#include <base/loemptydialog.h>
#include "base/qiplineedit.h"
#include "base/switchcontrol.h"
#include <QButtonGroup>
#include <QJsonObject>
#include <QRadioButton>
#include <QGroupBox>
#include <QCheckBox>
struct ApnInfo {
QString apn;
QString carrier;
QString mcc;
QString mmsc;
QString mmsport;
QString mmsproxy;
QString mnc;
QString password;
QString port;
QString proxy;
QString server;
QString type;
QString user;
};
class CtrlNetworkPanel : public QWidget {
Q_OBJECT
public:
explicit CtrlNetworkPanel(QWidget *parent = nullptr);
void getCurrentAPN(QString &);
protected:
void showEvent(QShowEvent *event) override;
void init();
void changeEvent(QEvent *) override;
void transUi();
private:
QLabel *lbLanCfg;
QRadioButton *fdDhcp, *fdSpecifyIp;
QGroupBox *gBoxSpecifyIp;
QLabel *labelIpAddress;
QIPLineEdit *fdIP;
QLabel *labelMaskAddress;
QIPLineEdit *fdGateWay;
QLabel *labelGateway;
QIPLineEdit *fdMask;
QLabel *labelDnsAddress;
QIPLineEdit *fdDns;
QPushButton *btnLanSet;
QPushButton *btnLanGet;
QLabel *label_5;
QLabel *lbWifiName;
QLabel *lbWifiPassword;
QRadioButton *fdIsWifi, *fdIsHotspot;
QComboBox *fdWifiName;
QLineEdit *fdWifiPassword;
QPushButton *btnScan;
QPushButton *btnWiFiSet;
QPushButton *btnWiFiGet;
QLabel *lbHotspotName;
QLabel *lbHotspotPassword;
QLineEdit *fdHotspotName;
QLineEdit *fdHotspotPassword;
QFrame *line_3;
QLabel *lbCellularConfig;
QCheckBox *fdEnableCellular;
QPushButton *btnSIMStatusGet;
QGroupBox *groupApn;
QLabel *lbCheckStatusTip;
QLabel *label_2;
QComboBox *fdMcc;
QLabel *label_3;
QComboBox *fdCarrierName;
QPushButton *btnAPNCusSet, *btnAPNCusGet;
QLabel *label_10;
SwitchControl *fdFightModel;
QPushButton *btnFlightModelGet;
QLabel *lbCus_Name, *lbCus_User, *lbCus_pwd, *lbCus_mmsPort, *lbCus_mmsProxy, *lbCus_port, *lbCus_proxy, *lbCus_server, *lbCus_type;
QLineEdit *fdCus_apn, *fdCus_Name, *fdCus_User, *fdCus_pwd, *fdCus_type, *fdCus_server, *fdCus_port, *fdCus_proxy, *fdCus_mmsc, *fdCus_mmsPort, *fdCus_mmsProxy;
};
#endif // CTRLNETWORKPANEL_H

View File

@ -0,0 +1,253 @@
#include "ctrlpwdpanel.h"
#include "gutil/qgui.h"
#include "base/waitingdlg.h"
#include "QFileDialog"
#include <QMessageBox>
#include <QJsonObject>
#include <globaldefine.h>
#include "tools.h"
CtrlPwdPanel::CtrlPwdPanel(QWidget *parent) : QWidget(parent) {
auto vBox = new VBox(this);
lbPwdConfig = new QLabel;
lbPwdConfig->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbPwdConfig);
vBox->addSpacing(20);
auto grid = new Grid(vBox);
grid->setColumnStretch(0, 1);
grid->setColumnStretch(3, 1);
lbOldPwd = new QLabel;
grid->addWidget(lbOldPwd, 0, 1);
lbNewPwd = new QLabel;
grid->addWidget(lbNewPwd, 1, 1);
lbPwdAgain = new QLabel;
grid->addWidget(lbPwdAgain, 2, 1);
fdOldPwd = new QLineEdit;
fdOldPwd->setFixedSize(160, 30);
fdOldPwd->setEchoMode(QLineEdit::PasswordEchoOnEdit);
grid->addWidget(fdOldPwd, 0, 2);
fdNewPwd = new QLineEdit;
fdNewPwd->setFixedSize(160, 30);
fdNewPwd->setEchoMode(QLineEdit::PasswordEchoOnEdit);
grid->addWidget(fdNewPwd, 1, 2);
fdPwdAgain = new QLineEdit;
fdPwdAgain->setFixedSize(160, 30);
fdPwdAgain->setEchoMode(QLineEdit::PasswordEchoOnEdit);
grid->addWidget(fdPwdAgain, 2, 2);
vBox->addSpacing(20);
auto hBox = new HBox(vBox);
hBox->addStretch();
btnPwdSet = new QPushButton;
btnPwdSet->setMinimumSize(60, 30);
btnPwdSet->setProperty("ssType", "progManageTool");
connect(btnPwdSet, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("InputOriginalPasswordTip"));
return;
}
if(fdNewPwd->text().isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("InputNewPasswordTip"));
return;
}
if(fdPwdAgain->text().isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("InputRepeatPasswordTip"));
return;
}
if(fdNewPwd->text() != fdPwdAgain->text()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("InputRepeatPasswordNotSameTip"));
return;
}
auto res = QMessageBox::information(gMainWin, 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);
if(res != QMessageBox::Ok) return;
QJsonObject json;
json.insert("_id", "SetControllerPassword");
json.insert("_type", "SetControllerPassword");
json.insert("pwd", fdOldPwd->text());
json.insert("newPwd", fdNewPwd->text());
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, card, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
if(json["result"].toInt()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Tip"), tr("OriginalPasswordErrorTip"));
return;
}
waitingDlg->success();
lbOldPwd->show();
fdOldPwd->show();
btnPwdClear->show();
btnPwdSet->setText(tr("Modify password"));
card->bPassword = true;
fdNewPwd->clear();
fdPwdAgain->clear();
fdOldPwd->clear();
});
} else {
foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, card, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) {
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
else {
err = tr("Success");
lbOldPwd->show();
fdOldPwd->show();
btnPwdClear->show();
btnPwdSet->setText(tr("Modify password"));
card->bPassword = true;
}
}
gFdResInfo->append(card->m_strCardId+" "+tr("SetControllerPassword")+" "+err);
});
}
}
});
hBox->addWidget(btnPwdSet);
btnPwdClear = new QPushButton;
btnPwdClear->setMinimumSize(60, 30);
btnPwdClear->setProperty("ssType", "progManageTool");
connect(btnPwdClear, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
if(fdOldPwd->isVisible() && fdOldPwd->text().isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("InputOriginalPasswordTip"));
return;
}
QJsonObject json;
json.insert("_id", "SetControllerPassword");
json.insert("_type", "SetControllerPassword");
json.insert("pwd", fdOldPwd->text());
json.insert("newPwd","");
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("SetControllerPassword")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, card, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
if(json["result"].toInt()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Tip"), tr("OriginalPasswordErrorTip"));
return;
}
waitingDlg->success();
lbOldPwd->hide();
fdOldPwd->hide();
btnPwdClear->hide();
btnPwdSet->setText(tr("Set encryption"));
card->bPassword = false;
fdNewPwd->clear();
fdPwdAgain->clear();
fdOldPwd->clear();
});
} else {
foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, card, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) {
if(json["result"].toInt()) err = tr("OriginalPasswordErrorTip");
else {
err = tr("Success");
lbOldPwd->hide();
fdOldPwd->hide();
btnPwdClear->hide();
btnPwdSet->setText(tr("Set encryption"));
card->bPassword = false;
}
}
gFdResInfo->append(card->m_strCardId+" "+tr("SetControllerPassword")+" "+err);
});
}
}
});
hBox->addWidget(btnPwdClear);
hBox->addStretch();
vBox->addStretch();
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
if(isVisible()) init();
});
transUi();
}
void CtrlPwdPanel::showEvent(QShowEvent *event) {
QWidget::showEvent(event);
init();
}
void CtrlPwdPanel::init() {
bool isSingle = gSelCards->count()==1;
if(! isSingle) return;
auto card = gSelCards->at(0);
QJsonObject json;
json.insert("_id", "HasControllerPassword");
json.insert("_type", "HasControllerPassword");
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, card, [=] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) return;
if(json["result"].toBool()) {
lbOldPwd->show();
fdOldPwd->show();
btnPwdClear->show();
btnPwdSet->setText(tr("Modify password"));
card->bPassword = true;
} else {
lbOldPwd->hide();
fdOldPwd->hide();
btnPwdClear->hide();
btnPwdSet->setText(tr("Set encryption"));
card->bPassword = false;
}
});
}
void CtrlPwdPanel::changeEvent(QEvent *event) {
QWidget::changeEvent(event);
if(event->type() == QEvent::LanguageChange) transUi();
}
void CtrlPwdPanel::transUi() {
lbPwdConfig->setText(tr("Set Password"));
lbOldPwd->setText(tr("Original password"));
lbNewPwd->setText(tr("New password"));
lbPwdAgain->setText(tr("Enter again"));
fdOldPwd->setPlaceholderText(tr("original password"));
fdNewPwd->setPlaceholderText(tr("New password"));
fdPwdAgain->setPlaceholderText(tr("Repeat new password"));
btnPwdSet->setText(tr("Set encryption"));
btnPwdClear->setText(tr("Cancel encryption"));
}

View File

@ -0,0 +1,30 @@
#ifndef CTRLPWDPANEL_H
#define CTRLPWDPANEL_H
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
class CtrlPwdPanel : public QWidget {
Q_OBJECT
public:
explicit CtrlPwdPanel(QWidget *parent = nullptr);
protected:
void showEvent(QShowEvent *event) override;
void init();
void changeEvent(QEvent *) override;
void transUi();
private:
QLabel *lbPwdConfig;
QLabel *lbOldPwd;
QLabel *lbNewPwd;
QLabel *lbPwdAgain;
QLineEdit *fdOldPwd;
QLineEdit *fdNewPwd;
QLineEdit *fdPwdAgain;
QPushButton *btnPwdSet;
QPushButton *btnPwdClear;
};
#endif // CTRLPWDPANEL_H

View File

@ -1,7 +1,7 @@
#include "ctrlverifyclockpanel.h" #include "ctrlverifyclockpanel.h"
#include "base/waitingdlg.h" #include "base/waitingdlg.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "gqt.h" #include "gutil/qgui.h"
#include "tools.h" #include "tools.h"
#include <QMessageBox> #include <QMessageBox>
#include <QLineEdit> #include <QLineEdit>
@ -10,7 +10,6 @@
CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) { CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
auto vBox = new VBox(this); auto vBox = new VBox(this);
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->setContentsMargins(-1, 0, -1, -1);
label = new QLabel; label = new QLabel;
hBox->addWidget(label); hBox->addWidget(label);
@ -130,10 +129,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
lbLang = new QLabel; lbLang = new QLabel;
hBox->addWidget(lbLang); hBox->addWidget(lbLang);
fdIsEn = new QRadioButton; fdIsEn = new QRadioButton("English");
hBox->addWidget(fdIsEn); hBox->addWidget(fdIsEn);
fdIsCn = new QRadioButton; fdIsCn = new QRadioButton("中文");
hBox->addWidget(fdIsCn); hBox->addWidget(fdIsCn);
btnLangSet = new QPushButton; btnLangSet = new QPushButton;
@ -181,11 +180,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = json["language"].toInt()==1 ? "中文" : "英文"; if(err.isEmpty()) err = json["language"].toInt()==1 ? "中文" : "英文";
gFdResInfo->append(card->m_strCardId+" 获取语言 "+err); gFdResInfo->append(cardId+" 获取语言 "+err);
}); });
} }
} }
@ -258,11 +258,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = json["date"].toString(); if(err.isEmpty()) err = json["date"].toString();
gFdResInfo->append(card->m_strCardId+" "+tr("GetControllerDate")+" "+err); gFdResInfo->append(cardId+" "+tr("GetControllerDate")+" "+err);
}); });
} }
} }
@ -301,8 +302,6 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
lineEdit_3 = new QLineEdit(groupBox); lineEdit_3 = new QLineEdit(groupBox);
lineEdit_3->setMinimumSize(QSize(160, 30)); lineEdit_3->setMinimumSize(QSize(160, 30));
lineEdit_3->setMaximumSize(QSize(160, 16777215)); lineEdit_3->setMaximumSize(QSize(160, 16777215));
lineEdit_3->setStyleSheet(QString::fromUtf8("background-color: #FFFFFF;"));
horizontalLayout_5->addWidget(lineEdit_3); horizontalLayout_5->addWidget(lineEdit_3);
labelmintime = new QLabel(groupBox); labelmintime = new QLabel(groupBox);
@ -360,9 +359,9 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
horizontalLayout_7 = new QHBoxLayout(); horizontalLayout_7 = new QHBoxLayout();
horizontalLayout_7->setContentsMargins(-1, 0, -1, -1); horizontalLayout_7->setContentsMargins(-1, 0, -1, -1);
pushButtonSetSync = new QPushButton(groupBox); btnSyncSet = new QPushButton(groupBox);
pushButtonSetSync->setMinimumSize(QSize(60, 30)); btnSyncSet->setMinimumSize(QSize(60, 30));
connect(pushButtonSetSync, &QPushButton::clicked, this, [this] { connect(btnSyncSet, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) { if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController")); QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return; return;
@ -394,7 +393,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
} }
} }
}); });
horizontalLayout_7->addWidget(pushButtonSetSync); horizontalLayout_7->addWidget(btnSyncSet);
fdSyncGet = new QPushButton; fdSyncGet = new QPushButton;
fdSyncGet->setMinimumSize(QSize(60, 30)); fdSyncGet->setMinimumSize(QSize(60, 30));
@ -417,7 +416,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json; QJsonDocument json;
QByteArray data; QByteArray data;
QString err = checkReplyForJson(reply, &json, &data); QString err = checkReplyForJson(reply, &json, &data);
@ -448,7 +448,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
err = time+"\n "+data; err = time+"\n "+data;
} }
} }
gFdResInfo->append(card->m_strCardId+" "+tr("GetingSyncMethod")+" "+err); gFdResInfo->append(cardId+" "+tr("GetingSyncMethod")+" "+err);
}); });
} }
} }
@ -463,18 +463,18 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
horizontalLayout_11 = new QHBoxLayout(groupBox_4); horizontalLayout_11 = new QHBoxLayout(groupBox_4);
horizontalLayout_11->setSpacing(6); horizontalLayout_11->setSpacing(6);
horizontalLayout_11->setContentsMargins(0, 0, 0, 0); horizontalLayout_11->setContentsMargins(0, 0, 0, 0);
radioButton_4 = new QRadioButton(groupBox_4); fdMaster = new QRadioButton(groupBox_4);
buttonGroup_2 = new QButtonGroup(this); buttonGroup_2 = new QButtonGroup(this);
buttonGroup_2->addButton(radioButton_4); buttonGroup_2->addButton(fdMaster);
radioButton_4->setChecked(true); fdMaster->setChecked(true);
horizontalLayout_11->addWidget(radioButton_4, 0, Qt::AlignHCenter); horizontalLayout_11->addWidget(fdMaster, 0, Qt::AlignHCenter);
radioButton_5 = new QRadioButton(groupBox_4); fdSlave = new QRadioButton(groupBox_4);
buttonGroup_2->addButton(radioButton_5); buttonGroup_2->addButton(fdSlave);
horizontalLayout_11->addWidget(radioButton_5, 0, Qt::AlignHCenter); horizontalLayout_11->addWidget(fdSlave, 0, Qt::AlignHCenter);
vvv->addWidget(groupBox_4); vvv->addWidget(groupBox_4);
@ -528,17 +528,18 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
bool isMaster = json["result"].toBool(); bool isMaster = json["result"].toBool();
radioButton_4->setChecked(isMaster); fdMaster->setChecked(isMaster);
radioButton_5->setChecked(! isMaster); fdSlave->setChecked(! isMaster);
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = json["result"].toBool() ? tr("Master") : tr("Slave"); if(err.isEmpty()) err = json["result"].toBool() ? tr("Master") : tr("Slave");
gFdResInfo->append(card->m_strCardId+" "+tr("Lora identity")+" "+err); gFdResInfo->append(cardId+" "+tr("Lora identity")+" "+err);
}); });
} }
} }
@ -614,11 +615,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, card] { auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = json["ntpServer"].toString(); if(err.isEmpty()) err = json["ntpServer"].toString();
gFdResInfo->append(card->m_strCardId+" "+tr("GetNtpServer")+" "+err); gFdResInfo->append(cardId+" "+tr("GetNtpServer")+" "+err);
}); });
} }
} }
@ -632,31 +634,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
vBox->addStretch(); vBox->addStretch();
label->setText(tr("TimeZone"));
lbLang->setText(tr("Language:"));
fdIsEn->setText(tr("English"));
fdIsCn->setText(tr("\344\270\255\346\226\207"));
labelVerifyClockConfiguration->setText(tr("Verify Clock Configuration"));
groupBox_5->setTitle(tr("Cur time of controller"));
groupBox->setTitle(tr("Enable Synchronous playing"));
fdIsLan->setText(tr("LAN"));
labelSyncTimeInterval->setText(tr("Sync time interval"));
lineEdit_3->setPlaceholderText(tr("Sync time interval"));
labelmintime->setText(tr("(min/time)"));
labelIdCode->setText(tr("Sync identificationCode"));
lineEditIdCode->setPlaceholderText(tr("identification code"));
labelTimeOffset->setText(tr("Time offset(msec)"));
checkBoxBrightness->setText(tr("Brightness"));
checkBoxVolume->setText(tr("Volume"));
checkBoxScreenSwitch->setText(tr("Screen on/off"));
radioButton_4->setText(tr("Slave"));
radioButton_5->setText(tr("Master "));
groupNTP->setTitle(tr("NTP Server"));
labelNtpServerAddress->setText(tr("NTP Server address"));
fdNtpServer->setPlaceholderText(tr("NTP Server address"));
btnNtpSet->setProperty("ssType", "progManageTool"); btnNtpSet->setProperty("ssType", "progManageTool");
pushButtonSetSync->setProperty("ssType", "progManageTool"); btnSyncSet->setProperty("ssType", "progManageTool");
btnSyncTime->setProperty("ssType", "progManageTool"); btnSyncTime->setProperty("ssType", "progManageTool");
fdSyncGet->setProperty("ssType", "progManageTool"); fdSyncGet->setProperty("ssType", "progManageTool");
btnNtpGet->setProperty("ssType", "progManageTool"); btnNtpGet->setProperty("ssType", "progManageTool");
@ -665,8 +644,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
btnLoraMasterGet->setProperty("ssType", "progManageTool"); btnLoraMasterGet->setProperty("ssType", "progManageTool");
btnDateGet->setProperty("ssType", "progManageTool"); btnDateGet->setProperty("ssType", "progManageTool");
fdTimeZoneSet->setProperty("ssType", "progManageTool"); fdTimeZoneSet->setProperty("ssType", "progManageTool");
buttonGroup_2->setId(radioButton_4, 0); buttonGroup_2->setId(fdMaster, 0);
buttonGroup_2->setId(radioButton_5, 1); buttonGroup_2->setId(fdSlave, 1);
fdIsLora->setChecked(true); fdIsLora->setChecked(true);
labelIdCode->setVisible(true); labelIdCode->setVisible(true);
@ -683,8 +662,6 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
connect(fdIsNTP,SIGNAL(clicked()),this,SLOT(OnRadioButton3())); connect(fdIsNTP,SIGNAL(clicked()),this,SLOT(OnRadioButton3()));
connect(fdIsLan,SIGNAL(clicked()),this,SLOT(OnRadioButton6())); connect(fdIsLan,SIGNAL(clicked()),this,SLOT(OnRadioButton6()));
//MARCO_DEFINE_CONTROL_FUNC2(parent->parent(),parent)
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] { connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
if(isVisible()) init(); if(isVisible()) init();
}); });
@ -707,10 +684,7 @@ void CtrlVerifyClockPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply] { connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
dealGetSync(json); dealGetSync(json);
}); });
@ -721,10 +695,7 @@ void CtrlVerifyClockPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply] { connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
fdTimezone->setCurrentText(json["timezone"].toString()); fdTimezone->setCurrentText(json["timezone"].toString());
}); });
@ -735,10 +706,7 @@ void CtrlVerifyClockPanel::init() {
connect(reply, &QNetworkReply::finished, this, [this, reply] { connect(reply, &QNetworkReply::finished, this, [this, reply] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
if(json["language"].toInt()==1) fdIsCn->setChecked(true); if(json["language"].toInt()==1) fdIsCn->setChecked(true);
else fdIsEn->setChecked(true); else fdIsEn->setChecked(true);
}); });
@ -748,37 +716,37 @@ void CtrlVerifyClockPanel::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi(); if(event->type() == QEvent::LanguageChange) transUi();
} }
void CtrlVerifyClockPanel::transUi() { void CtrlVerifyClockPanel::transUi() {
labelNtpServerAddress->setText(tr("NTP Server address"));
labelTimeOffset->setText(tr("Time offset(msec)"));
labelVerifyClockConfiguration->setText(tr("Verify clock configuration"));
lbLang->setText(tr("Language:"));
btnNtpSet->setText(tr("Set"));
pushButtonSetSync->setText(tr("Set"));
btnLangSet->setText(tr("Set"));
btnSyncTime->setText(tr("Verify to Computer time"));
fdTimeZoneSet->setText(tr("Set"));
btnLoraMasterSet->setText(tr("Set"));
btnLangGet->setText(tr("Readback"));
btnLoraMasterGet->setText(tr("Readback"));
btnNtpGet->setText(tr("Readback"));
fdSyncGet->setText(tr("Readback"));
btnDateGet->setText(tr("Readback")); btnDateGet->setText(tr("Readback"));
groupNTP->setTitle(tr("NTP Server")); btnLangGet->setText(tr("Readback"));
groupBox->setTitle(tr("Enable Synchronous playing")); btnLangSet->setText(tr("Set"));
radioButton_4->setText(tr("Master")); btnLoraMasterGet->setText(tr("Readback"));
radioButton_5->setText(tr("Slave")); btnLoraMasterSet->setText(tr("Set"));
labelSyncTimeInterval->setText(tr("Sync time interval")); btnNtpGet->setText(tr("Readback"));
labelIdCode->setText(tr("Identification Code")); btnNtpSet->setText(tr("Set"));
btnSyncTime->setText(tr("Verify to Computer time"));
checkBoxBrightness->setText(tr("Brightness")); checkBoxBrightness->setText(tr("Brightness"));
checkBoxVolume->setText(tr("Volume"));
checkBoxScreenSwitch->setText(tr("Screen on/off")); checkBoxScreenSwitch->setText(tr("Screen on/off"));
checkBoxVolume->setText(tr("Volume"));
groupBox_5->setTitle(tr("Cur time of controller")); fdIsLan->setText(tr("LAN"));
fdNtpServer->setPlaceholderText(tr("NTP Server address")); fdNtpServer->setPlaceholderText(tr("NTP Server address"));
lineEdit_3->setPlaceholderText(tr("Sync time interval")); fdSyncGet->setText(tr("Readback"));
lineEditIdCode->setPlaceholderText(tr("identification code")); fdTimeZoneSet->setText(tr("Set"));
groupBox->setTitle(tr("Enable Synchronous playing"));
groupBox_5->setTitle(tr("Cur time of controller"));
groupNTP->setTitle(tr("NTP Server"));
label->setText(tr("TimeZone")); label->setText(tr("TimeZone"));
labelIdCode->setText(tr("Identification Code"));
labelNtpServerAddress->setText(tr("NTP Server address"));
labelSyncTimeInterval->setText(tr("Sync time interval"));
labelTimeOffset->setText(tr("Time offset(msec)"));
labelVerifyClockConfiguration->setText(tr("Verify Clock Configuration"));
labelmintime->setText(tr("(min/time)"));
lbLang->setText(tr("Language:"));
lineEditIdCode->setPlaceholderText(tr("identification code"));
lineEdit_3->setPlaceholderText(tr("Sync time interval"));
btnSyncSet->setText(tr("Set"));
fdMaster->setText(tr("Master"));
fdSlave->setText(tr("Slave"));
} }
void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) { void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
QString strType = json["time"].toString().toLower(); QString strType = json["time"].toString().toLower();
@ -800,7 +768,7 @@ void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
checkBoxScreenSwitch->setVisible(true); checkBoxScreenSwitch->setVisible(true);
checkBoxVolume->setVisible(true); checkBoxVolume->setVisible(true);
checkBoxBrightness->setVisible(true); checkBoxBrightness->setVisible(true);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} else if(strType=="ntp") { } else if(strType=="ntp") {
fdIsNTP->setChecked(true); fdIsNTP->setChecked(true);
@ -813,14 +781,14 @@ void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
labelSyncTimeInterval->setVisible(true); labelSyncTimeInterval->setVisible(true);
labelmintime->setVisible(true); labelmintime->setVisible(true);
groupBox_4->setVisible(false); groupBox_4->setVisible(false);
radioButton_4->setVisible(false); fdMaster->setVisible(false);
radioButton_5->setVisible(false); fdSlave->setVisible(false);
btnLoraMasterSet->setVisible(false); btnLoraMasterSet->setVisible(false);
btnLoraMasterGet->setVisible(false); btnLoraMasterGet->setVisible(false);
checkBoxScreenSwitch->setVisible(false); checkBoxScreenSwitch->setVisible(false);
checkBoxVolume->setVisible(false); checkBoxVolume->setVisible(false);
checkBoxBrightness->setVisible(false); checkBoxBrightness->setVisible(false);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} else if(strType=="gps") { } else if(strType=="gps") {
fdIsGPS->setChecked(true); fdIsGPS->setChecked(true);
@ -832,14 +800,14 @@ void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
lineEdit_3->setVisible(false); lineEdit_3->setVisible(false);
labelmintime->setVisible(false); labelmintime->setVisible(false);
groupBox_4->setVisible(false); groupBox_4->setVisible(false);
radioButton_4->setVisible(false); fdMaster->setVisible(false);
radioButton_5->setVisible(false); fdSlave->setVisible(false);
btnLoraMasterSet->setVisible(false); btnLoraMasterSet->setVisible(false);
btnLoraMasterGet->setVisible(false); btnLoraMasterGet->setVisible(false);
checkBoxScreenSwitch->setVisible(false); checkBoxScreenSwitch->setVisible(false);
checkBoxVolume->setVisible(false); checkBoxVolume->setVisible(false);
checkBoxBrightness->setVisible(false); checkBoxBrightness->setVisible(false);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} }
} }
@ -853,14 +821,14 @@ void CtrlVerifyClockPanel::OnRadioButton()//gps
lineEdit_3->setVisible(false); lineEdit_3->setVisible(false);
labelmintime->setVisible(false); labelmintime->setVisible(false);
groupBox_4->setVisible(false); groupBox_4->setVisible(false);
radioButton_4->setVisible(false); fdMaster->setVisible(false);
radioButton_5->setVisible(false); fdSlave->setVisible(false);
btnLoraMasterSet->setVisible(false); btnLoraMasterSet->setVisible(false);
btnLoraMasterGet->setVisible(false); btnLoraMasterGet->setVisible(false);
checkBoxScreenSwitch->setVisible(false); checkBoxScreenSwitch->setVisible(false);
checkBoxVolume->setVisible(false); checkBoxVolume->setVisible(false);
checkBoxBrightness->setVisible(false); checkBoxBrightness->setVisible(false);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} }
void CtrlVerifyClockPanel::OnRadioButton2()//lora void CtrlVerifyClockPanel::OnRadioButton2()//lora
@ -873,14 +841,14 @@ void CtrlVerifyClockPanel::OnRadioButton2()//lora
labelSyncTimeInterval->setVisible(false); labelSyncTimeInterval->setVisible(false);
labelmintime->setVisible(false); labelmintime->setVisible(false);
groupBox_4->setVisible(true); groupBox_4->setVisible(true);
radioButton_4->setVisible(true); fdMaster->setVisible(true);
radioButton_5->setVisible(true); fdSlave->setVisible(true);
btnLoraMasterSet->setVisible(true); btnLoraMasterSet->setVisible(true);
btnLoraMasterGet->setVisible(true); btnLoraMasterGet->setVisible(true);
checkBoxScreenSwitch->setVisible(true); checkBoxScreenSwitch->setVisible(true);
checkBoxVolume->setVisible(true); checkBoxVolume->setVisible(true);
checkBoxBrightness->setVisible(true); checkBoxBrightness->setVisible(true);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} }
@ -894,14 +862,14 @@ void CtrlVerifyClockPanel::OnRadioButton3()//ntp
labelSyncTimeInterval->setVisible(true); labelSyncTimeInterval->setVisible(true);
labelmintime->setVisible(true); labelmintime->setVisible(true);
groupBox_4->setVisible(false); groupBox_4->setVisible(false);
radioButton_4->setVisible(false); fdMaster->setVisible(false);
radioButton_5->setVisible(false); fdSlave->setVisible(false);
btnLoraMasterSet->setVisible(false); btnLoraMasterSet->setVisible(false);
btnLoraMasterGet->setVisible(false); btnLoraMasterGet->setVisible(false);
checkBoxScreenSwitch->setVisible(false); checkBoxScreenSwitch->setVisible(false);
checkBoxVolume->setVisible(false); checkBoxVolume->setVisible(false);
checkBoxBrightness->setVisible(false); checkBoxBrightness->setVisible(false);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} }
void CtrlVerifyClockPanel::OnRadioButton6() { void CtrlVerifyClockPanel::OnRadioButton6() {
@ -913,13 +881,13 @@ void CtrlVerifyClockPanel::OnRadioButton6() {
labelSyncTimeInterval->setVisible(false); labelSyncTimeInterval->setVisible(false);
labelmintime->setVisible(false); labelmintime->setVisible(false);
groupBox_4->setVisible(true); groupBox_4->setVisible(true);
radioButton_4->setVisible(true); fdMaster->setVisible(true);
radioButton_5->setVisible(true); fdSlave->setVisible(true);
btnLoraMasterSet->setVisible(true); btnLoraMasterSet->setVisible(true);
btnLoraMasterGet->setVisible(true); btnLoraMasterGet->setVisible(true);
checkBoxScreenSwitch->setVisible(true); checkBoxScreenSwitch->setVisible(true);
checkBoxVolume->setVisible(true); checkBoxVolume->setVisible(true);
checkBoxBrightness->setVisible(true); checkBoxBrightness->setVisible(true);
pushButtonSetSync->setVisible(true); btnSyncSet->setVisible(true);
fdSyncGet->setVisible(true); fdSyncGet->setVisible(true);
} }

View File

@ -59,12 +59,12 @@ private:
QCheckBox *checkBoxVolume; QCheckBox *checkBoxVolume;
QCheckBox *checkBoxScreenSwitch; QCheckBox *checkBoxScreenSwitch;
QHBoxLayout *horizontalLayout_7; QHBoxLayout *horizontalLayout_7;
QPushButton *pushButtonSetSync; QPushButton *btnSyncSet;
QPushButton *fdSyncGet; QPushButton *fdSyncGet;
QGroupBox *groupBox_4; QGroupBox *groupBox_4;
QHBoxLayout *horizontalLayout_11; QHBoxLayout *horizontalLayout_11;
QRadioButton *radioButton_4; QRadioButton *fdMaster;
QRadioButton *radioButton_5; QRadioButton *fdSlave;
QHBoxLayout *horizontalLayout_12; QHBoxLayout *horizontalLayout_12;
QPushButton *btnLoraMasterSet; QPushButton *btnLoraMasterSet;
QPushButton *btnLoraMasterGet; QPushButton *btnLoraMasterGet;

View File

@ -2,7 +2,7 @@
#define LEDCARD_H #define LEDCARD_H
#include <QObject> #include <QObject>
#include <QDebug>
class LedCard : public QObject { class LedCard : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString strCardId MEMBER m_strCardId NOTIFY CardIdChanged) Q_PROPERTY(QString strCardId MEMBER m_strCardId NOTIFY CardIdChanged)
@ -13,6 +13,9 @@ class LedCard : public QObject {
public: public:
LedCard(QObject *p = nullptr); LedCard(QObject *p = nullptr);
~LedCard(){
qDebug()<<"~~~~LedCard";
}
signals: signals:
void CardIdChanged(const QString &); void CardIdChanged(const QString &);
void CardIpChanged(const QString &); void CardIpChanged(const QString &);
@ -31,8 +34,7 @@ public:
QString androidVersion = ""; QString androidVersion = "";
int iHttpGetId = 0; int iHttpGetId = 0;
int androidHeight = 0; int androidHeight = 0;
//int iCardSystemVersion = 0; int bright{100};
int brightness = 255;
int androidWidth = 0; int androidWidth = 0;
int lastActive = 0; int lastActive = 0;
QString strIMEI=""; QString strIMEI="";

View File

@ -0,0 +1,647 @@
#include "upgradeapkdialog.h"
#include "gutil/qcore.h"
#include "gutil/qgui.h"
#include "gutil/qnetwork.h"
#include "base/waitingdlg.h"
#include "tools.h"
#include <QAction>
#include <QFileDialog>
#include <QLineEdit>
#include <QMessageBox>
#include <QHeaderView>
#include <QKeyEvent>
#include <QJsonArray>
#include <QHttpMultiPart>
UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
resize(1280, 720);
setWindowFlag(Qt::WindowMaximizeButtonHint);
setWindowState(Qt::WindowMaximized);
setWindowTitle(tr("Update APK"));
auto vBox = new VBox(this);
auto hBox = new HBox(vBox);
auto btnSelectOnlineApk = new QPushButton(tr("Select Online APK"));
btnSelectOnlineApk->setMinimumSize(QSize(100, 30));
btnSelectOnlineApk->setProperty("ssType", "progManageTool");
hBox->addWidget(btnSelectOnlineApk);
auto btnSelectApk = new QPushButton(tr("Select apk"));
btnSelectApk->setMinimumSize(QSize(100, 30));
btnSelectApk->setProperty("ssType", "progManageTool");
hBox->addWidget(btnSelectApk);
auto btnSelectFpga = new QPushButton(tr("Select Fpga"));
btnSelectFpga->setMinimumSize(QSize(100, 30));
btnSelectFpga->setProperty("ssType", "progManageTool");
hBox->addWidget(btnSelectFpga);
auto fdFileName = new QLabel;
fdFileName->setMinimumSize(200, 30);
fdFileName->setStyleSheet("background-color: #fff;");
hBox->addWidget(fdFileName);
connect(btnSelectApk, &QPushButton::clicked, this, [=] {
filePath = QFileDialog::getOpenFileName(this, "Open file", QString(), "apk package (*.apk *.zip)");
if(filePath.isEmpty()) return;
fileId = "";
fdFileName->setText(QFileInfo(filePath).fileName());
});
connect(btnSelectFpga, &QPushButton::clicked, this, [=] {
filePath = QFileDialog::getOpenFileName(this, "Open File", QString(), "rpd package (*.rpd)");
if(filePath.isEmpty()) return;
fileId = "";
fdFileName->setText(QFileInfo(filePath).fileName());
});
connect(btnSelectOnlineApk, &QPushButton::clicked, this, [=] {
NetReq req("https://www.ledokcloud.com/aips4/screen/upgrade/getGeneric?type=0&page=1&limit=10");
req.setRawHeader("token","e183653f716cb150ebf3b4f8a83c95e7");
auto reply = req.timeout(60000).post("");
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
auto err = errStrWithData(reply, &json);
if(! err.isEmpty()) {
QMessageBox::critical(this, "Error", err);
return;
}
if(json["code"].toInt()) {
QMessageBox::critical(this, "Error", json["msg"].toString());
return;
}
auto files = json["page"]["list"].toArray();
if(files.isEmpty()) {
QMessageBox::critical(this, "Error", tr("No Files"));
return;
}
QDialog dlg(this);
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
dlg.setWindowTitle(tr("Select Online APK"));
dlg.resize(800, 500);
auto vBox = new VBox(&dlg);
vBox->setContentsMargins(0,0,0,0);
auto table = new Table{
{"name", tr("Name"), 200, QHeaderView::Stretch},
{"size", tr("Size"), 80},
{"createTime", tr("Create Time"), 150}
};
table->setDefs();
table->setSelectionMode(QAbstractItemView::SingleSelection);
foreach(auto file, files) {
auto rr = table->appendRow();
table->setText(rr, "name", file["fileName"].toString()+"."+file["suffix"].toString());
table->setText(rr, "size", byteSizeStr(file["fileSize"].toInt()))->setTextAlignment(AlignRight);
table->setText(rr, "createTime", file["createTime"].toString());
table->setData(rr, 0, file["fileId"].toString());
}
connect(table, &Table::cellDoubleClicked, &dlg, [=, &dlg](int row) {
fdFileName->setText(table->text(row, "name"));
fileId = table->data(row, 0).toString();
filePath = "";
dlg.accept();
});
vBox->addWidget(table);
auto hBox = new HBox(vBox);
hBox->addStretch();
auto btnOk = new QPushButton("确定");
btnOk->setMinimumWidth(80);
connect(btnOk, &QPushButton::clicked, &dlg, [=, &dlg] {
auto sels = table->selectedRanges();
if(sels.isEmpty()) {
QMessageBox::warning(&dlg, "Warning", "请选择文件");
return;
}
auto row = sels[0].topRow();
fdFileName->setText(table->text(row, "name"));
fileId = table->data(row, 0).toString();
filePath = "";
dlg.accept();
});
hBox->addWidget(btnOk);
hBox->addStretch();
auto btnClose = new QPushButton("关闭");
btnClose->setMinimumWidth(80);
connect(btnClose, &QPushButton::clicked, &dlg, &QDialog::reject);
hBox->addWidget(btnClose);
hBox->addStretch();
dlg.exec();
});
});
auto btnUpgread = new QPushButton(tr("Upgrade"));
btnUpgread->setMinimumSize(QSize(80, 30));
btnUpgread->setProperty("ssType", "progManageTool");
connect(btnUpgread, &QPushButton::clicked, this, [=] {
auto fileName = fdFileName->text();
if(fileName.length() < 3) return;
int cnt = table->topLevelItemCount();
QList<wUpgradeApkItem *> items;
for(int i=0; i<cnt; i++) if(table->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<wUpgradeApkItem *>(table->topLevelItem(i));
if(item->isUpdating) {
QMessageBox::information(this, tr("Tip"), tr("Is upgrading now. Please wait"));
return;
}
if(item->mCard->bPassword && item->mCard->m_bLockStatus && item->m_lockFlag) {
item->setResult(tr("This screen is encrypted"), Qt::red);
return;
}
items.append(item);
}
if(items.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
return;
}
QByteArray fileData;
if(! filePath.isEmpty()) {
QFile file(filePath);
if(! file.exists()) return;
if(! file.open(QIODevice::ReadOnly)) return;
fileData = file.readAll();
file.close();
} else if(! fileId.isEmpty()) {
auto waitingDlg = new WaitingDlg(this, tr("Downloading Online File")+" ...");
waitingDlg->show();
auto reply = NetReq("https://www.ledokcloud.com/aips4/sys/file/download/"+fileId).timeout(120000).get();
QEventLoop loop;
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
connect(reply, &QNetworkReply::downloadProgress, waitingDlg, [=](qint64 bytesReceived, qint64 bytesTotal) {
waitingDlg->fdText->setText(tr("Downloading Online File")+" "+QString::number(bytesReceived*100/bytesTotal)+" %");
});
loop.exec(QEventLoop::ExcludeUserInputEvents);
waitingDlg->close();
auto err = errStr(reply);
fileData = reply->readAll();
if(! err.isEmpty()) {
if(! fileData.isEmpty()) err += "\n"+fileData;
QMessageBox::critical(this, tr("Error"), err);
return;
}
if(fileData.isEmpty()) {
QMessageBox::critical(this, tr("Error"), tr("Online file is empty"));
return;
}
}
auto nameBytes = fileName.toUtf8();
auto Boundary = "----QtLedOK_.oOo._"+QUuid::createUuid().toByteArray(QUuid::WithoutBraces);
QByteArray data;
data.append("--").append(Boundary).append("\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\n10005\r\n");
data.append("--").append(Boundary).append("\r\nContent-Disposition: form-data; name=\"").append(nameBytes).append("\"; filename=\"").append(nameBytes).append("\"\r\n\r\n").append(fileData).append("\r\n");
data.append("--").append(Boundary).append("--\r\n");
bool isApk = ! fileName.endsWith(".rpd", Qt::CaseInsensitive);
foreach(auto item, items) {
item->setResult(tr("Uploading")+" ...");
item->mProgress->setValue(0);
item->isUpdating = true;
NetReq req("http://"+item->mCard->m_strCardIp+":2016/upload?type="+(isApk ? "software":"hardware"));
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->mProgress->setValue(bytesSent*100/bytesTotal);
});
connect(reply, &QNetworkReply::finished, item, [=] {
QString err = errStrWithData(reply);
if(! err.isEmpty()) {
item->setResult(tr("Upload error")+": "+err, Qt::red);
item->isUpdating = false;
return;
}
item->mProgress->setValue(100);
item->setResult(tr("Installing")+" ...");
QJsonObject json;
if(isApk) {
json.insert("_id", "UpgradeSoftware");
json.insert("_type", "UpgradeSoftware");
json.insert("fileName", fileName);
json.insert("isCustom", true);
} else {
json.insert("_id", "SynchronousHardwareVersion");
json.insert("_type", "SynchronousHardwareVersion");
}
auto reply = NetReq("http://"+item->mCard->m_strCardIp+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, item, [=] {
item->isUpdating = false;
QString err = errStrWithData(reply);
if(! err.isEmpty()) {
item->setResult(tr("Install error")+": "+err, Qt::red);
return;
}
item->setResult(tr("Install success"), Qt::darkGreen);
if(isApk) item->OnCheckSoftVersions();
else item->OnCheckFpgaVersions();
});
});
}
});
hBox->addWidget(btnUpgread);
hBox->addStretch();
hBox->addWidget(new QLabel("APK:"));
auto fdApk = new QComboBox;
fdApk->setMinimumWidth(200);
fdApk->setEditable(true);
fdApk->addItem("com.xixun.xixunplayer");
fdApk->addItem("com.xixun.joey.cardsystem");
fdApk->addItem("com.xixun.joey.systemcore");
fdApk->addItem("net.sysolution.taxiapp");
fdApk->addItem("net.sysolution.starter");
fdApk->addItem("com.xixun.display");
fdApk->addItem("com.xixun.xy.conn");
fdApk->addItem("com.xixun.xy.update");
fdApk->addItem("net.sysolution.basicapp");
hBox->addWidget(fdApk);
auto btnUninstall = new QPushButton(tr("Uninstall"));
btnUninstall->setMinimumSize(80, 30);
btnUninstall->setProperty("ssType", "progManageTool");
connect(btnUninstall, &QPushButton::clicked, this, [this, fdApk] {
auto strApkName = fdApk->currentText();
if(strApkName.isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), "APK is Empty");
return;
}
if(! strApkName.endsWith(".xixunplayer") && ! strApkName.endsWith(".taxiapp") && QMessageBox::warning(gMainWin, 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;
int cnt = table->topLevelItemCount();
for(int i=0; i<cnt; i++) if(table->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<wUpgradeApkItem *>(table->topLevelItem(i));
item->setResult(tr("Uninstalling")+" ...");
QJsonObject json;
json.insert("_id", "UninstallSoftware");
json.insert("_type", "UninstallSoftware");
json.insert("packageName", strApkName);
auto reply = NetReq("http://"+item->mCard->m_strCardIp+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [reply, item, strApkName] {
QString err = errStrWithData(reply);
if(! err.isEmpty()) {
item->setResult(tr("Uninstall error")+": "+err, Qt::red);
return;
}
item->setResult(tr("Uninstall success"), Qt::darkGreen);
});
}
});
hBox->addWidget(btnUninstall);
auto btnCheck = new QPushButton(tr("check running state"));
btnCheck->setMinimumSize(QSize(140, 30));
btnCheck->setProperty("ssType", "progManageTool");
connect(btnCheck, &QPushButton::clicked, this, [this, fdApk] {
QString strApkName = fdApk->currentText();
int cnt = table->topLevelItemCount();
for(int i=0; i<cnt; i++) if(table->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<wUpgradeApkItem *>(table->topLevelItem(i));
item->setResult(tr("Check apk running status"));
QJsonObject json;
json.insert("_id", "IsSoftwareRunning");
json.insert("_type", "IsSoftwareRunning");
json.insert("packageName", strApkName);
auto reply = NetReq("http://"+item->mCard->m_strCardIp+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [reply, item, strApkName] {
QJsonDocument json;
QString err = errStrWithData(reply, &json);
if(! err.isEmpty()) {
item->setResult(tr("Check error")+": "+err, Qt::red);
return;
}
if(json["running"].toBool()) item->setResult(tr("Running"), Qt::darkGreen);
else item->setResult(tr("Not running"), Qt::red);
});
}
});
hBox->addWidget(btnCheck);
hBox = new HBox(vBox);
auto label = new QLabel;
hBox->addWidget(label);
hBox->addStretch();
auto btnRefresh = new QPushButton(tr("Refresh"));
btnRefresh->setMinimumSize(QSize(0, 30));
btnRefresh->setProperty("ssType", "progManageTool");
connect(btnRefresh, &QPushButton::clicked, this, [this, label] {
table->clear();
table->onCheckAll(false);
int iCount = gDevicePanel->mLedCards.count();
for(int i=0;i<iCount;i++) onAddLedCard(gDevicePanel->mLedCards.at(i));
label->setText(tr("All")+":"+QString::number(iCount));
});
hBox->addWidget(btnRefresh);
auto txtSearch = new QLineEdit();
txtSearch->setClearButtonEnabled(true);
txtSearch->setMaximumWidth(200);
txtSearch->addAction(new QAction(QIcon(":/res/program/bnSearch.png"), ""), QLineEdit::LeadingPosition);
connect(txtSearch,SIGNAL(textChanged(const QString &)),this,SLOT(FilterProgram(const QString &)));
hBox->addWidget(txtSearch);
table = new LoQTreeWidget();
table->setProperty("ssType", "topList");
vBox->addWidget(table);
hBox = new HBox(vBox);
hBox->addStretch();
auto pushButtonCancel = new QPushButton(tr("Cancel"));
pushButtonCancel->setMinimumSize(QSize(0, 30));
pushButtonCancel->setProperty("ssType", "progManageTool");
connect(pushButtonCancel, &QPushButton::clicked, this, &UpgradeApkDialog::reject);
hBox->addWidget(pushButtonCancel);
m_headerItem = new QTreeWidgetItem();
for(int i=1; i<Upgrade_END; i++) if(i!=Upgrade_Remark) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
m_headerItem->setText(Upgrade_Check, "");
m_headerItem->setText(Upgrade_SCREEN_ID, tr("Screen ID"));
m_headerItem->setText(Upgrade_ONLINE, tr("Online"));
m_headerItem->setText(Upgrade_SCREEN_IP, tr("Screen IP"));
m_headerItem->setText(Upgrade_ENCRYPT, tr("Security"));
m_headerItem->setText(Upgrade_REMARK_NAME, tr("Remark Name"));
m_headerItem->setText(Upgrade_PROGRESS, tr("Progress"));
m_headerItem->setText(Upgrade_Remark, tr("State"));
m_headerItem->setText(Upgrade_XIXUNPLAYER_VERSION, tr("xixunplayer"));
m_headerItem->setText(Upgrade_CARDSYSTEM_VERSION, tr("cardsystem"));
m_headerItem->setText(Upgrade_STARTER_VERSION, tr("starter"));
m_headerItem->setText(Upgrade_TAXIAPP_VERSION, tr("taxiapp"));
m_headerItem->setText(Upgrade_DISPLAYER_VERSION, tr("displayer"));
m_headerItem->setText(Upgrade_FPAG_VERSION, tr("FPGA"));
m_headerItem->setText(Upgrade_CONNECTION_VERSION, tr("connection"));
m_headerItem->setText(Upgrade_UPDATE_VERSION, tr("update"));
table->setHeaderItem(m_headerItem);
table->header()->setSectionResizeMode(Upgrade_Check, QHeaderView::Fixed);
table->setColumnWidth(Upgrade_Check, 40);
table->header()->setSectionResizeMode(Upgrade_SCREEN_ID, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_ONLINE, QHeaderView::Fixed);
table->setColumnWidth(Upgrade_ONLINE, 40);
table->header()->setSectionResizeMode(Upgrade_SCREEN_IP, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_ENCRYPT, QHeaderView::Fixed);
table->setColumnWidth(Upgrade_ENCRYPT, 40);
table->header()->setSectionResizeMode(Upgrade_PROGRESS, QHeaderView::Fixed);
table->setColumnWidth(Upgrade_PROGRESS, 100);
table->header()->setSectionResizeMode(Upgrade_XIXUNPLAYER_VERSION, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_CARDSYSTEM_VERSION, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_STARTER_VERSION, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_TAXIAPP_VERSION, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_DISPLAYER_VERSION, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_FPAG_VERSION, QHeaderView::Fixed);
table->setColumnWidth(Upgrade_FPAG_VERSION, 100);
table->header()->setSectionResizeMode(Upgrade_Remark, QHeaderView::Stretch);
table->header()->setSectionResizeMode(Upgrade_REMARK_NAME, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_CONNECTION_VERSION, QHeaderView::ResizeToContents);
table->header()->setSectionResizeMode(Upgrade_UPDATE_VERSION, QHeaderView::ResizeToContents);
int iCount = gDevicePanel->mLedCards.count();
for(int i=0; i<iCount; i++) onAddLedCard(gDevicePanel->mLedCards.at(i));
label->setText(tr("All")+":"+QString::number(iCount));
}
void UpgradeApkDialog::onAddLedCard(LedCard *card) {
int iExistFlg=0;
int cnt = table->topLevelItemCount();
for(int i=0; i<cnt; i++) {
QString strTempCardId=static_cast<wUpgradeApkItem*>(table->topLevelItem(i))->mCard->m_strCardId;
if(strTempCardId == card->m_strCardId) {
iExistFlg=1;
static_cast<wUpgradeApkItem*>(table->topLevelItem(i))->SetItemParam(card);
break;
}
}
if(iExistFlg==0) new wUpgradeApkItem(card, table, this);
}
void UpgradeApkDialog::keyPressEvent(QKeyEvent *ev) {
if(ev->key() == Qt::Key_F3) {
QMessageBox::warning(this, "Tip", tr("The encrypted control card can be upgraded directly"));
int cnt = table->topLevelItemCount();
for(int i=0; i<cnt; i++) static_cast<wUpgradeApkItem *>(table->topLevelItem(i))->m_lockFlag = false;
}
}
void UpgradeApkDialog::FilterProgram(const QString &strtemp)
{
if (strtemp.isEmpty()) //显示全部
{
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false);
}
}
else
{
QList<QTreeWidgetItem*> resultList = table->findItems(strtemp, Qt::MatchContains,Upgrade_SCREEN_ID); //搜索结果
if (resultList.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList6 = table->findItems(strtemp, Qt::MatchContains,Upgrade_REMARK_NAME); //搜索结果
if (resultList6.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList6.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
//QMessageBox::warning(this, "Export", "FilterProgram");
QList<QTreeWidgetItem*> resultList1 = table->findItems(strtemp, Qt::MatchContains,Upgrade_XIXUNPLAYER_VERSION); //搜索结果
if (resultList1.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList1.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_SCREEN_IP); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_XIXUNPLAYER_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_CARDSYSTEM_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_TAXIAPP_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_DISPLAYER_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_STARTER_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_CONNECTION_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_UPDATE_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_FPAG_VERSION); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = table->findItems(strtemp, Qt::MatchContains,Upgrade_Remark); //搜索结果
if (resultList2.size() > 0)
{
//QMessageBox::warning(this, "Export", QString(resultList.size()));
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
if (resultList2.contains(topItem))
table->setRowHidden(i,table->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
for (int i = 0; i< table->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = table->topLevelItem(i);
table->setRowHidden(i,table->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

View File

@ -9,6 +9,7 @@ class UpgradeApkDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit UpgradeApkDialog(QWidget *parent = nullptr); explicit UpgradeApkDialog(QWidget *parent = nullptr);
QString filePath, fileId;
protected: protected:
virtual void keyPressEvent(QKeyEvent *ev); virtual void keyPressEvent(QKeyEvent *ev);
protected slots: protected slots:
@ -17,9 +18,8 @@ protected slots:
private: private:
void onAddLedCard(LedCard *p); void onAddLedCard(LedCard *p);
LoQTreeWidget *wDevicePublishList; LoQTreeWidget *table;
QTreeWidgetItem *m_headerItem=nullptr; QTreeWidgetItem *m_headerItem=nullptr;
QString m_strUrl="";
}; };
#endif // UpgradeApkDialog_H #endif // UpgradeApkDialog_H

View File

@ -0,0 +1,138 @@
#include "wupgradeapkitem.h"
#include "tools.h"
#include "base/x_uimsgboxok.h"
#include "passwordindlg.h"
#include <QMessageBox>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QProgressBar>
#include <globaldefine.h>
#include <QSizePolicy>
#include <QUuid>
#include <QMap>
#include <QMessageBox>
#include <QHostAddress>
#include <QInputDialog>
#include <QTextCodec>
wUpgradeApkItem::wUpgradeApkItem(LedCard *pLedCard, LoQTreeWidget *parent, QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent) {
m_pWnd=pWnd;
mCard=pLedCard;
setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
setCheckState(0, Qt::Unchecked);
m_parent->addTopLevelItem(this);
m_ImageOnline = new QLabel();
m_parent->setItemWidget(this, Upgrade_ONLINE, m_ImageOnline);
m_ImageOnline->setAlignment(Qt::AlignCenter);
for(int i=1; i<Upgrade_END; i++) setTextAlignment(i, Qt::AlignCenter);
SetItemParam(mCard);
mProgress = new QProgressBar;
mProgress->setAlignment(Qt::AlignCenter);
mProgress->setStyleSheet("margin-top:8px; margin-bottom:8px; ");
m_parent->setItemWidget(this, Upgrade_PROGRESS, mProgress);
OnCheckSoftVersions();
OnCheckFpgaVersions();
}
void wUpgradeApkItem::OnCheckFpgaVersions() {
QJsonObject json;
json.insert("_id", "CheckHardwareVersions");
json.insert("_type", "CheckHardwareVersions");
auto reply = Tools::netManager().post(reqForJson("http://"+mCard->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, this] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) {
return;
}
QString strBuf;
auto vers = json["versions"].toArray();
for(int i=0; i<vers.size(); i++) {
if(i==0) strBuf += "["+QString::number(i)+"]:"+vers[i].toString();
else strBuf +="\r\n["+QString::number(i)+"]:"+vers[i].toString();
}
setData(Upgrade_FPAG_VERSION, 0, strBuf);
});
}
void wUpgradeApkItem::OnCheckSoftVersions() {
QJsonObject json;
json.insert("_id", "CheckSoftVersions");
json.insert("_type", "CheckSoftVersions");
auto reply = Tools::netManager().post(reqForJson("http://"+mCard->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, this] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) {
return;
}
auto apps = json["apps"].toArray();
foreach(QJsonValue app, apps) {
QString packageName = app["packageName"].toString();
QString verName = app["versionName"].toString();
if(packageName=="com.xixun.xixunplayer") setData(Upgrade_XIXUNPLAYER_VERSION, 0, verName);
else if(packageName=="com.xixun.joey.cardsystem") setData(Upgrade_CARDSYSTEM_VERSION, 0, verName);
else if(packageName=="net.sysolution.starter") setData(Upgrade_STARTER_VERSION, 0, verName);
else if(packageName=="net.sysolution.taxiapp") setData(Upgrade_TAXIAPP_VERSION, 0, verName);
else if(packageName=="com.xixun.display") setData(Upgrade_DISPLAYER_VERSION, 0, verName);
else if(packageName=="com.xixun.xy.conn") setData(Upgrade_CONNECTION_VERSION, 0, verName);
else if(packageName=="com.xixun.xy.update") setData(Upgrade_UPDATE_VERSION, 0, verName);
}
});
}
void wUpgradeApkItem::onVerifyLockPassword() {
bool ok;
auto pwd = QInputDialog::getText(gMainWin, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
if(! ok) return;
QJsonObject json;
json.insert("_id", "VerifyPassword");
json.insert("_type", "VerifyPassword");
json.insert("pwd", pwd);
auto reply = Tools::netManager().post(reqForJson("http://"+mCard->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply, this] {
QJsonDocument json;
QString err = checkReplyForJson(reply, &json);
if(! err.isEmpty()) {
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
if(json["result"].toBool()) mCard->m_bLockStatus = false;
else {
mCard->m_bLockStatus = true;
QMessageBox::critical(gMainWin, tr("Tip Info"), tr("password is wrong"));
}
SetPasswordItem(mCard);
});
}
void wUpgradeApkItem::SetPasswordItem(LedCard *p){
if(p->bPassword) {//加过密
if(m_bnLock==nullptr){
m_bnLock = new QPushButton(m_pWnd);
m_bnLock->setStyleSheet("background-color:transparent;");
m_bnLock->setStyleSheet("margin-left:12px; margin-right:12px;margin-top:12px; margin-bottom:12px;");
m_parent->setItemWidget(this, Upgrade_ENCRYPT, m_bnLock);
connect(m_bnLock, SIGNAL(clicked()), this, SLOT(onVerifyLockPassword()));
}
if(p->m_bLockStatus) m_bnLock->setIcon(QIcon(":/res/device/Lock.png")); //如果已经验证通过密码显示绿色图标
else m_bnLock->setIcon(QIcon(":/res/device/UnLock.png")); //如果没有验证显示蓝色锁图标
m_parent->setItemWidget(this, Upgrade_ENCRYPT, m_bnLock);
}
}
void wUpgradeApkItem::setResult(QString tip, QColor color) {
setText(Upgrade_Remark, tip);
setToolTip(Upgrade_Remark, tip);
setForeground(Upgrade_Remark, color);
}
void wUpgradeApkItem::SetItemParam(LedCard *p) {
setData(Upgrade_SCREEN_ID, 0, p->m_strCardId);
setData(Upgrade_SCREEN_IP, 0, p->m_strCardIp);
mCard->m_strCardId = p->m_strCardId;
mCard->m_strCardIp = p->m_strCardIp;
mCard->m_bOnLine = p->m_bOnLine;
if(mCard->m_bOnLine) m_ImageOnline->setPixmap(QPixmap(mCard->m_bOnLine ? ":/res/device/O_Online.png" : ":/res/device/O_Offline.png"));
SetPasswordItem(mCard);
setData(Upgrade_REMARK_NAME, 0, p->m_strCardRemarkName);
OnCheckSoftVersions();
OnCheckFpgaVersions();
}

View File

@ -0,0 +1,68 @@
#ifndef WUPGRADEAPKITEM_H
#define WUPGRADEAPKITEM_H
#include <QObject>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QDir>
#include <QDateTime>
#include <QJsonObject>
#include <QJsonDocument>
#include <QPushButton>
#include <base/loqtreewidget.h>
#include <device/ledcard.h>
#include <communication/hpptclient.h>
#include <QProgressBar>
#include <QLabel>
class wUpgradeApkItem : public QObject, public QTreeWidgetItem {
Q_OBJECT
public:
explicit wUpgradeApkItem(LedCard *pLedCard, LoQTreeWidget *parent = nullptr,QWidget *pWnd=nullptr);
void SetItemParam(LedCard *p);
void setResult(QString, QColor cr = Qt::blue);
LedCard *mCard = nullptr;
bool isUpdating{false};
bool m_lockFlag=true;
QLabel *m_ImageOnline=nullptr;
LoQTreeWidget *m_parent = nullptr;
QWidget *m_pWnd=nullptr;
QProgressBar *mProgress=nullptr;
QPushButton *m_bnLock = nullptr;
signals:
void sigUpgradeSuccess();
void sigUpgradeFail();
public slots:
void onVerifyLockPassword();
void OnCheckSoftVersions();
void OnCheckFpgaVersions();
private:
void SetPasswordItem(LedCard *p);
void postFileTask(const QString& strUrl, const QString& strFilePath);//需要的数据
};
enum ENUM_DEVICE_PUBLISH_HEADERITEM
{
Upgrade_Check=0,
Upgrade_SCREEN_ID,
Upgrade_ONLINE,
Upgrade_SCREEN_IP,
Upgrade_ENCRYPT,
Upgrade_REMARK_NAME,
Upgrade_PROGRESS,
Upgrade_Remark,
Upgrade_XIXUNPLAYER_VERSION,
Upgrade_CARDSYSTEM_VERSION,
Upgrade_STARTER_VERSION,
Upgrade_TAXIAPP_VERSION,
Upgrade_DISPLAYER_VERSION,
Upgrade_FPAG_VERSION,
Upgrade_CONNECTION_VERSION,
Upgrade_UPDATE_VERSION,
Upgrade_END,
};
#endif // WPROGRAMPUBLISHITEM_H

View File

@ -1,19 +1,20 @@
#include "devicectrlpanel.h" #include "devicectrlpanel.h"
#include "devicepanel.h" #include "devicepanel.h"
#include "tools.h"
#include <QEvent> #include <QEvent>
#include <QGridLayout> #include <QGridLayout>
#include <QButtonGroup> #include <QButtonGroup>
#include <QToolButton> #include <QToolButton>
#include <wDevicesManager/ctrlbrightpanel.h> #include <device/ctrlbrightpanel.h>
#include <wDevicesManager/controlpowerwidget.h> #include <device/controlpowerwidget.h>
#include <wDevicesManager/controlnetconfigwidget.h> #include <device/ctrlnetworkpanel.h>
#include <wDevicesManager/ctrlverifyclockpanel.h> #include <device/ctrlverifyclockpanel.h>
#include <wDevicesManager/controlhdmiwidget.h> #include <device/ctrlhdmipanel.h>
#include <wDevicesManager/controlvolumewidget.h> #include <device/controlvolumewidget.h>
#include <wDevicesManager/controlencryptwidget.h> #include <device/ctrlpwdpanel.h>
#include <wDevicesManager/ctrladvancedpanel.h> #include <device/ctrladvancedpanel.h>
#include <wDevicesManager/controltestwidget.h> #include <device/controltestwidget.h>
QTextEdit *gFdResInfo; QTextEdit *gFdResInfo;
@ -53,14 +54,14 @@ DeviceCtrlPanel::DeviceCtrlPanel(DevicePanel *parent) : QWidget(parent), mDevWgt
curIndex = index; curIndex = index;
if(wgts[index]==0) { if(wgts[index]==0) {
if(index==Setting_Bright) wgts[index] = new CtrlBrightPanel(this); if(index==Setting_Bright) wgts[index] = new CtrlBrightPanel(this);
else if(index==Setting_PowerControl) wgts[index] = new ControlPowerWidget(this,m_pLedlist); else if(index==Setting_PowerControl) wgts[index] = new ControlPowerWidget(this, gSelCards);
else if(index==Setting_NetCfg) wgts[index] = new ControlNetConfigWidget(this,m_pLedlist); else if(index==Setting_NetCfg) wgts[index] = new CtrlNetworkPanel(this);
else if(index==Setting_VerifyClock) wgts[index] = new CtrlVerifyClockPanel(this); else if(index==Setting_VerifyClock) wgts[index] = new CtrlVerifyClockPanel(this);
else if(index==Setting_Encrypt) wgts[index] = new ControlEncryptWidget(this,m_pLedlist); else if(index==Setting_Encrypt) wgts[index] = new CtrlPwdPanel(this);
else if(index==Setting_HDMI) wgts[index] = new ControlHdmiWidget(this,m_pLedlist); else if(index==Setting_HDMI) wgts[index] = new CtrlHdmiPanel(this);
else if(index==Setting_Volume) wgts[index] = new ControlVolumeWidget(this,m_pLedlist); else if(index==Setting_Volume) wgts[index] = new ControlVolumeWidget(this, gSelCards);
else if(index==Setting_Advanced) wgts[index] = new CtrlAdvancedPanel(this,m_pLedlist); else if(index==Setting_Advanced) wgts[index] = new CtrlAdvancedPanel(this);
else if(index==Setting_Test) wgts[index] = new ControlTestWidget(this,m_pLedlist); else if(index==Setting_Test) wgts[index] = new ControlTestWidget(this, gSelCards);
} }
scrollArea->takeWidget(); scrollArea->takeWidget();
scrollArea->setWidget(wgts[index]); scrollArea->setWidget(wgts[index]);
@ -97,19 +98,14 @@ DeviceCtrlPanel::DeviceCtrlPanel(DevicePanel *parent) : QWidget(parent), mDevWgt
vBox->addLayout(hBox); vBox->addLayout(hBox);
connect(mDevWgt, &DevicePanel::sigSelectedDeviceList, this, [this](QList<LedCard*> *list) { connect(mDevWgt, &DevicePanel::sigSelectedDeviceList, this, [this]() {
m_pLedlist = list; if(gSelCards->count() < 2) {
if(m_pLedlist==nullptr) return; if(gSelCards->count()==1) mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+gSelCards->at(0)->m_strCardId);
if(m_pLedlist->count()<=1) { else mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
if(m_pLedlist->count()==1) {
m_pLedCard=list->at(0);
mDevWgt->fdCardNumInfo->setText(tr("single screen operation")+"->"+tr("Current Screen")+":"+m_pLedCard->m_strCardId);
} else mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
fdInfo->hide(); fdInfo->hide();
btnClear->hide(); btnClear->hide();
} else { } else {
QString strSelectNum = QString::number(m_pLedlist->count()); mDevWgt->fdCardNumInfo->setText(tr("Multi screen operation")+". "+tr("selected num")+": "+QString::number(gSelCards->count()));
mDevWgt->fdCardNumInfo->setText(tr("Multi screen operation")+"->"+tr("selected num")+":"+strSelectNum);
fdInfo->clear(); fdInfo->clear();
fdInfo->show(); fdInfo->show();
btnClear->show(); btnClear->show();
@ -129,15 +125,16 @@ void DeviceCtrlPanel::transUi() {
mBtnGrp->button(Setting_Bright)->setText(tr("Brightness Adjustment")); mBtnGrp->button(Setting_Bright)->setText(tr("Brightness Adjustment"));
mBtnGrp->button(Setting_PowerControl)->setText(tr("Power Control")); mBtnGrp->button(Setting_PowerControl)->setText(tr("Power Control"));
mBtnGrp->button(Setting_NetCfg)->setText(tr("Net Config")); mBtnGrp->button(Setting_NetCfg)->setText(tr("Net Config"));
mBtnGrp->button(Setting_VerifyClock)->setText(tr("Time Synchronization")); mBtnGrp->button(Setting_VerifyClock)->setText(tr("Time Sync"));
mBtnGrp->button(Setting_HDMI)->setText(tr("Video source")); mBtnGrp->button(Setting_HDMI)->setText(tr("Video source"));
mBtnGrp->button(Setting_Encrypt)->setText(tr("Encrypt")); mBtnGrp->button(Setting_Encrypt)->setText(tr("Password"));
mBtnGrp->button(Setting_Advanced)->setText(tr("Advanced parameters")); mBtnGrp->button(Setting_Advanced)->setText(tr("Advanced"));
mBtnGrp->button(Setting_Volume)->setText(tr("Volume Adjustment")); mBtnGrp->button(Setting_Volume)->setText(tr("Volume Adj."));
mBtnGrp->button(Setting_Test)->setText(tr("Test")); mBtnGrp->button(Setting_Test)->setText(tr("Test"));
if(m_pLedCard!=nullptr) mDevWgt->fdCardNumInfo->setText(tr("single screen operation")+" -> "+tr("Current Screen:")+m_pLedCard->m_strCardId); if(gSelCards->count() < 1) mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
else mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none")); else if(gSelCards->count()==1) mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+gSelCards->at(0)->m_strCardId);
else mDevWgt->fdCardNumInfo->setText(tr("Multi screen operation")+". "+tr("selected num")+": "+QString::number(gSelCards->count()));
btnClear->setText(tr("Clear")); btnClear->setText(tr("Clear"));
} }

View File

@ -2,7 +2,7 @@
#define DEVICECTRLPANEL_H #define DEVICECTRLPANEL_H
#include "globaldefine.h" #include "globaldefine.h"
#include "wDevicesManager/ledcard.h" #include "device/ledcard.h"
#include <QScrollArea> #include <QScrollArea>
#include <QPushButton> #include <QPushButton>
#include <QToolButton> #include <QToolButton>
@ -32,8 +32,6 @@ private:
QPushButton *btnClear; QPushButton *btnClear;
QWidget *wgts[Setting_End]{}; QWidget *wgts[Setting_End]{};
int curIndex{-1}; int curIndex{-1};
QList<LedCard*> *m_pLedlist{0};
LedCard *m_pLedCard{0};
}; };

View File

@ -11,7 +11,6 @@
#include <cfg.h> #include <cfg.h>
#include <QHttpMultiPart> #include <QHttpMultiPart>
#include <QUuid> #include <QUuid>
#include "base/updaterdialog.h"
#include <QBuffer> #include <QBuffer>
#include "base/pixbmpshowdialog.h" #include "base/pixbmpshowdialog.h"
#include <QThread> #include <QThread>
@ -21,7 +20,7 @@
DeviceItem::DeviceItem(LedCard *pLedCard, LoQTreeWidget *parent,QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent){ DeviceItem::DeviceItem(LedCard *pLedCard, LoQTreeWidget *parent,QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent){
m_pWnd=pWnd; m_pWnd=pWnd;
m_pLedCard=pLedCard; mCard=pLedCard;
pHpptClient = new HpptClient(this); pHpptClient = new HpptClient(this);
setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
setCheckState(0, Qt::Unchecked); setCheckState(0, Qt::Unchecked);
@ -33,24 +32,24 @@ DeviceItem::DeviceItem(LedCard *pLedCard, LoQTreeWidget *parent,QWidget *pWnd) :
m_bnCardDetailInfo->setStyleSheet(R"rrr( m_bnCardDetailInfo->setStyleSheet(R"rrr(
QPushButton { QPushButton {
border-radius: 4px; border-radius: 4px;
image: url(:/res/DeviceManager/bnDetail.png); image: url(:/res/device/bnDetail.png);
} }
QPushButton:hover{background-color: #cccccc;} QPushButton:hover{background-color: #ccc;}
)rrr"); )rrr");
connect(m_bnCardDetailInfo, &QPushButton::clicked, this, [this]{ connect(m_bnCardDetailInfo, &QPushButton::clicked, this, [this]{
QString strTip=""; QString strTip="";
strTip.append(tr("cur brightness:")).append(QString::number(m_pLedCard->brightness)).append("\r\n"); strTip.append(tr("cur brightness:")).append(QString::number(mCard->bright)).append("\r\n");
//strTip.append("cardsystem apk version:"+QString::number(m_LedCard.iCardSystemVersion)+"\r\n"); //strTip.append("cardsystem apk version:"+QString::number(m_LedCard.iCardSystemVersion)+"\r\n");
//strTip.append("device apk:"+m_LedCard.starterversionName+"\r\n"); //strTip.append("device apk:"+m_LedCard.starterversionName+"\r\n");
strTip.append(tr("android version:")).append(m_pLedCard->androidVersion).append("\r\n"); strTip.append(tr("android version:")).append(mCard->androidVersion).append("\r\n");
//strTip.append(tr("android width:")+QString::number(m_LedCard.androidWidth)+"\r\n"); //strTip.append(tr("android width:")+QString::number(m_LedCard.androidWidth)+"\r\n");
//strTip.append(tr("android height:")+QString::number(m_LedCard.androidHeight)+"\r\n"); //strTip.append(tr("android height:")+QString::number(m_LedCard.androidHeight)+"\r\n");
strTip.append(tr("IMEI:")).append(m_pLedCard->strIMEI).append("\r\n"); strTip.append(tr("IMEI:")).append(mCard->strIMEI).append("\r\n");
strTip.append(tr("HardWard Version:")).append(m_pLedCard->HardVersion).append("\r\n"); strTip.append(tr("HardWard Version:")).append(mCard->HardVersion).append("\r\n");
strTip.append(tr("MAX Brightness level:")).append(QString::number(m_pLedCard->BrightnessLevel)).append("\r\n"); strTip.append(tr("MAX Brightness level:")).append(QString::number(mCard->BrightnessLevel)).append("\r\n");
strTip.append(tr("Android OS Resolution:")).append(m_pLedCard->ScreenResolution).append("\r\n"); strTip.append(tr("Android OS Resolution:")).append(mCard->ScreenResolution).append("\r\n");
strTip.append(tr("Firmware Version:")).append(m_pLedCard->FirmwareVersion).append("\r\n"); strTip.append(tr("Firmware Version:")).append(mCard->FirmwareVersion).append("\r\n");
strTip.append(tr("Player Version:")).append(m_pLedCard->strXixunplayerVersion).append("\r\n"); strTip.append(tr("Player Version:")).append(mCard->strXixunplayerVersion).append("\r\n");
QMessageBox::information(gMainWin, tr("Detail Info"), strTip); QMessageBox::information(gMainWin, tr("Detail Info"), strTip);
}); });
@ -60,24 +59,24 @@ QPushButton:hover{background-color: #cccccc;}
m_bnReadbackPic->setStyleSheet(R"rrr( m_bnReadbackPic->setStyleSheet(R"rrr(
QPushButton { QPushButton {
border-radius: 4px; border-radius: 4px;
image: url(:/res/DeviceManager/deviceReadbackPic.png); image: url(:/res/device/deviceReadbackPic.png);
} }
QPushButton:hover{background-color: #cccccc;} QPushButton:hover{background-color: #ccc;}
)rrr"); )rrr");
connect(m_bnReadbackPic, SIGNAL(clicked()), this, SLOT(onReadbackPic())); connect(m_bnReadbackPic, SIGNAL(clicked()), this, SLOT(onReadbackPic()));
m_ImageOnline = new QLabel(); m_ImageOnline = new QLabel();
m_pLedCard->m_bOnLine=true; mCard->m_bOnLine=true;
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png")); m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
setData(DeviceTable_ID, 0, m_pLedCard->m_strCardId); setData(DeviceTable_ID, 0, mCard->m_strCardId);
setData(DeviceTable_IP, 0, m_pLedCard->m_strCardIp); setData(DeviceTable_IP, 0, mCard->m_strCardIp);
setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(m_pLedCard->m_iWidth).arg(m_pLedCard->m_iHeight)); setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(mCard->m_iWidth).arg(mCard->m_iHeight));
m_parent->setItemWidget(this, DeviceTable_Info, m_bnCardDetailInfo); m_parent->setItemWidget(this, DeviceTable_Info, m_bnCardDetailInfo);
m_parent->setItemWidget(this, DeviceTable_Screenshot, m_bnReadbackPic); m_parent->setItemWidget(this, DeviceTable_Screenshot, m_bnReadbackPic);
m_parent->setItemWidget(this, DeviceTable_Online, m_ImageOnline); m_parent->setItemWidget(this, DeviceTable_Online, m_ImageOnline);
m_ImageOnline->setAlignment(Qt::AlignCenter); m_ImageOnline->setAlignment(Qt::AlignCenter);
SetPasswordItem(m_pLedCard); SetPasswordItem(mCard);
for(int i=1; i<DeviceTable_Screenshot; i++) setTextAlignment(i, Qt::AlignCenter); for(int i=1; i<DeviceTable_Screenshot; i++) setTextAlignment(i, Qt::AlignCenter);
//启动心跳监测设备在线和下线3次超时表示下线 //启动心跳监测设备在线和下线3次超时表示下线
@ -91,12 +90,12 @@ QPushButton:hover{background-color: #cccccc;}
HttpPostByTypeJsonObject(json4); HttpPostByTypeJsonObject(json4);
if(m_HeartbeatCount>10) { if(m_HeartbeatCount>10) {
//下线 //下线
m_pLedCard->m_bOnLine=false; mCard->m_bOnLine=false;
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Offline.png")); m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Offline.png"));
} else { } else {
//在线 //在线
m_pLedCard->m_bOnLine=true; mCard->m_bOnLine=true;
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png")); m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
} }
}); });
mHeartbeatTimer.start(60000); mHeartbeatTimer.start(60000);
@ -157,7 +156,7 @@ void DeviceItem::OnControlTcpSend(int iProgramIndex) {
QTcpSocket *send = new QTcpSocket(); QTcpSocket *send = new QTcpSocket();
connect(send, SIGNAL(connected()), this, SLOT(connect_sucessful())); connect(send, SIGNAL(connected()), this, SLOT(connect_sucessful()));
connect(send, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(show_error(QAbstractSocket::SocketError))); connect(send, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(show_error(QAbstractSocket::SocketError)));
send->connectToHost(QHostAddress(m_pLedCard->m_strCardIp),31299); send->connectToHost(QHostAddress(mCard->m_strCardIp),31299);
ST_ANSY_PROGRAM_PACKET tempStreadPakcet; ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
tempStreadPakcet.SyncHead[0]=0x7e; tempStreadPakcet.SyncHead[0]=0x7e;
@ -175,8 +174,8 @@ void DeviceItem::OnControlTcpSend(int iProgramIndex) {
QByteArray databuf = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket); QByteArray databuf = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
if(!send->waitForConnected(10000)) //等待连接返回 if(!send->waitForConnected(10000)) //等待连接返回
{ {
qDebug()<<m_pLedCard->m_strCardIp<<"Connect timeout "; qDebug()<<mCard->m_strCardIp<<"Connect timeout ";
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("Connect")+":"+tr("timeout")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("Connect")+":"+tr("timeout"));
send->close(); send->close();
delete send; delete send;
return ; return ;
@ -186,7 +185,7 @@ void DeviceItem::OnControlTcpSend(int iProgramIndex) {
{ {
send->read(send->bytesAvailable()); send->read(send->bytesAvailable());
qDebug()<<"recv anycast success ack"; qDebug()<<"recv anycast success ack";
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("Anycast")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("Anycast")+":"+tr("success"));
} }
send->close(); send->close();
delete send; delete send;
@ -197,23 +196,12 @@ void DeviceItem::HttpPostByTypeJsonObject(QJsonObject json)
QJsonDocument doc; QJsonDocument doc;
doc.setObject(json); doc.setObject(json);
QByteArray post_loginArray = doc.toJson(QJsonDocument::Compact); QByteArray post_loginArray = doc.toJson(QJsonDocument::Compact);
m_strUrl="http://"+m_pLedCard->m_strCardIp+":2016/settings"; m_strUrl="http://"+mCard->m_strCardIp+":2016/settings";
if(m_pLedCard->m_strCardId.left(2)!="M8"&&m_pLedCard->m_strCardId.left(2)!="m8") if(mCard->m_strCardId.left(2)!="M8" && mCard->m_strCardId.left(2)!="m8")
{ {
if(json["_type"]=="GetAllScreenSizeM80"||json["_type"]=="SetSpecialResolution"||json["_type"]=="GetSpecialResolution"||json["_type"]=="CleanDisplayScreenSize") if(json["_type"]!="GetAllScreenSizeM80") pHpptClient->httpPost(m_strUrl,post_loginArray);
{
// pHpptClient->httpPost(m_strUrl,post_loginArray);
}
else {
pHpptClient->httpPost(m_strUrl,post_loginArray);
}
}
else
{
pHpptClient->httpPost(m_strUrl,post_loginArray);
} }
else pHpptClient->httpPost(m_strUrl,post_loginArray);
} }
void DeviceItem::HttpGetLedCardWidthHeight() void DeviceItem::HttpGetLedCardWidthHeight()
{ {
@ -230,7 +218,7 @@ void DeviceItem::HttpGetLedCardRemarkName(){
} }
void DeviceItem::refreshLable(){ void DeviceItem::refreshLable(){
if(m_pLedCard->m_bPowerStatus){ if(mCard->m_bPowerStatus){
this->setForeground(DeviceTable_Power, Qt::green); this->setForeground(DeviceTable_Power, Qt::green);
setData(DeviceTable_Power, 0, tr("on")); setData(DeviceTable_Power, 0, tr("on"));
} else { } else {
@ -267,10 +255,10 @@ void DeviceItem::onReadbackPic() {
} }
void DeviceItem::SetPasswordItem(LedCard *p){ void DeviceItem::SetPasswordItem(LedCard *p){
if(p->bPassword) {//加过密 if(p->bPassword) {//加过密
if(p->m_bLockStatus) m_bnLock->setIcon(QIcon(":/res/DeviceManager/Lock.png")); //如果已经验证通过密码显示绿色图标 if(p->m_bLockStatus) m_bnLock->setIcon(QIcon(":/res/device/Lock.png")); //如果已经验证通过密码显示绿色图标
else m_bnLock->setIcon(QIcon(":/res/DeviceManager/UnLock.png")); //如果没有验证显示蓝色锁图标 else m_bnLock->setIcon(QIcon(":/res/device/UnLock.png")); //如果没有验证显示蓝色锁图标
m_parent->setItemWidget(this, DeviceTable_Password, m_bnLock); m_parent->setItemWidget(this, DeviceTable_Password, m_bnLock);
} else m_bnLock->setIcon(QIcon(":/res/DeviceManager/Transparent.png")); //显示空白 } else m_bnLock->setIcon(QIcon()); //显示空白
} }
//获取到httpPost的应答如果参数变化需要出发修改控件item的内容 //获取到httpPost的应答如果参数变化需要出发修改控件item的内容
void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data) { void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data) {
@ -295,38 +283,35 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
QString strType=jsonObject["_type"].toString(); QString strType=jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) if(jsonObject["success"].toBool()==true)
{ {
//alahover 20200521 qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
if(strType=="GetScreenSize" ) if(strType=="GetScreenSize" )
{ {
if(m_pLedCard->m_iWidth!=jsonObject["width"].toInt()||m_pLedCard->m_iHeight!=jsonObject["height"].toInt()) if(mCard->m_iWidth!=jsonObject["width"].toInt()||mCard->m_iHeight!=jsonObject["height"].toInt())
{ {
m_pLedCard->m_iWidth=jsonObject["width"].toInt(); mCard->m_iWidth=jsonObject["width"].toInt();
m_pLedCard->m_iHeight=jsonObject["height"].toInt(); mCard->m_iHeight=jsonObject["height"].toInt();
} }
setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(m_pLedCard->m_iWidth).arg(m_pLedCard->m_iHeight)); setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(mCard->m_iWidth).arg(mCard->m_iHeight));
} }
else if(strType=="GetCardAlias" ) else if(strType=="GetCardAlias" )
{ {
m_pLedCard->m_strCardRemarkName = QString::fromUtf8(QByteArray::fromBase64(jsonObject["alias"].toString().toLatin1())); mCard->m_strCardRemarkName = QString::fromUtf8(QByteArray::fromBase64(jsonObject["alias"].toString().toLatin1()));
setData(DeviceTable_Remark,0,m_pLedCard->m_strCardRemarkName); setData(DeviceTable_Remark,0,mCard->m_strCardRemarkName);
} }
else if(strType=="GetCardName") else if(strType=="GetCardName")
{ {
m_HeartbeatCount=0; m_HeartbeatCount=0;
m_pLedCard->m_bOnLine=true; mCard->m_bOnLine=true;
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png")); m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
} }
else if(strType=="GetBuildInformation" ) else if(strType=="GetBuildInformation" )
{ {
m_pLedCard->strIMEI=jsonObject["IMEI"].toString(); mCard->strIMEI=jsonObject["IMEI"].toString();
m_pLedCard->HardVersion=jsonObject["HardVersion"].toString(); mCard->HardVersion=jsonObject["HardVersion"].toString();
m_pLedCard->BrightnessLevel=jsonObject["BrightnessLevel"].toInt(); mCard->BrightnessLevel=jsonObject["BrightnessLevel"].toInt();
m_pLedCard->ScreenResolution=jsonObject["ScreenResolution"].toString(); mCard->ScreenResolution=jsonObject["ScreenResolution"].toString();
m_pLedCard->FirmwareVersion=jsonObject["FirmwareVersion"].toString(); mCard->FirmwareVersion=jsonObject["FirmwareVersion"].toString();
//if(m_pLedCard->CompareHTTPPostParam()==false)
} }
else if(strType=="CheckSoftVersions" ) else if(strType=="CheckSoftVersions" )
{ {
@ -335,42 +320,36 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
QJsonObject oApp = value.toObject(); QJsonObject oApp = value.toObject();
if(oApp["packageName"].toString().contains("xixunplayer")) if(oApp["packageName"].toString().contains("xixunplayer"))
{ {
m_pLedCard->strXixunplayerVersion=oApp["versionName"].toString(); mCard->strXixunplayerVersion=oApp["versionName"].toString();
m_pLedCard->strXixunplayerVersionCode=oApp["versionCode"].toInt(); mCard->strXixunplayerVersionCode=oApp["versionCode"].toInt();
} }
} }
} }
else if(strType == "HasControllerPassword") else if(strType == "HasControllerPassword")
{ {
//if(m_pLedCard->bPassword!=jsonObject["result"].toBool())
{ {
m_pLedCard->bPassword=jsonObject["result"].toBool(); mCard->bPassword=jsonObject["result"].toBool();
SetPasswordItem(m_pLedCard); SetPasswordItem(mCard);
} }
} }
else if(strType == "SetScreenOn")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetScreenOn")+":"+tr("success"));
}
else if(strType == "AliIotSetting") else if(strType == "AliIotSetting")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("AliIotSetting")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("AliIotSetting")+":"+tr("success"));
} }
else if(strType == "IsScreenOn") else if(strType == "IsScreenOn")
{ {
//if(m_pLedCard->m_bPowerStatus!=jsonObject["on"].toBool())
{ {
m_pLedCard->m_bPowerStatus=jsonObject["on"].toBool(); mCard->m_bPowerStatus=jsonObject["on"].toBool();
if(m_pLedCard->m_bPowerStatus) { if(mCard->m_bPowerStatus) {
this->setForeground(DeviceTable_Power, Qt::green); this->setForeground(DeviceTable_Power, Qt::green);
setData(DeviceTable_Power, 0, tr("on")); setData(DeviceTable_Power, 0, tr("on"));
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetScreenStatus")+tr("success")+","+tr("Status")+":"+tr("on")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetScreenStatus")+tr("success")+","+tr("Status")+":"+tr("on"));
} else { } else {
this->setForeground(DeviceTable_Power, Qt::red); this->setForeground(DeviceTable_Power, Qt::red);
setData(DeviceTable_Power, 0, tr("off")); setData(DeviceTable_Power, 0, tr("off"));
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetScreenStatus")+tr("success")+","+tr("Status")+":"+tr("off")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetScreenStatus")+tr("success")+","+tr("Status")+":"+tr("off"));
} }
} }
} }
@ -380,140 +359,56 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
if(bStatus)//解密成功 if(bStatus)//解密成功
{ {
qDebug()<<"解密成功"; qDebug()<<"解密成功";
m_pLedCard->m_bLockStatus=false; mCard->m_bLockStatus=false;
} }
else else
{ {
qDebug()<<"解密失败"; qDebug()<<"解密失败";
X_UIMsgBoxOk *mb = new X_UIMsgBoxOk(tr("Tip Info"),tr("password is wrong"), m_pWnd,0); X_UIMsgBoxOk *mb = new X_UIMsgBoxOk(tr("Tip Info"),tr("password is wrong"), m_pWnd,0);
mb->exec(); mb->exec();
m_pLedCard->m_bLockStatus=true; mCard->m_bLockStatus=true;
} }
SetPasswordItem(m_pLedCard); SetPasswordItem(mCard);
} else if(strType == "GetBrightness") { } else if(strType == "GetBrightness") {
m_pLedCard->brightness = jsonObject["brightness"].toInt(); mCard->bright = jsonObject["brightnessPercentage"].toInt(-1);
QString bright = QString::number(m_pLedCard->brightness); if(mCard->bright==-1) mCard->bright = qRound(jsonObject["brightness"].toInt() * 100.0 / mCard->BrightnessLevel);
setData(DeviceTable_Brightness, 0, QString::number(m_pLedCard->brightness*100/m_pLedCard->BrightnessLevel)+"% ("+bright+")"); QString bright = QString::number(mCard->bright);
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetBrightness")+tr("success")+","+tr("brightness")+"="+bright); setData(DeviceTable_Brightness, 0, QString::number(mCard->bright)+"%");
} emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetBrightness")+tr("success")+","+tr("brightness")+"="+bright+"%");
else if(strType == "SetBrightness")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetBrightness")+":"+tr("success"));
}
else if(strType == "SetBrightnessSensitivity")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetBrightnessSensitivity")+tr("success"));
}
else if(strType == "SetMinBrightness")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetMinBrightness")+":"+tr("success"));
}
else if(strType == "GetBrightnessSensitivity")
{
int iTemp=jsonObject["sensitivity"].toInt();
QString strSensitivity=QString::number(iTemp);
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetBrightnessSensitivity")+tr("success")+","+tr("sensitivity")+"="+strSensitivity);
}
else if(strType == "GetMinBrightness")
{
int iTemp=jsonObject["brightness"].toInt();
QString strMinBrightness=QString::number(iTemp);
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetMinBrightness")+tr("success")+","+tr("brightness")+"="+strMinBrightness);
}
else if(strType == "SensorBrightnessTable")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetSensorBrightnessTable")+":"+tr("success"));
}
else if(strType == "SetSwitchWiFi")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetSwitchWiFi")+":"+tr("success"));
}
else if(strType == "ConfigurationWiFi")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("ConfigurationWiFi")+":"+tr("success"));
}
else if(strType == "ConfigurationHotSpot")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("ConfigurationHotSpot")+":"+tr("success"));
}
else if(strType == "GetSwitchWiFi")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetSwitchWiFi")+":"+tr("success"));
} }
else if(strType == "SetAutoBrightnessTask") else if(strType == "SetAutoBrightnessTask")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetAutoBrightnessTask")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetAutoBrightnessTask")+":"+tr("success"));
} }
else if(strType == "SetAutoVolumeTask") else if(strType == "SetAutoVolumeTask")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetAutoVolumeTask")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetAutoVolumeTask")+":"+tr("success"));
} }
else if(strType == "SetVolume") else if(strType == "SetVolume")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetVolume")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetVolume")+":"+tr("success"));
} }
else if(strType == "GetVolume") else if(strType == "GetVolume")
{ {
int itempVolume=jsonObject["volume"].toInt(); int itempVolume=jsonObject["volume"].toInt();
QString strCurVolume=QString::number(itempVolume); QString strCurVolume=QString::number(itempVolume);
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetVolume")+":"+tr("success")+","+tr("volume")+"="+strCurVolume); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetVolume")+":"+tr("success")+","+tr("volume")+"="+strCurVolume);
} }
else if(strType == "SetTimingScreenTask") else if(strType == "SetTimingScreenTask")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetTimingScreenTask")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetTimingScreenTask")+":"+tr("success"));
}
else if(strType == "SetHighForBusy")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetHighForBusy")+":"+tr("success"));
}
else if(strType == "GetStateForBusy")
{
if(jsonObject["result"].toInt()==0)
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetStateForBusy")+":"+tr("Service:Low Out of service:High"));
else
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetStateForBusy")+":"+tr("Service:High Out of service:Low"));
}
else if(strType =="UpgradeSoftware")
{
qDebug()<<"slotUploadFinished success ack";
MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK
}
else if(strType == "IsPortableHotSpot")
{
QString strWifi=jsonObject["wifi"].toString();
if(!strWifi.isEmpty())
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("IsPortableHotSpot")+":"+tr("success")+","+tr("WifiName")+":"+strWifi);
QString strAp=jsonObject["hotSpots"].toString();
if(!strAp.isEmpty())
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("IsPortableHotSpot")+":"+tr("success")+","+tr("ApName")+":"+strAp);
if(strWifi.isEmpty()&&strAp.isEmpty())
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("IsPortableHotSpot")+":"+tr("success"));
} }
else if(strType == "TestScreen") else if(strType == "TestScreen")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("TestScreen")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("TestScreen")+":"+tr("success"));
} }
else if(strType == "SetOnlineAddr") else if(strType == "SetOnlineAddr")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetOnlineAddr")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetOnlineAddr")+":"+tr("success"));
} }
else if(strType == "SetRealtimeServer") else if(strType == "SetRealtimeServer")
{ {
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetRealtimeServer")+":"+tr("success")); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetRealtimeServer")+":"+tr("success"));
}
else if(strType == "GetOnlineAddr")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetOnlineAddr")+":"+jsonObject["server"].toString()+" ID:"+jsonObject["companuID"].toString());
}
else if(strType == "GetRealtimeServer")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetRealtimeServer")+":"+jsonObject["server"].toString());
}
else if(strType == "DelPrograms")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("DelPrograms")+":"+tr("success"));
} }
else if(strType == "GetCurrentSensorBrightness") else if(strType == "GetCurrentSensorBrightness")
{ {
@ -529,33 +424,7 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
int iTempValue=jsonObject["value"].toInt(); int iTempValue=jsonObject["value"].toInt();
QString strSensorValue=QString::number(iTempValue); QString strSensorValue=QString::number(iTempValue);
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetCurrentSensorBrightness")+":"+strSensorType+","+tr("Cur brightness")+":"+strSensorValue); emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetCurrentSensorBrightness")+":"+strSensorType+","+tr("Cur brightness")+":"+strSensorValue);
}
else if(strType == "SetSpecialResolution")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetSpecialResolution")+":"+tr("success"));
}
else if(strType == "GetSpecialResolution")
{
QString strTotalResolution = jsonObject["totalResolution"].toString();
QString strCurDisplayResolution = jsonObject["displayResolution"].toString();
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetSpecialResolution")+":"+tr("totalResolution")+"["+strTotalResolution+"],"+tr("strCurDisplayResolution")+"["+strCurDisplayResolution+"]");
}
else if(strType == "CleanDisplayScreenSize")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("CleanDisplayScreenSize")+":"+tr("success"));
}
else if(strType == "SetMinBrightness")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetMinBrightness")+":"+tr("success"));
}
else if(strType == "SetMaxBrightness")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetMaxBrightness")+":"+tr("success"));
}
else if(strType == "GetMaxBrightness")
{
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetMaxBrightness")+":"+QString::number(jsonObject["brightness"].toInt()));
} else if(strType == "GetScreenshotFull") { } else if(strType == "GetScreenshotFull") {
MACRO_ASKTIME_STOP MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK MACRO_POSTING_DLG_UNLOCK
@ -570,18 +439,10 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
//imageresult.loadFromData(Ret_bytearray); //imageresult.loadFromData(Ret_bytearray);
PixbmpShowDialog *dlg=new PixbmpShowDialog(m_pWnd); PixbmpShowDialog *dlg=new PixbmpShowDialog(m_pWnd);
dlg->m_PixMap.loadFromData(Ret_bytearray); dlg->m_PixMap.loadFromData(Ret_bytearray);
dlg->ResizeByPixmap(m_pLedCard->m_iWidth,m_pLedCard->m_iHeight); dlg->ResizeByPixmap(mCard->m_iWidth,mCard->m_iHeight);
dlg->exec(); dlg->exec();
} }
} else {//失败应答,打印失败和错误信息
if(strType == "UpgradeSoftware") {
qDebug()<<"slotUploadFinished failed ack";
MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK
} }
emit sigOutputInfo(m_pLedCard->m_strCardId+"<-"+strType+":failed,error:"+jsonObject["error"].toString());
}
} }
} }
QPixmap DeviceItem::Base64_To_Image(QByteArray bytearray,QString SavePath) QPixmap DeviceItem::Base64_To_Image(QByteArray bytearray,QString SavePath)
@ -600,17 +461,6 @@ QPixmap DeviceItem::Base64_To_Image(QByteArray bytearray,QString SavePath)
return imageresult; return imageresult;
} }
void DeviceItem::slotUploadProgress(qint64 A,qint64 B)
{
if(B!=0)
{
QString strbaifenbi=tr("Uploadding")+":"+QString("%1%").arg(A*100/B);
emit sigSetTipTextContent(strbaifenbi);
m_pGetAskTimer->stop();
m_pGetAskTimer->start(50000);
}
}
void DeviceItem::DeletePostingDlg() void DeviceItem::DeletePostingDlg()
{ {
if(m_PostingDlg!=nullptr) if(m_PostingDlg!=nullptr)

View File

@ -7,7 +7,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QPushButton> #include <QPushButton>
#include <base/loqtreewidget.h> #include <base/loqtreewidget.h>
#include <wDevicesManager/ledcard.h> #include <device/ledcard.h>
#include <communication/hpptclient.h> #include <communication/hpptclient.h>
#include <QLabel> #include <QLabel>
#include <QMap> #include <QMap>
@ -44,11 +44,10 @@ public:
void HttpGetLedCardRemarkName(); void HttpGetLedCardRemarkName();
QPixmap Base64_To_Image(QByteArray bytearray,QString SavePath); QPixmap Base64_To_Image(QByteArray bytearray,QString SavePath);
LedCard *m_pLedCard{0}; LedCard *mCard{0};
QTimer mHeartbeatTimer; QTimer mHeartbeatTimer;
signals: signals:
void sigOutputInfo(QString); void sigOutputInfo(QString);
void sigSetTipTextContent(QString);
public slots: public slots:
void DeletePostingDlg(); void DeletePostingDlg();
@ -57,7 +56,6 @@ public slots:
protected slots: protected slots:
void onReadbackPic(); void onReadbackPic();
void onVerifyLockPassword(); void onVerifyLockPassword();
void slotUploadProgress(qint64 A,qint64 B);
private: private:
int m_intIndexFlagOfInfoOrControl=0; int m_intIndexFlagOfInfoOrControl=0;
void SetPasswordItem(LedCard *p); void SetPasswordItem(LedCard *p);

View File

@ -1,7 +1,7 @@
#include "devicepanel.h" #include "devicepanel.h"
#include "devicectrlpanel.h" #include "devicectrlpanel.h"
#include "tools.h" #include "tools.h"
#include "gqt.h" #include "gutil/qgui.h"
#include <QAction> #include <QAction>
#include <QBoxLayout> #include <QBoxLayout>
#include <QEvent> #include <QEvent>
@ -31,7 +31,7 @@ DevicePanel::DevicePanel(QSettings &settings, QWidget *parent) : QWidget(parent)
hBox->setSpacing(2); hBox->setSpacing(2);
auto label = new QLabel(); auto label = new QLabel();
label->setPixmap({":/res/DeviceManager/DeviceNum_All.png"}); label->setPixmap({":/res/device/DeviceNum_All.png"});
label->setScaledContents(true); label->setScaledContents(true);
label->setFixedSize(33, 24); label->setFixedSize(33, 24);
hBox->addWidget(label); hBox->addWidget(label);
@ -46,9 +46,16 @@ DevicePanel::DevicePanel(QSettings &settings, QWidget *parent) : QWidget(parent)
auto fdSearch = new QLineEdit(); auto fdSearch = new QLineEdit();
fdSearch->setClearButtonEnabled(true); fdSearch->setClearButtonEnabled(true);
fdSearch->setFixedSize(220, 30); fdSearch->setFixedSize(220, 30);
fdSearch->addAction(new QAction(QIcon(":/res/ProgramManager/bnSearch.png"), QString()), QLineEdit::LeadingPosition); fdSearch->addAction(new QAction(QIcon(":/res/program/bnSearch.png"), QString()), QLineEdit::LeadingPosition);
fdSearch->setStyleSheet("border: 1px solid #aaaaaa;"); fdSearch->setStyleSheet("border: 1px solid #aaaaaa;");
connect(fdSearch, &QLineEdit::textChanged, this, &DevicePanel::FilterProgram); connect(fdSearch, &QLineEdit::textChanged, this, [this](const QString &search) {
auto cnt = mDeviceTable->topLevelItemCount();
if(search.isEmpty()) for(int i=0; i<cnt; i++) mDeviceTable->topLevelItem(i)->setHidden(false);
else for(int i=0; i<cnt; i++) {
auto item = mDeviceTable->topLevelItem(i);
item->setHidden(! (item->text(DeviceTable_ID).contains(search) || item->text(DeviceTable_Remark).contains(search) || item->text(DeviceTable_IP).contains(search)));
}
});
hBox->addWidget(fdSearch); hBox->addWidget(fdSearch);
hBox->addSpacing(10); hBox->addSpacing(10);
@ -80,7 +87,7 @@ QComboBox {
} }
QComboBox:hover {background-color: #08b;} QComboBox:hover {background-color: #08b;}
QComboBox::drop-down {width: 25px;} QComboBox::drop-down {width: 25px;}
QComboBox::down-arrow {image: url(:/res/DeviceManager/FlashArrow.png);} QComboBox::down-arrow {image: url(:/res/device/FlashArrow.png);}
QComboBox QAbstractItemView::item { QComboBox QAbstractItemView::item {
height: 28px; height: 28px;
color: #fff; color: #fff;
@ -91,7 +98,7 @@ QComboBox QAbstractItemView::item:selected {background-color: #09c;}
btnRefresh = new QPushButton(tr("Refresh"), areaFlash); btnRefresh = new QPushButton(tr("Refresh"), areaFlash);
btnRefresh->setGeometry(0, 0, 75, areaFlash->height()); btnRefresh->setGeometry(0, 0, 75, areaFlash->height());
connect(btnRefresh, &QPushButton::clicked, this, [this] { connect(btnRefresh, &QPushButton::clicked, this, [this] {
LedCardList.clear(); mLedCards.clear();
mDeviceTable->onCheckAll(false); mDeviceTable->onCheckAll(false);
mDeviceTable->clear(); mDeviceTable->clear();
nDeviceNum->setText("0"); nDeviceNum->setText("0");
@ -137,12 +144,12 @@ QPushButton:hover {background-color: #08b;}
parseInfo(document.object(), addr); parseInfo(document.object(), addr);
} else { } else {
auto bytes = gram.data(); auto bytes = gram.data();
STREAM_PACKET *pStreamPacket = (STREAM_PACKET *)bytes.data(); auto packet = (Packet *)bytes.data();
LedCard *pLedCard = new LedCard(this);//alahover 没有释放 LedCard *pLedCard = new LedCard(this);//alahover 没有释放
pLedCard->m_strCardId = pStreamPacket->ucSerialCode; pLedCard->m_strCardId = packet->serialCode;
pLedCard->m_strCardIp = addr; pLedCard->m_strCardIp = addr;
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) {//如果已经存在在列表中 for(int i=0;i<mLedCards.count();i++) if(mLedCards.at(i)->m_strCardId==pLedCard->m_strCardId ) {//如果已经存在在列表中
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针 auto pOldLedCard = mLedCards.at(i);//获取到旧的对象指针
pOldLedCard->m_bOnLine = true; pOldLedCard->m_bOnLine = true;
if(pOldLedCard->CompareHTTPGetParam(pLedCard)==false) {//如果ip地址变化了 if(pOldLedCard->CompareHTTPGetParam(pLedCard)==false) {//如果ip地址变化了
pOldLedCard->copyLedCardHTTPGetParam(pLedCard); pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
@ -154,7 +161,7 @@ QPushButton:hover {background-color: #08b;}
delete pLedCard; delete pLedCard;
return; return;
} }
LedCardList.append(pLedCard); mLedCards.append(pLedCard);
addLedCard(pLedCard);//发送信号到界面 addLedCard(pLedCard);//发送信号到界面
} }
} }
@ -164,7 +171,7 @@ QPushButton:hover {background-color: #08b;}
for(int i=1; i<DeviceTable_End; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter); for(int i=1; i<DeviceTable_End; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
mDeviceTable->setHeaderItem(m_headerItem); mDeviceTable->setHeaderItem(m_headerItem);
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Check, QHeaderView::Fixed); mDeviceTable->header()->setSectionResizeMode(DeviceTable_Check, QHeaderView::Fixed);
mDeviceTable->setColumnWidth(DeviceTable_Check, 48); mDeviceTable->setColumnWidth(DeviceTable_Check, 36);
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Online, QHeaderView::Fixed); mDeviceTable->header()->setSectionResizeMode(DeviceTable_Online, QHeaderView::Fixed);
mDeviceTable->setColumnWidth(DeviceTable_Online, 48); mDeviceTable->setColumnWidth(DeviceTable_Online, 48);
mDeviceTable->header()->setSectionResizeMode(DeviceTable_ID, QHeaderView::Stretch); mDeviceTable->header()->setSectionResizeMode(DeviceTable_ID, QHeaderView::Stretch);
@ -188,7 +195,6 @@ QPushButton:hover {background-color: #08b;}
mDeviceTable->hideColumn(0); mDeviceTable->hideColumn(0);
mDeviceTable->fdIsSelAll->hide(); mDeviceTable->fdIsSelAll->hide();
specifyIPDlg = new QDialog(this); specifyIPDlg = new QDialog(this);
specifyIPDlg->setWindowTitle(tr("Specify IP")); specifyIPDlg->setWindowTitle(tr("Specify IP"));
@ -246,30 +252,28 @@ DevicePanel::~DevicePanel() {
} }
void DevicePanel::sendGetInfo() { void DevicePanel::sendGetInfo() {
QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact); const QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
// if(mUdpSocket.writeDatagram(data, QHostAddress("255.255.255.255"), 22222) != data.length()) { uchar ccc[]{0x7E, 0x7E, 0x7E, 0x90, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x21,
// qDebug() << "getInfo writeDatagram to 255.255.255.255 Failed"; 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};
// } if(mUdpSocket.writeDatagram(data, QHostAddress("255.255.255.255"), 22222) != data.length()) qDebug() << "getInfo write to 255.255.255.255 failed";
if(mUdpSocket.writeDatagram((char *)ccc, sizeof(ccc), QHostAddress("255.255.255.255"), 31296) != sizeof(ccc)) qDebug() << "getInfo write to 255.255.255.255 failed";
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces(); QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
foreach(QNetworkInterface face, networkinterfaces) { foreach(QNetworkInterface face, networkinterfaces) {
auto flags = face.flags(); auto flags = face.flags();
bool can = (flags & QNetworkInterface::IsRunning) && (flags & QNetworkInterface::CanBroadcast) && ! (flags & QNetworkInterface::IsLoopBack); bool can = (flags & QNetworkInterface::IsRunning) && (flags & QNetworkInterface::CanBroadcast) && ! (flags & QNetworkInterface::IsLoopBack);
if(! can) continue; if(! can) continue;
qDebug() << face;
auto addrEntries = face.addressEntries(); auto addrEntries = face.addressEntries();
foreach(QNetworkAddressEntry addrEntry, addrEntries) { foreach(QNetworkAddressEntry addrEntry, addrEntries) {
auto ip = addrEntry.ip(); auto ip = addrEntry.ip();
if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue; if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue;
auto broadcast = addrEntry.broadcast(); auto broadcast = addrEntry.broadcast();
if(mUdpSocket.writeDatagram(data, broadcast, 22222) != data.length()) qDebug() << "getInfo writeDatagram Failed." << ip.toString() << "->" << broadcast.toString(); if(mUdpSocket.writeDatagram(data, broadcast, 22222) != data.length()) qDebug() << "getInfo write failed." << ip.toString() << "->" << broadcast.toString();
} }
} }
auto ipstr = fdIP->toPlainText(); auto ipstr = fdIP->toPlainText();
if(! ipstr.isEmpty()) { if(! ipstr.isEmpty()) {
auto ips = ipstr.split("\n", Qt::SkipEmptyParts); auto ips = ipstr.split("\n", Qt::SkipEmptyParts);
foreach(auto ip, ips) { foreach(auto ip, ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "getInfo specify IP write failed." << ip;
if(gDevicePanel->mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "Specify IP write Failed." << ip;
}
} }
} }
@ -308,82 +312,21 @@ void DevicePanel::transUi() {
bnSpecifyIP->setItemText(0,tr("Specify IP")); bnSpecifyIP->setItemText(0,tr("Specify IP"));
label_3->setText(tr("All")); label_3->setText(tr("All"));
m_headerItem->setData(DeviceTable_Check, 0, ""); m_headerItem->setText(DeviceTable_Online, tr("Online"));
m_headerItem->setData(DeviceTable_Online, 0, tr("Online")); m_headerItem->setText(DeviceTable_ID, tr("Screen ID"));
m_headerItem->setData(DeviceTable_ID, 0, tr("Screen ID")); m_headerItem->setText(DeviceTable_IP, tr("Screen IP"));
m_headerItem->setData(DeviceTable_IP, 0, tr("Screen IP")); m_headerItem->setText(DeviceTable_ScreenSize, tr("Screen Size"));
m_headerItem->setData(DeviceTable_ScreenSize, 0, tr("Screen Size")); m_headerItem->setText(DeviceTable_Remark, tr("Remark Name"));
m_headerItem->setData(DeviceTable_Remark, 0, tr("Remark Name")); m_headerItem->setText(DeviceTable_Screenshot, tr("readback pic"));
m_headerItem->setData(DeviceTable_Screenshot, 0, tr("readback pic")); m_headerItem->setText(DeviceTable_Brightness, tr("Cur Brightness"));
m_headerItem->setData(DeviceTable_Brightness, 0, tr("Cur Brightness")); m_headerItem->setText(DeviceTable_Power, tr("Power Status"));
m_headerItem->setData(DeviceTable_Power, 0, tr("Power Status")); m_headerItem->setText(DeviceTable_Password, tr("Security"));
m_headerItem->setData(DeviceTable_Password, 0, tr("Security")); m_headerItem->setText(DeviceTable_Info, tr("More Info"));
m_headerItem->setData(DeviceTable_Info, 0, tr("More Info"));
auto cnt = mDeviceTable->topLevelItemCount(); auto cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->refreshLable(); for(int i=0; i<cnt; i++) static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->refreshLable();
} }
void DevicePanel::FilterProgram(const QString &strtemp){
if (strtemp.isEmpty()) //显示全部
{
for (int i = 0; i< mDeviceTable->topLevelItemCount(); ++i){
QTreeWidgetItem* topItem = mDeviceTable->topLevelItem(i);
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),false);
}
}
else
{
QList<QTreeWidgetItem*> resultList = mDeviceTable->findItems(strtemp, Qt::MatchContains,DeviceTable_ID); //搜索结果
if (resultList.size() > 0)
{
for (int i = 0; i< mDeviceTable->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = mDeviceTable->topLevelItem(i);
if (resultList.contains(topItem))
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList1 = mDeviceTable->findItems(strtemp, Qt::MatchContains,DeviceTable_Remark); //搜索结果
if (resultList1.size() > 0)
{
for (int i = 0; i< mDeviceTable->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = mDeviceTable->topLevelItem(i);
if (resultList1.contains(topItem))
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
QList<QTreeWidgetItem*> resultList2 = mDeviceTable->findItems(strtemp, Qt::MatchContains,DeviceTable_IP); //搜索结果
if (resultList2.size() > 0)
{
for (int i = 0; i< mDeviceTable->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = mDeviceTable->topLevelItem(i);
if (resultList2.contains(topItem))
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),false); //显示匹配的结果
else
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
else {
for (int i = 0; i< mDeviceTable->topLevelItemCount(); ++i)
{
QTreeWidgetItem* topItem = mDeviceTable->topLevelItem(i);
mDeviceTable->setRowHidden(i,mDeviceTable->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
}
}
}
}
}
}
void DevicePanel::OnControlTcpSend(int iProgramIndex){ void DevicePanel::OnControlTcpSend(int iProgramIndex){
int cnt = mDeviceTable->topLevelItemCount(); int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->OnControlTcpSend(iProgramIndex); for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->OnControlTcpSend(iProgramIndex);
@ -394,7 +337,7 @@ void DevicePanel::OnControlSendJson(QJsonObject &json,QString strFanYi){
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) { for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) {
DeviceItem *item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i)); DeviceItem *item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
item->HttpPostByTypeJsonObject(json); item->HttpPostByTypeJsonObject(json);
QString strCardId=item->m_pLedCard->m_strCardId; QString strCardId=item->mCard->m_strCardId;
mDeviceCtrlPanel->OnOutputInfo(strCardId+":"+tr("send")+"->"+strFanYi); mDeviceCtrlPanel->OnOutputInfo(strCardId+":"+tr("send")+"->"+strFanYi);
} }
} }
@ -405,7 +348,7 @@ int DevicePanel::GetSelectDeviceNum() {
mSelCards.clear(); mSelCards.clear();
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) { for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) {
iSelectCount++; iSelectCount++;
mSelCards.append(static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->m_pLedCard); mSelCards.append(static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->mCard);
} }
return iSelectCount; return iSelectCount;
} }
@ -420,28 +363,35 @@ void DevicePanel::onCheckStateChanged(int f){
emit sigSelectedDeviceList(&mSelCards); emit sigSelectedDeviceList(&mSelCards);
} }
} }
void DevicePanel::addLedCard(LedCard *p){ void DevicePanel::addLedCard(LedCard *card) {
int cnt = mDeviceTable->topLevelItemCount(); int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) { for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i)); auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue; if(item->mCard->m_strCardId != card->m_strCardId) continue;
item->setData(DeviceTable_ID, 0, p->m_strCardId); item->setData(DeviceTable_ID, 0, card->m_strCardId);
item->setData(DeviceTable_IP, 0, p->m_strCardIp); item->setData(DeviceTable_IP, 0, card->m_strCardIp);
item->setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(p->m_iWidth).arg(p->m_iHeight)); item->setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(card->m_iWidth).arg(card->m_iHeight));
return; return;
} }
new DeviceItem(p, mDeviceTable, this); new DeviceItem(card, mDeviceTable, this);
nDeviceNum->setText(QString::number(mDeviceTable->topLevelItemCount())); nDeviceNum->setText(QString::number(mDeviceTable->topLevelItemCount()));
QJsonObject json;
json.insert("_id", "SyncTime");
json.insert("_type", "SyncTime");
json.insert("time", QDateTime::currentDateTime().toMSecsSinceEpoch());
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
} }
void DevicePanel::clearUdpHeartbeat(LedCard *p) { void DevicePanel::clearUdpHeartbeat(LedCard *p) {
int cnt = mDeviceTable->topLevelItemCount(); int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) { for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i)); auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue; if(item->mCard->m_strCardId != p->m_strCardId) continue;
item->m_HeartbeatCount = 0; item->m_HeartbeatCount = 0;
if(item->m_ImageOnline) { if(item->m_ImageOnline) {
item->m_pLedCard->m_bOnLine = true; item->mCard->m_bOnLine = true;
item->m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png")); item->m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
} }
return; return;
} }
@ -465,8 +415,8 @@ void DevicePanel::parseInfo(const QJsonObject &subObj, const QString &strIp) {
pLedCard->androidWidth=subObj["androidWidth"].toInt(); pLedCard->androidWidth=subObj["androidWidth"].toInt();
pLedCard->lastActive=subObj["lastActive"].toInt(); pLedCard->lastActive=subObj["lastActive"].toInt();
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) { //如果已经存在在列表中 for(int i=0;i<mLedCards.count();i++) if(mLedCards.at(i)->m_strCardId==pLedCard->m_strCardId ) { //如果已经存在在列表中
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针 auto pOldLedCard = mLedCards.at(i);//获取到旧的对象指针
pOldLedCard->m_bOnLine = true; pOldLedCard->m_bOnLine = true;
if(! pOldLedCard->CompareHTTPGetParam(pLedCard)) {//如果ip地址变化了 if(! pOldLedCard->CompareHTTPGetParam(pLedCard)) {//如果ip地址变化了
pOldLedCard->copyLedCardHTTPGetParam(pLedCard); pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
@ -478,7 +428,7 @@ void DevicePanel::parseInfo(const QJsonObject &subObj, const QString &strIp) {
delete pLedCard; delete pLedCard;
return; return;
} }
LedCardList.append(pLedCard); mLedCards.append(pLedCard);
addLedCard(pLedCard);//发送信号到界面 addLedCard(pLedCard);//发送信号到界面
} }
@ -486,7 +436,7 @@ STREAM_PACKET LedOkMakeStreamPacket(int iComType,int iLen,unsigned char *ucBuf,Q
STREAM_PACKET Temp; STREAM_PACKET Temp;
memset(&Temp, 0, sizeof(STREAM_PACKET)); memset(&Temp, 0, sizeof(STREAM_PACKET));
if(iLen>2048) return Temp; if(iLen>2048) return Temp;
memset(Temp.SyncHead,STREAM_SYNC_HEAD,STREAM_SYNC_HEAD_NUM); memset(Temp.SyncHead, 0x7e, 3);
memset(Temp.ucSerialCode,0x00,20); memset(Temp.ucSerialCode,0x00,20);
char* ch; char* ch;
QByteArray ba = str.toLatin1(); // must QByteArray ba = str.toLatin1(); // must
@ -521,11 +471,10 @@ void DevicePanel::RestoreLedCardIpByUdpCmd() {
if(strGateway.length()<=20) if(strGateway.length()<=20)
memcpy(stTempIp.cDns,strGateway.toLatin1().data(),strGateway.length()); memcpy(stTempIp.cDns,strGateway.toLatin1().data(),strGateway.length());
STREAM_PACKET tempStreadPacket = LedOkMakeStreamPacket(COMMAND_ONLY_RESET_CARD_IP, 80, (unsigned char *)&stTempIp,"Broadcast!"); STREAM_PACKET tempStreadPacket = LedOkMakeStreamPacket(COMMAND_ONLY_RESET_CARD_IP, 80, (unsigned char *)&stTempIp,"Broadcast!");
int iLenPacket=tempStreadPacket.iLength+sizeof(int)+STREAM_SYNC_HEAD_NUM*sizeof(unsigned char)+sizeof(char)+20*sizeof(char)+sizeof(char);/////除正文外的协议结构大小; int iLenPacket=tempStreadPacket.iLength+sizeof(int)+3*sizeof(unsigned char)+sizeof(char)+20*sizeof(char)+sizeof(char);/////除正文外的协议结构大小;
QUdpSocket *tempUdpSocket = new QUdpSocket(this); QUdpSocket *tempUdpSocket = new QUdpSocket(this);
if(!tempUdpSocket->bind(entry.ip())) break; if(!tempUdpSocket->bind(entry.ip())) break;
tempUdpSocket->writeDatagram((char *)&tempStreadPacket,iLenPacket,broadcastAddress, 31296); tempUdpSocket->writeDatagram((char *)&tempStreadPacket,iLenPacket,broadcastAddress, 31296);
} }
} }
} }

View File

@ -32,7 +32,7 @@ public:
void clearUdpHeartbeat(LedCard *); void clearUdpHeartbeat(LedCard *);
void parseInfo(const QJsonObject &subObj,const QString &strIp); void parseInfo(const QJsonObject &subObj,const QString &strIp);
void RestoreLedCardIpByUdpCmd(); void RestoreLedCardIpByUdpCmd();
QList<LedCard *> LedCardList; QList<LedCard *> mLedCards;
protected: protected:
void changeEvent(QEvent *) override; void changeEvent(QEvent *) override;
void transUi(); void transUi();
@ -40,7 +40,6 @@ public slots:
void ShowDevicesInfoOrControlWidget(int index); void ShowDevicesInfoOrControlWidget(int index);
protected slots: protected slots:
void onCheckStateChanged(int f); void onCheckStateChanged(int f);
void FilterProgram(const QString &strtemp);
void OnControlSendJson(QJsonObject &json,QString strFanYi); void OnControlSendJson(QJsonObject &json,QString strFanYi);
void OnControlTcpSend(int iProgramIndex); void OnControlTcpSend(int iProgramIndex);

View File

@ -11,12 +11,12 @@ using namespace std;
AVFmt::AVFmt(QByteArray url) { AVFmt::AVFmt(QByteArray url) {
fmt_ctx = avformat_alloc_context(); fmt_ctx = avformat_alloc_context();
int res = avformat_open_input(&fmt_ctx, url.constData(), nullptr, nullptr); int res = avformat_open_input(&fmt_ctx, url.constData(), 0, 0);
if(res < 0) { if(res < 0) {
err = "Open input fail: "+errStr(res); err = "Open input fail: "+errStr(res);
return; return;
} }
res = avformat_find_stream_info(fmt_ctx, nullptr); res = avformat_find_stream_info(fmt_ctx, 0);
if(res < 0) { if(res < 0) {
err = "Find stream info fail: "+errStr(res); err = "Find stream info fail: "+errStr(res);
return; return;
@ -31,28 +31,28 @@ AVFmt::AVFmt(QByteArray url) {
auto decoder = avcodec_find_decoder(viStream->codecpar->codec_id); auto decoder = avcodec_find_decoder(viStream->codecpar->codec_id);
if(decoder==0) { if(decoder==0) {
vi.idx = -1; vi.idx = -1;
qInfo()<<"Couldn't found Video Decoder"; qCritical()<<"avcodec_find_decoder fail";
} else { } else {
vi.ctx = avcodec_alloc_context3(decoder); vi.ctx = avcodec_alloc_context3(decoder);
avcodec_parameters_to_context(vi.ctx, viStream->codecpar); avcodec_parameters_to_context(vi.ctx, viStream->codecpar);
vi.ctx->thread_count = 0; vi.ctx->thread_count = 0;
if(avcodec_open2(vi.ctx, decoder, nullptr) < 0) { if((res = avcodec_open2(vi.ctx, decoder, 0)) < 0) {
vi.idx = -1; vi.idx = -1;
qInfo()<<"Couldn't open Video Codec Ctx"; qCritical()<<"avcodec_open2 fail:"<<errStr(res);
} else { } else {
dstStride[0] = (vi.ctx->width*4+63)/64*64;
dstStride[3] = dstStride[0] * vi.ctx->height;
sws_ctx = sws_getContext(vi.ctx->width, vi.ctx->height, vi.ctx->pix_fmt, vi.ctx->width, vi.ctx->height, AV_PIX_FMT_RGB32, SWS_FAST_BILINEAR, 0, 0, 0); sws_ctx = sws_getContext(vi.ctx->width, vi.ctx->height, vi.ctx->pix_fmt, vi.ctx->width, vi.ctx->height, AV_PIX_FMT_RGB32, SWS_FAST_BILINEAR, 0, 0, 0);
if(vi.ctx->color_primaries==AVCOL_PRI_BT2020) { if(vi.ctx->color_primaries==AVCOL_PRI_BT2020) {
res = sws_setColorspaceDetails(sws_ctx, sws_getCoefficients(SWS_CS_BT2020), 0, sws_getCoefficients(SWS_CS_DEFAULT), 0, -0x2200, 0x1c000, 0x18000); //0x12800, 0x40000 res = sws_setColorspaceDetails(sws_ctx, sws_getCoefficients(SWS_CS_BT2020), 0, sws_getCoefficients(SWS_CS_DEFAULT), 0, -0x2200, 0x1c000, 0x18000); //0x12800, 0x40000
qInfo()<<"sws_setColorspaceDetails"<<res; if(res < 0) qInfo()<<"sws_setColorspaceDetails fail:"<<errStr(res);
if(res < 0) {
err = "Colorspace not support";
return;
}
} }
vi.time_num = viStream->time_base.num * 1000000; vi.time_num = viStream->time_base.num * 1000000;
vi.time_den = viStream->time_base.den; vi.time_den = viStream->time_base.den;
vi.start = viStream->start_time * vi.time_num / vi.time_den; vi.start = viStream->start_time * vi.time_num / vi.time_den;
qInfo()<<"Video Idx" << vi.idx << "Start" << vi.start << "Dur" << viStream->duration * vi.time_num / vi.time_den; frmDur = viStream->r_frame_rate.den * 1000000 / viStream->r_frame_rate.num;
qInfo()<<"Video idx" << vi.idx << "Start" << vi.start << "dur" << viStream->duration * vi.time_num / vi.time_den << "frame dur" << frmDur;
if(frmDur <= 0) frmDur = 16666;
} }
} }
} }
@ -137,9 +137,11 @@ AVFmt::AVFmt(QByteArray url) {
au.idx = -1; au.idx = -1;
qWarning()<<"Couldn't open aCodecCtx"; qWarning()<<"Couldn't open aCodecCtx";
} else { } else {
#if(QT_VERSION_MAJOR < 6)
out_ch_layout.order = AV_CHANNEL_ORDER_NATIVE; out_ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
out_ch_layout.nb_channels = 2; out_ch_layout.nb_channels = 2;
out_ch_layout.u.mask = AV_CH_LAYOUT_STEREO; out_ch_layout.u.mask = AV_CH_LAYOUT_STEREO;
#endif
swr_alloc_set_opts2(&swr_ctx, swr_alloc_set_opts2(&swr_ctx,
&out_ch_layout, packed_sample_fmt, audioFmt.sampleRate(), &out_ch_layout, packed_sample_fmt, audioFmt.sampleRate(),
&au.ctx->ch_layout, au.ctx->sample_fmt, au.ctx->sample_rate, 0, nullptr); &au.ctx->ch_layout, au.ctx->sample_fmt, au.ctx->sample_rate, 0, nullptr);
@ -213,7 +215,7 @@ void AVFmt::mainRead() {
lock.unlock(); lock.unlock();
vi.pkts.cv.notify_all(); vi.pkts.cv.notify_all();
} }
av_seek_frame(fmt_ctx, -1, act->arg, AVSEEK_FLAG_BACKWARD); av_seek_frame(fmt_ctx, -1, act->arg, act->arg==0 ? AVSEEK_FLAG_FRAME : AVSEEK_FLAG_BACKWARD);
} else if(act->act=='Q') { } else if(act->act=='Q') {
if(au.idx!=-1) { if(au.idx!=-1) {
unique_lock<mutex> lock(au.pkts.mtx); unique_lock<mutex> lock(au.pkts.mtx);
@ -249,7 +251,7 @@ void AVFmt::mainRead() {
qInfo()<<"Read Packet End"; qInfo()<<"Read Packet End";
wait = 500; continue; wait = 500; continue;
} }
int res_seek = av_seek_frame(fmt_ctx, -1, 0, AVSEEK_FLAG_BACKWARD); int res_seek = av_seek_frame(fmt_ctx, -1, 0, AVSEEK_FLAG_FRAME);
if(res_seek < 0) { if(res_seek < 0) {
qCritical()<<"Seek Packet fail:"<<errStr(res_seek); qCritical()<<"Seek Packet fail:"<<errStr(res_seek);
wait = 500; continue; wait = 500; continue;
@ -270,7 +272,11 @@ void AVFmt::mainRead() {
wait = 0; wait = 0;
} }
} }
static void imgCleanupHandler(void *info) {
delete [] (uchar*)info;
}
void AVFmt::mainViDecode() { void AVFmt::mainViDecode() {
uint8_t *dst[4]{0};
while(true) { while(true) {
if(vi_frms.size >= 7) { if(vi_frms.size >= 7) {
unique_lock<mutex> lock(vi.pkts.mtx); unique_lock<mutex> lock(vi.pkts.mtx);
@ -293,14 +299,14 @@ void AVFmt::mainViDecode() {
while((res = avcodec_receive_frame(vi.ctx, vi.frm)) != AVERROR(EAGAIN)) { while((res = avcodec_receive_frame(vi.ctx, vi.frm)) != AVERROR(EAGAIN)) {
if(res == AVERROR_EOF) break; if(res == AVERROR_EOF) break;
else if(res < 0) {qCritical()<<"Video receive frame fail:"<<errStr(res); break;} else if(res < 0) {qCritical()<<"Video receive frame fail:"<<errStr(res); break;}
QImage img(vi.ctx->width, vi.ctx->height, QImage::Format_ARGB32); dst[0] = new uchar[dstStride[3]];
uint8_t *dst[4]{img.bits()};
int dstStride[4]{(int)img.bytesPerLine()};
sws_scale(sws_ctx, vi.frm->data, vi.frm->linesize, 0, vi.ctx->height, dst, dstStride); sws_scale(sws_ctx, vi.frm->data, vi.frm->linesize, 0, vi.ctx->height, dst, dstStride);
QImage img(dst[0], vi.ctx->width, vi.ctx->height, dstStride[0], QImage::Format_ARGB32, imgCleanupHandler, dst[0]);
{ {
lock_guard<mutex> lock(vi_frms.mtx); lock_guard<mutex> lock(vi_frms.mtx);
if(vi.stop) goto end; if(vi.stop) goto end;
viLmt = (vi.frm->best_effort_timestamp + vi.frm->pkt_duration) * vi.time_num / vi.time_den; if(vi.frm->pkt_duration) viLmt = (vi.frm->best_effort_timestamp + vi.frm->pkt_duration) * vi.time_num / vi.time_den;
else viLmt = vi.frm->best_effort_timestamp * vi.time_num / vi.time_den + frmDur;
vi_frms.add(new Img{img, vi.frm->best_effort_timestamp * vi.time_num / vi.time_den, viLmt, vi.deLoop, 0}); vi_frms.add(new Img{img, vi.frm->best_effort_timestamp * vi.time_num / vi.time_den, viLmt, vi.deLoop, 0});
} }
} }
@ -560,13 +566,13 @@ void FFPlayer::onClose() {
void FFPlayer::onPlay() { void FFPlayer::onPlay() {
if(ctx==0) return; if(ctx==0) return;
status = Playing; status = Playing;
ctx->sink->resume(); if(ctx->sink) ctx->sink->resume();
startAudioDaemon(); startAudioDaemon();
} }
void FFPlayer::onPause() { void FFPlayer::onPause() {
if(ctx==0) return; if(ctx==0) return;
status = Paused; status = Paused;
ctx->sink->suspend(); if(ctx->sink) ctx->sink->suspend();
} }
void FFPlayer::onStop() { void FFPlayer::onStop() {
if(audioDaemonTimerId!=0) { if(audioDaemonTimerId!=0) {

View File

@ -169,23 +169,28 @@ protected:
void playAudio(Pcm *, FFPlayer *, qint64, qint64 lmt = INT64_MAX); void playAudio(Pcm *, FFPlayer *, qint64, qint64 lmt = INT64_MAX);
void whiteAudio(Pcm *, FFPlayer *, bool, qint64 cur, qint64 lmt = INT64_MAX); void whiteAudio(Pcm *, FFPlayer *, bool, qint64 cur, qint64 lmt = INT64_MAX);
QString errStr(int err) { QString errStr(int err) {
if(av_strerror(err, err_str, err_size)==0) return QString::fromUtf8(err_str); if(av_strerror(err, errbuf, AV_ERROR_MAX_STRING_SIZE)==0) return QString::fromUtf8(errbuf);
return QString::number(err); return QString::number(err);
} }
QString err; QString err;
const static int err_size{255}; char errbuf[AV_ERROR_MAX_STRING_SIZE]{};
char err_str[err_size]{};
AVFormatContext *fmt_ctx{0}; AVFormatContext *fmt_ctx{0};
std::thread *read_thd{0}; std::thread *read_thd{0};
qint64 start{0}; qint64 start{0};
Type vi, au; Type vi, au;
qint64 frmDur{0};
qint64 viLmt{0}; qint64 viLmt{0};
SwsContext *sws_ctx{0}; SwsContext *sws_ctx{0};
int dstStride[4]{0};
SwrContext *swr_ctx{0}; SwrContext *swr_ctx{0};
AVChannelLayout out_ch_layout; AVChannelLayout out_ch_layout
#if(QT_VERSION_MAJOR > 5)
AV_CHANNEL_LAYOUT_STEREO
#endif
;
int sample_rate{0}, pcm_sample_size{0}; int sample_rate{0}, pcm_sample_size{0};
QAudioSink *sink{0}; QAudioSink *sink{0};
QIODevice *sinkWriter{0}; QIODevice *sinkWriter{0};

View File

@ -12,14 +12,14 @@ bool gTextAntialiasing = false;
bool gShowLoraScreen = false; bool gShowLoraScreen = false;
bool gWidthSplit = false; bool gWidthSplit = false;
QNetworkRequest netReq(const QString &url, int timeout, const QVariant &contentType) { QNetworkRequest netReq(const QString &url, const QByteArray &contentType, int timeout) {
QNetworkRequest request{url}; QNetworkRequest request{url};
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy); request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
request.setTransferTimeout(timeout); if(timeout) request.setTransferTimeout(timeout);
if(contentType.isValid()) request.setHeader(QNetworkRequest::ContentTypeHeader, contentType); if(! contentType.isEmpty()) request.setRawHeader("Content-Type", contentType);
return request; return request;
} }
QString parseReplyJson(QNetworkReply *reply, QJsonDocument *outJson) { QString replyErr(QNetworkReply *reply) {
reply->deleteLater(); reply->deleteLater();
auto error = reply->error(); auto error = reply->error();
if(error != QNetworkReply::NoError) { if(error != QNetworkReply::NoError) {
@ -29,41 +29,41 @@ QString parseReplyJson(QNetworkReply *reply, QJsonDocument *outJson) {
error = QNetworkReply::TimeoutError; error = QNetworkReply::TimeoutError;
errStr = QCoreApplication::translate("Def","Connection Timeout"); errStr = QCoreApplication::translate("Def","Connection Timeout");
} }
return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error))+" ("+QString::number(error)+") "+errStr+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+reply->readAll(); return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error))+" ("+QString::number(error)+") "+errStr;
} }
} }
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if(status != 200) return QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+reply->readAll(); if(status != 200) return QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
return "";
}
QString checkReply(QNetworkReply *reply, QJsonDocument *outJson) {
auto err = replyErr(reply);
if(! err.isEmpty()) {
auto data = reply->readAll();
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
return err;
}
if(outJson) { if(outJson) {
auto data = reply->readAll(); auto data = reply->readAll();
QJsonParseError jsonErr; QJsonParseError jsonErr;
*outJson = QJsonDocument::fromJson(data, &jsonErr); *outJson = QJsonDocument::fromJson(data, &jsonErr);
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+data; if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
} }
return ""; return "";
} }
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *doc, QByteArray *outData) { QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
reply->deleteLater(); auto err = replyErr(reply);
auto error = reply->error();
auto data = reply->readAll(); auto data = reply->readAll();
if(outData) *outData = data; if(outData) *outData = data;
if(error != QNetworkReply::NoError) { if(! err.isEmpty()) {
auto errStr = reply->errorString(); if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
if(error!=QNetworkReply::InternalServerError || ! errStr.endsWith("replied: Unknown")) { return err;
if(error==QNetworkReply::OperationCanceledError) {
error = QNetworkReply::TimeoutError;
errStr = QCoreApplication::translate("Def","Connection Timeout");
} }
return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error))+" ("+QString::number(error)+") "+errStr+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+data;
}
}
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if(status != 200) return QString::number(status)+" - "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+data;
QJsonParseError jsonErr; QJsonParseError jsonErr;
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr); QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+data; 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")+":\n"+data; if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
if(doc) doc->swap(json); if(outJson) outJson->swap(json);
return ""; return "";
} }
@ -92,22 +92,13 @@ bool isFileExist(QString fullFileName)
return false; return false;
} }
quint64 dirFileSize(const QString &path) quint64 dirFileSize(const QString &path) {
{
QDir dir(path); QDir dir(path);
quint64 size = 0; quint64 size = 0;
//dir.entryInfoList(QDir::Files)返回文件信息 auto infos = dir.entryInfoList(QDir::Files);
foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files)) foreach(QFileInfo fileInfo, infos) size += fileInfo.size();
{ auto subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
//计算文件大小 foreach(QString subDir, subDirs) size += dirFileSize(path + QDir::separator() + subDir);
size += fileInfo.size();
}
//dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot)返回所有子目录,并进行过滤
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
{
//若存在子目录则递归调用dirFileSize()函数
size += dirFileSize(path + QDir::separator() + subDir);
}
return size; return size;
} }

View File

@ -1,7 +1,6 @@
#ifndef GLOBALDEFINE_H #ifndef GLOBALDEFINE_H
#define GLOBALDEFINE_H #define GLOBALDEFINE_H
#include <QString> #include <QString>
#define MACRO_FENGEFU "/"
#include <QJsonValue> #include <QJsonValue>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonDocument> #include <QJsonDocument>
@ -15,47 +14,34 @@ enum {
MainPage_End, MainPage_End,
}; };
enum { struct RESTORE_IP {
ENUM_IMPORT_DLG=1,
ENUM_EXPORT_DLG=2,
ENUM_DELETE_DLG=3,
ENUM_SELECT_NETWORK=5,
};
#define STREAM_SYNC_HEAD_NUM 3
#define STREAM_SYNC_HEAD 0x7e
typedef struct _SYSTIMER
{
int y; //获取年份
int m; //获取当前月份
int d; //获得几号
int h; //获取当前为几时
int mm; //获取分钟
int s; //获取秒
int w; //获取星期几注意1为星期天7为星期六
}SYSTIMER,*P_SYSTIMER;
typedef struct _RESTORE_IP
{
char cNewIp[20]; char cNewIp[20];
char cMask[20]; char cMask[20];
char cGateway[20]; char cGateway[20];
char cDns[20]; char cDns[20];
// char cLocalIp[20]; };
struct Packet {
}RESTORE_IP,*P_RESTORE_IP; unsigned char SyncHead[3];
typedef struct _STREAM_PACKET unsigned char ucCommType;
{ char serialCode[20];
unsigned char SyncHead[STREAM_SYNC_HEAD_NUM]; unsigned int iLength;
};
struct STREAM_PACKET {
unsigned char SyncHead[3];
unsigned char ucCommType; unsigned char ucCommType;
char ucSerialCode[20]; char ucSerialCode[20];
unsigned int iLength; unsigned int iLength;
char pDataBuffer[2049]; char pDataBuffer[2049];
}STREAM_PACKET,* P_STREAM_PACKET; };
enum _NET_COMMU_TYPE struct ST_ANSY_PROGRAM_PACKET {
{ unsigned char SyncHead[3];
unsigned char ucCommType;
int iBaoLiu;
unsigned int iLength;
unsigned char pDataBuffer[20];
};
enum _NET_COMMU_TYPE {
COMMAND_SAVE_ADVANCE_PARAM_NOT_RESET=0x40, COMMAND_SAVE_ADVANCE_PARAM_NOT_RESET=0x40,
COMMAND_ONLY_RESET_CARD_IP=0X43, COMMAND_ONLY_RESET_CARD_IP=0X43,
COMMAND_SET_M31_DOUBLE_HUB=0X44, COMMAND_SET_M31_DOUBLE_HUB=0X44,
@ -78,7 +64,7 @@ enum _NET_COMMU_TYPE
NET_COMMU_TYPE_LIMITE_TIME, NET_COMMU_TYPE_LIMITE_TIME,
NET_COMMU_TYPE_SYSTEM_BROADCAST,//0X90 NET_COMMU_TYPE_SYSTEM_BROADCAST,//0X90
NET_COMMU_TYPE_REALTIME_INSERT_PLAY, NET_COMMU_TYPE_REALTIME_INSERT_PLAY,
//NET_COMMU_TYPE_SHANSUO_INSERT_PLAY,
NET_COMMU_TYPE_MODIFY_SERIAL_ID, NET_COMMU_TYPE_MODIFY_SERIAL_ID,
NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM, NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM,
NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT, NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT,
@ -139,7 +125,6 @@ enum _NET_COMMU_TYPE
NET_COMMU_TYPE_IO_CHECK_ANSWER, NET_COMMU_TYPE_IO_CHECK_ANSWER,
NET_COMMU_TYPE_LIMITE_TIME_ANSWER, NET_COMMU_TYPE_LIMITE_TIME_ANSWER,
////
NET_COMMU_TYPE_SYSTEM_BROADCAST_ANSWER, NET_COMMU_TYPE_SYSTEM_BROADCAST_ANSWER,
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_ANSWER, NET_COMMU_TYPE_REALTIME_INSERT_PLAY_ANSWER,
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_WITH_GLINT_ANSWER , //带闪烁功能的实时插播 NET_COMMU_TYPE_REALTIME_INSERT_PLAY_WITH_GLINT_ANSWER , //带闪烁功能的实时插播
@ -157,10 +142,9 @@ enum _NET_COMMU_TYPE
NET_COMMU_TYPE_GET_SYSTEM_STATUS_ANSWER,//获取系统状态 NET_COMMU_TYPE_GET_SYSTEM_STATUS_ANSWER,//获取系统状态
NET_COMMU_TYPE_NUM_ANSWER, NET_COMMU_TYPE_NUM_ANSWER,
COMMAND_CONNECT_COLSE_ANSWER COMMAND_CONNECT_COLSE_ANSWER
}; };
extern bool gVideoCompress; extern bool gVideoCompress;
extern bool gVideoTranscoding; extern bool gVideoTranscoding;
extern bool gTextAntialiasing; extern bool gTextAntialiasing;
@ -188,17 +172,24 @@ enum _ENUM_CONTRL_WIDGET {
Setting_End, Setting_End,
}; };
QNetworkRequest netReq(const QString &url, int = QNetworkRequest::DefaultTransferTimeoutConstant, const QVariant &contentType = QVariant::Invalid); QNetworkRequest netReq(const QString &url, const QByteArray & = QByteArray(), int = QNetworkRequest::DefaultTransferTimeoutConstant);
inline QNetworkRequest reqForJson(const QString &url) { inline QNetworkRequest reqForJson(const QString &url, int timeout = QNetworkRequest::DefaultTransferTimeoutConstant) {
return netReq(url, 30000, "application/json"); return netReq(url, "application/json", timeout);
} }
QString parseReplyJson(QNetworkReply *, QJsonDocument * = 0); QString replyErr(QNetworkReply *);
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0); QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
#define Def_CtrlReqPre \ #define Def_CtrlReqPre \
waitingDlg->show();\ waitingDlg->show();\
auto card = gSelCards->at(0);\ auto card = gSelCards->at(0);\
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact)); auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));\
connect(waitingDlg, &WaitingDlg::rejected, reply, [reply] {\
reply->blockSignals(true);\
reply->abort();\
reply->blockSignals(false);\
reply->deleteLater();\
});
#define Def_CtrlSetReqAfter \ #define Def_CtrlSetReqAfter \
QString err = checkReplyForJson(reply);\ QString err = checkReplyForJson(reply);\
@ -220,56 +211,19 @@ QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0
#define Def_CtrlSetMulti(tip) \ #define Def_CtrlSetMulti(tip) \
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));\ auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":2016/settings"), QJsonDocument{json}.toJson(QJsonDocument::Compact));\
connect(reply, &QNetworkReply::finished, this, [reply, card] {\ connect(reply, &QNetworkReply::finished, card, [=] {\
QString err = checkReplyForJson(reply);\ QString err = checkReplyForJson(reply);\
gFdResInfo->append(card->m_strCardId+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\ gFdResInfo->append(card->m_strCardId+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\
}); });
#define DDDef_HttpCheckJsonErr\
auto error = reply->error();\
if(error != QNetworkReply::NoError) {\
auto errStr = reply->errorString();\
if(error==QNetworkReply::OperationCanceledError) {\
error = QNetworkReply::TimeoutError;\
errStr = QCoreApplication::translate("Def","Connection Timeout");\
}\
if(waitingDlg) waitingDlg->close();\
QMessageBox::critical(gMainWin, QCoreApplication::translate("Def","Error"), QString::number(error)+" "+QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error)+" "+errStr);\
return;\
}\
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();\
if(status != 200) {\
if(waitingDlg) waitingDlg->close();\
QMessageBox::critical(gMainWin, QCoreApplication::translate("Def","Error"), QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString());\
return;\
}\
auto resp = reply->readAll();\
QJsonParseError jsonErr;\
QJsonDocument json = QJsonDocument::fromJson(resp, &jsonErr);\
if(jsonErr.error != QJsonParseError::NoError) {\
if(waitingDlg) waitingDlg->close();\
QMessageBox::critical(gMainWin, QCoreApplication::translate("Def","Error"), "JsonParseError "+jsonErr.errorString());\
return;\
}\
if(! json["success"].toBool()) {\
if(waitingDlg) waitingDlg->close();\
QMessageBox::warning(gMainWin, QCoreApplication::translate("Def","Tip Info"), QCoreApplication::translate("Def","Fail"));\
return;\
}
#define CHECK_CARD_SELECTED \ #define CHECK_CARD_SELECTED \
if(m_pLedlist!=nullptr) {\ if(gSelCards->isEmpty()) {\
if(m_pLedlist->count()==0 || (m_pLedlist->count()==1 && m_pLedCard==nullptr)) {\
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));\ QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));\
return;\ return;\
}\
} }
#define MACRO_DEFINE_TIPDLG_FUCN(TIP,SUCCESS,FAILED) \ #define MACRO_DEFINE_TIPDLG_FUCN(TIP,SUCCESS,FAILED) \
if(m_pLedlist!=nullptr) {\ if(gSelCards->count()==1) {\
if(m_pLedlist->count()<=1) {\
if(m_pLedCard!=nullptr) {\
HttpPostByTypeJsonObject(pHpptClient, m_strUrl, json);\ HttpPostByTypeJsonObject(pHpptClient, m_strUrl, json);\
if(m_PostingDlg==nullptr) {\ if(m_PostingDlg==nullptr) {\
m_PostingDlg = new LoEmptyDialog(this);\ m_PostingDlg = new LoEmptyDialog(this);\
@ -279,19 +233,16 @@ QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0
m_pGetAskTimer->start(5000);\ m_pGetAskTimer->start(5000);\
m_PostingDlg->exec();\ m_PostingDlg->exec();\
}\ }\
}\ } else if(gSelCards->count() > 1) emit sigSend(json,TIP);
} else emit sigSend(json,TIP);\
}
#define MACRO_DEFINE_TIPDLG_ALL_FUCN(READBACK,SUCCESS,FAILED) \ #define MACRO_DEFINE_TIPDLG_ALL_FUCN(READBACK,SUCCESS,FAILED) \
if(m_pLedCard!=nullptr)\ if(gSelCards->count()==1) {\
{\ if(m_PostingDlg==nullptr) {\
if(m_PostingDlg==nullptr)\
{\
m_PostingDlg = new LoEmptyDialog(this);\ m_PostingDlg = new LoEmptyDialog(this);\
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\ connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\ connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
m_PostingDlg->lock(READBACK+" "+m_pLedCard->m_strCardId,SUCCESS,FAILED);\ m_PostingDlg->lock(READBACK+" "+gSelCards->at(0)->m_strCardId,SUCCESS,FAILED);\
m_pGetAskTimer->start(5000);\ m_pGetAskTimer->start(5000);\
m_PostingDlg->exec();\ m_PostingDlg->exec();\
}\ }\
@ -330,13 +281,4 @@ if(m_PostingDlg && m_PostingDlg->getLockStatus()) m_PostingDlg->unlock();
}\ }\
} }
typedef struct _ST_ANSY_PROGRAM_PACKET
{
unsigned char SyncHead[3];
unsigned char ucCommType;
int iBaoLiu;
unsigned int iLength;
unsigned char pDataBuffer[20];
}ST_ANSY_PROGRAM_PACKET,*P_ST_ANSY_PROGRAM_PACKET;
#endif // GLOBALDEFINE_H #endif // GLOBALDEFINE_H

1
LedOK/gutil/qcore.cpp Normal file
View File

@ -0,0 +1 @@
#include "qcore.h"

33
LedOK/gutil/qcore.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef QCORE_H
#define QCORE_H
#include <QThread>
inline QString byteSizeStr(double size) {
const char *units[]{"B", "KB", "MB", "GB", "TB", "PB"};
auto i = 0;
for(; size >= 1024 && i < 5; i++) size /= 1024;
return QString::number(size, 'g', 3)+" "+units[i];
}
inline long long steady_milli() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
inline long long system_milli() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
inline long long steady_micro() {
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
inline long long system_micro() {
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
template <typename Func>
inline QThread *ThreadStart(Func &&f) {
QThread* thread = QThread::create(f);
QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater);
thread->start();
return thread;
}
#endif

33
LedOK/gutil/qgui.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "qgui.h"
const int AlignRight = Qt::AlignRight | Qt::AlignVCenter;
Table::Table(std::initializer_list<ColAttr> colAttrs, int rows, QWidget *parent) : NumTable{rows, (int)colAttrs.size(), parent} {
int i = 0;
for(typename std::initializer_list<ColAttr>::const_iterator it = colAttrs.begin(); it != colAttrs.end(); ++it) {
auto item = horizontalHeaderItem(i);
if(item==0) setHorizontalHeaderItem(i, item = new QTableWidgetItem());
item->setText(it->text);
item->setData(0x99, it->width);
if(it->width > 0) horizontalHeader()->resizeSection(i, it->width);
if(it->resizeMode > -1) horizontalHeader()->setSectionResizeMode(i, (QHeaderView::ResizeMode)it->resizeMode);
mFieldMap.insert(it->field, i++);
}
}
int Table::sizeHintForColumn(int column) const {
auto item = horizontalHeaderItem(column);
if(item==0) return QTableWidget::sizeHintForColumn(column);
int width = item->data(0x99).toInt();
if(width==0) return QTableWidget::sizeHintForColumn(column);
auto header = horizontalHeader();
if(header->sectionResizeMode(column) != QHeaderView::ResizeToContents) return QTableWidget::sizeHintForColumn(column);
int colCnt = columnCount();
int remainWidth = header->width(), stretchWidth = width;
for(int cc=0; cc<colCnt; cc++) if(cc!=column && (item = horizontalHeaderItem(cc))) {
if(header->sectionResizeMode(cc) == QHeaderView::ResizeToContents) stretchWidth += item->data(0x99).toInt();
else remainWidth -= item->data(0x99).toInt();
}
if(remainWidth<=0) return QTableWidget::sizeHintForColumn(column);
return width * remainWidth / stretchWidth;
}

301
LedOK/gutil/qgui.h Normal file
View File

@ -0,0 +1,301 @@
#ifndef QGUI_H
#define QGUI_H
#include <QComboBox>
#include <QStackedLayout>
#include <QTableWidget>
#include <QHeaderView>
extern const int AlignRight;
inline int setCurrentData(QComboBox *combo, const QVariant &data) {
auto idx = combo->findData(data);
if(idx>-1) combo->setCurrentIndex(idx);
return idx;
}
class VBox : public QBoxLayout {
public:
inline VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {}
inline VBox(QBoxLayout *parent) : QBoxLayout(TopToBottom) {
parent->addLayout(this);
};
inline VBox(QStackedLayout *parent) : QBoxLayout(TopToBottom) {
setContentsMargins(0,0,0,0);
auto wgt = new QWidget;
wgt->setLayout(this);
parent->addWidget(wgt);
};
};
class HBox : public QBoxLayout {
public:
inline HBox(QWidget *parent=nullptr) : QBoxLayout(LeftToRight, parent) {}
inline HBox(QBoxLayout *parent) : QBoxLayout(LeftToRight) {
parent->addLayout(this);
};
inline HBox(QStackedLayout *parent) : QBoxLayout(LeftToRight) {
setContentsMargins(0,0,0,0);
auto wgt = new QWidget;
wgt->setLayout(this);
parent->addWidget(wgt);
};
};
class Grid : public QGridLayout {
public:
inline Grid(QWidget *parent=0) : QGridLayout(parent) {}
inline Grid(QBoxLayout *parent) {
parent->addLayout(this);
};
inline Grid(QStackedLayout *parent) {
auto wgt = new QWidget;
wgt->setLayout(this);
parent->addWidget(wgt);
};
};
class NumTable : public QTableWidget {
Q_OBJECT
public:
explicit NumTable(QWidget *parent = 0) : QTableWidget{parent} {}
NumTable(int rows, int columns, QWidget *parent = 0) : QTableWidget{rows, columns, parent} {}
inline auto setNoEdit() {
setEditTriggers(QAbstractItemView::NoEditTriggers);
return this;
}
inline auto setColWidth(int value) {
horizontalHeader()->setDefaultSectionSize(value);
return this;
}
inline auto setRowHeight(int value) {
verticalHeader()->setDefaultSectionSize(value);
return this;
}
inline auto setHeaderText(int column, QString text) {
auto item = horizontalHeaderItem(column);
if(item==0) setHorizontalHeaderItem(column, item = new QTableWidgetItem());
item->setText(text);
return item;
}
inline auto itemValid(int row, int column) {
auto item = QTableWidget::item(row, column);
if(item==0) setItem(row, column, item = new QTableWidgetItem);
return item;
}
inline auto text(int row, int column) {
auto item = QTableWidget::item(row, column);
if(item==0) return QString();
return item->text();
}
inline auto setText(int row, int column, const QString &text) {
auto item = QTableWidget::item(row, column);
if(item) item->setText(text);
else setItem(row, column, item = new QTableWidgetItem(text));
return item;
}
inline auto data(int row, int col) {
auto item = QTableWidget::item(row, col);
if(item==0) return QVariant();
return item->data(Qt::UserRole);
}
inline auto setData(int row, int col, const QVariant &value) {
auto item = QTableWidget::item(row, col);
if(item==0) setItem(row, col, item = new QTableWidgetItem);
item->setData(Qt::UserRole, value);
return item;
}
};
struct ColAttr {
QString field;
QString text;
int width{0};
int resizeMode{-1};
};
class Table : public NumTable {
Q_OBJECT
public:
explicit Table(QWidget *parent = nullptr) : NumTable{parent} {}
Table(std::initializer_list<ColAttr> colAttrs, int rows = 0, QWidget *parent = nullptr);
inline auto setDefs() {
setSelectionBehavior(QTableWidget::SelectRows);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setAlternatingRowColors(true);
return this;
}
inline auto setColStretch() {
horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
return this;
}
inline auto setRowStretch() {
verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
return this;
}
inline auto setColFit() {
horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
return this;
}
inline auto setRowFit() {
verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
return this;
}
inline auto setColWidth(int value) {
horizontalHeader()->setDefaultSectionSize(value);
return this;
}
inline auto setRowHeight(int value) {
verticalHeader()->setDefaultSectionSize(value);
return this;
}
inline auto setHeaderText(QString column, QString text) {
auto col = mFieldMap[column];
auto item = horizontalHeaderItem(col);
if(item==0) setHorizontalHeaderItem(col, item = new QTableWidgetItem());
item->setText(text);
return item;
}
inline auto appendRow() {
auto value = rowCount();
setRowCount(value + 1);
return value;
}
inline auto item(int row, QString column) {
auto col = mFieldMap[column];
return QTableWidget::item(row, col);
}
inline void setItem(int row, QString column, QTableWidgetItem *item) {
auto col = mFieldMap[column];
QTableWidget::setItem(row, col, item);
}
inline auto text(int row, QString column) {
auto col = mFieldMap[column];
auto item = QTableWidget::item(row, col);
if(item==0) return QString();
return item->text();
}
inline auto setText(int row, QString column, const QString &text) {
auto col = mFieldMap[column];
auto item = QTableWidget::item(row, col);
if(item) item->setText(text);
else QTableWidget::setItem(row, col, item = new QTableWidgetItem(text));
return item;
}
inline auto data(int row, QString column) {
auto col = mFieldMap[column];
auto item = QTableWidget::item(row, col);
if(item==0) return QVariant();
return item->data(Qt::UserRole);
}
inline auto setData(int row, QString column, const QVariant &value) {
auto col = mFieldMap[column];
auto item = QTableWidget::item(row, col);
if(item==0) QTableWidget::setItem(row, col, item = new QTableWidgetItem);
item->setData(Qt::UserRole, value);
return item;
}
inline auto cellWidget(int row, QString column) {
auto col = mFieldMap[column];
return QTableWidget::cellWidget(row, col);
}
inline void setCellWidget(int row, QString column, QWidget *widget) {
auto col = mFieldMap[column];
QTableWidget::setCellWidget(row, col, widget);
}
QMap<QString,int> mFieldMap;
public Q_SLOTS:
inline void clearRows() {setRowCount(0);}
protected:
int sizeHintForColumn(int column) const override;
};
class ResizeEmitedWgt : public QWidget {
Q_OBJECT
public:
explicit ResizeEmitedWgt(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QWidget{parent, f} {}
protected:
void resizeEvent(QResizeEvent *) override {emit resized();}
signals:
void resized();
};
template<class T>
class Wrp {
public:
T *obj;
Wrp(T *obj = nullptr){
this->obj = obj;
};
inline Wrp& operator()(T *obj){
this->obj = obj;
return *this;
}
inline Wrp& operator()(T *obj, QLayout *layout){
this->obj = obj;
layout->addWidget(obj);
return *this;
}
inline Wrp& addTo(QLayout *layout){
layout->addWidget(obj);
return *this;
}
inline Wrp& margin(int a){
obj->setMargin(a);
return *this;
}
inline Wrp& font(const QFont &font){
obj->setFont(font);
return *this;
}
inline Wrp& font(int size){
QFont font = obj->font();
font.setPointSize(size);
obj->setFont(font);
return *this;
}
inline Wrp& width(int w){
obj->setFixedWidth(w);
return *this;
}
inline Wrp& height(int h){
obj->setFixedHeight(h);
return *this;
}
inline Wrp& padding(int wAdd, int hAdd, int minW = 32, int minH = 16){
wAdd+=8;
hAdd+=8;
QSize size = obj->fontMetrics().size(Qt::TextShowMnemonic, obj->text());
int &rwidth = size.rwidth();
rwidth += wAdd;
if(rwidth < minW) rwidth = minW;
int &rheight = size.rheight();
rheight += hAdd;
if(rheight < minH) rheight = minH;
obj->setFixedSize(size);
return *this;
}
inline Wrp& alignC(){
obj->setAlignment(Qt::AlignCenter);
return *this;
}
inline Wrp& alignR(){
obj->setAlignment(Qt::AlignRight);
return *this;
}
};
#endif

83
LedOK/gutil/qnetwork.cpp Normal file
View File

@ -0,0 +1,83 @@
#include "qnetwork.h"
#include <QCoreApplication>
#include <QMetaEnum>
const char *const FormBoundary = "----GangphonQtBoundary_.oOo._";
QNetworkAccessManager &netAccess() {
static QNetworkAccessManager access;
return access;
};
QString errStr(QNetworkReply *reply) {
reply->deleteLater();
auto error = reply->error();
if(error != QNetworkReply::NoError) {
if(error==QNetworkReply::OperationCanceledError) return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(QNetworkReply::TimeoutError))+" ("+QString::number(QNetworkReply::TimeoutError)+") "+QCoreApplication::translate("Net","Connection Timeout");
auto errStr = reply->errorString();
if(error!=QNetworkReply::InternalServerError || ! errStr.endsWith("replied: Unknown")) return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error))+" ("+QString::number(error)+") "+errStr;
}
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if(status != 200) return QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
return "";
}
QString errStrWithData(QNetworkReply *reply, QJsonDocument *outJson) {
auto err = errStr(reply);
if(! err.isEmpty()) {
auto data = reply->readAll();
if(! data.isEmpty()) err += "\n"+data;
return err;
}
if(outJson) {
auto data = reply->readAll();
QJsonParseError jsonErr;
*outJson = QJsonDocument::fromJson(data, &jsonErr);
if(jsonErr.error != QJsonParseError::NoError) return "JSON "+QCoreApplication::translate("Net","Error")+": "+data;
}
return "";
}
const char* socketErrKey(int value) {
static auto metaEnum = QMetaEnum::fromType<QAbstractSocket::SocketError>();
return metaEnum.valueToKey(value);
}
bool TcpSocket::waitForConnected(int msecs) {
if(state() == ConnectedState) return true;
QEventLoop loop;
connect(this, &QTcpSocket::connected, &loop, &QEventLoop::quit);
return connAndExec(msecs, &loop);
}
bool TcpSocket::waitForDisconnected(int msecs) {
if(state() == UnconnectedState) return true;
QEventLoop loop;
connect(this, &QTcpSocket::disconnected, &loop, &QEventLoop::quit);
return connAndExec(msecs, &loop);
}
bool TcpSocket::waitForBytesWritten(int msecs) {
QEventLoop loop;
connect(this, &QTcpSocket::bytesWritten, &loop, &QEventLoop::quit);
return connAndExec(msecs, &loop);
}
bool TcpSocket::waitForReadyRead(int msecs) {
QEventLoop loop;
connect(this, &QTcpSocket::readyRead, &loop, &QEventLoop::quit);
return connAndExec(msecs, &loop);
}
bool TcpSocket::connAndExec(int msecs, QEventLoop *loop) {
connect(this, &QTcpSocket::errorOccurred, loop, [loop] {
loop->exit(1);
});
if(msecs > 0) {
connect(this, &TcpSocket::timeout, loop, &QEventLoop::exit);
if(timerId!=0) killTimer(timerId);
timerId = startTimer(msecs);
}
auto res = loop->exec();
timerStop();
if(res==5) setSocketError(SocketTimeoutError);
return res==0;
}

90
LedOK/gutil/qnetwork.h Normal file
View File

@ -0,0 +1,90 @@
#ifndef QNETWORK_H
#define QNETWORK_H
#include <QNetworkReply>
#include <QJsonDocument>
#include <QEventLoop>
#include <QTimerEvent>
extern const char *const FormBoundary;
QNetworkAccessManager &netAccess();
class NetReq : public QNetworkRequest {
public:
NetReq();
explicit NetReq(const QString &url) : QNetworkRequest{url}{};
explicit NetReq(const QUrl &url) : QNetworkRequest{url}{};
NetReq(const QNetworkRequest &other) : QNetworkRequest{other}{};
inline NetReq &type(const QByteArray &value) {
setRawHeader("Content-Type", value);
return *this;
}
inline NetReq &typeJson() {
setRawHeader("Content-Type", "application/json");
return *this;
}
inline NetReq &timeout(int timeout) {
setTransferTimeout(timeout);
return *this;
}
inline NetReq &v5() {
setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
return *this;
}
inline QNetworkReply *get() {
return netAccess().get(*this);
}
inline QNetworkReply *post(const QByteArray &data) {
return netAccess().post(*this, data);
}
inline QNetworkReply *post(const QJsonObject &json) {
setRawHeader("Content-Type", "application/json");
return netAccess().post(*this, QJsonDocument{json}.toJson(QJsonDocument::Compact));
}
inline QNetworkReply *post(const QJsonArray &json) {
setRawHeader("Content-Type", "application/json");
return netAccess().post(*this, QJsonDocument{json}.toJson(QJsonDocument::Compact));
}
inline QNetworkReply *post(QHttpMultiPart *multiPart) {
return netAccess().post(*this, multiPart);
}
};
QString errStr(QNetworkReply *);
QString errStrWithData(QNetworkReply *, QJsonDocument * = 0);
const char* socketErrKey(int value);
class TcpSocket : public QTcpSocket {
Q_OBJECT
public:
explicit TcpSocket(QObject *parent = nullptr) : QTcpSocket{parent} {};
~TcpSocket() {
if(timerId!=0) killTimer(timerId);
};
bool waitForConnected(int msecs = 30000) override;
bool waitForDisconnected(int msecs = 30000) override;
bool waitForBytesWritten(int msecs = 30000) override;
bool waitForReadyRead(int msecs = 30000) override;
protected:
void timerEvent(QTimerEvent *e) override {
if(e->timerId()!=timerId) return;
killTimer(timerId);
timerId = 0;
emit timeout(5);
};
bool connAndExec(int msecs, QEventLoop *loop);
inline void timerStop() {
if(timerId==0) return;
killTimer(timerId);
timerId = 0;
}
int timerId = 0;
signals:
void timeout(int);
};
#endif // QNETWORK_H

View File

@ -1,7 +1,9 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QStyleFactory>
#include <QMessageBox> #include <QMessageBox>
#include <QSplashScreen> #include <QSplashScreen>
#include <QStandardPaths>
#ifdef _MSC_VER //MSVC编译器 #ifdef _MSC_VER //MSVC编译器
#include <Windows.h> #include <Windows.h>
@ -29,7 +31,7 @@ LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
#endif #endif
QString gFileHome; QString gFileHome;
QString css;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
@ -38,12 +40,18 @@ int main(int argc, char *argv[]) {
QApplication::setOrganizationDomain("www.ledok.cn"); QApplication::setOrganizationDomain("www.ledok.cn");
QApplication::setApplicationName("LedOK Express"); QApplication::setApplicationName("LedOK Express");
QApplication a(argc, argv); QApplication a(argc, argv);
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); a.setStyle(QStyleFactory::create("Fusion"));
QFile file(":/css.css");
if(file.exists() && file.open(QFile::ReadOnly)) {
a.setStyleSheet(css = file.readAll());
file.close();
}
QFont font; QFont font;
font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"}); font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"});
font.setPixelSize(14); font.setPixelSize(14);
a.setFont(font); a.setFont(font);
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
QSplashScreen splash(QPixmap(":/res/splash.png")); QSplashScreen splash(QPixmap(":/res/splash.png"));
splash.show(); splash.show();
splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white); splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white);

View File

@ -1,10 +1,10 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "base/aboutdlg.h" #include "base/aboutdlg.h"
#include "base/softconfigdialog.h" #include "base/softconfigdialog.h"
#include "base/updaterdialog.h" #include "gutil/qgui.h"
#include "cfg.h" #include "cfg.h"
#include "tools.h" #include "tools.h"
#include "wDevicesManager/upgradeapkdialog.h" #include "device/upgradeapkdialog.h"
#include <QColorDialog> #include <QColorDialog>
#include <QDesktopServices> #include <QDesktopServices>
#include <QLabel> #include <QLabel>
@ -14,6 +14,7 @@
#include <QSettings> #include <QSettings>
#include <QButtonGroup> #include <QButtonGroup>
#include <QHeaderView> #include <QHeaderView>
#include "QSimpleUpdater.h"
QWidget *gMainWin; QWidget *gMainWin;
extern QPoint gPlayPos; extern QPoint gPlayPos;
@ -46,30 +47,36 @@ protected:
}; };
MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) { MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
setAttribute(Qt::WA_AlwaysShowToolTips);
gMainWin = this; gMainWin = this;
QMenu *menuLang = new QMenu(); auto menuLang = new QMenu();
QAction *actLan = nullptr;
QAction *actCN = new QAction("中文"); auto actCN = new QAction("中文");
actCN->setCheckable(true); actCN->setCheckable(true);
actCN->setObjectName("zh_CN"); actCN->setObjectName("zh_CN");
QAction *actTW = new QAction("中文繁体"); menuLang->addAction(actCN);
auto actTW = new QAction("中文繁体");
actTW->setCheckable(true); actTW->setCheckable(true);
actTW->setObjectName("zh_TW"); actTW->setObjectName("zh_TW");
QAction *actEn = new QAction("English"); menuLang->addAction(actTW);
auto actEn = new QAction("English");
actEn->setCheckable(true); actEn->setCheckable(true);
actEn->setObjectName("en"); actEn->setObjectName("en");
QAction *actJa = new QAction("日本語"); menuLang->addAction(actEn);
auto actJa = new QAction("日本語");
actJa->setCheckable(true); actJa->setCheckable(true);
actJa->setObjectName("ja"); actJa->setObjectName("ja");
menuLang->addAction(actCN);
menuLang->addAction(actTW);
menuLang->addAction(actEn);
menuLang->addAction(actJa); menuLang->addAction(actJa);
langGrp = new QActionGroup(menuLang); langGrp = new QActionGroup(menuLang);
langGrp->addAction(actCN); langGrp->addAction(actCN);
langGrp->addAction(actTW); langGrp->addAction(actTW);
langGrp->addAction(actEn); langGrp->addAction(actEn);
langGrp->addAction(actJa); langGrp->addAction(actJa);
connect(menuLang, &QMenu::triggered, this, [this](QAction* action) { connect(menuLang, &QMenu::triggered, this, [this](QAction* action) {
auto lanName = action->objectName(); auto lanName = action->objectName();
translator.load("app_"+lanName, ":/i18n"); translator.load("app_"+lanName, ":/i18n");
@ -77,12 +84,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
}); });
QSettings settings; QSettings settings;
settings.remove("MainSetting");
settings.remove("MainWindowMaximized");
settings.remove("posMainWindow");
settings.remove("sizeMainWindow");
settings.remove("DirectlyConnectNetWork");
QString langName = settings.value("Language").toString(); QString langName = settings.value("Language").toString();
QAction *actLan = nullptr;
if(! langName.isEmpty()) { if(! langName.isEmpty()) {
if(langName.endsWith("CN")) actLan = actCN; if(langName.endsWith("CN")) actLan = actCN;
else if(langName.endsWith("TW")) actLan = actTW; else if(langName.endsWith("TW")) actLan = actTW;
@ -105,8 +108,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
QApplication::installTranslator(&transQt); QApplication::installTranslator(&transQt);
auto geo = settings.value("MainGeo").toRect(); auto geo = settings.value("MainGeo").toRect();
if(geo.width()>=800 && geo.height()>=500 && geo.x()>=-600 && geo.x()<=1280 && geo.y()>=-200 && geo.y()<=720) setGeometry(geo); if(geo.width()>=800 && geo.height()>=500 && geo.x()>=-600 && geo.x()<=1280 && geo.y()>=-200 && geo.y()<=800) setGeometry(geo);
else resize(1280, 720); else resize(1280, 800);
if(settings.value("MainIsMax", false).toBool()) setWindowState(Qt::WindowMaximized); if(settings.value("MainIsMax", false).toBool()) setWindowState(Qt::WindowMaximized);
gPlayPos = settings.value("PlayPos").toPoint(); gPlayPos = settings.value("PlayPos").toPoint();
@ -115,7 +118,6 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
icon.load(":/res/Logo.png"); icon.load(":/res/Logo.png");
titlePos = QPointF(26, 80); titlePos = QPointF(26, 80);
iconPos = QPointF(38, 20); iconPos = QPointF(38, 20);
setStyleSheet(Tools::styleSheet());
auto plt = palette(); auto plt = palette();
plt.setBrush(QPalette::Window, QColor(0xdddddd)); plt.setBrush(QPalette::Window, QColor(0xdddddd));
setPalette(plt); setPalette(plt);
@ -146,33 +148,87 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
bn_Setting = new QPushButton(); bn_Setting = new QPushButton();
bn_Setting->setIcon(QIcon(":/res/AppSetting.png")); bn_Setting->setIcon(QIcon(":/res/AppSetting.png"));
bn_Setting->setToolTip(tr("Setting"));
pLayout->addWidget(bn_Setting); pLayout->addWidget(bn_Setting);
pLayout->addWidget(m_wTitle->bn_Minimize); pLayout->addWidget(m_wTitle->bn_Minimize);
pLayout->addWidget(m_wTitle->bn_Maximize); pLayout->addWidget(m_wTitle->bn_Maximize);
pLayout->addWidget(m_wTitle->bn_Close); pLayout->addWidget(m_wTitle->bn_Close);
QMenu *menu_setting = new QMenu(); auto menu_setting = new QMenu();
act_lang = new QAction(); act_lang = new QAction();
act_lang->setMenu(menuLang); act_lang->setMenu(menuLang);
menu_setting->addAction(act_lang); menu_setting->addAction(act_lang);
act_softconfiguration = new QAction(tr("Software Configuration")); act_softconfiguration = new QAction(tr("Software Config"));
act_softconfiguration->setObjectName("Software Configuration"); connect(act_softconfiguration, &QAction::triggered, this, [this] {
SoftConfigDialog dlg(this);
dlg.exec();
mBtnGrp->button(MainPage_LoraScreen)->setVisible(gShowLoraScreen);
});
menu_setting->addAction(act_softconfiguration); menu_setting->addAction(act_softconfiguration);
act_update = new QAction(tr("Check for updates")); act_update = new QAction(tr("Check for updates"));
act_update->setObjectName("Update"); connect(act_update, &QAction::triggered, this, [this] {
QDialog dlg(this);
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
dlg.setWindowTitle(tr("Software Update"));
dlg.resize(500, 400);
auto vBox = new VBox(&dlg);
auto label = new QLabel(tr("CurVersion")+": "+APP_VERSION);
auto font = label->font();
font.setPointSize(14);
label->setFont(font);
vBox->addWidget(label);
auto fdVerInfo = new QTextEdit;
fdVerInfo->setReadOnly(true);
vBox->addWidget(fdVerInfo);
auto btnUpdate = new QPushButton(tr("Update"));
btnUpdate->setFixedWidth(80);
connect(btnUpdate, &QPushButton::clicked, this, [] {
QSimpleUpdater::getInstance()->setNotifyOnUpdate(UpdVerUrl, true);
QSimpleUpdater::getInstance()->setNotifyOnFinish(UpdVerUrl, false);
QSimpleUpdater::getInstance()->setMandatoryUpdate(UpdVerUrl, true);
QSimpleUpdater::getInstance()->checkForUpdates(UpdVerUrl);
});
vBox->addWidget(btnUpdate, 0, Qt::AlignHCenter);
auto updater = QSimpleUpdater::getInstance();
connect(updater, &QSimpleUpdater::checkingFinished, fdVerInfo, [fdVerInfo, btnUpdate] {
if(QSimpleUpdater::getInstance()->getUpdateAvailable(UpdVerUrl)) fdVerInfo->setText(tr("LatestVersion:") + QSimpleUpdater::getInstance()->getLatestVersion(UpdVerUrl) + "\n" + tr("Update log:") + "\n" + QSimpleUpdater::getInstance()->getChangelog(UpdVerUrl));
else {
fdVerInfo->setText(tr("The current version is already the latest version") + "\n\n" + tr("Update log:") + "\n" + QSimpleUpdater::getInstance()->getChangelog(UpdVerUrl));
btnUpdate->setVisible(false);
}
});
updater->setModuleVersion(UpdVerUrl, APP_VERSION);
updater->setNotifyOnUpdate(UpdVerUrl, false);
updater->setNotifyOnFinish(UpdVerUrl, false);
updater->checkForUpdates(UpdVerUrl);
dlg.exec();
});
menu_setting->addAction(act_update); menu_setting->addAction(act_update);
act_updatefirmware = new QAction(tr("firmware manager")); act_updatefirmware = new QAction(tr("firmware manager"));
act_updatefirmware->setObjectName("Update firmware"); connect(act_updatefirmware, &QAction::triggered, this, [this] {
UpgradeApkDialog dlg(this);
dlg.exec();
});
menu_setting->addAction(act_updatefirmware); menu_setting->addAction(act_updatefirmware);
act_help = new QAction(); act_help = new QAction();
act_help->setObjectName("Help"); connect(act_help, &QAction::triggered, this, [this] {
auto act = langGrp->checkedAction();
if(act==0) return;
QDesktopServices::openUrl(QUrl::fromLocalFile(QCoreApplication::applicationDirPath()+"/help/"+act->objectName()+".pdf"));
});
menu_setting->addAction(act_help); menu_setting->addAction(act_help);
auto actInfo = new QAction(tr("Info")); actInfo = new QAction;
connect(actInfo, &QAction::triggered, this, [this] { connect(actInfo, &QAction::triggered, this, [this] {
QMessageBox::information(this, tr("Info"), QMessageBox::information(this, tr("Info"),
QString("SupportsSsl: ").append(QSslSocket::supportsSsl()?"true":"false") QString("SupportsSsl: ").append(QSslSocket::supportsSsl()?"true":"false")
@ -182,32 +238,12 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
menu_setting->addAction(actInfo); menu_setting->addAction(actInfo);
act_about = new QAction(tr("About")); act_about = new QAction(tr("About"));
act_about->setObjectName("About"); connect(act_about, &QAction::triggered, this, [this] {
menu_setting->addAction(act_about); AboutDlg dlg(this);
bn_Setting->setMenu(menu_setting);//按钮上添加下拉菜单
bn_Setting->setToolTip(tr("Setting"));
connect(menu_setting, &QMenu::triggered, this, [this](QAction* act) {
if(act->objectName()=="About") {
AboutDlg pDlg(this);
pDlg.exec();
}else if(act->objectName()=="Help") {
auto act = langGrp->checkedAction();
if(act==0) return;
QDesktopServices::openUrl(QUrl::fromLocalFile(QCoreApplication::applicationDirPath()+"/help/"+act->objectName()+".pdf"));
} else if(act->objectName()=="Update") {
UpdaterDialog *pDlg=new UpdaterDialog(this);
pDlg->exec();
} else if(act->objectName()=="Update firmware") {
auto dlg = new UpgradeApkDialog(this);
dlg->showMaximized();
} else if(act->objectName()=="Software Configuration") {
SoftConfigDialog dlg(this);
dlg.exec(); dlg.exec();
mBtnGrp->button(MainPage_LoraScreen)->setVisible(gShowLoraScreen);
}
}); });
menu_setting->addAction(act_about);
bn_Setting->setMenu(menu_setting);//按钮上添加下拉菜单
QSimpleUpdater *updater = QSimpleUpdater::getInstance(); QSimpleUpdater *updater = QSimpleUpdater::getInstance();
connect(updater, &QSimpleUpdater::checkingFinished, this, [this]() { connect(updater, &QSimpleUpdater::checkingFinished, this, [this]() {
@ -296,6 +332,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
hBox->addWidget(m_pOneKeyCheckCard); hBox->addWidget(m_pOneKeyCheckCard);
hBox->addStretch(); hBox->addStretch();
//hBox->addWidget(new QLabel("ver: " APP_VERSION ".2"));
vBox->addLayout(hBox); vBox->addLayout(hBox);
gVideoCompress = settings.value("VideoCompress", true).toBool(); gVideoCompress = settings.value("VideoCompress", true).toBool();
@ -373,9 +411,7 @@ void MainWindow::test() {
qDebug()<<"status"<<status; qDebug()<<"status"<<status;
return; return;
} }
auto req = reply->request();
qDebug()<<"reply url"<<reply->url(); qDebug()<<"reply url"<<reply->url();
qDebug()<<"req url"<<req.url();
auto resp = reply->readAll(); auto resp = reply->readAll();
qDebug()<<"resp"<<resp; qDebug()<<"resp"<<resp;
}; };
@ -405,6 +441,7 @@ MainWindow::~MainWindow() {
if(mDevicePanel->fdIP) { if(mDevicePanel->fdIP) {
auto ipstr = mDevicePanel->fdIP->toPlainText(); auto ipstr = mDevicePanel->fdIP->toPlainText();
if(! ipstr.isEmpty()) settings.setValue("SpecifyIP", ipstr); if(! ipstr.isEmpty()) settings.setValue("SpecifyIP", ipstr);
else settings.remove("SpecifyIP");
} }
if(m_pTimerSendResoreIpOneKey!=nullptr) { if(m_pTimerSendResoreIpOneKey!=nullptr) {
if(m_pTimerSendResoreIpOneKey->isActive()) m_pTimerSendResoreIpOneKey->stop(); if(m_pTimerSendResoreIpOneKey->isActive()) m_pTimerSendResoreIpOneKey->stop();
@ -426,9 +463,10 @@ void MainWindow::transUi() {
m_pOneKeyCheckCard->setText(tr("Check card")); m_pOneKeyCheckCard->setText(tr("Check card"));
act_lang->setText(tr("Language")); act_lang->setText(tr("Language"));
act_help->setText(tr("Help")); act_help->setText(tr("Help"));
actInfo->setText(tr("Info"));
act_about->setText(tr("About")); act_about->setText(tr("About"));
act_update->setText(tr("Check for updates")); act_update->setText(tr("Check for updates"));
act_updatefirmware->setText(tr("firmware manager")); act_updatefirmware->setText(tr("firmware manager"));
act_softconfiguration->setText(tr("Software Configuration")); act_softconfiguration->setText(tr("Software Config"));
bn_Setting->setToolTip(tr("Setting")); bn_Setting->setToolTip(tr("Setting"));
} }

View File

@ -8,6 +8,7 @@
#include "mguangyingpinwidget.h" #include "mguangyingpinwidget.h"
#include "progpanel.h" #include "progpanel.h"
#include <QTranslator> #include <QTranslator>
#include <QActionGroup>
class MainWindow : public BaseWin { class MainWindow : public BaseWin {
Q_OBJECT Q_OBJECT
@ -23,7 +24,7 @@ private:
LoQTitleBar *m_wTitle; LoQTitleBar *m_wTitle;
QActionGroup *langGrp; QActionGroup *langGrp;
QAction *act_lang; QAction *act_lang;
QAction *act_help; QAction *act_help, *actInfo;
QAction *act_update; QAction *act_update;
QAction *act_updatefirmware; QAction *act_updatefirmware;
QAction *act_softconfiguration; QAction *act_softconfiguration;

View File

@ -1,5 +1,5 @@
#include "digiclock.h" #include "digiclock.h"
#include "gqt.h" #include "gutil/qgui.h"
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include <QVBoxLayout> #include <QVBoxLayout>

View File

@ -1,72 +1,80 @@
#include "eleanaclock.h" #include "eleanaclock.h"
#include <QJsonObject> #include <QJsonObject>
#include <QPainter> #include <QPainter>
#include <QtMath>
EleAnaClock::EleAnaClock(QString path, const QJsonObject &layer, QWidget *parent) : QWidget{parent} { EleAnaClock::EleAnaClock(double w, double h, QString path, const QJsonObject &layer, QWidget *parent) : QWidget{parent} {
timeZone = QTimeZone(layer["timezone"].toString().toUtf8()); timeZone = QTimeZone(layer["timezone"].toString().toUtf8());
img.load(path); img.load(path);
pinHourColor = layer["pinHourColor"].toString(); pinHourColor = layer["pinHourColor"].toString();
pinMinColor = layer["pinMinColor"].toString(); pinMinColor = layer["pinMinColor"].toString();
pinSecColor = layer["pinSecColor"].toString(); pinSecColor = layer["pinSecColor"].toString();
auto hhLen = layer["pinHourLen"].toInt();
auto mhLen = layer["pinMinLen"].toInt();
auto shLen = layer["pinSecLen"].toInt();
auto hhWidth = layer["pinHourWidth"].toInt();
auto mhWidth = layer["pinMinWidth"].toInt();
auto shWidth = layer["pinSecWidth"].toInt();
showSecHand = layer["showSecond"].toBool();
auto sideLen = w;
if(h < sideLen) sideLen = h;
auto lineWidth = sideLen/128;
if(lineWidth < 1) lineWidth = 1;
pen.setWidthF(lineWidth);
pen.setJoinStyle(Qt::RoundJoin);
hPoses[0].rx() = hhWidth*sideLen/400;
hPoses[1].ry() = hhLen*sideLen/-200;
hPoses[2].rx() = -hPoses[0].rx();
mPoses[0].rx() = mhWidth*sideLen/400;
mPoses[1].ry() = mhLen*sideLen/-200;
mPoses[2].rx() = -mPoses[0].rx();
sPoses[0].rx() = shWidth*sideLen/400;
sPoses[1].ry() = shLen*sideLen/-200;
sPoses[2].rx() = -sPoses[0].rx();
} }
void EleAnaClock::cal() { void EleAnaClock::cal() {
QTime time = QDateTime::currentDateTime().toTimeZone(timeZone).time(); auto time = QDateTime::currentDateTime().toTimeZone(timeZone).time();
double rad = time.second()*M_PI/30; sAngle = time.second() * 6;
double rsin = sin(rad); mAngle = time.minute() * 6 + sAngle/60;
double rcos = cos(rad); hAngle = time.hour() * 30 + mAngle/12;
double sideLen = width();
if(height() < sideLen) sideLen = height();
sPath = QPainterPath(QPointF(sideLen*0.55*rsin, sideLen*-0.55*rcos));
double pinWidth = sideLen/36;
double sx = pinWidth*rcos;
double sy = pinWidth*rsin;
sPath.lineTo(sx, sy);
sPath.lineTo(-sx, -sy);
sPath.closeSubpath();
rad = time.minute()*M_PI/30 + rad/60;
rsin = sin(rad);
rcos = cos(rad);
mPath = QPainterPath(QPointF(sideLen*0.45*rsin, sideLen*-0.45*rcos));
pinWidth = sideLen/30;
sx = pinWidth*rcos;
sy = pinWidth*rsin;
mPath.lineTo(sx, sy);
mPath.lineTo(-sx, -sy);
mPath.closeSubpath();
rad = time.hour()*M_PI/6 + rad/12;
rsin = sin(rad);
rcos = cos(rad);
hPath = QPainterPath(QPointF(sideLen*0.3*rsin, sideLen*-0.3*rcos));
pinWidth = sideLen/18;
sx = pinWidth*rcos;
sy = pinWidth*rsin;
hPath.lineTo(sx, sy);
hPath.lineTo(-sx, -sy);
hPath.closeSubpath();
} }
void EleAnaClock::paintEvent(QPaintEvent *) { void EleAnaClock::paintEvent(QPaintEvent *) {
if(timerId==0) { if(timerId==0) {
timerId = startTimer(1000, Qt::PreciseTimer); timerId = startTimer(500, Qt::PreciseTimer);
cal(); cal();
} }
QPainter painter(this); QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform); painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
if(! img.isNull()) painter.drawPixmap(0, 0, width(), height(), img); if(! img.isNull()) painter.drawPixmap(0, 0, width(), height(), img);
painter.translate(width()/2, height()/2); painter.translate(width()/2, height()/2);
painter.fillPath(hPath, QBrush(pinHourColor));
painter.fillPath(mPath, QBrush(pinMinColor)); pen.setColor(pinHourColor);
painter.fillPath(sPath, QBrush(pinSecColor)); painter.setPen(pen);
painter.translate(-width()/2, -height()/2); painter.setBrush(pen.brush());
painter.rotate(hAngle);
painter.drawPolygon(hPoses, 3);
pen.setColor(pinMinColor);
painter.setPen(pen);
painter.setBrush(pen.brush());
painter.rotate(mAngle-hAngle);
painter.drawPolygon(mPoses, 3);
if(showSecHand) {
pen.setColor(pinSecColor);
painter.setPen(pen);
painter.setBrush(pen.brush());
painter.rotate(sAngle-mAngle);
painter.drawPolygon(sPoses, 3);
}
} }
void EleAnaClock::timerEvent(QTimerEvent *) { void EleAnaClock::timerEvent(QTimerEvent *) {
if(isVisible()) { if(isVisible()) {
cal(); cal();
repaint(); update();
} else if(timerId!=0) { } else if(timerId!=0) {
killTimer(timerId); killTimer(timerId);
timerId = 0; timerId = 0;

View File

@ -3,18 +3,21 @@
#include <QWidget> #include <QWidget>
#include <QTimeZone> #include <QTimeZone>
#include <QPainterPath> #include <QPen>
class EleAnaClock : public QWidget { class EleAnaClock : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit EleAnaClock(QString path, const QJsonObject &layer, QWidget *parent = nullptr); explicit EleAnaClock(double w, double h, QString path, const QJsonObject &layer, QWidget *parent = nullptr);
void cal(); void cal();
QTimeZone timeZone; QTimeZone timeZone;
QPixmap img; QPixmap img;
QColor pinHourColor, pinMinColor, pinSecColor; QColor pinHourColor, pinMinColor, pinSecColor;
QPainterPath sPath, mPath, hPath; QPointF hPoses[3]{}, mPoses[3]{}, sPoses[3]{};
int timerId = 0; double hAngle, mAngle, sAngle;
QPen pen;
int timerId{0};
bool showSecHand{true};
protected: protected:
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;

View File

@ -11,10 +11,10 @@ public:
int w; int w;
int h; int h;
int startTime; int startTime;
int timeSpan;
int endTime; int endTime;
bool repeat;
QWidget* wgt = nullptr; QWidget *wgt{0};
}; };
#endif // ELEBASE_H #endif // ELEBASE_H

View File

@ -24,7 +24,7 @@ void EleGif::sltNext(){
if(isVisible()) { if(isVisible()) {
movie->jumpToNextFrame(); movie->jumpToNextFrame();
timer->inter = movie->nextFrameDelay(); timer->inter = movie->nextFrameDelay();
repaint(); update();
} else if(timer!=nullptr) { } else if(timer!=nullptr) {
timer->stop(); timer->stop();
timer = nullptr; timer = nullptr;

View File

@ -7,10 +7,9 @@ const QChar effTypes[] = {'l', 't', 'r', 'b'};
EleMultiPng::EleMultiPng(QString dirPre, QJsonArray maps, QWidget *parent) : QWidget{parent} { EleMultiPng::EleMultiPng(QString dirPre, QJsonArray maps, QWidget *parent) : QWidget{parent} {
QJsonObject map = maps[0].toObject(); QJsonObject map = maps[0].toObject();
EffDur = map["effectSpeed"].toInt()*1000;
if(EffDur==0) return;
picDur = map["picDuration"].toInt()*1000; picDur = map["picDuration"].toInt()*1000;
if(picDur==0) picDur = EffDur; if(picDur==0) return;
EffDur = map["effectSpeed"].toInt()*1000;
foreach(auto map, maps) imgs.append(QPixmap(dirPre+map["id"].toString())); foreach(auto map, maps) imgs.append(QPixmap(dirPre+map["id"].toString()));
QString effStr = map["effect"].toString(); QString effStr = map["effect"].toString();
if(effStr.isEmpty() || effStr=="no") EffDur = 0; if(effStr.isEmpty() || effStr=="no") EffDur = 0;
@ -85,6 +84,7 @@ void EleMultiPng::timerEvent(QTimerEvent *e) {
} }
} }
update(); update();
foreach(auto split, splits) split->update();
} else { } else {
if(timerId!=0) { if(timerId!=0) {
killTimer(timerId); killTimer(timerId);
@ -96,3 +96,9 @@ void EleMultiPng::timerEvent(QTimerEvent *e) {
} }
} }
} }
void EleSplitPng::paintEvent(QPaintEvent *) {
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
painter.drawPixmap(multiPng->imgx, multiPng->imgy, multiPng->imgs[multiPng->imgc]);
}

View File

@ -3,7 +3,7 @@
#include <QWidget> #include <QWidget>
#include <QRandomGenerator> #include <QRandomGenerator>
class EleSplitPng;
class EleMultiPng : public QWidget { class EleMultiPng : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
@ -16,9 +16,22 @@ public:
QChar effType = 0; QChar effType = 0;
QRandomGenerator rand; QRandomGenerator rand;
bool needRand = false; bool needRand = false;
QList<EleSplitPng*> splits;
protected: protected:
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
void timerEvent(QTimerEvent *) override; void timerEvent(QTimerEvent *) override;
}; };
class EleSplitPng : public QWidget {
Q_OBJECT
public:
explicit EleSplitPng(EleMultiPng *multiPng, QWidget *parent) : QWidget{parent}, multiPng(multiPng) {}
protected:
void paintEvent(QPaintEvent *) override;
EleMultiPng *multiPng;
};
#endif // ELEMULTIPNG_H #endif // ELEMULTIPNG_H

View File

@ -33,12 +33,15 @@ EleScroll::EleScroll(QWidget *parent, QString imgPath, char effect, double effDu
} }
void EleScroll::paintEvent(QPaintEvent *) { void EleScroll::paintEvent(QPaintEvent *) {
paint(this);
}
void EleScroll::paint(QPaintDevice *that) {
if(img.isNull()) return; if(img.isNull()) return;
if(timerId==0 && effect!=0 && interval!=0) { if(timerId==0 && effect!=0 && interval!=0) {
cur = 0; cur = 0;
timerId = startTimer(interval, Qt::PreciseTimer); timerId = startTimer(interval, Qt::PreciseTimer);
} }
QPainter painter(this); QPainter painter(that);
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform); painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
if(effect=='l') { if(effect=='l') {
painter.drawPixmap(cur, 0, img); painter.drawPixmap(cur, 0, img);
@ -65,8 +68,13 @@ void EleScroll::timerEvent(QTimerEvent *) {
else cur+=curAdd; else cur+=curAdd;
} }
update(); update();
foreach(auto split, splits) split->update();
} else if(timerId!=0) { } else if(timerId!=0) {
killTimer(timerId); killTimer(timerId);
timerId = 0; timerId = 0;
} }
} }
void EleSplitScroll::paintEvent(QPaintEvent *) {
scroll->paint(this);
}

View File

@ -2,7 +2,7 @@
#define ELESCROLL_H #define ELESCROLL_H
#include <QWidget> #include <QWidget>
class EleSplitScroll;
class EleScroll : public QWidget { class EleScroll : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
@ -11,10 +11,21 @@ public:
QPixmap img; QPixmap img;
char effect = 0; char effect = 0;
int interval = 0, timerId = 0, cur = 0, end = 0, curAdd = 1; int interval = 0, timerId = 0, cur = 0, end = 0, curAdd = 1;
QList<EleSplitScroll*> splits;
void paint(QPaintDevice *);
protected: protected:
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
void timerEvent(QTimerEvent *) override; void timerEvent(QTimerEvent *) override;
}; };
class EleSplitScroll : public QWidget {
Q_OBJECT
public:
explicit EleSplitScroll(QWidget *parent, EleScroll *scroll) : QWidget{parent}, scroll(scroll) {};
protected:
void paintEvent(QPaintEvent *) override;
EleScroll *scroll;
};
#endif // ELESCROLL_H #endif // ELESCROLL_H

View File

@ -32,10 +32,10 @@ EleVideo::EleVideo(QString path, QWidget *parent) : QWidget{parent} {
// qDebug()<<"viSize"<<player->viSize; // qDebug()<<"viSize"<<player->viSize;
//} //}
void EleVideo::showEvent(QShowEvent *) { void EleVideo::showEvent(QShowEvent *) {
if(player!=nullptr) player->play(); if(player) player->play();
} }
void EleVideo::hideEvent(QHideEvent *) { void EleVideo::hideEvent(QHideEvent *) {
if(player!=nullptr) player->stop(); if(player) player->stop();
} }
void EleVideo::paintEvent(QPaintEvent *e) { void EleVideo::paintEvent(QPaintEvent *e) {

View File

@ -8,7 +8,7 @@
#include "elescroll.h" #include "elescroll.h"
#include "eletimer.h" #include "eletimer.h"
#include "elevideo.h" #include "elevideo.h"
#include "gqt.h" #include "gutil/qgui.h"
#include "posdlg.h" #include "posdlg.h"
#include <QFileInfo> #include <QFileInfo>
#include <QJsonArray> #include <QJsonArray>
@ -43,23 +43,24 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const QJsonOb
setPalette(plt); setPalette(plt);
connect(this, &PlayWin::sigSetVisible, this, &PlayWin::sltSetVisible); connect(this, &PlayWin::sigSetVisible, this, &PlayWin::sltSetVisible);
QJsonObject prog = aprog["task"].toObject(); const auto pageMaps = aprog["task"]["items"].toArray();
QJsonArray pageMaps = prog["items"].toArray();
int pageCnt = pageMaps.size(); int pageCnt = pageMaps.size();
EleBase ele; Page *page; EleBase ele; Page *page;
for(int p=0; p<pageCnt; p++) { for(int p=0; p<pageCnt; p++) {
QJsonObject pageMap = pageMaps[p].toObject()["_program"].toObject(); auto _program = pageMaps[p]["_program"].toObject();
QJsonArray layers = pageMap["layers"].toArray(); auto layers = _program["layers"].toArray();
if(layers.isEmpty()) continue; if(layers.isEmpty()) continue;
auto splitWidths = _program["splitWidths"].toArray();
page = new Page(this); page = new Page(this);
page->setGeometry(0, 0, width, height); page->setGeometry(0, 0, width, height);
page->setVisible(false); page->setVisible(false);
for(int ll=layers.size()-1; ll>=0; ll--) { for(int ll=layers.size()-1; ll>=0; ll--) {
QJsonObject layer = layers[ll].toObject(); QJsonObject layer = layers[ll].toObject();
auto repeat = layer["repeat"].toBool();
QJsonArray srcMaps = layer["sources"].toArray(); QJsonArray srcMaps = layer["sources"].toArray();
QJsonValue border = layer["border"]; QJsonValue border = layer["border"];
EleBorder *bdEle = nullptr; EleBorder *bdEle = nullptr;
int bdWidth = 0, startTime = 0xffff, endTime = 0; int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
if(! border.isNull()) { if(! border.isNull()) {
bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page); bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page);
bdWidth = bdEle->img.height(); bdWidth = bdEle->img.height();
@ -67,21 +68,22 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const QJsonOb
foreach(auto srcMap, srcMaps) { foreach(auto srcMap, srcMaps) {
ele.type = srcMap["_type"].toString(); ele.type = srcMap["_type"].toString();
if(ele.type.isEmpty()) continue; if(ele.type.isEmpty()) continue;
ele.timeSpan = srcMap["timeSpan"].toInt()*1000; auto timeSpan = srcMap["timeSpan"].toInt()*1000;
if(ele.timeSpan==0) continue; if(timeSpan==0) continue;
ele.x = srcMap["left"].toInt()+bdWidth; ele.x = srcMap["left"].toInt()+bdWidth;
ele.y = srcMap["top"].toInt()+bdWidth; ele.y = srcMap["top"].toInt()+bdWidth;
ele.w = srcMap["width"].toInt()-bdWidth-bdWidth; ele.w = srcMap["width"].toInt()-bdWidth-bdWidth;
ele.h = srcMap["height"].toInt()-bdWidth-bdWidth; ele.h = srcMap["height"].toInt()-bdWidth-bdWidth;
bool notAudio = ele.type!="Audio"; bool notAudio = ele.type!="Audio";
if((ele.w<=0 || ele.h<=0) && notAudio) continue; if((ele.w<=0 || ele.h<=0) && notAudio) continue;
ele.repeat = repeat;
ele.startTime = srcMap["playTime"].toInt()*1000; ele.startTime = srcMap["playTime"].toInt()*1000;
if(startTime > ele.startTime) startTime = ele.startTime; if(bdStart > ele.startTime) bdStart = ele.startTime;
ele.endTime = ele.startTime + ele.timeSpan; ele.endTime = ele.startTime + timeSpan;
if(endTime < ele.endTime) endTime = ele.endTime; if(bdEnd < ele.endTime) bdEnd = ele.endTime;
if(ele.endTime > page->timeSpan && notAudio) page->timeSpan = ele.endTime; if(page->timeSpan < ele.endTime && notAudio) page->timeSpan = ele.endTime;
ele.id = srcMap["id"].toString(); ele.id = srcMap["id"].toString();
ele.wgt = nullptr; ele.wgt = 0;
if(ele.type=="Image") { if(ele.type=="Image") {
if(srcMap["mime"].toString().endsWith("gif")) ele.wgt = new EleGif(dir+"/"+ele.id, page); if(srcMap["mime"].toString().endsWith("gif")) ele.wgt = new EleGif(dir+"/"+ele.id, page);
else ele.wgt = new EleImg(dir+"/"+ele.id, page); else ele.wgt = new EleImg(dir+"/"+ele.id, page);
@ -97,8 +99,36 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const QJsonOb
if(imgs.isEmpty()) continue; if(imgs.isEmpty()) continue;
if(imgs.size()==1 && imgs.at(0)["picDuration"].toInt()==0) ele.wgt = new EleScroll(page, dir+"/", imgs[0].toObject()); if(imgs.size()==1 && imgs.at(0)["picDuration"].toInt()==0) ele.wgt = new EleScroll(page, dir+"/", imgs[0].toObject());
else ele.wgt = new EleMultiPng(dir+"/", imgs, page); else ele.wgt = new EleMultiPng(dir+"/", imgs, page);
} else if(ele.type=="SplitText") {
QJsonArray imgs = srcMap["arrayPics"].toArray();
if(imgs.isEmpty()) continue;
ele.wgt = new QWidget(page);
ele.wgt->setGeometry(0, 0, width, height);
auto height = _program["height"].toInt();
if(imgs.size()==1 && imgs.at(0)["picDuration"].toInt()==0) {
auto wgt = new EleScroll(ele.wgt, dir+"/", imgs[0].toObject());
wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
for(int i=1; i<splitWidths.size(); i++) {
ele.x -= splitWidths[i-1].toInt();
ele.y += height;
auto split = new EleSplitScroll(ele.wgt, wgt);
split->setGeometry(ele.x, ele.y, splitWidths[i].toInt()-ele.x, ele.h);
wgt->splits.append(split);
}
} else {
auto wgt = new EleMultiPng(dir+"/", imgs, ele.wgt);
wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
for(int i=1; i<splitWidths.size(); i++) {
ele.x -= splitWidths[i-1].toInt();
ele.y += height;
auto split = new EleSplitPng(wgt, ele.wgt);
split->setGeometry(ele.x, ele.y, splitWidths[i].toInt()-ele.x, ele.h);
wgt->splits.append(split);
}
}
ele.w = 0;
} else if(ele.type=="DigitalClockNew") ele.wgt = new DigiClock(dir+"/", srcMap.toObject(), page); } else if(ele.type=="DigitalClockNew") ele.wgt = new DigiClock(dir+"/", srcMap.toObject(), page);
else if(ele.type=="AnalogClock") ele.wgt = new EleAnaClock(dir+"/"+ele.id, srcMap.toObject(), page); else if(ele.type=="AnalogClock") ele.wgt = new EleAnaClock(ele.w, ele.h, dir+"/"+ele.id, srcMap.toObject(), page);
else if(ele.type=="Video" || ele.type=="Audio") { else if(ele.type=="Video" || ele.type=="Audio") {
auto video = new EleVideo(dir+"/"+ele.id, page); auto video = new EleVideo(dir+"/"+ele.id, page);
auto vol = srcMap["vol"].toInt(100); auto vol = srcMap["vol"].toInt(100);
@ -111,27 +141,28 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const QJsonOb
} }
else if(ele.type=="Timer") ele.wgt = new EleTimer(srcMap.toObject(), page); else if(ele.type=="Timer") ele.wgt = new EleTimer(srcMap.toObject(), page);
else continue; else continue;
if(ele.wgt==nullptr) continue; if(ele.wgt==0) continue;
if(ele.startTime>0) ele.wgt->setVisible(false); if(ele.startTime>0) ele.wgt->setVisible(false);
ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h); if(ele.w) ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
page->eles.append(ele); page->eles.append(ele);
} }
if(bdEle!=nullptr && srcMaps.size()>0) { if(bdEle && ! srcMaps.isEmpty()) {
QJsonArray geometry = border["geometry"].toArray(); QJsonArray geometry = border["geometry"].toArray();
ele.x = geometry[0].toInt(); ele.x = geometry[0].toInt();
ele.y = geometry[1].toInt(); ele.y = geometry[1].toInt();
ele.w = geometry[2].toInt(); ele.w = geometry[2].toInt();
ele.h = geometry[3].toInt(); ele.h = geometry[3].toInt();
ele.startTime = startTime; ele.startTime = bdStart;
ele.endTime = endTime; ele.endTime = bdEnd;
ele.timeSpan = endTime - startTime;
ele.wgt = bdEle; ele.wgt = bdEle;
if(ele.startTime>0) ele.wgt->setVisible(false); if(ele.startTime>0) ele.wgt->setVisible(false);
ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h); ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
page->eles.append(ele); page->eles.append(ele);
} }
} }
if(page->timeSpan>0) pages.append(page); if(page->timeSpan==0) continue;
for(int i=0; i<page->eles.size(); i++) if(page->eles[i].repeat) page->eles[i].endTime = page->timeSpan;
pages.append(page);
} }
setVisible(true); setVisible(true);
if(! pages.isEmpty()) { if(! pages.isEmpty()) {
@ -165,7 +196,7 @@ void PlayWin::sltNext() {
if(cur+2 > pages.size()) cur = 0; if(cur+2 > pages.size()) cur = 0;
else cur++; else cur++;
Page* page = pages[cur]; Page* page = pages[cur];
if(timer!=nullptr) timer->inter = page->timeSpan; if(timer) timer->inter = page->timeSpan;
EleBase* ele; EleBase* ele;
for(int ee=0; ee<page->eles.size(); ee++) if((ele = &page->eles[ee])->startTime > 0 || ele->endTime < page->timeSpan) { for(int ee=0; ee<page->eles.size(); ee++) if((ele = &page->eles[ee])->startTime > 0 || ele->endTime < page->timeSpan) {
if(ele->startTime > 0) timerMap.insert(startTimer(ele->startTime), TimerValue(ele->wgt, true)); if(ele->startTime > 0) timerMap.insert(startTimer(ele->startTime), TimerValue(ele->wgt, true));
@ -173,22 +204,22 @@ void PlayWin::sltNext() {
timerMap.insert(startTimer(ele->endTime), TimerValue(ele->wgt, false)); timerMap.insert(startTimer(ele->endTime), TimerValue(ele->wgt, false));
} }
page->setVisible(true); page->setVisible(true);
} else if(timer!=nullptr) { } else if(timer) {
timer->stop(); timer->stop();
timer = nullptr; timer = 0;
} }
} }
void PlayWin::timerEvent(QTimerEvent *e){ void PlayWin::timerEvent(QTimerEvent *e){
int id = e->timerId(); int id = e->timerId();
killTimer(id); killTimer(id);
TimerValue value = timerMap[id]; TimerValue value = timerMap[id];
if(value.ele!=nullptr){ if(value.ele) {
timerMap.remove(id); timerMap.remove(id);
value.ele->setVisible(value.visible); value.ele->setVisible(value.visible);
} }
} }
void PlayWin::paintEvent(QPaintEvent *e){ void PlayWin::paintEvent(QPaintEvent *e){
if(timer==nullptr && isVisible() && ! pages.isEmpty()) { if(timer==0 && isVisible() && ! pages.isEmpty()) {
if(cur!=0) { if(cur!=0) {
pages[cur]->setVisible(false); pages[cur]->setVisible(false);
cur = 0; cur = 0;

View File

@ -10,7 +10,7 @@
class Page : public QWidget { class Page : public QWidget {
public: public:
explicit Page(QWidget *parent = nullptr); explicit Page(QWidget *parent = nullptr);
int timeSpan = 0; int timeSpan{0};
QVector<EleBase> eles; QVector<EleBase> eles;
}; };
@ -28,7 +28,7 @@ public:
static PlayWin *newIns(int width, int height, QString dir, const QJsonObject &prog, QWidget *parent = nullptr); static PlayWin *newIns(int width, int height, QString dir, const QJsonObject &prog, QWidget *parent = nullptr);
PlayWin(int x, int y, int width, int height, QString dir, const QJsonObject &prog, QWidget *parent = nullptr); PlayWin(int x, int y, int width, int height, QString dir, const QJsonObject &prog, QWidget *parent = nullptr);
SyncTimer* timer = nullptr; SyncTimer* timer = 0;
int cur = 0; int cur = 0;
QVector<Page*> pages; QVector<Page*> pages;
QMap<int,TimerValue> timerMap; QMap<int,TimerValue> timerMap;

View File

@ -1,12 +1,17 @@
#include "progpanel.h" #include "progpanel.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "tools.h" #include "tools.h"
#include "gutil/qgui.h"
#include "cfg.h"
#include "player/playwin.h" #include "player/playwin.h"
#include "tipdialog.h" #include "program/progcreatedlg.h"
#include "program/progeditorwin.h"
#include "program/copydirthread.h"
#include <QApplication> #include <QApplication>
#include <QHeaderView> #include <QHeaderView>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QStandardPaths>
#include <QProgressBar>
ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) { ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -28,10 +33,27 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
bnNew->setProperty("ssType", "progManageTool"); bnNew->setProperty("ssType", "progManageTool");
hBox->addWidget(bnNew); hBox->addWidget(bnNew);
connect(bnNew, &QPushButton::clicked, this, [this] { connect(bnNew, &QPushButton::clicked, this, [this] {
ProgCreateDlg dlg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"), 512, 512, "", this); ProgCreateDlg dlg("", 512, 256, "", "", this);
if(dlg.exec() != QDialog::Accepted) return; if(dlg.exec() != QDialog::Accepted) return;
if(checkIfNameRepeated(dlg.fdName->text())) return; if(checkIfNameRepeated(dlg.fdName->text())) return;
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), dlg.fdWidth->value(), dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), dlg.fdSplitWidth->value(), mProgTree, this); auto splitWidths = dlg.fdSplitWidths->text().split(" ", Qt::SkipEmptyParts);
QList<int> widths; int max = 0, ttl = 0;
foreach(auto splitWidth, splitWidths) {
int val = splitWidth.toInt();
if(val==0) continue;
if(max < val) max = val;
ttl += val;
widths.append(val);
}
auto width = dlg.fdWidth->value();
if(max) {
while(ttl < width) {
widths.append(max);
ttl += max;
}
if(ttl > width) widths.last() -= ttl - width;
}
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), width, dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, mProgTree, this);
item->save();//保存pro.json item->save();//保存pro.json
mProgTree->adjustCheckState(); mProgTree->adjustCheckState();
auto editor = new ProgEditorWin(item, gMainWin); auto editor = new ProgEditorWin(item, gMainWin);
@ -53,13 +75,60 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
connect(bnDelete, SIGNAL(clicked(bool)), this, SLOT(onDeleteClicked(bool))); connect(bnDelete, SIGNAL(clicked(bool)), this, SLOT(onDeleteClicked(bool)));
bnImport = new QPushButton(tr("Import")); bnImport = new QPushButton(tr("Import"));
bnImport->setFixedSize(QSize(88, 38)); bnImport->setFixedSize(88, 38);
bnImport->setProperty("ssType", "progManageTool"); bnImport->setProperty("ssType", "progManageTool");
hBox->addWidget(bnImport); hBox->addWidget(bnImport);
connect(bnImport, &QPushButton::clicked, this, [this] { connect(bnImport, &QPushButton::clicked, this, [this] {
auto dlg = new TipDialog(this, ENUM_IMPORT_DLG); QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
connect(dlg, SIGNAL(sigAcceptData(QString,QString)), this, SLOT(onImportProgram(QString,QString))); if(dir.isEmpty()) return;
dlg->exec(); QString 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!"));
return;
}
QStringList progDirs;
if(QFileInfo::exists(dir + "/pro.json")) progDirs.append(dir);
else {
QStringList subdirNames = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
foreach(QString subdirName, subdirNames) {
auto subdir = dir + "/" + subdirName;
if(! QFileInfo::exists(subdir + "/pro.json")) continue;
if(QFileInfo::exists(progsDir + "/" + subdirName)) {
auto res = QMessageBox::information(gMainWin, tr("Tip Info"), 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);
}
if(progDirs.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->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;
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
});
thread->start();
});
dlg.exec();
mProgTree->clear();
QStringList progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
foreach(QString pro_name, progNames) {
QFile jFile(mProgsDir + "/" + pro_name + "/pro.json");
if(! jFile.exists()) continue;
if(! jFile.open(QIODevice::ReadOnly)) continue;
auto data = jFile.readAll();
jFile.close();
m_pwPorgramItemList.append(new ProgItem(mProgsDir, QJsonDocument::fromJson(data).object(), mProgTree,this));
}
}); });
bnExport = new QPushButton(tr("Export")); bnExport = new QPushButton(tr("Export"));
@ -67,7 +136,36 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
bnExport->setEnabled(false); bnExport->setEnabled(false);
bnExport->setProperty("ssType", "progManageTool"); bnExport->setProperty("ssType", "progManageTool");
hBox->addWidget(bnExport); hBox->addWidget(bnExport);
connect(bnExport, SIGNAL(clicked(bool)), this, SLOT(onExportClicked(bool))); connect(bnExport, &QPushButton::clicked, this, [=] {
int cnt = mProgTree->topLevelItemCount();
QStringList progNames;
for(int i=0; i<cnt; i++) if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) progNames.append(static_cast<ProgItem*>(mProgTree->topLevelItem(i))->mName);
if(progNames.isEmpty()) return;
ProgPortDlg dlg(this, tr("Export"));
dlg.table->setRowCount(progNames.count());
for(int i=0; i<progNames.count(); i++) {
dlg.table->setItem(i, 0, new QTableWidgetItem(progNames[i]));
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);
if(dirDst.isEmpty()) return;
auto progsDir = programsDir();
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->dirDst = dirDst;
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
});
thread->start();
});
dlg.exec();
});
bnSend = new QPushButton(tr("Send")); bnSend = new QPushButton(tr("Send"));
bnSend->setFixedSize(QSize(88, 38)); bnSend->setFixedSize(QSize(88, 38));
@ -95,11 +193,8 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
QJsonObject prog = QJsonDocument::fromJson(value.toUtf8(), &jsErr).object(); QJsonObject prog = QJsonDocument::fromJson(value.toUtf8(), &jsErr).object();
if(jsErr.error) return; if(jsErr.error) return;
if(PlayWin::self!=nullptr) PlayWin::self->close(); if(PlayWin::self!=nullptr) PlayWin::self->close();
if(item->mSplitWidth==0) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog); if(item->mSplitWidths.isEmpty()) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog);
else { else PlayWin::self = PlayWin::newIns(item->mMaxWidth, item->mHeight * item->mSplitWidths.size(), dir, prog);
int cnt = (item->mWidth+item->mSplitWidth-1) / item->mSplitWidth;
PlayWin::self = PlayWin::newIns(item->mSplitWidth, item->mHeight*cnt, dir, prog);
}
break; break;
} }
} }
@ -111,7 +206,7 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
auto txtSearch = new QLineEdit(this); auto txtSearch = new QLineEdit(this);
txtSearch->setFixedSize(QSize(240, 36)); txtSearch->setFixedSize(QSize(240, 36));
QAction *search = new QAction(txtSearch); QAction *search = new QAction(txtSearch);
search->setIcon(QIcon(":/res/ProgramManager/bnSearch.png")); search->setIcon(QIcon(":/res/program/bnSearch.png"));
txtSearch->addAction(search, QLineEdit::LeadingPosition); txtSearch->addAction(search, QLineEdit::LeadingPosition);
txtSearch->setClearButtonEnabled(true); txtSearch->setClearButtonEnabled(true);
txtSearch->setStyleSheet("border: 2px solid #aaaaaa;"); txtSearch->setStyleSheet("border: 2px solid #aaaaaa;");
@ -252,10 +347,10 @@ bool ProgPanel::checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip){
} }
return false; return false;
} }
void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, int sp) void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &splitWidths, int max)
{ {
if(checkIfNameRepeated(name)) return; if(checkIfNameRepeated(name)) return;
auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, sp, mProgTree, this); auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, splitWidths, max, mProgTree, this);
item->save();//保存pro.json item->save();//保存pro.json
mProgTree->adjustCheckState(); mProgTree->adjustCheckState();
auto editor = new ProgEditorWin(item, gMainWin); auto editor = new ProgEditorWin(item, gMainWin);
@ -281,40 +376,6 @@ void ProgPanel::onDeleteClicked(bool){
} }
} }
void ProgPanel::onImportProgram(QString strImportDir, QString){
if(!strImportDir.isEmpty()){
mProgTree->clear();
//查找根路径下的项目文件夹查找文件夹下的节目pro.json信息包括节目名称大小像素备注等信息
if(!mProgsDir.isEmpty()) {
QDir root_dir(mProgsDir);
QStringList pro_list = root_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
foreach(QString pro_name, pro_list) {
QDir pro_dir(mProgsDir + MACRO_FENGEFU + pro_name);
if(pro_dir.exists("pro.json")) {
QFile fPro(pro_dir.path() + MACRO_FENGEFU+"pro.json");
fPro.open(QIODevice::ReadOnly);
QJsonDocument pro = QJsonDocument::fromJson(fPro.readAll());
fPro.close();
m_pwPorgramItemList.append(new ProgItem(mProgsDir, pro.object(), mProgTree,this));
}
}
}
}
}
void ProgPanel::onExportClicked(bool){
int cnt = mProgTree->topLevelItemCount();
QStringList selectProgramlist;
for(int i=0; i<cnt; i++) {
if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
QString string =static_cast<ProgItem*>(mProgTree->topLevelItem(i))->m_bnName->text();
selectProgramlist.append(string);
}
}
TipDialog *dlg = new TipDialog(this,ENUM_EXPORT_DLG,&selectProgramlist,0);
dlg->exec();
}
void ProgPanel::FilterProgram(const QString &strtemp){ void ProgPanel::FilterProgram(const QString &strtemp){
if (strtemp.isEmpty()) //显示全部 if (strtemp.isEmpty()) //显示全部
{ {
@ -358,3 +419,47 @@ void ProgPanel::FilterProgram(const QString &strtemp){
} }
ProgPortDlg::ProgPortDlg(QWidget *parent, QString title) : BaseDlg(parent) {
resize(600, 400);
auto vBox = new VBox(this);
auto hBox = new HBox(vBox);
hBox->setContentsMargins(0, 0, 0, 0);
hBox->addStretch();
auto fdTitle = new QLabel(title);
fdTitle->setStyleSheet("QLabel{font-size:16px;}");
hBox->addWidget(fdTitle);
hBox->addStretch();
bnClose = new QPushButton("X");
bnClose->setFixedSize(30, 24);
connect(bnClose, &QPushButton::clicked, this, &BaseDlg::close);
hBox->addWidget(bnClose);
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
table = new QTableWidget(0, 2);
table->setSelectionMode(QTableWidget::NoSelection);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setAlternatingRowColors(true);
table->horizontalHeader()->setBackgroundRole(QPalette::Window);
table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
table->horizontalHeader()->resizeSection(1, 200);
table->setHorizontalHeaderLabels({tr("Solution Name"), tr("Progress")});
vBox->addWidget(table);
hBox = new HBox(vBox);
hBox->addStretch();
bnOK = new QPushButton(title);
hBox->addWidget(bnOK);
auto bnDone = new QPushButton(tr("Done"));
connect(bnDone, &QPushButton::clicked, this, &BaseDlg::accept);
hBox->addWidget(bnDone);
}

View File

@ -1,31 +1,12 @@
#ifndef PROGPANEL_H #ifndef PROGPANEL_H
#define PROGPANEL_H #define PROGPANEL_H
#include <QWidget> #include "base/loqtreewidget.h"
#include <QStyleOption> #include "program/progitem.h"
#include <QPainter> #include "basedlg.h"
#include <QFile>
#include <QAction>
#include <QTreeWidgetItem>
#include <QCheckBox>
#include <QPushButton> #include <QPushButton>
#include <QDebug>
#include <QLabel>
#include <QDateTime>
#include <QList>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QStringList>
#include <QJsonObject>
#include <QJsonDocument>
#include <QSettings> #include <QSettings>
#include <QTableWidget>
#include "cfg.h"
#include <base/loqtreewidget.h>
#include <wProgramManager/progcreatedlg.h>
#include <wProgramManager/progeditorwin.h>
#include "wProgramManager/progitem.h"
class ProgPanel : public QWidget { class ProgPanel : public QWidget {
Q_OBJECT Q_OBJECT
@ -42,9 +23,7 @@ protected:
public slots: public slots:
void onEditClicked(bool f); void onEditClicked(bool f);
void onDeleteClicked(bool f); void onDeleteClicked(bool f);
void onExportClicked(bool f); void onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &, int);
void onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, int);
void onImportProgram(QString strImportDir,QString strTip1);
void FilterProgram(const QString &strtemp); void FilterProgram(const QString &strtemp);
private slots: private slots:
@ -60,4 +39,13 @@ private:
QPushButton *bnSend, *btnPlay; QPushButton *bnSend, *btnPlay;
}; };
class ProgPortDlg : public BaseDlg {
Q_OBJECT
public:
ProgPortDlg(QWidget *parent, QString title);
QTableWidget *table{0};
QPushButton *bnOK, *bnClose;
};
#endif // PROGPANEL_H #endif // PROGPANEL_H

View File

@ -0,0 +1,32 @@
#include "copydirthread.h"
#include <QDir>
CopyDirThread::CopyDirThread() {
connect(this, &CopyDirThread::finished, this, &CopyDirThread::deleteLater);
}
void CopyDirThread::run() {
for(; i<dirSrcs.size(); i++) {
copiedSize = 0;
copyDir(dirSrcs[i], dirDst+"/"+QFileInfo(dirSrcs[i]).fileName(), true);
}
}
bool CopyDirThread::copyDir(const QString &fromDir, const QString &toDir, bool coverIfExist) {
QDir targetDir(toDir);
if(! targetDir.exists() && ! targetDir.mkdir(".")) return false;
QFileInfoList fileInfos = QDir(fromDir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
foreach(QFileInfo fileInfo, fileInfos) {
if(fileInfo.isDir()) { //< 当为目录时递归的进行copy
if(! copyDir(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()), coverIfExist)) return false;
} else { //当允许覆盖操作时,将旧文件进行删除操作
if(coverIfExist && targetDir.exists(fileInfo.fileName())) targetDir.remove(fileInfo.fileName());
if(! QFile::copy(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()))) return false;
else {
copiedSize += fileInfo.size();
emit sigProgress(i, copiedSize);
}
}
}
return true;
}

View File

@ -0,0 +1,21 @@
#ifndef COPYDIRTHREAD_H
#define COPYDIRTHREAD_H
#include <QThread>
class CopyDirThread : public QThread {
Q_OBJECT
public:
CopyDirThread();
QStringList dirSrcs;
QString dirDst;
protected:
void run();
bool copyDir(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
int i{0};
int copiedSize = 0;
signals:
void sigProgress(int, int);
};
#endif // COPYDIRTHREAD_H

View File

@ -1,37 +1,32 @@
#include "eaclock.h" #include "eaclock.h"
#include "cfg.h" #include "cfg.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "gutil/qgui.h"
#include "tools.h" #include "tools.h"
#include "base/locolorselector.h"
#include <QtMath>
#include <QBoxLayout> #include <QBoxLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QPainter> #include <QPainter>
#include <QTimeZone> #include <QSpinBox>
#include <QFontComboBox>
#include <QToolButton>
eAClock::eAClock(EBase *multiWin) : EBase(multiWin) { EAClock::EAClock(EBase *multiWin) : EBase(multiWin) {
mType = EBase::AClock; mType = EBase::AClock;
m_attr.timeZoneId = QTimeZone::systemTimeZoneId(); m_attr.timeZone = QTimeZone::systemTimeZone();
m_attr.hourMark = 0;
m_attr.hourMarkSize = 5;
m_attr.hourMarkColor = Qt::green;
m_attr.minMark = 1;
m_attr.minMarkSize = 2;
m_attr.minMarkColor = Qt::yellow;
m_attr.hourHandColor = Qt::yellow; m_attr.hourHandColor = Qt::yellow;
m_attr.minHandColor = Qt::green; m_attr.minHandColor = Qt::green;
m_attr.secHandColor = Qt::red; m_attr.secHandColor = Qt::red;
m_attr.textFont = QFont("Arial", 9);
m_attr.textColor = Qt::red; m_attr.textColor = Qt::red;
m_attr.playDuration = 10;
m_attr.hasDialImg = false;
init();
} }
eAClock::eAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) { EAClock::EAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
mType = EBase::AClock; mType = EBase::AClock;
setBaseAttr(json); setBaseAttr(json);
auto widget = json["widget"]; auto widget = json["widget"];
m_attr.timeZoneId = QByteArray().append(widget["timeZone"].toString().toUtf8()); m_attr.timeZone = QTimeZone(widget["timeZone"].toString().toUtf8());
m_attr.hourMark = widget["hourMark"].toInt(); m_attr.hourMark = widget["hourMark"].toInt();
m_attr.hourMarkSize = widget["hourMarkSize"].toInt(); m_attr.hourMarkSize = widget["hourMarkSize"].toInt();
auto color = widget["hourMarkColor"]; auto color = widget["hourMarkColor"];
@ -53,6 +48,13 @@ eAClock::eAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
m_attr.textFont.setBold(widget["textFontBold"].toBool()); m_attr.textFont.setBold(widget["textFontBold"].toBool());
m_attr.textFont.setItalic(widget["textFontItalics"].toBool()); m_attr.textFont.setItalic(widget["textFontItalics"].toBool());
m_attr.textFont.setUnderline(widget["textFontUnderline"].toBool()); m_attr.textFont.setUnderline(widget["textFontUnderline"].toBool());
m_attr.hhLen = widget["hhLen"].toInt(m_attr.hhLen);
m_attr.mhLen = widget["mhLen"].toInt(m_attr.mhLen);
m_attr.shLen = widget["shLen"].toInt(m_attr.shLen);
m_attr.hhWidth = widget["hhWidth"].toInt(m_attr.hhWidth);
m_attr.mhWidth = widget["mhWidth"].toInt(m_attr.mhWidth);
m_attr.shWidth = widget["shWidth"].toInt(m_attr.shWidth);
m_attr.showSecHand = widget["showSecHand"].toBool(true);
m_attr.playDuration = json["play"]["duration"].toInt(); m_attr.playDuration = json["play"]["duration"].toInt();
m_attr.path = widget["path"].toString(); m_attr.path = widget["path"].toString();
m_attr.name = widget["name"].toString(); m_attr.name = widget["name"].toString();
@ -61,27 +63,24 @@ eAClock::eAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
if(! m_attr.hasDialImg) m_attr.selfCreateDialName = QString("%1%2%3%4%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight); if(! m_attr.hasDialImg) m_attr.selfCreateDialName = QString("%1%2%3%4%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
else dial_img.load(m_attr.path+"/"+m_attr.name); else dial_img.load(m_attr.path+"/"+m_attr.name);
init();
} }
void eAClock::init() { void EAClock::timerEvent(QTimerEvent *) {
connect(Tools::getInstance(), &Tools::sTick, this, [this]() { if(isVisible()) {
time = QDateTime::currentDateTime().toTimeZone(QTimeZone(m_attr.timeZoneId)).time(); cal();
update(); update();
}); } else if(timerId) {
killTimer(timerId);
timerId = 0;
} }
qreal eAClock::radiusHour() const {
qreal r = (rect().width() < rect().height() ? rect().width() : rect().height()) / 2;
return r - m_attr.hourMarkSize / 2;
} }
void EAClock::cal() {
qreal eAClock::radiusMin() const { auto time = QDateTime::currentDateTime().toTimeZone(m_attr.timeZone).time();
qreal r = (rect().width() < rect().height() ? rect().width() : rect().height()) / 2; sAngle = time.second() * 6;
return r - m_attr.minMarkSize / 2; mAngle = time.minute() * 6 + sAngle/60;
hAngle = time.hour() * 30 + mAngle/12;
} }
void EAClock::paintDial(QPainter *painter) {
void eAClock::paintDial(QPainter *painter) {
if(! m_attr.hasDialImg || dial_img.isNull()) { if(! m_attr.hasDialImg || dial_img.isNull()) {
auto inner = innerRect(); auto inner = innerRect();
qreal r = radius(); qreal r = radius();
@ -150,7 +149,7 @@ void eAClock::paintDial(QPainter *painter) {
} }
} }
void eAClock::drawMarkCircular(QPainter *painter, const QPointF &pos, const QColor &color, qreal diameter) { void EAClock::drawMarkCircular(QPainter *painter, const QPointF &pos, const QColor &color, qreal diameter) {
QPointF cp(pos.x(), pos.y()); QPointF cp(pos.x(), pos.y());
qreal r = diameter / 2; qreal r = diameter / 2;
painter->save(); painter->save();
@ -161,7 +160,7 @@ void eAClock::drawMarkCircular(QPainter *painter, const QPointF &pos, const QCol
painter->restore(); painter->restore();
} }
void eAClock::drawMarkRectangle(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, qreal angle) void EAClock::drawMarkRectangle(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, qreal angle)
{ {
QPointF cp(pos.x(), pos.y()); QPointF cp(pos.x(), pos.y());
QRectF rect(-len/2, -len/2, len, len); QRectF rect(-len/2, -len/2, len, len);
@ -175,7 +174,7 @@ void eAClock::drawMarkRectangle(QPainter *painter, const QPointF &pos, const QCo
painter->restore(); painter->restore();
} }
void eAClock::drawMarkNumber(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, int num) void EAClock::drawMarkNumber(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, int num)
{ {
QRectF rect(pos.x()-len/2, pos.y()-len/2, len, len); QRectF rect(pos.x()-len/2, pos.y()-len/2, len, len);
QFont font("Arial"); QFont font("Arial");
@ -192,61 +191,72 @@ void eAClock::drawMarkNumber(QPainter *painter, const QPointF &pos, const QColor
painter->restore(); painter->restore();
} }
void eAClock::drawHand(QPainter *painter, qreal angle, const QColor &color, qreal len, qreal base) { void EAClock::paintText(QPainter *painter){
auto inner = innerRect();
qreal cx = inner.width() / 2;
qreal cy = inner.height() / 2;
QPointF points[3] = {
QPointF(-base, 0),
QPointF( base, 0),
QPointF( 0, -len),
};
painter->save();
painter->setBrush(color);
painter->setPen(color);
painter->translate(cx, cy);
painter->rotate(angle);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawPolygon(points, 3);
painter->restore();
}
void eAClock::paintText(QPainter *painter){
if(m_attr.text.isNull() || m_attr.text.isEmpty()) return; if(m_attr.text.isNull() || m_attr.text.isEmpty()) return;
QRectF r(0, rect().height()/6, rect().width(), rect().height()/4); auto inner = innerRect();
QTextOption opt;
opt.setAlignment(Qt::AlignCenter);
painter->save();
painter->setPen(m_attr.textColor); painter->setPen(m_attr.textColor);
m_attr.textFont.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias); m_attr.textFont.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
painter->setFont(m_attr.textFont); painter->setFont(m_attr.textFont);
painter->drawText(r, m_attr.text, opt); painter->drawText(QRectF(0, inner.height()/6, inner.width(), inner.height()/4), m_attr.text, QTextOption(Qt::AlignCenter));
painter->restore();
} }
void eAClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { void EAClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
if(timerId==0) {
timerId = startTimer(500, Qt::PreciseTimer);
cal();
}
painter->save(); painter->save();
painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
auto inner = innerRect(); auto inner = innerRect();
auto sideLen = qMin(inner.width(), inner.height());
auto lineWidth = sideLen/128;
if(lineWidth < 1) lineWidth = 1;
painter->translate(inner.x(), inner.y()); painter->translate(inner.x(), inner.y());
paintDial(painter); paintDial(painter);
paintText(painter); paintText(painter);
drawHand(painter, time.hour() * 30.0, m_attr.hourHandColor, radius()/2, radius() / 20); painter->translate(inner.width() / 2, inner.height() / 2);
drawHand(painter, time.minute() * 6.0, m_attr.minHandColor, radius()*3/4, radius() / 30);
drawHand(painter, time.second() * 6.0, m_attr.secHandColor, radius(), radius() / 40); QPen pen(m_attr.hourHandColor, lineWidth);
pen.setJoinStyle(Qt::RoundJoin);
painter->setPen(pen);
painter->setBrush(pen.brush());
painter->rotate(hAngle);
QPointF poses[3]{{m_attr.hhWidth*sideLen/400, 0}, {0, m_attr.hhLen*sideLen/-200}};
poses[2].rx() = -poses[0].rx();
painter->drawPolygon(poses, 3);
pen.setColor(m_attr.minHandColor);
painter->setPen(pen);
painter->setBrush(pen.brush());
painter->rotate(mAngle-hAngle);
poses[0].rx() = m_attr.mhWidth*sideLen/400;
poses[1].ry() = m_attr.mhLen*sideLen/-200;
poses[2].rx() = -poses[0].rx();
painter->drawPolygon(poses, 3);
if(m_attr.showSecHand) {
pen.setColor(m_attr.secHandColor);
painter->setPen(pen);
painter->setBrush(pen.brush());
painter->rotate(sAngle-mAngle);
poses[0].rx() = m_attr.shWidth*sideLen/400;
poses[1].ry() = m_attr.shLen*sideLen/-200;
poses[2].rx() = -poses[0].rx();
painter->drawPolygon(poses, 3);
}
painter->restore(); painter->restore();
EBase::paint(painter, option, widget); EBase::paint(painter, option, widget);
} }
QWidget* eAClock::attrWgt() { QWidget* EAClock::attrWgt() {
auto wgtAttr = new QWidget(); auto wgtAttr = new QWidget();
auto vBox = new QVBoxLayout(wgtAttr); auto vBox = new VBox(wgtAttr);
vBox->setContentsMargins(6, 0, 6, 0); vBox->setContentsMargins(6, 0, 6, 0);
if(mMultiWin!=nullptr) vBox->setSpacing(3); if(mMultiWin) vBox->setSpacing(3);
addBaseAttrWgt(vBox); addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout(); auto hBox = new HBox(vBox);
hBox->addWidget(new QLabel(tr("Basic Properties"))); hBox->addWidget(new QLabel(tr("Basic Properties")));
auto line = new QFrame(); auto line = new QFrame();
@ -254,26 +264,24 @@ QWidget* eAClock::attrWgt() {
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1); hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
hBox->addSpacing(6); hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Time Zone"))); hBox->addWidget(new QLabel(tr("Time Zone")));
auto wTimeZone = new QComboBox(); auto wTimeZone = new QComboBox();
QList<QByteArray> ids = QTimeZone::availableTimeZoneIds(); QList<QByteArray> ids = QTimeZone::availableTimeZoneIds();
foreach(QByteArray id, ids) wTimeZone->addItem(QString::fromUtf8(id)); foreach(QByteArray id, ids) wTimeZone->addItem(QString::fromUtf8(id));
wTimeZone->setCurrentText(m_attr.timeZoneId); wTimeZone->setCurrentText(m_attr.timeZone.id());
connect(wTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) { connect(wTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) {
m_attr.timeZoneId = text.toUtf8(); m_attr.timeZone = QTimeZone(text.toUtf8());
update(); update();
}); });
hBox->addWidget(wTimeZone); hBox->addWidget(wTimeZone);
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
auto fdHasDialImg = new QCheckBox(tr("Custom Dial")); auto fdHasDialImg = new QCheckBox(tr("Custom Dial"));
fdHasDialImg->setChecked(m_attr.hasDialImg); fdHasDialImg->setChecked(m_attr.hasDialImg);
hBox->addWidget(fdHasDialImg); hBox->addWidget(fdHasDialImg);
@ -283,11 +291,10 @@ QWidget* eAClock::attrWgt() {
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1); hBox->addWidget(line, 1);
vBox->addLayout(hBox);
auto wgtDial = new QWidget(); auto wgtDial = new QWidget();
if(! m_attr.hasDialImg) wgtDial->setVisible(false); if(! m_attr.hasDialImg) wgtDial->setVisible(false);
hBox = new QHBoxLayout(wgtDial); hBox = new HBox(wgtDial);
hBox->setContentsMargins(0, 0, 0, 0); hBox->setContentsMargins(0, 0, 0, 0);
hBox->addSpacing(6); hBox->addSpacing(6);
auto fdDialImg = new QLineEdit(); auto fdDialImg = new QLineEdit();
@ -334,10 +341,10 @@ QWidget* eAClock::attrWgt() {
update(); update();
}); });
auto vbMarks = new QVBoxLayout(wgtMarks); auto vbMarks = new VBox(wgtMarks);
vbMarks->setContentsMargins(0, 0, 0, 0); vbMarks->setContentsMargins(0, 0, 0, 0);
hBox = new QHBoxLayout(); hBox = new HBox(vbMarks);
hBox->addSpacing(6); hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Hour Mark"))); hBox->addWidget(new QLabel(tr("Hour Mark")));
@ -370,9 +377,8 @@ QWidget* eAClock::attrWgt() {
hBox->addWidget(fdHourMarkColor); hBox->addWidget(fdHourMarkColor);
hBox->addStretch(); hBox->addStretch();
vbMarks->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vbMarks);
hBox->addSpacing(6); hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Min Mark"))); hBox->addWidget(new QLabel(tr("Min Mark")));
@ -404,40 +410,108 @@ QWidget* eAClock::attrWgt() {
hBox->addWidget(fdMinMarkColor); hBox->addWidget(fdMinMarkColor);
hBox->addStretch(); hBox->addStretch();
vbMarks->addLayout(hBox);
vBox->addWidget(wgtMarks); vBox->addWidget(wgtMarks);
hBox = new QHBoxLayout(); auto grid = new QGridLayout;
hBox->addSpacing(6); grid->setColumnStretch(4, 1);
hBox->addWidget(new QLabel(tr("Hand Color"))); vBox->addLayout(grid);
auto fdHourHandColor = new LoColorSelector(tr("H"), m_attr.hourHandColor); grid->addWidget(new QLabel(tr("Color")), 0, 1);
grid->addWidget(new QLabel(tr("Length")+" (%)"), 0, 2);
grid->addWidget(new QLabel(tr("Width")+" (%)"), 0, 3);
grid->addWidget(new QLabel(tr("Hour Hand")), 1, 0, Qt::AlignRight);
auto fdHourHandColor = new LoColorSelector("", m_attr.hourHandColor);
fdHourHandColor->setFixedWidth(30); fdHourHandColor->setFixedWidth(30);
connect(fdHourHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) { connect(fdHourHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
m_attr.hourHandColor = color; m_attr.hourHandColor = color;
update(); update();
}); });
hBox->addWidget(fdHourHandColor); grid->addWidget(fdHourHandColor, 1, 1);
auto fdMinHandColor = new LoColorSelector(tr("M"), m_attr.minHandColor); auto hhLen = new QSpinBox;
hhLen->setRange(0, 999);
hhLen->setValue(m_attr.hhLen);
connect(hhLen, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
m_attr.hhLen = value;
update();
});
grid->addWidget(hhLen, 1, 2);
auto hhWidth = new QSpinBox;
hhWidth->setRange(0, 999);
hhWidth->setValue(m_attr.hhWidth);
connect(hhWidth, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
m_attr.hhWidth = value;
update();
});
grid->addWidget(hhWidth, 1, 3);
grid->addWidget(new QLabel(tr("Min Hand")), 2, 0, Qt::AlignRight);
auto fdMinHandColor = new LoColorSelector("", m_attr.minHandColor);
fdMinHandColor->setFixedWidth(30); fdMinHandColor->setFixedWidth(30);
connect(fdMinHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) { connect(fdMinHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
m_attr.minHandColor = color; m_attr.minHandColor = color;
update(); update();
}); });
hBox->addWidget(fdMinHandColor); grid->addWidget(fdMinHandColor, 2, 1);
auto fdSecHandColor = new LoColorSelector(tr("S"), m_attr.secHandColor); auto mhLen = new QSpinBox;
mhLen->setRange(0, 999);
mhLen->setValue(m_attr.mhLen);
connect(mhLen, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
m_attr.mhLen = value;
update();
});
grid->addWidget(mhLen, 2, 2);
auto mhWidth = new QSpinBox;
mhWidth->setRange(0, 999);
mhWidth->setValue(m_attr.mhWidth);
connect(mhWidth, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
m_attr.mhWidth = value;
update();
});
grid->addWidget(mhWidth, 2, 3);
grid->addWidget(new QLabel(tr("Sec Hand")), 3, 0, Qt::AlignRight);
auto fdSecHandColor = new LoColorSelector("", m_attr.secHandColor);
fdSecHandColor->setFixedWidth(30); fdSecHandColor->setFixedWidth(30);
connect(fdSecHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) { connect(fdSecHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
m_attr.secHandColor = color; m_attr.secHandColor = color;
update(); update();
}); });
hBox->addWidget(fdSecHandColor); grid->addWidget(fdSecHandColor, 3, 1);
hBox->addStretch();
auto shLen = new QSpinBox;
shLen->setRange(0, 999);
shLen->setValue(m_attr.shLen);
connect(shLen, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
m_attr.shLen = value;
update();
});
grid->addWidget(shLen, 3, 2);
auto shWidth = new QSpinBox;
shWidth->setRange(0, 999);
shWidth->setValue(m_attr.shWidth);
connect(shWidth, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
m_attr.shWidth = value;
update();
});
grid->addWidget(shWidth, 3, 3);
auto fdShowSecHand = new QCheckBox(tr("Show"));
fdShowSecHand->setChecked(m_attr.showSecHand);
connect(fdShowSecHand, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.showSecHand = checked;
update();
});
grid->addWidget(fdShowSecHand, 3, 4);
vBox->addLayout(hBox);
line = new QFrame(); line = new QFrame();
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
@ -452,7 +526,7 @@ QWidget* eAClock::attrWgt() {
}); });
vBox->addWidget(fdText); vBox->addWidget(fdText);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
hBox->addSpacing(6); hBox->addSpacing(6);
auto fdFontFamily = new QFontComboBox(); auto fdFontFamily = new QFontComboBox();
@ -478,20 +552,14 @@ QWidget* eAClock::attrWgt() {
hBox->addWidget(fdFontSize); hBox->addWidget(fdFontSize);
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
hBox->addSpacing(6); hBox->addSpacing(6);
auto fdBold = new QPushButton(); auto fdBold = new QPushButton("B");
fdBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
fdBold->setFixedSize(30, 30); fdBold->setFixedSize(30, 30);
QIcon icon;
icon.addFile(":/res/ProgramManager/EditProgram/FontBold_u.png", QSize(), QIcon::Normal, QIcon::Off);
icon.addFile(":/res/ProgramManager/EditProgram/FontBold_s.png", QSize(), QIcon::Normal, QIcon::On);
fdBold->setIcon(icon);
fdBold->setIconSize(QSize(30, 30));
fdBold->setCheckable(true); fdBold->setCheckable(true);
fdBold->setFlat(true);
fdBold->setChecked(m_attr.textFont.bold()); fdBold->setChecked(m_attr.textFont.bold());
connect(fdBold, &QPushButton::toggled, this, [this](bool checked) { connect(fdBold, &QPushButton::toggled, this, [this](bool checked) {
m_attr.textFont.setBold(checked); m_attr.textFont.setBold(checked);
@ -499,15 +567,10 @@ QWidget* eAClock::attrWgt() {
}); });
hBox->addWidget(fdBold); hBox->addWidget(fdBold);
auto fdItalic = new QPushButton(); auto fdItalic = new QPushButton("I");
fdItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
fdItalic->setFixedSize(30, 30); fdItalic->setFixedSize(30, 30);
QIcon icon1;
icon1.addFile(":/res/ProgramManager/EditProgram/FontItalics_u.png", QSize(), QIcon::Normal, QIcon::Off);
icon1.addFile(":/res/ProgramManager/EditProgram/FontItalics_s.png", QSize(), QIcon::Normal, QIcon::On);
fdItalic->setIcon(icon1);
fdItalic->setIconSize(QSize(30, 30));
fdItalic->setCheckable(true); fdItalic->setCheckable(true);
fdItalic->setFlat(true);
fdItalic->setChecked(m_attr.textFont.italic()); fdItalic->setChecked(m_attr.textFont.italic());
connect(fdItalic, &QPushButton::toggled, this, [this](bool checked) { connect(fdItalic, &QPushButton::toggled, this, [this](bool checked) {
m_attr.textFont.setItalic(checked); m_attr.textFont.setItalic(checked);
@ -515,15 +578,10 @@ QWidget* eAClock::attrWgt() {
}); });
hBox->addWidget(fdItalic); hBox->addWidget(fdItalic);
auto fdUnderline = new QPushButton(); auto fdUnderline = new QPushButton("U");
fdUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
fdUnderline->setFixedSize(30, 30); fdUnderline->setFixedSize(30, 30);
QIcon icon2;
icon2.addFile(":/res/ProgramManager/EditProgram/FontUnderline_u.png", QSize(), QIcon::Normal, QIcon::Off);
icon2.addFile(":/res/ProgramManager/EditProgram/FontUnderline_s.png", QSize(), QIcon::Normal, QIcon::On);
fdUnderline->setIcon(icon2);
fdUnderline->setIconSize(QSize(30, 30));
fdUnderline->setCheckable(true); fdUnderline->setCheckable(true);
fdUnderline->setFlat(true);
fdUnderline->setChecked(m_attr.textFont.underline()); fdUnderline->setChecked(m_attr.textFont.underline());
connect(fdUnderline, &QPushButton::toggled, this, [this](bool checked) { connect(fdUnderline, &QPushButton::toggled, this, [this](bool checked) {
m_attr.textFont.setUnderline(checked); m_attr.textFont.setUnderline(checked);
@ -541,9 +599,8 @@ QWidget* eAClock::attrWgt() {
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
hBox->addWidget(new QLabel(tr("Play Properties"))); hBox->addWidget(new QLabel(tr("Play Properties")));
line = new QFrame(); line = new QFrame();
@ -551,9 +608,8 @@ QWidget* eAClock::attrWgt() {
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1); hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout(); hBox = new HBox(vBox);
hBox->addSpacing(6); hBox->addSpacing(6);
hBox->addWidget(new QLabel(tr("Play Duration"))); hBox->addWidget(new QLabel(tr("Play Duration")));
@ -568,12 +624,11 @@ QWidget* eAClock::attrWgt() {
hBox->addWidget(new QLabel(tr("s"))); hBox->addWidget(new QLabel(tr("s")));
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox);
vBox->addStretch(); vBox->addStretch();
return wgtAttr; return wgtAttr;
} }
bool eAClock::save(const QString &pRoot){ bool EAClock::save(const QString &pRoot){
if(m_attr.hasDialImg) { if(m_attr.hasDialImg) {
QString file0 = m_attr.path + PAGEDEL_SUFFIX + "/" + m_attr.name; QString file0 = m_attr.path + PAGEDEL_SUFFIX + "/" + m_attr.name;
QString file1 = m_attr.path + "/" + m_attr.name; QString file1 = m_attr.path + "/" + m_attr.name;
@ -595,45 +650,50 @@ bool eAClock::save(const QString &pRoot){
m_attr.selfCreateDialName = QString("%1%2%3%4%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight); m_attr.selfCreateDialName = QString("%1%2%3%4%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
m_attr.path = pRoot; m_attr.path = pRoot;
QRectF inner = innerRect(); QRectF inner = innerRect();
QPixmap *tempPixamp = new QPixmap(inner.width(), inner.height()); QImage img(inner.width(), inner.height(), QImage::Format_ARGB32);
tempPixamp->fill(Qt::transparent); img.fill(Qt::transparent);
QPainter painter; {
painter.begin(tempPixamp); QPainter painter(&img);
this->paintDial(&painter); paintDial(&painter);
this->paintText(&painter); paintText(&painter);
painter.end(); }
tempPixamp->save(pRoot+"/"+m_attr.selfCreateDialName, "PNG"); img.save(pRoot+"/"+m_attr.selfCreateDialName, "PNG");
delete tempPixamp;
//生成表盘背景图
return true; return true;
} }
QJsonObject eAClock::attrJson() const { QJsonObject EAClock::attrJson() const {
QJsonObject oRoot; QJsonObject json;
addBaseAttr(oRoot); addBaseAttr(json);
oRoot["elementType"] = "AClock"; json["elementType"] = "AClock";
QJsonObject oWidget; QJsonObject widget;
oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId); widget["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
oWidget["hourMark"] = m_attr.hourMark; widget["hourMark"] = m_attr.hourMark;
oWidget["hourMarkSize"] = m_attr.hourMarkSize; widget["hourMarkSize"] = m_attr.hourMarkSize;
oWidget["hourMarkColor"] = m_attr.hourMarkColor.name(); widget["hourMarkColor"] = m_attr.hourMarkColor.name();
oWidget["minMark"] = m_attr.minMark; widget["minMark"] = m_attr.minMark;
oWidget["minMarkSize"] = m_attr.minMarkSize; widget["minMarkSize"] = m_attr.minMarkSize;
oWidget["minMarkColor"] = m_attr.minMarkColor.name(); widget["minMarkColor"] = m_attr.minMarkColor.name();
oWidget["hourHandColor"] = m_attr.hourHandColor.name(); widget["hourHandColor"] = m_attr.hourHandColor.name();
oWidget["minHandColor"] = m_attr.minHandColor.name(); widget["minHandColor"] = m_attr.minHandColor.name();
oWidget["secHandColor"] = m_attr.secHandColor.name(); widget["secHandColor"] = m_attr.secHandColor.name();
oWidget["text"] = m_attr.text; widget["text"] = m_attr.text;
oWidget["textFontFamily"] = m_attr.textFont.family(); widget["textFontFamily"] = m_attr.textFont.family();
oWidget["textFontSize"] = m_attr.textFont.pointSize(); widget["textFontSize"] = m_attr.textFont.pointSize();
oWidget["textFontBold"] = m_attr.textFont.bold(); widget["textFontBold"] = m_attr.textFont.bold();
oWidget["textFontItalics"] = m_attr.textFont.italic(); widget["textFontItalics"] = m_attr.textFont.italic();
oWidget["textFontUnderline"] = m_attr.textFont.underline(); widget["textFontUnderline"] = m_attr.textFont.underline();
oWidget["textColor"] = m_attr.textColor.name(); widget["textColor"] = m_attr.textColor.name();
oWidget["path"] = m_attr.path; widget["hhLen"] = m_attr.hhLen;
oWidget["name"] = m_attr.name; widget["mhLen"] = m_attr.mhLen;
oWidget["selfCreateDialName"] = m_attr.selfCreateDialName; widget["shLen"] = m_attr.shLen;
oWidget["bCustomDial"] = m_attr.hasDialImg; widget["hhWidth"] = m_attr.hhWidth;
oRoot["widget"] = oWidget; widget["mhWidth"] = m_attr.mhWidth;
oRoot["play"] = QJsonObject{{"duration", m_attr.playDuration}}; widget["shWidth"] = m_attr.shWidth;
return oRoot; widget["showSecHand"] = m_attr.showSecHand;
widget["path"] = m_attr.path;
widget["name"] = m_attr.name;
widget["selfCreateDialName"] = m_attr.selfCreateDialName;
widget["bCustomDial"] = m_attr.hasDialImg;
json["widget"] = widget;
json["play"] = QJsonObject{{"duration", m_attr.playDuration}};
return json;
} }

67
LedOK/program/eaclock.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef EACLOCK_H
#define EACLOCK_H
#include "ebase.h"
#include <QTimeZone>
#include <QFont>
class EAClock : public EBase {
Q_OBJECT
public:
struct Data {
QTimeZone timeZone;
int hourMark{0};//时针
int hourMarkSize{5};//时针大小
QColor hourMarkColor{Qt::green};//时针颜色
int minMark{1};//分针
int minMarkSize{2};//分针大小
QColor minMarkColor{Qt::yellow};//分针颜色
QColor hourHandColor;//秒针
QColor minHandColor;//秒针大小
QColor secHandColor;//秒针颜色
int hhLen{50}, mhLen{75}, shLen{100};
int hhWidth{15}, mhWidth{10}, shWidth{5};
// r/2, r / 20
// r*3/4, r / 30
// r, r / 40
QString text;//标题
QFont textFont{"Arial", 9};//标题字体
QColor textColor;//标题字体颜色
int playDuration{10};//
QString path;
QString name;
QString selfCreateDialName;
bool hasDialImg{false};
bool showSecHand{true};
};
explicit EAClock(EBase *multiWin = nullptr);
explicit EAClock(const QJsonObject &json, EBase *multiWin = nullptr);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
int type() const override { return EBase::AClock; }
QWidget* attrWgt() override;
bool save(const QString &pRoot) override;
QJsonObject attrJson() const override;
protected:
void timerEvent(QTimerEvent *) override;
void drawMarkCircular (QPainter *painter, const QPointF &pos, const QColor &color, qreal diameter);
void drawMarkRectangle(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, qreal rotate);
void drawMarkNumber (QPainter *painter, const QPointF &pos, const QColor &color, qreal len, int num);
void paintDial(QPainter *painter);
void paintText(QPainter *painter);
qreal radius() const {
return (qMin(rect().width(), rect().height()) - qMax(m_attr.minMarkSize, m_attr.hourMarkSize)) / 2;
}
void cal();
Data m_attr;
QImage dial_img;
double hAngle, mAngle, sAngle;
int timerId{0};
};
#endif // EACLOCK_H

View File

@ -1,6 +1,7 @@
#include "eaudio.h" #include "eaudio.h"
#include "cfg.h" #include "cfg.h"
#include "tools.h" #include "tools.h"
#include "base/ffutil.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QDir> #include <QDir>
#include <QLabel> #include <QLabel>
@ -13,7 +14,7 @@
EAudio *EAudio::create(const QString &file, PageListItem *pageItem, EBase *multiWin) { EAudio *EAudio::create(const QString &file, PageListItem *pageItem, EBase *multiWin) {
int64_t dur; int64_t dur;
QString err = Tools::audioInfo(file.toUtf8(), &dur); QString err = audioInfo(file.toUtf8(), &dur);
if(! err.isEmpty()) { if(! err.isEmpty()) {
QMessageBox::critical(gMainWin, "Audio Error", err+"\n"+file); QMessageBox::critical(gMainWin, "Audio Error", err+"\n"+file);
return nullptr; return nullptr;
@ -79,7 +80,7 @@ bool EAudio::save(const QString &pageDir) {
void EAudio::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) { void EAudio::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform); painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
static auto img = QPixmap(":/res/ProgramManager/EditProgram/Audio.png"); static auto img = QPixmap(":/res/program/Audio.png");
auto inner = innerRect(); auto inner = innerRect();
if(inner.width() > inner.height()) inner.setWidth(inner.height()); if(inner.width() > inner.height()) inner.setWidth(inner.height());
else if(inner.height() > inner.width()) inner.setHeight(inner.width()); else if(inner.height() > inner.width()) inner.setHeight(inner.width());
@ -144,7 +145,7 @@ QWidget* EAudio::attrWgt() {
auto file = QFileDialog::getOpenFileName(gMainWin, tr("Select File"), gFileHome, EAudio::filters()); auto file = QFileDialog::getOpenFileName(gMainWin, tr("Select File"), gFileHome, EAudio::filters());
if(file.isEmpty()) return; if(file.isEmpty()) return;
int64_t dur; int64_t dur;
QString err = Tools::audioInfo(file.toUtf8(), &dur); QString err = audioInfo(file.toUtf8(), &dur);
if(! err.isEmpty()) { if(! err.isEmpty()) {
QMessageBox::critical(gMainWin, "Audio Error", err+"\n"+file); QMessageBox::critical(gMainWin, "Audio Error", err+"\n"+file);
return; return;

View File

@ -1,5 +1,5 @@
#include "ebase.h" #include "ebase.h"
#include "gqt.h" #include "gutil/qgui.h"
#include "tools.h" #include "tools.h"
#include <QDirIterator> #include <QDirIterator>
#include <QGraphicsScene> #include <QGraphicsScene>
@ -90,7 +90,7 @@ void EBase::addBaseAttr(QJsonObject &obj) const {
} }
QRectF EBase::innerRect() const { QRectF EBase::innerRect() const {
auto ele = mMultiWin!=nullptr ? mMultiWin : this; auto ele = mMultiWin ? mMultiWin : this;
int bdWidth = ele->bdImgIdx > -1 ? borderImgs[ele->bdImgIdx].img.height() : 0; int bdWidth = ele->bdImgIdx > -1 ? borderImgs[ele->bdImgIdx].img.height() : 0;
return QRectF(bdWidth, bdWidth, ele->mWidth-bdWidth-bdWidth, ele->mHeight-bdWidth-bdWidth); return QRectF(bdWidth, bdWidth, ele->mWidth-bdWidth-bdWidth, ele->mHeight-bdWidth-bdWidth);
} }
@ -520,7 +520,7 @@ void EBase::clearSnap() {
update(); update();
} }
void EBase::addBaseAttrWgt(QVBoxLayout *vBox) { void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
if(mMultiWin!=nullptr) return; if(mMultiWin!=nullptr) return;
auto hBox = new QHBoxLayout(); auto hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Area"))); hBox->addWidget(new QLabel(tr("Area")));
@ -648,10 +648,11 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
hBox->setSpacing(0); hBox->setSpacing(0);
hBox->addStretch(); hBox->addStretch();
auto borderFd = new QComboBox(); auto borderFd = new QComboBox;
borderFd->addItem(tr("None")); borderFd->addItem(tr("None"));
for(int i=0; i<borderImgs.size(); i++) borderFd->addItem(QIcon(borderImgs[i].img), QString::number(borderImgs[i].img.height()), borderImgs[i].name); for(int i=0; i<borderImgs.size(); i++) borderFd->addItem(QIcon(borderImgs[i].img), QString::number(borderImgs[i].img.height()), borderImgs[i].name);
borderFd->setIconSize(QSize(borderImgMaxWidth, borderImgMaxHeight)); borderFd->setIconSize(QSize(borderImgMaxWidth, borderImgMaxHeight));
if(bdImgIdx>-1) borderFd->setCurrentIndex(bdImgIdx+1);
connect(borderFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int idx){ connect(borderFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int idx){
bdImgIdx = idx-1; bdImgIdx = idx-1;
if(bdImgIdx==-1 && bdTimerId>0) { if(bdImgIdx==-1 && bdTimerId>0) {
@ -670,6 +671,7 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
borderEffFd->addItem(tr("Rotate"), "rotate"); borderEffFd->addItem(tr("Rotate"), "rotate");
borderEffFd->addItem(tr("Blink"), "blink"); borderEffFd->addItem(tr("Blink"), "blink");
borderEffFd->addItem(tr("None"), ""); borderEffFd->addItem(tr("None"), "");
if(bdImgIdx>-1) setCurrentData(borderEffFd, bdEff);
connect(borderEffFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, borderEffFd] { connect(borderEffFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, borderEffFd] {
bdEff = borderEffFd->currentData().toString(); bdEff = borderEffFd->currentData().toString();
if(bdTimerId>0) { if(bdTimerId>0) {
@ -687,7 +689,7 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
borderSpeedFd->addItem(tr("Slow"), 1); borderSpeedFd->addItem(tr("Slow"), 1);
borderSpeedFd->addItem(tr("Moderate"), 2); borderSpeedFd->addItem(tr("Moderate"), 2);
borderSpeedFd->addItem(tr("Fast"), 3); borderSpeedFd->addItem(tr("Fast"), 3);
borderSpeedFd->setCurrentIndex(1); if(bdImgIdx>-1) setCurrentData(borderSpeedFd, bdSpeed);
connect(borderSpeedFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, borderSpeedFd] { connect(borderSpeedFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, borderSpeedFd] {
bdSpeed = borderSpeedFd->currentData().toInt(); bdSpeed = borderSpeedFd->currentData().toInt();
if(bdTimerId>0) { if(bdTimerId>0) {
@ -700,10 +702,4 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox); vBox->addLayout(hBox);
if(bdImgIdx>-1) {
borderFd->setCurrentIndex(bdImgIdx+1);
select(borderEffFd, bdEff);
select(borderSpeedFd, bdSpeed);
}
} }

View File

@ -31,7 +31,7 @@ public:
virtual bool save(const QString &) {return true;} virtual bool save(const QString &) {return true;}
virtual QWidget* attrWgt() = 0; virtual QWidget* attrWgt() = 0;
void addBaseAttrWgt(QVBoxLayout *vBox); void addBaseAttrWgt(QBoxLayout *vBox);
inline void setSize(qreal width, qreal height) { inline void setSize(qreal width, qreal height) {
prepareGeometryChange(); prepareGeometryChange();
mWidth = width; mWidth = width;

View File

@ -7,8 +7,9 @@
#include <QFontComboBox> #include <QFontComboBox>
#include <QLabel> #include <QLabel>
#include <QSpinBox> #include <QSpinBox>
#include <QToolButton>
eDClock::eDClock(EBase *multiWin) : EBase(multiWin) { EDClock::EDClock(EBase *multiWin) : EBase(multiWin) {
mType = EBase::DClock; mType = EBase::DClock;
m_attr.timeZoneId = QTimeZone::systemTimeZoneId(); m_attr.timeZoneId = QTimeZone::systemTimeZoneId();
m_attr.font = QFont("Arial", 9); m_attr.font = QFont("Arial", 9);
@ -29,7 +30,7 @@ eDClock::eDClock(EBase *multiWin) : EBase(multiWin) {
init(); init();
} }
eDClock::eDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) { EDClock::EDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
mType = EBase::DClock; mType = EBase::DClock;
setBaseAttr(json); setBaseAttr(json);
auto widget = json["widget"]; auto widget = json["widget"];
@ -58,14 +59,14 @@ eDClock::eDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
init(); init();
} }
void eDClock::init() { void EDClock::init() {
connect(Tools::getInstance(), &Tools::sTick, this, [this]() { connect(Tools::getInstance(), &Tools::sTick, this, [this]() {
datetime = QDateTime::currentDateTime().toTimeZone(QTimeZone(m_attr.timeZoneId)); datetime = QDateTime::currentDateTime().toTimeZone(QTimeZone(m_attr.timeZoneId));
update(); update();
}); });
} }
void eDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
QString text; QString text;
QDate date = datetime.date(); QDate date = datetime.date();
QTime time = datetime.time(); QTime time = datetime.time();
@ -133,7 +134,7 @@ void eDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
EBase::paint(painter, option, widget); EBase::paint(painter, option, widget);
} }
QWidget* eDClock::attrWgt() { QWidget* EDClock::attrWgt() {
auto wgtAttr = new QWidget(); auto wgtAttr = new QWidget();
auto vBox = new QVBoxLayout(wgtAttr); auto vBox = new QVBoxLayout(wgtAttr);
vBox->setContentsMargins(6, 0, 6, 0); vBox->setContentsMargins(6, 0, 6, 0);
@ -378,15 +379,10 @@ QWidget* eDClock::attrWgt() {
hBox = new QHBoxLayout(); hBox = new QHBoxLayout();
hBox->addSpacing(6); hBox->addSpacing(6);
auto fdBold = new QPushButton(); auto fdBold = new QPushButton("B");
fdBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
fdBold->setFixedSize(30, 30); fdBold->setFixedSize(30, 30);
QIcon icon;
icon.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontBold_u.png"), QSize(), QIcon::Normal, QIcon::Off);
icon.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontBold_s.png"), QSize(), QIcon::Normal, QIcon::On);
fdBold->setIcon(icon);
fdBold->setIconSize(QSize(30, 30));
fdBold->setCheckable(true); fdBold->setCheckable(true);
fdBold->setFlat(true);
fdBold->setChecked(m_attr.font.bold()); fdBold->setChecked(m_attr.font.bold());
connect(fdBold, &QCheckBox::toggled, this, [this](bool checked) { connect(fdBold, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.font.setBold(checked); m_attr.font.setBold(checked);
@ -394,15 +390,10 @@ QWidget* eDClock::attrWgt() {
}); });
hBox->addWidget(fdBold); hBox->addWidget(fdBold);
auto fdItalic = new QPushButton(); auto fdItalic = new QPushButton("I");
fdItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
fdItalic->setFixedSize(30, 30); fdItalic->setFixedSize(30, 30);
QIcon icon1;
icon1.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontItalics_u.png"), QSize(), QIcon::Normal, QIcon::Off);
icon1.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontItalics_s.png"), QSize(), QIcon::Normal, QIcon::On);
fdItalic->setIcon(icon1);
fdItalic->setIconSize(QSize(30, 30));
fdItalic->setCheckable(true); fdItalic->setCheckable(true);
fdItalic->setFlat(true);
fdItalic->setChecked(m_attr.font.italic()); fdItalic->setChecked(m_attr.font.italic());
connect(fdItalic, &QCheckBox::toggled, this, [this](bool checked) { connect(fdItalic, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.font.setItalic(checked); m_attr.font.setItalic(checked);
@ -410,21 +401,16 @@ QWidget* eDClock::attrWgt() {
}); });
hBox->addWidget(fdItalic); hBox->addWidget(fdItalic);
auto fdUnderline = new QPushButton(); auto fdFontUnderline = new QPushButton("U");
fdUnderline->setFixedSize(30, 30); fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
QIcon icon2; fdFontUnderline->setFixedSize(30, 30);
icon2.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontUnderline_u.png"), QSize(), QIcon::Normal, QIcon::Off); fdFontUnderline->setCheckable(true);
icon2.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontUnderline_s.png"), QSize(), QIcon::Normal, QIcon::On); fdFontUnderline->setChecked(m_attr.font.underline());
fdUnderline->setIcon(icon2); connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
fdUnderline->setIconSize(QSize(30, 30));
fdUnderline->setCheckable(true);
fdUnderline->setFlat(true);
fdUnderline->setChecked(m_attr.font.underline());
connect(fdUnderline, &QCheckBox::toggled, this, [this](bool checked) {
m_attr.font.setUnderline(checked); m_attr.font.setUnderline(checked);
update(); update();
}); });
hBox->addWidget(fdUnderline); hBox->addWidget(fdFontUnderline);
auto fdColor = new LoColorSelector("T", m_attr.textColor); auto fdColor = new LoColorSelector("T", m_attr.textColor);
fdColor->setFixedWidth(30); fdColor->setFixedWidth(30);
@ -467,7 +453,7 @@ QWidget* eDClock::attrWgt() {
return wgtAttr; return wgtAttr;
} }
QJsonObject eDClock::attrJson() const{ QJsonObject EDClock::attrJson() const{
QJsonObject oWidget; QJsonObject oWidget;
oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId); oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId);
oWidget["year"] = m_attr.year; oWidget["year"] = m_attr.year;

View File

@ -9,7 +9,7 @@
#include <QTimer> #include <QTimer>
#include "ebase.h" #include "ebase.h"
class eDClock : public EBase { class EDClock : public EBase {
Q_OBJECT Q_OBJECT
public: public:
struct Data { struct Data {
@ -32,8 +32,8 @@ public:
int playDuration = 10; int playDuration = 10;
}; };
explicit eDClock(EBase *multiWin = nullptr); explicit EDClock(EBase *multiWin = nullptr);
explicit eDClock(const QJsonObject &json, EBase *multiWin = nullptr); explicit EDClock(const QJsonObject &json, EBase *multiWin = nullptr);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
int type() const override { return EBase::DClock; } int type() const override { return EBase::DClock; }

View File

@ -13,6 +13,7 @@
#include <QSpinBox> #include <QSpinBox>
#include <QTextOption> #include <QTextOption>
#include <QJsonArray> #include <QJsonArray>
#include <QToolButton>
QJsonObject EEnviron::genProg(const QJsonObject &json, const QString &dstDir, const QString &srcPageDir) { QJsonObject EEnviron::genProg(const QJsonObject &json, const QString &dstDir, const QString &srcPageDir) {
auto widget = json["widget"]; auto widget = json["widget"];
@ -602,54 +603,41 @@ QWidget* EEnviron::attrWgt() {
hBox = new QHBoxLayout(); hBox = new QHBoxLayout();
hBox->addSpacing(6); hBox->addSpacing(6);
auto fdBold = new QPushButton(); auto fdFontBold = new QPushButton("B");
fdBold->setFixedSize(QSize(30, 30)); fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
fdBold->setIconSize(QSize(30, 30)); fdFontBold->setFixedSize(30, 30);
QIcon icon(":/res/ProgramManager/EditProgram/FontBold_u.png"); fdFontBold->setCheckable(true);
icon.addFile(":/res/ProgramManager/EditProgram/FontBold_s.png", QSize(), QIcon::Normal, QIcon::On); fdFontBold->setChecked(m_attr.font.bold());
fdBold->setIcon(icon); connect(fdFontBold, &QPushButton::toggled, this, [this](bool checked) {
fdBold->setCheckable(true);
fdBold->setFlat(true);
fdBold->setChecked(m_attr.font.bold());
connect(fdBold, &QPushButton::toggled, this, [this](bool checked) {
m_attr.font.setBold(checked); m_attr.font.setBold(checked);
calAttr(); calAttr();
update(); update();
}); });
hBox->addWidget(fdBold); hBox->addWidget(fdFontBold);
auto fdItalic = new QPushButton(); auto fdFontItalic = new QPushButton("I");
fdItalic->setFixedSize(QSize(30, 30)); fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
fdItalic->setIconSize(QSize(30, 30)); fdFontItalic->setFixedSize(30, 30);
QIcon icon1(":/res/ProgramManager/EditProgram/FontItalics_u.png"); fdFontItalic->setCheckable(true);
icon1.addFile(":/res/ProgramManager/EditProgram/FontItalics_s.png", QSize(), QIcon::Normal, QIcon::On); fdFontItalic->setChecked(m_attr.font.italic());
fdItalic->setIcon(icon1); connect(fdFontItalic, &QPushButton::toggled, this, [this](bool checked) {
fdItalic->setCheckable(true);
fdItalic->setFlat(true);
fdItalic->setChecked(m_attr.font.italic());
connect(fdItalic, &QPushButton::toggled, this, [this](bool checked) {
m_attr.font.setItalic(checked); m_attr.font.setItalic(checked);
calAttr(); calAttr();
update(); update();
}); });
hBox->addWidget(fdItalic); hBox->addWidget(fdFontItalic);
auto fdUnderline = new QPushButton(); auto fdFontUnderline = new QPushButton("U");
fdUnderline->setFixedSize(QSize(30, 30)); fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
fdUnderline->setIconSize(QSize(30, 30)); fdFontUnderline->setFixedSize(30, 30);
QIcon icon2(":/res/ProgramManager/EditProgram/FontUnderline_u.png"); fdFontUnderline->setCheckable(true);
icon2.addFile(":/res/ProgramManager/EditProgram/FontUnderline_s.png", QSize(), QIcon::Normal, QIcon::On); fdFontUnderline->setChecked(m_attr.font.underline());
fdUnderline->setIcon(icon2); connect(fdFontUnderline, &QPushButton::toggled, this, [this](bool checked) {
fdUnderline->setCheckable(true);
fdUnderline->setFlat(true);
fdUnderline->setChecked(m_attr.font.underline());
connect(fdUnderline, &QPushButton::toggled, this, [this](bool checked) {
m_attr.font.setUnderline(checked); m_attr.font.setUnderline(checked);
calAttr(); calAttr();
update(); update();
}); });
hBox->addWidget(fdUnderline); hBox->addWidget(fdFontUnderline);
auto fdColor = new LoColorSelector("T", m_attr.textColor); auto fdColor = new LoColorSelector("T", m_attr.textColor);
fdColor->setFixedWidth(30); fdColor->setFixedWidth(30);

View File

@ -34,8 +34,8 @@ EMultiWin::EMultiWin(const QJsonObject &json, PageListItem *pageItem) : mPageIte
else if(type=="Photo") inner = EPhoto::create(element.toObject(), pageItem, this); else if(type=="Photo") inner = EPhoto::create(element.toObject(), pageItem, this);
else if(type=="Gif") inner = EGif::create(element.toObject(), pageItem, this); else if(type=="Gif") inner = EGif::create(element.toObject(), pageItem, this);
else if(type=="Movie") inner = EVideo::create(element.toObject(), pageItem, this); else if(type=="Movie") inner = EVideo::create(element.toObject(), pageItem, this);
else if(type=="DClock") inner = new eDClock(element.toObject(), this); else if(type=="DClock") inner = new EDClock(element.toObject(), this);
else if(type=="AClock") inner = new eAClock(element.toObject(), this); else if(type=="AClock") inner = new EAClock(element.toObject(), this);
else if(type=="Temp") inner = new EEnviron(element.toObject(), this); else if(type=="Temp") inner = new EEnviron(element.toObject(), this);
else if(type=="Web") inner = new EWeb(element.toObject(), this); else if(type=="Web") inner = new EWeb(element.toObject(), this);
else if(type=="Timer") inner = new ETimer(element.toObject(), this); else if(type=="Timer") inner = new ETimer(element.toObject(), this);
@ -123,16 +123,16 @@ QWidget* EMultiWin::attrWgt() {
auto hBox = new QHBoxLayout(); auto hBox = new QHBoxLayout();
auto btnAdd = new QPushButton(); auto btnAdd = new QPushButton();
btnAdd->setIcon(QIcon(":/res/ProgramManager/EditProgram/Add.png")); btnAdd->setIcon(QIcon(":/res/program/Add.png"));
btnAdd->setProperty("style","multiTool"); btnAdd->setProperty("style","multiTool");
auto menu = new QMenu(); auto menu = new QMenu();
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Text.png"), tr("Text"))->setData(EBase::Text); menu->addAction(QIcon(":/res/program/Text.png"), tr("Text"))->setData(EBase::Text);
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Photo.png"), tr("Photo"))->setData(EBase::Photo); menu->addAction(QIcon(":/res/program/Photo.png"), tr("Photo"))->setData(EBase::Photo);
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Movie.png"), tr("Video"))->setData(EBase::Video); menu->addAction(QIcon(":/res/program/Movie.png"), tr("Video"))->setData(EBase::Video);
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Gif.png"), tr("Gif"))->setData(EBase::Gif); menu->addAction(QIcon(":/res/program/Gif.png"), tr("Gif"))->setData(EBase::Gif);
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/DClock.png"), tr("DClock"))->setData(EBase::DClock); menu->addAction(QIcon(":/res/program/DClock.png"), tr("DClock"))->setData(EBase::DClock);
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/AClock.png"), tr("AClock"))->setData(EBase::AClock); menu->addAction(QIcon(":/res/program/AClock.png"), tr("AClock"))->setData(EBase::AClock);
auto listWgt = new MListWidget(); auto listWgt = new MListWidget();
connect(menu, &QMenu::triggered, this, [this, listWgt](QAction *act) { connect(menu, &QMenu::triggered, this, [this, listWgt](QAction *act) {
int type = act->data().toInt(); int type = act->data().toInt();
@ -148,7 +148,7 @@ QWidget* EMultiWin::attrWgt() {
ePhoto->setZValue(order++); ePhoto->setZValue(order++);
ePhoto->setFlag(QGraphicsItem::ItemStacksBehindParent); ePhoto->setFlag(QGraphicsItem::ItemStacksBehindParent);
inners.append(ePhoto); inners.append(ePhoto);
auto item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Photo.png"), tr("Photo")+" "+ePhoto->mName); auto item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+ePhoto->mName);
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(ePhoto))); item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(ePhoto)));
listWgt->addItem(item); listWgt->addItem(item);
if(i==files.count()-1) { if(i==files.count()-1) {
@ -165,7 +165,7 @@ QWidget* EMultiWin::attrWgt() {
eGif->setZValue(order++); eGif->setZValue(order++);
eGif->setFlag(QGraphicsItem::ItemStacksBehindParent); eGif->setFlag(QGraphicsItem::ItemStacksBehindParent);
inners.append(eGif); inners.append(eGif);
auto item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Gif.png"), tr("Gif")+" "+eGif->mName); auto item = new QListWidgetItem(QIcon(":/res/program/Gif.png"), tr("Gif")+" "+eGif->mName);
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(eGif))); item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(eGif)));
listWgt->addItem(item); listWgt->addItem(item);
if(i == files.count()-1) { if(i == files.count()-1) {
@ -178,25 +178,25 @@ QWidget* EMultiWin::attrWgt() {
if(! file.isEmpty()) { if(! file.isEmpty()) {
auto eVideo = EVideo::create(file, mPageItem, this); auto eVideo = EVideo::create(file, mPageItem, this);
if(eVideo==nullptr) return; if(eVideo==nullptr) return;
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Movie.png"), tr("Video")+" "+eVideo->mRawName); item = new QListWidgetItem(QIcon(":/res/program/Movie.png"), tr("Video")+" "+eVideo->mRawName);
gFileHome = eVideo->mRawDir; gFileHome = eVideo->mRawDir;
ele = eVideo; ele = eVideo;
} }
} else if(type==EBase::Text) { } else if(type==EBase::Text) {
ele = new EText(this); ele = new EText(this);
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Text.png"), tr("Text")); item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
} else if(type==EBase::DClock) { } else if(type==EBase::DClock) {
ele = new eDClock(this); ele = new EDClock(this);
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/DClock.png"), tr("DClock")); item = new QListWidgetItem(QIcon(":/res/program/DClock.png"), tr("DClock"));
} else if(type==EBase::AClock) { } else if(type==EBase::AClock) {
ele = new eAClock(this); ele = new EAClock(this);
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/AClock.png"), tr("AClock")); item = new QListWidgetItem(QIcon(":/res/program/AClock.png"), tr("AClock"));
} else if(type==EBase::Environ) { } else if(type==EBase::Environ) {
ele = new EEnviron(this); ele = new EEnviron(this);
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Temp.png"), tr("Environment")); item = new QListWidgetItem(QIcon(":/res/program/Temp.png"), tr("Environment"));
} else if(type==EBase::Timer) { } else if(type==EBase::Timer) {
ele = new ETimer(this); ele = new ETimer(this);
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Timer.png"), tr("Timer")); item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
} }
if(ele != nullptr) { if(ele != nullptr) {
ele->setSize(mWidth, mHeight); ele->setSize(mWidth, mHeight);
@ -212,7 +212,7 @@ QWidget* EMultiWin::attrWgt() {
hBox->addWidget(btnAdd); hBox->addWidget(btnAdd);
auto btnDel = new QPushButton(); auto btnDel = new QPushButton();
btnDel->setIcon(QIcon(":/res/ProgramManager/EditProgram/Delete.png")); btnDel->setIcon(QIcon(":/res/program/Delete.png"));
btnDel->setProperty("style","multiTool"); btnDel->setProperty("style","multiTool");
connect(btnDel, &QPushButton::clicked, this, [this, listWgt] { connect(btnDel, &QPushButton::clicked, this, [this, listWgt] {
auto row = listWgt->currentRow(); auto row = listWgt->currentRow();
@ -229,7 +229,7 @@ QWidget* EMultiWin::attrWgt() {
hBox->addWidget(btnDel); hBox->addWidget(btnDel);
auto btnClean = new QPushButton(); auto btnClean = new QPushButton();
btnClean->setIcon(QIcon(":/res/ProgramManager/EditProgram/Clean.png")); btnClean->setIcon(QIcon(":/res/program/Clean.png"));
btnClean->setProperty("style","multiTool"); btnClean->setProperty("style","multiTool");
connect(btnClean, &QPushButton::clicked, this, [this, listWgt] { connect(btnClean, &QPushButton::clicked, this, [this, listWgt] {
listWgt->clear(); listWgt->clear();
@ -239,7 +239,7 @@ QWidget* EMultiWin::attrWgt() {
hBox->addWidget(btnClean); hBox->addWidget(btnClean);
auto btnGoUp = new QPushButton(); auto btnGoUp = new QPushButton();
btnGoUp->setIcon(QIcon(":/res/ProgramManager/EditProgram/GoUp.png")); btnGoUp->setIcon(QIcon(":/res/program/GoUp.png"));
btnGoUp->setProperty("style","multiTool"); btnGoUp->setProperty("style","multiTool");
connect(btnGoUp, &QPushButton::clicked, this, [this, listWgt] { connect(btnGoUp, &QPushButton::clicked, this, [this, listWgt] {
int row = listWgt->currentRow(); int row = listWgt->currentRow();
@ -253,7 +253,7 @@ QWidget* EMultiWin::attrWgt() {
hBox->addWidget(btnGoUp); hBox->addWidget(btnGoUp);
auto btnGoDown = new QPushButton(); auto btnGoDown = new QPushButton();
btnGoDown->setIcon(QIcon(":/res/ProgramManager/EditProgram/GoDown.png")); btnGoDown->setIcon(QIcon(":/res/program/GoDown.png"));
btnGoDown->setProperty("style","multiTool"); btnGoDown->setProperty("style","multiTool");
connect(btnGoDown, &QPushButton::clicked, this, [this, listWgt] { connect(btnGoDown, &QPushButton::clicked, this, [this, listWgt] {
int row = listWgt->currentRow(); int row = listWgt->currentRow();
@ -273,14 +273,14 @@ QWidget* EMultiWin::attrWgt() {
foreach(auto inner, inners) { foreach(auto inner, inners) {
QListWidgetItem *item = nullptr; QListWidgetItem *item = nullptr;
int type = inner->type(); int type = inner->type();
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Text.png"), tr("Text")); if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
else if(type==EBase::Photo) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Photo.png"), tr("Photo")+" "+static_cast<EPhoto*>(inner)->mName); else if(type==EBase::Photo) item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+static_cast<EPhoto*>(inner)->mName);
else if(type==EBase::Video) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Movie.png"), tr("Video")+" "+static_cast<EVideo*>(inner)->mRawName); else if(type==EBase::Video) item = new QListWidgetItem(QIcon(":/res/program/Movie.png"), tr("Video")+" "+static_cast<EVideo*>(inner)->mRawName);
else if(type==EBase::Gif) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Gif.png"), tr("Gif")+" "+static_cast<EGif*>(inner)->mName); else if(type==EBase::Gif) item = new QListWidgetItem(QIcon(":/res/program/Gif.png"), tr("Gif")+" "+static_cast<EGif*>(inner)->mName);
else if(type==EBase::DClock) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/DClock.png"), tr("DClock")); else if(type==EBase::DClock) item = new QListWidgetItem(QIcon(":/res/program/DClock.png"), tr("DClock"));
else if(type==EBase::AClock) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/AClock.png"), tr("AClock")); else if(type==EBase::AClock) item = new QListWidgetItem(QIcon(":/res/program/AClock.png"), tr("AClock"));
else if(type==EBase::Environ) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Temp.png"), tr("Environment")); else if(type==EBase::Environ) item = new QListWidgetItem(QIcon(":/res/program/Temp.png"), tr("Environment"));
else if(type==EBase::Timer) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Timer.png"), tr("Timer")); else if(type==EBase::Timer) item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
if(item != nullptr) { if(item != nullptr) {
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(inner))); item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(inner)));
listWgt->addItem(item); listWgt->addItem(item);

View File

@ -76,14 +76,14 @@ void EPhoto::loadFiles() {
if(! img.isNull()) return; if(! img.isNull()) return;
if(! QFileInfo::exists(mDir + "/" + mName)) return; if(! QFileInfo::exists(mDir + "/" + mName)) return;
img = QImage(mDir + "/" + mName); img = QImage(mDir + "/" + mName);
if(gProgItem->mSplitWidth) { if(gProgItem->mMaxWidth) {
int cnt = (gProgItem->mWidth+gProgItem->mSplitWidth-1) / gProgItem->mSplitWidth; QImage square(gProgItem->mMaxWidth, gProgItem->mHeight*gProgItem->mSplitWidths.size(), QImage::Format_ARGB32);
QImage square(gProgItem->mSplitWidth, gProgItem->mHeight*cnt, QImage::Format_ARGB32);
QPainter painter(&square); QPainter painter(&square);
auto rect = innerRect(); QRectF rect(x(), y(), mWidth, mHeight);
painter.drawImage(rect, img); painter.drawImage(rect, img);
for(int i=1; i<cnt; i++) { auto end = gProgItem->mSplitWidths.size() - 1;
rect.moveTo(rect.x() - gProgItem->mSplitWidth, rect.y() + gProgItem->mHeight); for(int i=0; i<end; i++) {
rect.moveTo(rect.x() - gProgItem->mSplitWidths[i], rect.y() + gProgItem->mHeight);
painter.drawImage(rect, img); painter.drawImage(rect, img);
} }
square.save(mDir + "/" + mName+"-square.png", "PNG"); square.save(mDir + "/" + mName+"-square.png", "PNG");

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