ledok
This commit is contained in:
parent
d441f6fbc1
commit
f2f5742ba5
219
LedOK/LedOK.pro
219
LedOK/LedOK.pro
|
@ -17,7 +17,7 @@ CONFIG += embed_translations
|
|||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
TARGET = $$quote(LedOK Express)
|
||||
VERSION = 1.3.0
|
||||
VERSION = 1.3.5
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
msvc {
|
||||
QMAKE_CXXFLAGS += -execution-charset:utf-8
|
||||
|
@ -25,6 +25,15 @@ msvc {
|
|||
|
||||
CONFIG += force_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* {
|
||||
LIBS += -lwinmm
|
||||
|
@ -46,7 +55,6 @@ SOURCES += \
|
|||
base/switchcontrol.cpp \
|
||||
base/taesclass.cpp \
|
||||
base/updateledset3dialog.cpp \
|
||||
base/updaterdialog.cpp \
|
||||
base/x_checkboxdelegate.cpp \
|
||||
base/x_spinboxdelegate.cpp \
|
||||
base/x_timeeditdelegate.cpp \
|
||||
|
@ -57,18 +65,22 @@ SOURCES += \
|
|||
base/lodateselector.cpp \
|
||||
base/loqtitlebar.cpp \
|
||||
base/loqtreewidget.cpp \
|
||||
base/table.cpp \
|
||||
base/waitingdlg.cpp \
|
||||
basedlg.cpp \
|
||||
basewin.cpp \
|
||||
cfg.cpp \
|
||||
communication/hpptclient.cpp \
|
||||
communication/taserialthread.cpp \
|
||||
device/ctrlhdmipanel.cpp \
|
||||
device/ctrlnetworkpanel.cpp \
|
||||
device/ctrlpwdpanel.cpp \
|
||||
devicectrlpanel.cpp \
|
||||
deviceitem.cpp \
|
||||
devicepanel.cpp \
|
||||
ffplayer.cpp \
|
||||
globaldefine.cpp \
|
||||
gutil/qgui.cpp \
|
||||
gutil/qnetwork.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
mguangyingpinwidget.cpp \
|
||||
|
@ -87,55 +99,45 @@ SOURCES += \
|
|||
player/posdlg.cpp \
|
||||
progpanel.cpp \
|
||||
synctimer.cpp \
|
||||
tcpsocket.cpp \
|
||||
test.cpp \
|
||||
tipdialog.cpp \
|
||||
tools.cpp \
|
||||
wDevicesManager/controlencryptwidget.cpp \
|
||||
wDevicesManager/controlhdmischedule.cpp \
|
||||
wDevicesManager/controlhdmiwidget.cpp \
|
||||
wDevicesManager/controlnetconfigwidget.cpp \
|
||||
wDevicesManager/controlpowermanual.cpp \
|
||||
wDevicesManager/controlpowerschedule.cpp \
|
||||
wDevicesManager/controlpowerwidget.cpp \
|
||||
wDevicesManager/controltestwidget.cpp \
|
||||
wDevicesManager/controlvolumemanual.cpp \
|
||||
wDevicesManager/controlvolumeschedule.cpp \
|
||||
wDevicesManager/controlvolumewidget.cpp \
|
||||
wDevicesManager/ctrladvancedpanel.cpp \
|
||||
wDevicesManager/ctrlbrightpanel.cpp \
|
||||
wDevicesManager/ctrlverifyclockpanel.cpp \
|
||||
wDevicesManager/ledcard.cpp \
|
||||
wDevicesManager/threadupgradeapk.cpp \
|
||||
wDevicesManager/upgradeapkdialog.cpp \
|
||||
wDevicesManager/wupgradeapkitem.cpp \
|
||||
wProgramManager/eaclock.cpp \
|
||||
wProgramManager/eaudio.cpp \
|
||||
wProgramManager/ebase.cpp \
|
||||
wProgramManager/edclock.cpp \
|
||||
wProgramManager/eenviron.cpp \
|
||||
wProgramManager/egif.cpp \
|
||||
wProgramManager/emultiwin.cpp \
|
||||
wProgramManager/ephoto.cpp \
|
||||
wProgramManager/etext.cpp \
|
||||
wProgramManager/etimer.cpp \
|
||||
wProgramManager/evideo.cpp \
|
||||
wProgramManager/eweb.cpp \
|
||||
wProgramManager/gentmpthread.cpp \
|
||||
wProgramManager/pageeditor.cpp \
|
||||
wProgramManager/pagelistitem.cpp \
|
||||
wProgramManager/progcreatedlg.cpp \
|
||||
wProgramManager/progeditorwin.cpp \
|
||||
wProgramManager/progitem.cpp \
|
||||
wProgramManager/sendprogramdialog.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 \
|
||||
device/controlpowerschedule.cpp \
|
||||
device/controlpowerwidget.cpp \
|
||||
device/controltestwidget.cpp \
|
||||
device/controlvolumeschedule.cpp \
|
||||
device/controlvolumewidget.cpp \
|
||||
device/ctrladvancedpanel.cpp \
|
||||
device/ctrlbrightpanel.cpp \
|
||||
device/ctrlverifyclockpanel.cpp \
|
||||
device/ledcard.cpp \
|
||||
device/upgradeapkdialog.cpp \
|
||||
device/wupgradeapkitem.cpp \
|
||||
program/copydirthread.cpp \
|
||||
program/eaclock.cpp \
|
||||
program/eaudio.cpp \
|
||||
program/ebase.cpp \
|
||||
program/edclock.cpp \
|
||||
program/eenviron.cpp \
|
||||
program/egif.cpp \
|
||||
program/emultiwin.cpp \
|
||||
program/ephoto.cpp \
|
||||
program/etext.cpp \
|
||||
program/etimer.cpp \
|
||||
program/evideo.cpp \
|
||||
program/eweb.cpp \
|
||||
program/gentmpthread.cpp \
|
||||
program/pageeditor.cpp \
|
||||
program/pagelistitem.cpp \
|
||||
program/progcreatedlg.cpp \
|
||||
program/progeditorwin.cpp \
|
||||
program/progitem.cpp \
|
||||
program/sendprogramdialog.cpp \
|
||||
program/sendprogthread.cpp \
|
||||
program/usbdetectdialog.cpp \
|
||||
program/videosplitthread.cpp \
|
||||
program/wplanitem.cpp \
|
||||
program/wplanlist.cpp \
|
||||
program/wprogrampublishitem.cpp \
|
||||
|
||||
HEADERS += \
|
||||
base/aboutdlg.h \
|
||||
|
@ -148,7 +150,6 @@ HEADERS += \
|
|||
base/switchcontrol.h \
|
||||
base/taesclass.h \
|
||||
base/updateledset3dialog.h \
|
||||
base/updaterdialog.h \
|
||||
base/x_checkboxdelegate.h \
|
||||
base/x_spinboxdelegate.h \
|
||||
base/x_timeeditdelegate.h \
|
||||
|
@ -158,19 +159,22 @@ HEADERS += \
|
|||
base/lodateselector.h \
|
||||
base/loqtitlebar.h \
|
||||
base/loqtreewidget.h \
|
||||
base/table.h \
|
||||
base/waitingdlg.h \
|
||||
basedlg.h \
|
||||
basewin.h \
|
||||
cfg.h \
|
||||
communication/hpptclient.h \
|
||||
communication/taserialthread.h \
|
||||
device/ctrlhdmipanel.h \
|
||||
device/ctrlnetworkpanel.h \
|
||||
device/ctrlpwdpanel.h \
|
||||
devicectrlpanel.h \
|
||||
deviceitem.h \
|
||||
devicepanel.h \
|
||||
ffplayer.h \
|
||||
globaldefine.h \
|
||||
gqt.h \
|
||||
gutil/qgui.h \
|
||||
gutil/qnetwork.h \
|
||||
mainwindow.h \
|
||||
mguangyingpinwidget.h \
|
||||
passwordindlg.h \
|
||||
|
@ -188,73 +192,54 @@ HEADERS += \
|
|||
player/posdlg.h \
|
||||
progpanel.h \
|
||||
synctimer.h \
|
||||
tcpsocket.h \
|
||||
tipdialog.h \
|
||||
tools.h \
|
||||
wDevicesManager/controlencryptwidget.h \
|
||||
wDevicesManager/controlhdmischedule.h \
|
||||
wDevicesManager/controlhdmiwidget.h \
|
||||
wDevicesManager/controlnetconfigwidget.h \
|
||||
wDevicesManager/controlpowermanual.h \
|
||||
wDevicesManager/controlpowerschedule.h \
|
||||
wDevicesManager/controlpowerwidget.h \
|
||||
wDevicesManager/controltestwidget.h \
|
||||
wDevicesManager/controlvolumemanual.h \
|
||||
wDevicesManager/controlvolumeschedule.h \
|
||||
wDevicesManager/controlvolumewidget.h \
|
||||
wDevicesManager/ctrladvancedpanel.h \
|
||||
wDevicesManager/ctrlbrightpanel.h \
|
||||
wDevicesManager/ctrlverifyclockpanel.h \
|
||||
wDevicesManager/ledcard.h \
|
||||
wDevicesManager/threadupgradeapk.h \
|
||||
wDevicesManager/upgradeapkdialog.h \
|
||||
wDevicesManager/wupgradeapkitem.h \
|
||||
wProgramManager/eaclock.h \
|
||||
wProgramManager/eaudio.h \
|
||||
wProgramManager/ebase.h \
|
||||
wProgramManager/edclock.h \
|
||||
wProgramManager/eenviron.h \
|
||||
wProgramManager/egif.h \
|
||||
wProgramManager/emultiwin.h \
|
||||
wProgramManager/ephoto.h \
|
||||
wProgramManager/etext.h \
|
||||
wProgramManager/etimer.h \
|
||||
wProgramManager/evideo.h \
|
||||
wProgramManager/eweb.h \
|
||||
wProgramManager/gentmpthread.h \
|
||||
wProgramManager/pageeditor.h \
|
||||
wProgramManager/pagelistitem.h \
|
||||
wProgramManager/progcreatedlg.h \
|
||||
wProgramManager/progeditorwin.h \
|
||||
wProgramManager/progitem.h \
|
||||
wProgramManager/sendprogramdialog.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 \
|
||||
device/controlpowerschedule.h \
|
||||
device/controlpowerwidget.h \
|
||||
device/controltestwidget.h \
|
||||
device/controlvolumeschedule.h \
|
||||
device/controlvolumewidget.h \
|
||||
device/ctrladvancedpanel.h \
|
||||
device/ctrlbrightpanel.h \
|
||||
device/ctrlverifyclockpanel.h \
|
||||
device/ledcard.h \
|
||||
device/upgradeapkdialog.h \
|
||||
device/wupgradeapkitem.h \
|
||||
program/copydirthread.h \
|
||||
program/eaclock.h \
|
||||
program/eaudio.h \
|
||||
program/ebase.h \
|
||||
program/edclock.h \
|
||||
program/eenviron.h \
|
||||
program/egif.h \
|
||||
program/emultiwin.h \
|
||||
program/ephoto.h \
|
||||
program/etext.h \
|
||||
program/etimer.h \
|
||||
program/evideo.h \
|
||||
program/eweb.h \
|
||||
program/gentmpthread.h \
|
||||
program/pageeditor.h \
|
||||
program/pagelistitem.h \
|
||||
program/progcreatedlg.h \
|
||||
program/progeditorwin.h \
|
||||
program/progitem.h \
|
||||
program/sendprogramdialog.h \
|
||||
program/sendprogthread.h \
|
||||
program/usbdetectdialog.h \
|
||||
program/videosplitthread.h \
|
||||
program/wplanitem.h \
|
||||
program/wplanlist.h \
|
||||
program/wprogrampublishitem.h \
|
||||
|
||||
FORMS += \
|
||||
base/pixbmpshowdialog.ui \
|
||||
base/updateledset3dialog.ui \
|
||||
base/updaterdialog.ui \
|
||||
base/x_uimsgboxok.ui \
|
||||
mguangyingpinwidget.ui \
|
||||
tipdialog.ui \
|
||||
wDevicesManager/controlencryptwidget.ui \
|
||||
wDevicesManager/controlhdmischedule.ui \
|
||||
wDevicesManager/controlpowermanual.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 \
|
||||
device/controlpowerschedule.ui \
|
||||
device/controltestwidget.ui \
|
||||
device/controlvolumeschedule.ui \
|
||||
program/wplanitem.ui \
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/app_zh_CN.ts \
|
||||
|
@ -268,9 +253,7 @@ EXTRA_TRANSLATIONS += \
|
|||
translations/qt_ja.ts \
|
||||
translations/qt_en.ts
|
||||
|
||||
RESOURCES += \
|
||||
res.qrc \
|
||||
qss.qrc
|
||||
RESOURCES += res.qrc
|
||||
|
||||
win32:RC_ICONS = res/Logo.ico
|
||||
osx:ICON = res/Logo.icns
|
||||
|
@ -308,6 +291,10 @@ copy.files += 7z/7z.exe
|
|||
copy.path = $$OUT_PWD
|
||||
copy2.path = $$OUT_PWD/release
|
||||
|
||||
copy3.files += $$quote(y50 param)
|
||||
copy3.path = $$OUT_PWD/release
|
||||
|
||||
CONFIG += file_copies
|
||||
COPIES += copy
|
||||
COPIES += copy2
|
||||
COPIES += copy3
|
||||
|
|
|
@ -6,6 +6,10 @@ extern "C"{
|
|||
#include <libswscale/swscale.h>
|
||||
}
|
||||
|
||||
static void imgCleanupHandler(void *info) {
|
||||
delete [] (uchar*)info;
|
||||
}
|
||||
|
||||
QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id) {
|
||||
AVFormatContext *fmt_ctx = avformat_alloc_context();
|
||||
QString err;
|
||||
|
@ -44,9 +48,12 @@ QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id
|
|||
avcodec_free_context(&vcCtx);
|
||||
goto free;
|
||||
}
|
||||
auto sws_ctx = sws_getContext(vcCtx->width, vcCtx->height, vcCtx->pix_fmt, vcCtx->width, vcCtx->height, AV_PIX_FMT_RGB32, SWS_FAST_BILINEAR, 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 frm = av_frame_alloc();
|
||||
int dstStride[4]{(vcCtx->width*4+63)/64*64};
|
||||
dstStride[3] = dstStride[0] * vcCtx->height;
|
||||
uint8_t *dst[4]{0};
|
||||
while(1) {
|
||||
if(av_read_frame(fmt_ctx, packet) < 0) break;
|
||||
if(packet->stream_index != vi_idx) continue;
|
||||
|
@ -54,10 +61,9 @@ QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id
|
|||
if(res < 0) break;
|
||||
while((res = avcodec_receive_frame(vcCtx, frm)) != AVERROR(EAGAIN)) {
|
||||
if(res < 0) goto free2;
|
||||
img = QImage(vcCtx->width, vcCtx->height, QImage::Format_ARGB32);
|
||||
uint8_t *dst[4]{img.bits()};
|
||||
int dstStride[4]{img.bytesPerLine()};
|
||||
dst[0] = new uchar[dstStride[3]];
|
||||
sws_scale(sws_ctx, frm->data, frm->linesize, 0, vcCtx->height, dst, dstStride);
|
||||
img = QImage(dst[0], vcCtx->width, vcCtx->height, dstStride[0], QImage::Format_ARGB32, imgCleanupHandler, dst[0]);
|
||||
goto free2;
|
||||
}
|
||||
}
|
||||
|
@ -71,188 +77,6 @@ QString videoInfo(QByteArray url, QImage &img, int64_t *dur, AVCodecID *codec_id
|
|||
avformat_close_input(&fmt_ctx);
|
||||
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) {
|
||||
AVFormatContext *fmt_ctx = avformat_alloc_context();
|
||||
QString err;
|
||||
|
|
|
@ -7,7 +7,6 @@ extern "C"{
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
#endif // FFUTIL_H
|
||||
|
|
|
@ -13,9 +13,12 @@ LoColorSelector::LoColorSelector(const QString &text, const QColor &color, QWidg
|
|||
}
|
||||
void LoColorSelector::init() {
|
||||
connect(this, &QPushButton::clicked, this, [this]{
|
||||
QColorDialog colorDlg(this->color, this);
|
||||
QColorDialog colorDlg(this);
|
||||
colorDlg.setOption(QColorDialog::ShowAlphaChannel);
|
||||
colorDlg.setOption(QColorDialog::DontUseNativeDialog);
|
||||
auto color = this->color;
|
||||
color.setAlpha(255);
|
||||
colorDlg.setCurrentColor(color);
|
||||
|
||||
auto btn = new QPushButton(tr("Transparent"));
|
||||
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);
|
||||
|
||||
if(colorDlg.exec() != QColorDialog::Accepted) return;
|
||||
QColor color = colorDlg.selectedColor();
|
||||
if(color == this->color) return;
|
||||
color = colorDlg.selectedColor();
|
||||
if(! color.isValid()) return;
|
||||
if(color.alpha()==0 && this->color.alpha()==0) color.setAlpha(255);
|
||||
setColor(color);
|
||||
emit sColorChanged(color);
|
||||
});
|
||||
|
|
|
@ -7,13 +7,13 @@ LoDateSelector::LoDateSelector(QWidget *parent) : QPushButton(parent) {
|
|||
setStyleSheet(R"rrr(
|
||||
LoDateSelector {
|
||||
background-color: transparent;
|
||||
image: url(:/res/ProgramManager/EditProgram/DateSelect_enable.png);
|
||||
image: url(:/res/program/DateSelect_enable.png);
|
||||
padding: 0;
|
||||
max-width: 32px;
|
||||
max-height: 32px;
|
||||
}
|
||||
LoDateSelector:!enabled{
|
||||
image: url(:/res/ProgramManager/EditProgram/DateSelect_e.png);
|
||||
image: url(:/res/program/DateSelect_e.png);
|
||||
}
|
||||
LoDateSelector:pressed {
|
||||
margin-top: 1px;
|
||||
|
|
|
@ -19,13 +19,7 @@ void CheckableHeader::paintSection(QPainter *painter, const QRect &rect, int log
|
|||
|
||||
LoQTreeWidget::LoQTreeWidget(QWidget *parent) : QTreeWidget(parent), m_checkState(CheckNone) {
|
||||
fdIsSelAll = new QCheckBox();
|
||||
fdIsSelAll->setStyleSheet(R"rrr(
|
||||
QCheckBox::indicator {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
)rrr");
|
||||
fdIsSelAll->setStyleSheet("QCheckBox{margin-left: 5px;}");
|
||||
m_header = new CheckableHeader(Qt::Horizontal, fdIsSelAll);
|
||||
setHeader(m_header);
|
||||
setProperty("ssType", "topList");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
SoftConfigDialog::SoftConfigDialog(QWidget *parent) : BaseDlg(parent) {
|
||||
resize(400, 300);
|
||||
setWindowTitle(tr("Software Configuration"));
|
||||
setWindowTitle(tr("Software Config"));
|
||||
auto vbox = new QVBoxLayout(this);
|
||||
|
||||
auto pushButton = new QPushButton("X");
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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>
|
|
@ -1,6 +1,7 @@
|
|||
#include "waitingdlg.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QTimerEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : BaseDlg{parent}, sucText(sucText) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -11,8 +12,18 @@ WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : BaseDlg
|
|||
setPalette(pal);
|
||||
|
||||
auto vBox = new QVBoxLayout(this);
|
||||
vBox->setContentsMargins(6, 3, 6, 6);
|
||||
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->setDisplayModel(1);
|
||||
mIndicator->setColor(QColor(0x0088dd));
|
||||
|
|
|
@ -10,12 +10,12 @@ class WaitingDlg : public BaseDlg {
|
|||
public:
|
||||
explicit WaitingDlg(QWidget *parent = nullptr, QString text = 0, QString sucText = 0);
|
||||
|
||||
QPushButton *btnAbort;
|
||||
QLabel *fdText;
|
||||
QString sucText;
|
||||
CustomProgressIndicator *mIndicator;
|
||||
public slots:
|
||||
void success();
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
private:
|
||||
|
|
|
@ -48,7 +48,7 @@ bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){
|
|||
MSG *msg = (MSG*)message;
|
||||
if(msg->message==WM_NCACTIVATE){
|
||||
isActive = msg->wParam;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -122,7 +122,7 @@ bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *){
|
|||
MSG *msg = (MSG*)message;
|
||||
if(msg->message==WM_NCACTIVATE){
|
||||
isActive = msg->wParam;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ ControlPowerSchedule::ControlPowerSchedule(QWidget *parent,QList<LedCard *> *lis
|
|||
ui->setupUi(this);
|
||||
ui->labelPowerScheduleTip->setVisible(false);
|
||||
refreshLable();
|
||||
setStyleSheet(Tools::styleSheet());
|
||||
setStyleSheet(css);
|
||||
ui->pushButtonAdd->setProperty("ssType", "progManageTool");
|
||||
ui->pushButtonAdd->setFlat(true);
|
||||
ui->pushButtonDelete->setProperty("ssType", "progManageTool");
|
||||
|
@ -149,7 +149,6 @@ void ControlPowerSchedule::OnProHttpResponse(QString url, QString postMD5, QByte
|
|||
QString strType=jsonObject["_type"].toString();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
if(strType == "GetTimingScreenTask")
|
||||
{
|
||||
JieXiJsonTaskPower(jsonObject["screenTask"].toObject());
|
||||
|
@ -185,7 +184,6 @@ void ControlPowerSchedule::OnProHttpResponseAll(QString url, QString postMD5, QB
|
|||
QString strType=jsonObject["_type"].toString();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
if(strType == "GetTimingScreenTask")
|
||||
{
|
||||
emit sigHaveSchedule(JieXiJsonTaskPower(jsonObject["screenTask"].toObject()));
|
|
@ -2,7 +2,7 @@
|
|||
#define CONTROLPOWERSCHEDULE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <wDevicesManager/ledcard.h>
|
||||
#include <device/ledcard.h>
|
||||
#include <communication/hpptclient.h>
|
||||
#include <base/loemptydialog.h>
|
||||
#include <QStandardItemModel>
|
||||
|
@ -18,10 +18,10 @@ class ControlPowerSchedule : public QWidget
|
|||
public:
|
||||
explicit ControlPowerSchedule(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
|
||||
~ControlPowerSchedule();
|
||||
void refreshLable();
|
||||
private:
|
||||
Ui::ControlPowerSchedule *ui;
|
||||
protected slots:
|
||||
void refreshLable();
|
||||
void OnClickAdd();
|
||||
void OnClickImport();
|
||||
void OnClickExport();
|
|
@ -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();
|
||||
}
|
|
@ -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
|
|
@ -17,7 +17,7 @@ ControlTestWidget::ControlTestWidget(QWidget *parent,QList<LedCard *> *list) :
|
|||
m_pLedlist=list;
|
||||
ui->setupUi(this);
|
||||
refreshLable();
|
||||
setStyleSheet(Tools::styleSheet());
|
||||
setStyleSheet(css);
|
||||
ui->pushButtonStartLine->setProperty("ssType", "progManageTool");
|
||||
ui->pushButtonStartGray->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();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
if(strType == "TestScreen")
|
||||
{
|
||||
|
||||
}
|
||||
MACRO_ASKTIME_STOP
|
||||
MACRO_POSTING_DLG_UNLOCK
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -534,15 +528,8 @@ void ControlTestWidget::OnProHttpResponseAll(QString url, QString postMD5, QByte
|
|||
QString strType=jsonObject["_type"].toString();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
if(strType == "TestScreen")
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
MACRO_ASKTIME_STOP
|
||||
MACRO_POSTING_DLG_UNLOCK
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#define CONTROLTESTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <wDevicesManager/ledcard.h>
|
||||
#include <device/ledcard.h>
|
||||
#include <communication/hpptclient.h>
|
||||
#include <base/loemptydialog.h>
|
||||
namespace Ui {
|
|
@ -21,7 +21,7 @@ ControlVolumeSchedule::ControlVolumeSchedule(QWidget *parent,QList<LedCard *> *l
|
|||
m_pLedlist=list;
|
||||
ui->setupUi(this);
|
||||
refreshLable();
|
||||
setStyleSheet(Tools::styleSheet());
|
||||
setStyleSheet(css);
|
||||
ui->pushButtonAdd->setProperty("ssType", "progManageTool");
|
||||
ui->pushButtonAdd->setFlat(true);
|
||||
ui->pushButtonDelete->setProperty("ssType", "progManageTool");
|
||||
|
@ -146,7 +146,6 @@ void ControlVolumeSchedule::OnProHttpResponse(QString url, QString postMD5, QByt
|
|||
QString strType=jsonObject["_type"].toString();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
if(strType == "GetAutoVolumeTask")
|
||||
{
|
||||
JieXiJsonTaskVolume(jsonObject["taskVolume"].toObject());
|
||||
|
@ -182,7 +181,6 @@ void ControlVolumeSchedule::OnProHttpResponseAll(QString url, QString postMD5, Q
|
|||
QString strType=jsonObject["_type"].toString();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
if(strType == "GetAutoVolumeTask")
|
||||
{
|
||||
emit sigHaveSchedule(JieXiJsonTaskVolume(jsonObject["taskVolume"].toObject()));
|
|
@ -2,7 +2,7 @@
|
|||
#define CONTROLVOLUMESCHEDULE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <wDevicesManager/ledcard.h>
|
||||
#include <device/ledcard.h>
|
||||
#include <communication/hpptclient.h>
|
||||
#include <base/loemptydialog.h>
|
||||
#include <QStandardItemModel>
|
||||
|
@ -19,8 +19,8 @@ class ControlVolumeSchedule : public QWidget
|
|||
public:
|
||||
explicit ControlVolumeSchedule(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
|
||||
~ControlVolumeSchedule();
|
||||
protected slots:
|
||||
void refreshLable();
|
||||
protected slots:
|
||||
void OnClickAdd();
|
||||
void OnClickImport();
|
||||
void OnClickExport();
|
|
@ -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();
|
||||
}
|
|
@ -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
|
@ -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
|
|
@ -3,53 +3,58 @@
|
|||
#include "globaldefine.h"
|
||||
#include "deviceitem.h"
|
||||
#include "tools.h"
|
||||
#include "base/x_timeeditdelegate.h"
|
||||
#include "xlsxdocument.h"
|
||||
#include "xlsxworkbook.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
#include <QJsonArray>
|
||||
#include <QButtonGroup>
|
||||
#include <QThread>
|
||||
#include <QHeaderView>
|
||||
#include <QSettings>
|
||||
#include <QTimeEdit>
|
||||
|
||||
CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
||||
auto vBox = new QVBoxLayout(this);
|
||||
auto vBox = new VBox(this);
|
||||
vBox->setContentsMargins(0,0,0,0);
|
||||
vBox->addSpacing(8);
|
||||
|
||||
lbBrightCfg = new QLabel;
|
||||
auto font = lbBrightCfg->font();
|
||||
font.setPixelSize(font.pixelSize()+2);
|
||||
font.setBold(true);
|
||||
lbBrightCfg->setFont(font);
|
||||
lbBrightCfg->setAlignment(Qt::AlignCenter);
|
||||
vBox->addWidget(lbBrightCfg);
|
||||
vBox->addSpacing(9);
|
||||
|
||||
auto hBox = new QHBoxLayout();
|
||||
auto hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
radioAuto = new QRadioButton();
|
||||
radioAuto = new QRadioButton;
|
||||
radioAuto->setChecked(true);
|
||||
hBox->addWidget(radioAuto);
|
||||
hBox->addSpacing(40);
|
||||
|
||||
radioManual = new QRadioButton();
|
||||
radioManual = new QRadioButton;
|
||||
hBox->addWidget(radioManual);
|
||||
hBox->addSpacing(40);
|
||||
|
||||
radioSchedule = new QRadioButton();
|
||||
radioSchedule = new QRadioButton;
|
||||
hBox->addWidget(radioSchedule);
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
fdAdaptToOld = new QCheckBox;
|
||||
hBox->addWidget(fdAdaptToOld);
|
||||
|
||||
|
||||
auto line = new QFrame;
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
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->setAlignment(Qt::AlignCenter);
|
||||
|
@ -89,9 +94,9 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
json.insert("_type", "SetBrightnessSensitivity");
|
||||
json.insert("sensitivity", fdSensi->value());
|
||||
if(gSelCards->count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("SetBrightnessSensitivity"));
|
||||
auto waitingDlg = new WaitingDlg(this, tr("SetBrightnessSensitivity")+" ...");
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
|
||||
connect(reply, &QNetworkReply::finished, card, [reply, waitingDlg] {
|
||||
Def_CtrlSetReqAfter
|
||||
});
|
||||
} else {
|
||||
|
@ -114,7 +119,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
json.insert("_id", "GetBrightnessSensitivity");
|
||||
json.insert("_type", "GetBrightnessSensitivity");
|
||||
if(gSelCards->count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("GetBrightnessSensitivity"));
|
||||
auto waitingDlg = new WaitingDlg(this, tr("GetBrightnessSensitivity")+" ...");
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
||||
Def_CtrlSingleGetReply
|
||||
|
@ -124,11 +129,12 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
} 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, this, [reply, card] {
|
||||
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["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"));
|
||||
return;
|
||||
}
|
||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||
QJsonObject json;
|
||||
json.insert("_id", "SetMinBrightness");
|
||||
json.insert("_type", "SetMinBrightness");
|
||||
auto brightPercent = fdMinBright->value();
|
||||
if(! isAdaptToOld) json.insert("minBrightnessPercentage", brightPercent);
|
||||
if(gSelCards->count() == 1) {
|
||||
json.insert("brightness", (brightPercent * gSelCards->at(0)->BrightnessLevel + 50) / 100);
|
||||
auto waitingDlg = new WaitingDlg(this, tr("SetMinBrightness"));
|
||||
if(isAdaptToOld) json.insert("brightness", (brightPercent * gSelCards->at(0)->BrightnessLevel + 50) / 100);
|
||||
auto waitingDlg = new WaitingDlg(this, tr("SetMinBrightness")+" ...");
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
|
||||
Def_CtrlSetReqAfter
|
||||
});
|
||||
} else {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
@ -198,20 +206,30 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
json.insert("_id", "GetMinBrightness");
|
||||
json.insert("_type", "GetMinBrightness");
|
||||
if(gSelCards->count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness"));
|
||||
auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")+" ...");
|
||||
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
|
||||
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 {
|
||||
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, this, [reply, card] {
|
||||
auto cardId = card->m_strCardId;
|
||||
auto brightLevel = card->BrightnessLevel;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId, brightLevel] {
|
||||
QJsonDocument 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"));
|
||||
Def_CtrlReqPre
|
||||
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();
|
||||
if(json["is485"].toBool()) fdR68->setChecked(true);
|
||||
else fdRL2->setChecked(true);
|
||||
|
@ -400,7 +425,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
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->addStretch();
|
||||
}
|
||||
auto manualPanel = new QWidget;
|
||||
{
|
||||
auto vBox = new QVBoxLayout(manualPanel);
|
||||
auto vBox = new VBox(stack);
|
||||
|
||||
auto hBox = new QHBoxLayout;
|
||||
hBox->addStretch();
|
||||
|
@ -449,12 +473,14 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
|
||||
return;
|
||||
}
|
||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||
QJsonObject json;
|
||||
json.insert("_id", "SetBrightness");
|
||||
json.insert("_type", "SetBrightness");
|
||||
auto percent = fdFixedBright->value();
|
||||
if(! isAdaptToOld) json.insert("brightnessPercentage", percent);
|
||||
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"));
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
|
||||
|
@ -462,7 +488,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
});
|
||||
} else {
|
||||
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"))
|
||||
}
|
||||
}
|
||||
|
@ -484,10 +510,18 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
auto waitingDlg = new WaitingDlg(this, tr("GetBrightness"));
|
||||
Def_CtrlReqPre
|
||||
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();
|
||||
card->brightness = json["brightness"].toInt();
|
||||
fdFixedBright->setValue(qRound(card->brightness * 100.0 / card->BrightnessLevel));
|
||||
card->bright = json["brightnessPercentage"].toInt(-1);
|
||||
if(card->bright==-1) card->bright = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
|
||||
fdFixedBright->setValue(card->bright);
|
||||
});
|
||||
} else {
|
||||
foreach(auto card, *gSelCards) {
|
||||
|
@ -495,7 +529,12 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
||||
QJsonDocument 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->addStretch();
|
||||
}
|
||||
auto schedulePanel = new QWidget;
|
||||
{
|
||||
auto hBox = new QHBoxLayout(schedulePanel);
|
||||
auto hBox = new HBox(stack);
|
||||
hBox->addStretch();
|
||||
auto vBox = new QVBoxLayout;
|
||||
hBox->addLayout(vBox);
|
||||
auto vBox = new VBox(hBox);
|
||||
hBox->addStretch();
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
|
||||
fdScheTip = new QLabel;
|
||||
fdScheTip->setWordWrap(true);
|
||||
hBox->addWidget(fdScheTip);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
|
||||
btnScheAdd = new QPushButton;
|
||||
btnScheAdd->setMinimumSize(60, 30);
|
||||
|
@ -571,7 +607,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
btnScheClear = new QPushButton;
|
||||
btnScheClear->setMinimumSize(60, 30);
|
||||
btnScheClear->setProperty("ssType", "progManageTool");
|
||||
connect(btnScheClear, &QPushButton::clicked, this, [this] {tableSche->setRowCount(0);});
|
||||
connect(btnScheClear, &QPushButton::clicked, this, [this] {tableSche->setRowCount(0);});
|
||||
hBox->addWidget(btnScheClear);
|
||||
|
||||
hBox->addStretch();
|
||||
|
@ -609,7 +645,40 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
if(! scheQFile.open(QIODevice::ReadOnly)) return;
|
||||
auto data = scheQFile.readAll();
|
||||
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);
|
||||
|
||||
|
@ -625,23 +694,30 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
settings.setValue("CtrlScheduleDir", QFileInfo(scheFile).absolutePath());
|
||||
QFile scheQFile(scheFile);
|
||||
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();
|
||||
});
|
||||
hBox->addWidget(btnScheExport);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
tableSche = new Table({
|
||||
{"bright", tr("BrightnessValue"), 300},
|
||||
{"start", tr("Start Time"), 100},
|
||||
{"end", tr("End Time"), 100}
|
||||
{"bright", "", 300},
|
||||
{"start", "", 100},
|
||||
{"end", "", 100}
|
||||
});
|
||||
tableSche->setDefs();
|
||||
tableSche->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
vBox->addWidget(tableSche);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
btnScheSet = new QPushButton;
|
||||
|
@ -652,11 +728,13 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
|
||||
return;
|
||||
}
|
||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||
QJsonObject json;
|
||||
json.insert("_id", "SetAutoBrightnessTask");
|
||||
json.insert("_type", "SetAutoBrightnessTask");
|
||||
if(! isAdaptToOld) getScheduleJson(json, 0);
|
||||
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"));
|
||||
Def_CtrlReqPre;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
|
||||
|
@ -664,7 +742,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
});
|
||||
} else {
|
||||
foreach(auto card, *gSelCards) {
|
||||
json.insert("taskBrightness", getScheduleJson(card->BrightnessLevel));
|
||||
if(isAdaptToOld) getScheduleJson(json, card->BrightnessLevel);
|
||||
Def_CtrlSetMulti(tr("SetAutoBrightnessTask"))
|
||||
}
|
||||
}
|
||||
|
@ -690,27 +768,22 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, card] {
|
||||
Def_CtrlSingleGetReply
|
||||
waitingDlg->success();
|
||||
restoreScheduleJson(json["taskBrightness"].toObject(), card->BrightnessLevel);
|
||||
restoreScheduleJson(json, card->BrightnessLevel);
|
||||
});
|
||||
}
|
||||
});
|
||||
hBox->addWidget(btnScheGet);
|
||||
|
||||
hBox->addStretch();
|
||||
vBox->addLayout(hBox);
|
||||
}
|
||||
auto stackBox = new QStackedLayout(vBox);
|
||||
stackBox->addWidget(autoPanel);
|
||||
stackBox->addWidget(manualPanel);
|
||||
stackBox->addWidget(schedulePanel);
|
||||
stackBox->setCurrentIndex(0);
|
||||
stack->setCurrentIndex(0);
|
||||
|
||||
auto group = new QButtonGroup;
|
||||
group->addButton(radioAuto, 0);
|
||||
group->addButton(radioManual, 1);
|
||||
group->addButton(radioSchedule, 2);
|
||||
connect(group, &QButtonGroup::idToggled, stackBox, [stackBox](int idx, bool checked) {
|
||||
if(checked) stackBox->setCurrentIndex(idx);
|
||||
connect(group, &QButtonGroup::idToggled, stack, [=](int idx, bool checked) {
|
||||
if(checked) stack->setCurrentIndex(idx);
|
||||
});
|
||||
|
||||
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
|
||||
|
@ -740,11 +813,8 @@ void CtrlBrightPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
mTask = restoreScheduleJson(json["taskBrightness"].toObject(), card->BrightnessLevel);
|
||||
if(! err.isEmpty()) return;
|
||||
mTask = restoreScheduleJson(json, card->BrightnessLevel);
|
||||
if(mTask) radioSchedule->setChecked(true);
|
||||
else if(mSensi > 0) radioAuto->setChecked(true);
|
||||
else if(mSensi == 0) radioManual->setChecked(true);
|
||||
|
@ -757,10 +827,7 @@ void CtrlBrightPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
if(! err.isEmpty()) return;
|
||||
mSensi = json["sensitivity"].toInt();
|
||||
fdSensi->setValue(mSensi);
|
||||
if(mTask != 0) return;
|
||||
|
@ -775,11 +842,10 @@ void CtrlBrightPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
fdMinBright->setValue(qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel));
|
||||
if(! err.isEmpty()) return;
|
||||
auto value = json["minBrightnessPercentage"].toInt(-1);
|
||||
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
|
||||
fdMinBright->setValue(value);
|
||||
});
|
||||
|
||||
json = QJsonObject();
|
||||
|
@ -789,12 +855,10 @@ void CtrlBrightPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
card->brightness = json["brightness"].toInt();
|
||||
fdFixedBright->setValue(qRound(card->brightness * 100.0 / card->BrightnessLevel));
|
||||
if(! err.isEmpty()) return;
|
||||
card->bright = json["brightnessPercentage"].toInt(-1);
|
||||
if(card->bright==-1) card->bright = qRound(json["brightness"].toInt() * 100.0 / card->BrightnessLevel);
|
||||
fdFixedBright->setValue(card->bright);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -807,6 +871,7 @@ void CtrlBrightPanel::transUi() {
|
|||
radioAuto->setText(tr("Auto"));
|
||||
radioManual->setText(tr("Manual"));
|
||||
radioSchedule->setText(tr("Schedule"));
|
||||
fdAdaptToOld->setText(tr("Adapt to Old Devices"));
|
||||
|
||||
fdBrightTip->setText(tr("BrightTip1"));
|
||||
fdSensiTypeTip->setText(tr("BrightTip2"));
|
||||
|
@ -831,17 +896,26 @@ void CtrlBrightPanel::transUi() {
|
|||
btnScheDel->setText(tr("Delete"));
|
||||
btnScheImport->setText(tr("Import"));
|
||||
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"));
|
||||
btnScheGet->setText(tr("Readback"));
|
||||
fdScheTip->setText(tr("Default brightness tip"));
|
||||
}
|
||||
|
||||
bool CtrlBrightPanel::restoreScheduleJson(QJsonObject obj, int max) {
|
||||
bool CtrlBrightPanel::restoreScheduleJson(QJsonDocument &json, int max) {
|
||||
tableSche->setRowCount(0);
|
||||
fdDefBright->setValue(qRound(obj["defaultBrightness"].toInt() * 100.0 / max));
|
||||
auto jsitems = obj["items"].toArray();
|
||||
foreach(auto jsitem, jsitems) {
|
||||
auto schedule = jsitem["schedules"][0];
|
||||
auto taskBrightness = json["taskBrightness"];
|
||||
auto brightness = json["defaultBrightnessPercentage"].toInt(-1);
|
||||
if(brightness==-1) brightness = qRound(taskBrightness["defaultBrightness"].toInt() * 100.0 / max);
|
||||
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();
|
||||
tableSche->insertRow(row);
|
||||
|
||||
|
@ -850,7 +924,8 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonObject obj, int max) {
|
|||
|
||||
auto slider = new QSlider(Qt::Horizontal);
|
||||
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);
|
||||
|
||||
auto lb = new QLabel(QString::number(slider->value())+"%");
|
||||
|
@ -872,31 +947,36 @@ bool CtrlBrightPanel::restoreScheduleJson(QJsonObject obj, int max) {
|
|||
}
|
||||
return jsitems.count() > 0;
|
||||
}
|
||||
QJsonObject CtrlBrightPanel::getScheduleJson(int max) {
|
||||
QJsonObject obj;
|
||||
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;
|
||||
void CtrlBrightPanel::getScheduleJson(QJsonObject &json, int max) {
|
||||
QJsonArray items, brightnesses;
|
||||
for(int i=0; i<tableSche->rowCount(); i++) {
|
||||
QJsonObject item;
|
||||
item["brightness"] = (static_cast<QSlider*>(tableSche->cellWidget(i, "bright")->layout()->itemAt(0)->widget())->value() * max + 50) / 100;
|
||||
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["startDate"] = QJsonValue::Null;
|
||||
schedule["endDate"] = QJsonValue::Null;
|
||||
schedule["monthFilter"] = QJsonArray();
|
||||
schedule["filterType"] = "None";
|
||||
schedule["weekFilter"] = QJsonArray();
|
||||
item["schedules"] = QJsonArray{schedule};
|
||||
jsItems.append(item);
|
||||
auto brightness = static_cast<QSlider*>(tableSche->cellWidget(i, "bright")->layout()->itemAt(0)->widget())->value();
|
||||
if(max==0) brightnesses.append(brightness);
|
||||
else item.insert("brightness", (brightness * max + 50) / 100);
|
||||
item.insert("schedules", QJsonArray{QJsonObject{
|
||||
{"timeType", "Range"},
|
||||
{"startTime", static_cast<QTimeEdit*>(tableSche->cellWidget(i, "start"))->text()},
|
||||
{"endTime", static_cast<QTimeEdit*>(tableSche->cellWidget(i, "end"))->text()},
|
||||
{"dateType", "All"},
|
||||
{"filterType", "None"},
|
||||
{"monthFilter", QJsonArray()},
|
||||
{"weekFilter", QJsonArray()}
|
||||
}});
|
||||
items.append(item);
|
||||
}
|
||||
obj["items"] = jsItems;
|
||||
return obj;
|
||||
QJsonObject taskBrightness{
|
||||
{"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);
|
||||
}
|
|
@ -1,15 +1,12 @@
|
|||
#ifndef CTRLBRIGHTPANEL_H
|
||||
#define CTRLBRIGHTPANEL_H
|
||||
|
||||
#include "ledcard.h"
|
||||
#include "base/table.h"
|
||||
#include <QButtonGroup>
|
||||
#include "gutil/qgui.h"
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QCheckBox>
|
||||
#include <QSlider>
|
||||
#include <QStackedLayout>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class CtrlBrightPanel : public QWidget {
|
||||
Q_OBJECT
|
||||
|
@ -22,12 +19,13 @@ protected:
|
|||
void transUi();
|
||||
|
||||
private:
|
||||
bool restoreScheduleJson(QJsonObject, int = 100);
|
||||
QJsonObject getScheduleJson(int = 100);
|
||||
bool restoreScheduleJson(QJsonDocument &, int);
|
||||
void getScheduleJson(QJsonObject &, int);
|
||||
QLabel *lbBrightCfg;
|
||||
QRadioButton *radioAuto;
|
||||
QRadioButton *radioManual;
|
||||
QRadioButton *radioSchedule;
|
||||
QCheckBox *fdAdaptToOld;
|
||||
char mSensi{-1};
|
||||
char mTask{-1};
|
||||
|
|
@ -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}
|
||||
};
|
||||
}
|
|
@ -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
|
@ -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
|
|
@ -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"));
|
||||
}
|
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
#include "ctrlverifyclockpanel.h"
|
||||
#include "base/waitingdlg.h"
|
||||
#include "globaldefine.h"
|
||||
#include "gqt.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "tools.h"
|
||||
#include <QMessageBox>
|
||||
#include <QLineEdit>
|
||||
|
@ -10,7 +10,6 @@
|
|||
CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
||||
auto vBox = new VBox(this);
|
||||
auto hBox = new HBox(vBox);
|
||||
hBox->setContentsMargins(-1, 0, -1, -1);
|
||||
|
||||
label = new QLabel;
|
||||
hBox->addWidget(label);
|
||||
|
@ -130,10 +129,10 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
lbLang = new QLabel;
|
||||
hBox->addWidget(lbLang);
|
||||
|
||||
fdIsEn = new QRadioButton;
|
||||
fdIsEn = new QRadioButton("English");
|
||||
hBox->addWidget(fdIsEn);
|
||||
|
||||
fdIsCn = new QRadioButton;
|
||||
fdIsCn = new QRadioButton("中文");
|
||||
hBox->addWidget(fdIsCn);
|
||||
|
||||
btnLangSet = new QPushButton;
|
||||
|
@ -181,11 +180,12 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
} 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, this, [reply, card] {
|
||||
auto cardId = card->m_strCardId;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
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 {
|
||||
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, this, [reply, card] {
|
||||
auto cardId = card->m_strCardId;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
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->setMinimumSize(QSize(160, 30));
|
||||
lineEdit_3->setMaximumSize(QSize(160, 16777215));
|
||||
lineEdit_3->setStyleSheet(QString::fromUtf8("background-color: #FFFFFF;"));
|
||||
|
||||
horizontalLayout_5->addWidget(lineEdit_3);
|
||||
|
||||
labelmintime = new QLabel(groupBox);
|
||||
|
@ -360,9 +359,9 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
|
||||
horizontalLayout_7 = new QHBoxLayout();
|
||||
horizontalLayout_7->setContentsMargins(-1, 0, -1, -1);
|
||||
pushButtonSetSync = new QPushButton(groupBox);
|
||||
pushButtonSetSync->setMinimumSize(QSize(60, 30));
|
||||
connect(pushButtonSetSync, &QPushButton::clicked, this, [this] {
|
||||
btnSyncSet = new QPushButton(groupBox);
|
||||
btnSyncSet->setMinimumSize(QSize(60, 30));
|
||||
connect(btnSyncSet, &QPushButton::clicked, this, [this] {
|
||||
if(gSelCards->isEmpty()) {
|
||||
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
|
||||
return;
|
||||
|
@ -394,7 +393,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
}
|
||||
}
|
||||
});
|
||||
horizontalLayout_7->addWidget(pushButtonSetSync);
|
||||
horizontalLayout_7->addWidget(btnSyncSet);
|
||||
|
||||
fdSyncGet = new QPushButton;
|
||||
fdSyncGet->setMinimumSize(QSize(60, 30));
|
||||
|
@ -417,7 +416,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
} 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, this, [reply, card] {
|
||||
auto cardId = card->m_strCardId;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
QJsonDocument json;
|
||||
QByteArray data;
|
||||
QString err = checkReplyForJson(reply, &json, &data);
|
||||
|
@ -448,7 +448,7 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
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->setSpacing(6);
|
||||
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->addButton(radioButton_4);
|
||||
radioButton_4->setChecked(true);
|
||||
buttonGroup_2->addButton(fdMaster);
|
||||
fdMaster->setChecked(true);
|
||||
|
||||
horizontalLayout_11->addWidget(radioButton_4, 0, Qt::AlignHCenter);
|
||||
horizontalLayout_11->addWidget(fdMaster, 0, Qt::AlignHCenter);
|
||||
|
||||
radioButton_5 = new QRadioButton(groupBox_4);
|
||||
buttonGroup_2->addButton(radioButton_5);
|
||||
fdSlave = new QRadioButton(groupBox_4);
|
||||
buttonGroup_2->addButton(fdSlave);
|
||||
|
||||
horizontalLayout_11->addWidget(radioButton_5, 0, Qt::AlignHCenter);
|
||||
horizontalLayout_11->addWidget(fdSlave, 0, Qt::AlignHCenter);
|
||||
|
||||
|
||||
vvv->addWidget(groupBox_4);
|
||||
|
@ -528,17 +528,18 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
Def_CtrlSingleGetReply
|
||||
waitingDlg->success();
|
||||
bool isMaster = json["result"].toBool();
|
||||
radioButton_4->setChecked(isMaster);
|
||||
radioButton_5->setChecked(! isMaster);
|
||||
fdMaster->setChecked(isMaster);
|
||||
fdSlave->setChecked(! isMaster);
|
||||
});
|
||||
} 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, this, [reply, card] {
|
||||
auto cardId = card->m_strCardId;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
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 {
|
||||
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, this, [reply, card] {
|
||||
auto cardId = card->m_strCardId;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
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();
|
||||
|
||||
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");
|
||||
pushButtonSetSync->setProperty("ssType", "progManageTool");
|
||||
btnSyncSet->setProperty("ssType", "progManageTool");
|
||||
btnSyncTime->setProperty("ssType", "progManageTool");
|
||||
fdSyncGet->setProperty("ssType", "progManageTool");
|
||||
btnNtpGet->setProperty("ssType", "progManageTool");
|
||||
|
@ -665,8 +644,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
btnLoraMasterGet->setProperty("ssType", "progManageTool");
|
||||
btnDateGet->setProperty("ssType", "progManageTool");
|
||||
fdTimeZoneSet->setProperty("ssType", "progManageTool");
|
||||
buttonGroup_2->setId(radioButton_4, 0);
|
||||
buttonGroup_2->setId(radioButton_5, 1);
|
||||
buttonGroup_2->setId(fdMaster, 0);
|
||||
buttonGroup_2->setId(fdSlave, 1);
|
||||
|
||||
fdIsLora->setChecked(true);
|
||||
labelIdCode->setVisible(true);
|
||||
|
@ -683,8 +662,6 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel(QWidget *parent) : QWidget(parent) {
|
|||
connect(fdIsNTP,SIGNAL(clicked()),this,SLOT(OnRadioButton3()));
|
||||
connect(fdIsLan,SIGNAL(clicked()),this,SLOT(OnRadioButton6()));
|
||||
|
||||
//MARCO_DEFINE_CONTROL_FUNC2(parent->parent(),parent)
|
||||
|
||||
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
|
||||
if(isVisible()) init();
|
||||
});
|
||||
|
@ -707,10 +684,7 @@ void CtrlVerifyClockPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
if(! err.isEmpty()) return;
|
||||
dealGetSync(json);
|
||||
});
|
||||
|
||||
|
@ -721,10 +695,7 @@ void CtrlVerifyClockPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
if(! err.isEmpty()) return;
|
||||
fdTimezone->setCurrentText(json["timezone"].toString());
|
||||
});
|
||||
|
||||
|
@ -735,10 +706,7 @@ void CtrlVerifyClockPanel::init() {
|
|||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||
return;
|
||||
}
|
||||
if(! err.isEmpty()) return;
|
||||
if(json["language"].toInt()==1) fdIsCn->setChecked(true);
|
||||
else fdIsEn->setChecked(true);
|
||||
});
|
||||
|
@ -748,37 +716,37 @@ void CtrlVerifyClockPanel::changeEvent(QEvent *event) {
|
|||
if(event->type() == QEvent::LanguageChange) 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"));
|
||||
groupNTP->setTitle(tr("NTP Server"));
|
||||
groupBox->setTitle(tr("Enable Synchronous playing"));
|
||||
radioButton_4->setText(tr("Master"));
|
||||
radioButton_5->setText(tr("Slave"));
|
||||
labelSyncTimeInterval->setText(tr("Sync time interval"));
|
||||
labelIdCode->setText(tr("Identification Code"));
|
||||
checkBoxBrightness->setText(tr("Brightness"));
|
||||
checkBoxVolume->setText(tr("Volume"));
|
||||
checkBoxScreenSwitch->setText(tr("Screen on/off"));
|
||||
|
||||
groupBox_5->setTitle(tr("Cur time of controller"));
|
||||
|
||||
fdNtpServer->setPlaceholderText(tr("NTP Server address"));
|
||||
lineEdit_3->setPlaceholderText(tr("Sync time interval"));
|
||||
lineEditIdCode->setPlaceholderText(tr("identification code"));
|
||||
label->setText(tr("TimeZone"));
|
||||
btnDateGet->setText(tr("Readback"));
|
||||
btnLangGet->setText(tr("Readback"));
|
||||
btnLangSet->setText(tr("Set"));
|
||||
btnLoraMasterGet->setText(tr("Readback"));
|
||||
btnLoraMasterSet->setText(tr("Set"));
|
||||
btnNtpGet->setText(tr("Readback"));
|
||||
btnNtpSet->setText(tr("Set"));
|
||||
btnSyncTime->setText(tr("Verify to Computer time"));
|
||||
checkBoxBrightness->setText(tr("Brightness"));
|
||||
checkBoxScreenSwitch->setText(tr("Screen on/off"));
|
||||
checkBoxVolume->setText(tr("Volume"));
|
||||
fdIsLan->setText(tr("LAN"));
|
||||
fdNtpServer->setPlaceholderText(tr("NTP Server address"));
|
||||
fdSyncGet->setText(tr("Readback"));
|
||||
fdTimeZoneSet->setText(tr("Set"));
|
||||
groupBox->setTitle(tr("Enable Synchronous playing"));
|
||||
groupBox_5->setTitle(tr("Cur time of controller"));
|
||||
groupNTP->setTitle(tr("NTP Server"));
|
||||
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) {
|
||||
QString strType = json["time"].toString().toLower();
|
||||
|
@ -800,7 +768,7 @@ void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
|
|||
checkBoxScreenSwitch->setVisible(true);
|
||||
checkBoxVolume->setVisible(true);
|
||||
checkBoxBrightness->setVisible(true);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
} else if(strType=="ntp") {
|
||||
fdIsNTP->setChecked(true);
|
||||
|
@ -813,14 +781,14 @@ void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
|
|||
labelSyncTimeInterval->setVisible(true);
|
||||
labelmintime->setVisible(true);
|
||||
groupBox_4->setVisible(false);
|
||||
radioButton_4->setVisible(false);
|
||||
radioButton_5->setVisible(false);
|
||||
fdMaster->setVisible(false);
|
||||
fdSlave->setVisible(false);
|
||||
btnLoraMasterSet->setVisible(false);
|
||||
btnLoraMasterGet->setVisible(false);
|
||||
checkBoxScreenSwitch->setVisible(false);
|
||||
checkBoxVolume->setVisible(false);
|
||||
checkBoxBrightness->setVisible(false);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
} else if(strType=="gps") {
|
||||
fdIsGPS->setChecked(true);
|
||||
|
@ -832,14 +800,14 @@ void CtrlVerifyClockPanel::dealGetSync(QJsonDocument &json) {
|
|||
lineEdit_3->setVisible(false);
|
||||
labelmintime->setVisible(false);
|
||||
groupBox_4->setVisible(false);
|
||||
radioButton_4->setVisible(false);
|
||||
radioButton_5->setVisible(false);
|
||||
fdMaster->setVisible(false);
|
||||
fdSlave->setVisible(false);
|
||||
btnLoraMasterSet->setVisible(false);
|
||||
btnLoraMasterGet->setVisible(false);
|
||||
checkBoxScreenSwitch->setVisible(false);
|
||||
checkBoxVolume->setVisible(false);
|
||||
checkBoxBrightness->setVisible(false);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
@ -853,14 +821,14 @@ void CtrlVerifyClockPanel::OnRadioButton()//gps
|
|||
lineEdit_3->setVisible(false);
|
||||
labelmintime->setVisible(false);
|
||||
groupBox_4->setVisible(false);
|
||||
radioButton_4->setVisible(false);
|
||||
radioButton_5->setVisible(false);
|
||||
fdMaster->setVisible(false);
|
||||
fdSlave->setVisible(false);
|
||||
btnLoraMasterSet->setVisible(false);
|
||||
btnLoraMasterGet->setVisible(false);
|
||||
checkBoxScreenSwitch->setVisible(false);
|
||||
checkBoxVolume->setVisible(false);
|
||||
checkBoxBrightness->setVisible(false);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
}
|
||||
void CtrlVerifyClockPanel::OnRadioButton2()//lora
|
||||
|
@ -873,14 +841,14 @@ void CtrlVerifyClockPanel::OnRadioButton2()//lora
|
|||
labelSyncTimeInterval->setVisible(false);
|
||||
labelmintime->setVisible(false);
|
||||
groupBox_4->setVisible(true);
|
||||
radioButton_4->setVisible(true);
|
||||
radioButton_5->setVisible(true);
|
||||
fdMaster->setVisible(true);
|
||||
fdSlave->setVisible(true);
|
||||
btnLoraMasterSet->setVisible(true);
|
||||
btnLoraMasterGet->setVisible(true);
|
||||
checkBoxScreenSwitch->setVisible(true);
|
||||
checkBoxVolume->setVisible(true);
|
||||
checkBoxBrightness->setVisible(true);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -894,14 +862,14 @@ void CtrlVerifyClockPanel::OnRadioButton3()//ntp
|
|||
labelSyncTimeInterval->setVisible(true);
|
||||
labelmintime->setVisible(true);
|
||||
groupBox_4->setVisible(false);
|
||||
radioButton_4->setVisible(false);
|
||||
radioButton_5->setVisible(false);
|
||||
fdMaster->setVisible(false);
|
||||
fdSlave->setVisible(false);
|
||||
btnLoraMasterSet->setVisible(false);
|
||||
btnLoraMasterGet->setVisible(false);
|
||||
checkBoxScreenSwitch->setVisible(false);
|
||||
checkBoxVolume->setVisible(false);
|
||||
checkBoxBrightness->setVisible(false);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
}
|
||||
void CtrlVerifyClockPanel::OnRadioButton6() {
|
||||
|
@ -913,13 +881,13 @@ void CtrlVerifyClockPanel::OnRadioButton6() {
|
|||
labelSyncTimeInterval->setVisible(false);
|
||||
labelmintime->setVisible(false);
|
||||
groupBox_4->setVisible(true);
|
||||
radioButton_4->setVisible(true);
|
||||
radioButton_5->setVisible(true);
|
||||
fdMaster->setVisible(true);
|
||||
fdSlave->setVisible(true);
|
||||
btnLoraMasterSet->setVisible(true);
|
||||
btnLoraMasterGet->setVisible(true);
|
||||
checkBoxScreenSwitch->setVisible(true);
|
||||
checkBoxVolume->setVisible(true);
|
||||
checkBoxBrightness->setVisible(true);
|
||||
pushButtonSetSync->setVisible(true);
|
||||
btnSyncSet->setVisible(true);
|
||||
fdSyncGet->setVisible(true);
|
||||
}
|
|
@ -59,12 +59,12 @@ private:
|
|||
QCheckBox *checkBoxVolume;
|
||||
QCheckBox *checkBoxScreenSwitch;
|
||||
QHBoxLayout *horizontalLayout_7;
|
||||
QPushButton *pushButtonSetSync;
|
||||
QPushButton *btnSyncSet;
|
||||
QPushButton *fdSyncGet;
|
||||
QGroupBox *groupBox_4;
|
||||
QHBoxLayout *horizontalLayout_11;
|
||||
QRadioButton *radioButton_4;
|
||||
QRadioButton *radioButton_5;
|
||||
QRadioButton *fdMaster;
|
||||
QRadioButton *fdSlave;
|
||||
QHBoxLayout *horizontalLayout_12;
|
||||
QPushButton *btnLoraMasterSet;
|
||||
QPushButton *btnLoraMasterGet;
|
|
@ -2,7 +2,7 @@
|
|||
#define LEDCARD_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QDebug>
|
||||
class LedCard : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString strCardId MEMBER m_strCardId NOTIFY CardIdChanged)
|
||||
|
@ -13,6 +13,9 @@ class LedCard : public QObject {
|
|||
|
||||
public:
|
||||
LedCard(QObject *p = nullptr);
|
||||
~LedCard(){
|
||||
qDebug()<<"~~~~LedCard";
|
||||
}
|
||||
signals:
|
||||
void CardIdChanged(const QString &);
|
||||
void CardIpChanged(const QString &);
|
||||
|
@ -31,8 +34,7 @@ public:
|
|||
QString androidVersion = "";
|
||||
int iHttpGetId = 0;
|
||||
int androidHeight = 0;
|
||||
//int iCardSystemVersion = 0;
|
||||
int brightness = 255;
|
||||
int bright{100};
|
||||
int androidWidth = 0;
|
||||
int lastActive = 0;
|
||||
QString strIMEI="";
|
|
@ -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); //隐藏不匹配的结果
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ class UpgradeApkDialog : public QDialog {
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit UpgradeApkDialog(QWidget *parent = nullptr);
|
||||
QString filePath, fileId;
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *ev);
|
||||
protected slots:
|
||||
|
@ -17,9 +18,8 @@ protected slots:
|
|||
private:
|
||||
void onAddLedCard(LedCard *p);
|
||||
|
||||
LoQTreeWidget *wDevicePublishList;
|
||||
LoQTreeWidget *table;
|
||||
QTreeWidgetItem *m_headerItem=nullptr;
|
||||
QString m_strUrl="";
|
||||
};
|
||||
|
||||
#endif // UpgradeApkDialog_H
|
|
@ -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();
|
||||
}
|
|
@ -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
|
|
@ -1,19 +1,20 @@
|
|||
#include "devicectrlpanel.h"
|
||||
#include "devicepanel.h"
|
||||
#include "tools.h"
|
||||
#include <QEvent>
|
||||
#include <QGridLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <wDevicesManager/ctrlbrightpanel.h>
|
||||
#include <wDevicesManager/controlpowerwidget.h>
|
||||
#include <wDevicesManager/controlnetconfigwidget.h>
|
||||
#include <wDevicesManager/ctrlverifyclockpanel.h>
|
||||
#include <wDevicesManager/controlhdmiwidget.h>
|
||||
#include <wDevicesManager/controlvolumewidget.h>
|
||||
#include <wDevicesManager/controlencryptwidget.h>
|
||||
#include <wDevicesManager/ctrladvancedpanel.h>
|
||||
#include <wDevicesManager/controltestwidget.h>
|
||||
#include <device/ctrlbrightpanel.h>
|
||||
#include <device/controlpowerwidget.h>
|
||||
#include <device/ctrlnetworkpanel.h>
|
||||
#include <device/ctrlverifyclockpanel.h>
|
||||
#include <device/ctrlhdmipanel.h>
|
||||
#include <device/controlvolumewidget.h>
|
||||
#include <device/ctrlpwdpanel.h>
|
||||
#include <device/ctrladvancedpanel.h>
|
||||
#include <device/controltestwidget.h>
|
||||
|
||||
QTextEdit *gFdResInfo;
|
||||
|
||||
|
@ -53,14 +54,14 @@ DeviceCtrlPanel::DeviceCtrlPanel(DevicePanel *parent) : QWidget(parent), mDevWgt
|
|||
curIndex = index;
|
||||
if(wgts[index]==0) {
|
||||
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_NetCfg) wgts[index] = new ControlNetConfigWidget(this,m_pLedlist);
|
||||
else if(index==Setting_PowerControl) wgts[index] = new ControlPowerWidget(this, gSelCards);
|
||||
else if(index==Setting_NetCfg) wgts[index] = new CtrlNetworkPanel(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_HDMI) wgts[index] = new ControlHdmiWidget(this,m_pLedlist);
|
||||
else if(index==Setting_Volume) wgts[index] = new ControlVolumeWidget(this,m_pLedlist);
|
||||
else if(index==Setting_Advanced) wgts[index] = new CtrlAdvancedPanel(this,m_pLedlist);
|
||||
else if(index==Setting_Test) wgts[index] = new ControlTestWidget(this,m_pLedlist);
|
||||
else if(index==Setting_Encrypt) wgts[index] = new CtrlPwdPanel(this);
|
||||
else if(index==Setting_HDMI) wgts[index] = new CtrlHdmiPanel(this);
|
||||
else if(index==Setting_Volume) wgts[index] = new ControlVolumeWidget(this, gSelCards);
|
||||
else if(index==Setting_Advanced) wgts[index] = new CtrlAdvancedPanel(this);
|
||||
else if(index==Setting_Test) wgts[index] = new ControlTestWidget(this, gSelCards);
|
||||
}
|
||||
scrollArea->takeWidget();
|
||||
scrollArea->setWidget(wgts[index]);
|
||||
|
@ -97,19 +98,14 @@ DeviceCtrlPanel::DeviceCtrlPanel(DevicePanel *parent) : QWidget(parent), mDevWgt
|
|||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
connect(mDevWgt, &DevicePanel::sigSelectedDeviceList, this, [this](QList<LedCard*> *list) {
|
||||
m_pLedlist = list;
|
||||
if(m_pLedlist==nullptr) return;
|
||||
if(m_pLedlist->count()<=1) {
|
||||
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"));
|
||||
connect(mDevWgt, &DevicePanel::sigSelectedDeviceList, this, [this]() {
|
||||
if(gSelCards->count() < 2) {
|
||||
if(gSelCards->count()==1) mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+gSelCards->at(0)->m_strCardId);
|
||||
else mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
|
||||
fdInfo->hide();
|
||||
btnClear->hide();
|
||||
} else {
|
||||
QString strSelectNum = QString::number(m_pLedlist->count());
|
||||
mDevWgt->fdCardNumInfo->setText(tr("Multi screen operation")+"->"+tr("selected num")+":"+strSelectNum);
|
||||
mDevWgt->fdCardNumInfo->setText(tr("Multi screen operation")+". "+tr("selected num")+": "+QString::number(gSelCards->count()));
|
||||
fdInfo->clear();
|
||||
fdInfo->show();
|
||||
btnClear->show();
|
||||
|
@ -129,15 +125,16 @@ void DeviceCtrlPanel::transUi() {
|
|||
mBtnGrp->button(Setting_Bright)->setText(tr("Brightness Adjustment"));
|
||||
mBtnGrp->button(Setting_PowerControl)->setText(tr("Power Control"));
|
||||
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_Encrypt)->setText(tr("Encrypt"));
|
||||
mBtnGrp->button(Setting_Advanced)->setText(tr("Advanced parameters"));
|
||||
mBtnGrp->button(Setting_Volume)->setText(tr("Volume Adjustment"));
|
||||
mBtnGrp->button(Setting_Encrypt)->setText(tr("Password"));
|
||||
mBtnGrp->button(Setting_Advanced)->setText(tr("Advanced"));
|
||||
mBtnGrp->button(Setting_Volume)->setText(tr("Volume Adj."));
|
||||
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);
|
||||
else mDevWgt->fdCardNumInfo->setText(tr("Current Screen")+": "+tr("none"));
|
||||
if(gSelCards->count() < 1) 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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define DEVICECTRLPANEL_H
|
||||
|
||||
#include "globaldefine.h"
|
||||
#include "wDevicesManager/ledcard.h"
|
||||
#include "device/ledcard.h"
|
||||
#include <QScrollArea>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
|
@ -32,8 +32,6 @@ private:
|
|||
QPushButton *btnClear;
|
||||
QWidget *wgts[Setting_End]{};
|
||||
int curIndex{-1};
|
||||
QList<LedCard*> *m_pLedlist{0};
|
||||
LedCard *m_pLedCard{0};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <cfg.h>
|
||||
#include <QHttpMultiPart>
|
||||
#include <QUuid>
|
||||
#include "base/updaterdialog.h"
|
||||
#include <QBuffer>
|
||||
#include "base/pixbmpshowdialog.h"
|
||||
#include <QThread>
|
||||
|
@ -21,7 +20,7 @@
|
|||
|
||||
DeviceItem::DeviceItem(LedCard *pLedCard, LoQTreeWidget *parent,QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent){
|
||||
m_pWnd=pWnd;
|
||||
m_pLedCard=pLedCard;
|
||||
mCard=pLedCard;
|
||||
pHpptClient = new HpptClient(this);
|
||||
setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
setCheckState(0, Qt::Unchecked);
|
||||
|
@ -33,24 +32,24 @@ DeviceItem::DeviceItem(LedCard *pLedCard, LoQTreeWidget *parent,QWidget *pWnd) :
|
|||
m_bnCardDetailInfo->setStyleSheet(R"rrr(
|
||||
QPushButton {
|
||||
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");
|
||||
connect(m_bnCardDetailInfo, &QPushButton::clicked, this, [this]{
|
||||
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("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 height:")+QString::number(m_LedCard.androidHeight)+"\r\n");
|
||||
strTip.append(tr("IMEI:")).append(m_pLedCard->strIMEI).append("\r\n");
|
||||
strTip.append(tr("HardWard Version:")).append(m_pLedCard->HardVersion).append("\r\n");
|
||||
strTip.append(tr("MAX Brightness level:")).append(QString::number(m_pLedCard->BrightnessLevel)).append("\r\n");
|
||||
strTip.append(tr("Android OS Resolution:")).append(m_pLedCard->ScreenResolution).append("\r\n");
|
||||
strTip.append(tr("Firmware Version:")).append(m_pLedCard->FirmwareVersion).append("\r\n");
|
||||
strTip.append(tr("Player Version:")).append(m_pLedCard->strXixunplayerVersion).append("\r\n");
|
||||
strTip.append(tr("IMEI:")).append(mCard->strIMEI).append("\r\n");
|
||||
strTip.append(tr("HardWard Version:")).append(mCard->HardVersion).append("\r\n");
|
||||
strTip.append(tr("MAX Brightness level:")).append(QString::number(mCard->BrightnessLevel)).append("\r\n");
|
||||
strTip.append(tr("Android OS Resolution:")).append(mCard->ScreenResolution).append("\r\n");
|
||||
strTip.append(tr("Firmware Version:")).append(mCard->FirmwareVersion).append("\r\n");
|
||||
strTip.append(tr("Player Version:")).append(mCard->strXixunplayerVersion).append("\r\n");
|
||||
QMessageBox::information(gMainWin, tr("Detail Info"), strTip);
|
||||
});
|
||||
|
||||
|
@ -60,24 +59,24 @@ QPushButton:hover{background-color: #cccccc;}
|
|||
m_bnReadbackPic->setStyleSheet(R"rrr(
|
||||
QPushButton {
|
||||
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");
|
||||
connect(m_bnReadbackPic, SIGNAL(clicked()), this, SLOT(onReadbackPic()));
|
||||
|
||||
m_ImageOnline = new QLabel();
|
||||
m_pLedCard->m_bOnLine=true;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png"));
|
||||
setData(DeviceTable_ID, 0, m_pLedCard->m_strCardId);
|
||||
setData(DeviceTable_IP, 0, m_pLedCard->m_strCardIp);
|
||||
setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(m_pLedCard->m_iWidth).arg(m_pLedCard->m_iHeight));
|
||||
mCard->m_bOnLine=true;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
|
||||
setData(DeviceTable_ID, 0, mCard->m_strCardId);
|
||||
setData(DeviceTable_IP, 0, mCard->m_strCardIp);
|
||||
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_Screenshot, m_bnReadbackPic);
|
||||
m_parent->setItemWidget(this, DeviceTable_Online, m_ImageOnline);
|
||||
m_ImageOnline->setAlignment(Qt::AlignCenter);
|
||||
|
||||
SetPasswordItem(m_pLedCard);
|
||||
SetPasswordItem(mCard);
|
||||
for(int i=1; i<DeviceTable_Screenshot; i++) setTextAlignment(i, Qt::AlignCenter);
|
||||
|
||||
//启动心跳,监测设备在线和下线,3次超时表示下线
|
||||
|
@ -91,12 +90,12 @@ QPushButton:hover{background-color: #cccccc;}
|
|||
HttpPostByTypeJsonObject(json4);
|
||||
if(m_HeartbeatCount>10) {
|
||||
//下线
|
||||
m_pLedCard->m_bOnLine=false;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Offline.png"));
|
||||
mCard->m_bOnLine=false;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Offline.png"));
|
||||
} else {
|
||||
//在线
|
||||
m_pLedCard->m_bOnLine=true;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png"));
|
||||
mCard->m_bOnLine=true;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
|
||||
}
|
||||
});
|
||||
mHeartbeatTimer.start(60000);
|
||||
|
@ -157,7 +156,7 @@ void DeviceItem::OnControlTcpSend(int iProgramIndex) {
|
|||
QTcpSocket *send = new QTcpSocket();
|
||||
connect(send, SIGNAL(connected()), this, SLOT(connect_sucessful()));
|
||||
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;
|
||||
tempStreadPakcet.SyncHead[0]=0x7e;
|
||||
|
@ -175,8 +174,8 @@ void DeviceItem::OnControlTcpSend(int iProgramIndex) {
|
|||
QByteArray databuf = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
||||
if(!send->waitForConnected(10000)) //等待连接返回
|
||||
{
|
||||
qDebug()<<m_pLedCard->m_strCardIp<<"Connect timeout ";
|
||||
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("Connect")+":"+tr("timeout"));
|
||||
qDebug()<<mCard->m_strCardIp<<"Connect timeout ";
|
||||
emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("Connect")+":"+tr("timeout"));
|
||||
send->close();
|
||||
delete send;
|
||||
return ;
|
||||
|
@ -186,7 +185,7 @@ void DeviceItem::OnControlTcpSend(int iProgramIndex) {
|
|||
{
|
||||
send->read(send->bytesAvailable());
|
||||
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();
|
||||
delete send;
|
||||
|
@ -197,23 +196,12 @@ void DeviceItem::HttpPostByTypeJsonObject(QJsonObject json)
|
|||
QJsonDocument doc;
|
||||
doc.setObject(json);
|
||||
QByteArray post_loginArray = doc.toJson(QJsonDocument::Compact);
|
||||
m_strUrl="http://"+m_pLedCard->m_strCardIp+":2016/settings";
|
||||
if(m_pLedCard->m_strCardId.left(2)!="M8"&&m_pLedCard->m_strCardId.left(2)!="m8")
|
||||
m_strUrl="http://"+mCard->m_strCardIp+":2016/settings";
|
||||
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")
|
||||
{
|
||||
// pHpptClient->httpPost(m_strUrl,post_loginArray);
|
||||
|
||||
}
|
||||
else {
|
||||
pHpptClient->httpPost(m_strUrl,post_loginArray);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pHpptClient->httpPost(m_strUrl,post_loginArray);
|
||||
if(json["_type"]!="GetAllScreenSizeM80") pHpptClient->httpPost(m_strUrl,post_loginArray);
|
||||
}
|
||||
else pHpptClient->httpPost(m_strUrl,post_loginArray);
|
||||
}
|
||||
void DeviceItem::HttpGetLedCardWidthHeight()
|
||||
{
|
||||
|
@ -230,7 +218,7 @@ void DeviceItem::HttpGetLedCardRemarkName(){
|
|||
}
|
||||
|
||||
void DeviceItem::refreshLable(){
|
||||
if(m_pLedCard->m_bPowerStatus){
|
||||
if(mCard->m_bPowerStatus){
|
||||
this->setForeground(DeviceTable_Power, Qt::green);
|
||||
setData(DeviceTable_Power, 0, tr("on"));
|
||||
} else {
|
||||
|
@ -267,10 +255,10 @@ void DeviceItem::onReadbackPic() {
|
|||
}
|
||||
void DeviceItem::SetPasswordItem(LedCard *p){
|
||||
if(p->bPassword) {//加过密
|
||||
if(p->m_bLockStatus) m_bnLock->setIcon(QIcon(":/res/DeviceManager/Lock.png")); //如果已经验证通过密码显示绿色图标
|
||||
else m_bnLock->setIcon(QIcon(":/res/DeviceManager/UnLock.png")); //如果没有验证显示蓝色锁图标
|
||||
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, DeviceTable_Password, m_bnLock);
|
||||
} else m_bnLock->setIcon(QIcon(":/res/DeviceManager/Transparent.png")); //显示空白
|
||||
} else m_bnLock->setIcon(QIcon()); //显示空白
|
||||
}
|
||||
//获取到httpPost的应答,如果参数变化需要出发修改控件item的内容
|
||||
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();
|
||||
if(jsonObject["success"].toBool()==true)
|
||||
{
|
||||
//alahover 20200521 qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
|
||||
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();
|
||||
m_pLedCard->m_iHeight=jsonObject["height"].toInt();
|
||||
mCard->m_iWidth=jsonObject["width"].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" )
|
||||
{
|
||||
m_pLedCard->m_strCardRemarkName = QString::fromUtf8(QByteArray::fromBase64(jsonObject["alias"].toString().toLatin1()));
|
||||
setData(DeviceTable_Remark,0,m_pLedCard->m_strCardRemarkName);
|
||||
mCard->m_strCardRemarkName = QString::fromUtf8(QByteArray::fromBase64(jsonObject["alias"].toString().toLatin1()));
|
||||
setData(DeviceTable_Remark,0,mCard->m_strCardRemarkName);
|
||||
}
|
||||
else if(strType=="GetCardName")
|
||||
{
|
||||
m_HeartbeatCount=0;
|
||||
m_pLedCard->m_bOnLine=true;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png"));
|
||||
mCard->m_bOnLine=true;
|
||||
m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
|
||||
}
|
||||
else if(strType=="GetBuildInformation" )
|
||||
{
|
||||
m_pLedCard->strIMEI=jsonObject["IMEI"].toString();
|
||||
m_pLedCard->HardVersion=jsonObject["HardVersion"].toString();
|
||||
m_pLedCard->BrightnessLevel=jsonObject["BrightnessLevel"].toInt();
|
||||
m_pLedCard->ScreenResolution=jsonObject["ScreenResolution"].toString();
|
||||
m_pLedCard->FirmwareVersion=jsonObject["FirmwareVersion"].toString();
|
||||
//if(m_pLedCard->CompareHTTPPostParam()==false)
|
||||
|
||||
mCard->strIMEI=jsonObject["IMEI"].toString();
|
||||
mCard->HardVersion=jsonObject["HardVersion"].toString();
|
||||
mCard->BrightnessLevel=jsonObject["BrightnessLevel"].toInt();
|
||||
mCard->ScreenResolution=jsonObject["ScreenResolution"].toString();
|
||||
mCard->FirmwareVersion=jsonObject["FirmwareVersion"].toString();
|
||||
}
|
||||
else if(strType=="CheckSoftVersions" )
|
||||
{
|
||||
|
@ -335,42 +320,36 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
|
|||
QJsonObject oApp = value.toObject();
|
||||
if(oApp["packageName"].toString().contains("xixunplayer"))
|
||||
{
|
||||
m_pLedCard->strXixunplayerVersion=oApp["versionName"].toString();
|
||||
m_pLedCard->strXixunplayerVersionCode=oApp["versionCode"].toInt();
|
||||
mCard->strXixunplayerVersion=oApp["versionName"].toString();
|
||||
mCard->strXixunplayerVersionCode=oApp["versionCode"].toInt();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(strType == "HasControllerPassword")
|
||||
{
|
||||
//if(m_pLedCard->bPassword!=jsonObject["result"].toBool())
|
||||
{
|
||||
m_pLedCard->bPassword=jsonObject["result"].toBool();
|
||||
SetPasswordItem(m_pLedCard);
|
||||
mCard->bPassword=jsonObject["result"].toBool();
|
||||
SetPasswordItem(mCard);
|
||||
}
|
||||
}
|
||||
else if(strType == "SetScreenOn")
|
||||
{
|
||||
emit sigOutputInfo(m_pLedCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetScreenOn")+":"+tr("success"));
|
||||
}
|
||||
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")
|
||||
{
|
||||
//if(m_pLedCard->m_bPowerStatus!=jsonObject["on"].toBool())
|
||||
{
|
||||
m_pLedCard->m_bPowerStatus=jsonObject["on"].toBool();
|
||||
if(m_pLedCard->m_bPowerStatus) {
|
||||
mCard->m_bPowerStatus=jsonObject["on"].toBool();
|
||||
if(mCard->m_bPowerStatus) {
|
||||
this->setForeground(DeviceTable_Power, Qt::green);
|
||||
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 {
|
||||
this->setForeground(DeviceTable_Power, Qt::red);
|
||||
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)//解密成功
|
||||
{
|
||||
qDebug()<<"解密成功";
|
||||
m_pLedCard->m_bLockStatus=false;
|
||||
mCard->m_bLockStatus=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"解密失败";
|
||||
X_UIMsgBoxOk *mb = new X_UIMsgBoxOk(tr("Tip Info"),tr("password is wrong"), m_pWnd,0);
|
||||
mb->exec();
|
||||
m_pLedCard->m_bLockStatus=true;
|
||||
mCard->m_bLockStatus=true;
|
||||
}
|
||||
SetPasswordItem(m_pLedCard);
|
||||
SetPasswordItem(mCard);
|
||||
} else if(strType == "GetBrightness") {
|
||||
m_pLedCard->brightness = jsonObject["brightness"].toInt();
|
||||
QString bright = QString::number(m_pLedCard->brightness);
|
||||
setData(DeviceTable_Brightness, 0, QString::number(m_pLedCard->brightness*100/m_pLedCard->BrightnessLevel)+"% ("+bright+")");
|
||||
emit sigOutputInfo(m_pLedCard->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"));
|
||||
mCard->bright = jsonObject["brightnessPercentage"].toInt(-1);
|
||||
if(mCard->bright==-1) mCard->bright = qRound(jsonObject["brightness"].toInt() * 100.0 / mCard->BrightnessLevel);
|
||||
QString bright = QString::number(mCard->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 == "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")
|
||||
{
|
||||
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")
|
||||
{
|
||||
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")
|
||||
{
|
||||
int itempVolume=jsonObject["volume"].toInt();
|
||||
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")
|
||||
{
|
||||
emit sigOutputInfo(m_pLedCard->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"));
|
||||
emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetTimingScreenTask")+":"+tr("success"));
|
||||
}
|
||||
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")
|
||||
{
|
||||
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")
|
||||
{
|
||||
emit sigOutputInfo(m_pLedCard->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"));
|
||||
emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("SetRealtimeServer")+":"+tr("success"));
|
||||
}
|
||||
else if(strType == "GetCurrentSensorBrightness")
|
||||
{
|
||||
|
@ -529,33 +424,7 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
|
|||
int iTempValue=jsonObject["value"].toInt();
|
||||
QString strSensorValue=QString::number(iTempValue);
|
||||
|
||||
emit sigOutputInfo(m_pLedCard->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()));
|
||||
emit sigOutputInfo(mCard->m_strCardId+":"+tr("receive")+"<-"+tr("GetCurrentSensorBrightness")+":"+strSensorType+","+tr("Cur brightness")+":"+strSensorValue);
|
||||
} else if(strType == "GetScreenshotFull") {
|
||||
MACRO_ASKTIME_STOP
|
||||
MACRO_POSTING_DLG_UNLOCK
|
||||
|
@ -570,18 +439,10 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
|
|||
//imageresult.loadFromData(Ret_bytearray);
|
||||
PixbmpShowDialog *dlg=new PixbmpShowDialog(m_pWnd);
|
||||
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();
|
||||
}
|
||||
} 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)
|
||||
|
@ -600,17 +461,6 @@ QPixmap DeviceItem::Base64_To_Image(QByteArray bytearray,QString SavePath)
|
|||
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()
|
||||
{
|
||||
if(m_PostingDlg!=nullptr)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QPushButton>
|
||||
#include <base/loqtreewidget.h>
|
||||
#include <wDevicesManager/ledcard.h>
|
||||
#include <device/ledcard.h>
|
||||
#include <communication/hpptclient.h>
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
|
@ -44,11 +44,10 @@ public:
|
|||
void HttpGetLedCardRemarkName();
|
||||
QPixmap Base64_To_Image(QByteArray bytearray,QString SavePath);
|
||||
|
||||
LedCard *m_pLedCard{0};
|
||||
LedCard *mCard{0};
|
||||
QTimer mHeartbeatTimer;
|
||||
signals:
|
||||
void sigOutputInfo(QString);
|
||||
void sigSetTipTextContent(QString);
|
||||
|
||||
public slots:
|
||||
void DeletePostingDlg();
|
||||
|
@ -57,7 +56,6 @@ public slots:
|
|||
protected slots:
|
||||
void onReadbackPic();
|
||||
void onVerifyLockPassword();
|
||||
void slotUploadProgress(qint64 A,qint64 B);
|
||||
private:
|
||||
int m_intIndexFlagOfInfoOrControl=0;
|
||||
void SetPasswordItem(LedCard *p);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "devicepanel.h"
|
||||
#include "devicectrlpanel.h"
|
||||
#include "tools.h"
|
||||
#include "gqt.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include <QAction>
|
||||
#include <QBoxLayout>
|
||||
#include <QEvent>
|
||||
|
@ -31,7 +31,7 @@ DevicePanel::DevicePanel(QSettings &settings, QWidget *parent) : QWidget(parent)
|
|||
hBox->setSpacing(2);
|
||||
|
||||
auto label = new QLabel();
|
||||
label->setPixmap({":/res/DeviceManager/DeviceNum_All.png"});
|
||||
label->setPixmap({":/res/device/DeviceNum_All.png"});
|
||||
label->setScaledContents(true);
|
||||
label->setFixedSize(33, 24);
|
||||
hBox->addWidget(label);
|
||||
|
@ -46,9 +46,16 @@ DevicePanel::DevicePanel(QSettings &settings, QWidget *parent) : QWidget(parent)
|
|||
auto fdSearch = new QLineEdit();
|
||||
fdSearch->setClearButtonEnabled(true);
|
||||
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;");
|
||||
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->addSpacing(10);
|
||||
|
@ -80,7 +87,7 @@ QComboBox {
|
|||
}
|
||||
QComboBox:hover {background-color: #08b;}
|
||||
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 {
|
||||
height: 28px;
|
||||
color: #fff;
|
||||
|
@ -91,7 +98,7 @@ QComboBox QAbstractItemView::item:selected {background-color: #09c;}
|
|||
btnRefresh = new QPushButton(tr("Refresh"), areaFlash);
|
||||
btnRefresh->setGeometry(0, 0, 75, areaFlash->height());
|
||||
connect(btnRefresh, &QPushButton::clicked, this, [this] {
|
||||
LedCardList.clear();
|
||||
mLedCards.clear();
|
||||
mDeviceTable->onCheckAll(false);
|
||||
mDeviceTable->clear();
|
||||
nDeviceNum->setText("0");
|
||||
|
@ -137,12 +144,12 @@ QPushButton:hover {background-color: #08b;}
|
|||
parseInfo(document.object(), addr);
|
||||
} else {
|
||||
auto bytes = gram.data();
|
||||
STREAM_PACKET *pStreamPacket = (STREAM_PACKET *)bytes.data();
|
||||
auto packet = (Packet *)bytes.data();
|
||||
LedCard *pLedCard = new LedCard(this);//alahover 没有释放
|
||||
pLedCard->m_strCardId = pStreamPacket->ucSerialCode;
|
||||
pLedCard->m_strCardId = packet->serialCode;
|
||||
pLedCard->m_strCardIp = addr;
|
||||
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) {//如果已经存在在列表中
|
||||
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针
|
||||
for(int i=0;i<mLedCards.count();i++) if(mLedCards.at(i)->m_strCardId==pLedCard->m_strCardId ) {//如果已经存在在列表中
|
||||
auto pOldLedCard = mLedCards.at(i);//获取到旧的对象指针
|
||||
pOldLedCard->m_bOnLine = true;
|
||||
if(pOldLedCard->CompareHTTPGetParam(pLedCard)==false) {//如果ip地址变化了
|
||||
pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
|
||||
|
@ -154,7 +161,7 @@ QPushButton:hover {background-color: #08b;}
|
|||
delete pLedCard;
|
||||
return;
|
||||
}
|
||||
LedCardList.append(pLedCard);
|
||||
mLedCards.append(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);
|
||||
mDeviceTable->setHeaderItem(m_headerItem);
|
||||
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->setColumnWidth(DeviceTable_Online, 48);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_ID, QHeaderView::Stretch);
|
||||
|
@ -188,7 +195,6 @@ QPushButton:hover {background-color: #08b;}
|
|||
mDeviceTable->hideColumn(0);
|
||||
mDeviceTable->fdIsSelAll->hide();
|
||||
|
||||
|
||||
specifyIPDlg = new QDialog(this);
|
||||
specifyIPDlg->setWindowTitle(tr("Specify IP"));
|
||||
|
||||
|
@ -246,30 +252,28 @@ DevicePanel::~DevicePanel() {
|
|||
}
|
||||
|
||||
void DevicePanel::sendGetInfo() {
|
||||
QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
|
||||
// if(mUdpSocket.writeDatagram(data, QHostAddress("255.255.255.255"), 22222) != data.length()) {
|
||||
// qDebug() << "getInfo writeDatagram to 255.255.255.255 Failed";
|
||||
// }
|
||||
const QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
|
||||
uchar ccc[]{0x7E, 0x7E, 0x7E, 0x90, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x21,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x9F};
|
||||
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();
|
||||
foreach(QNetworkInterface face, networkinterfaces) {
|
||||
auto flags = face.flags();
|
||||
bool can = (flags & QNetworkInterface::IsRunning) && (flags & QNetworkInterface::CanBroadcast) && ! (flags & QNetworkInterface::IsLoopBack);
|
||||
if(! can) continue;
|
||||
qDebug() << face;
|
||||
auto addrEntries = face.addressEntries();
|
||||
foreach(QNetworkAddressEntry addrEntry, addrEntries) {
|
||||
auto ip = addrEntry.ip();
|
||||
if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue;
|
||||
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();
|
||||
if(! ipstr.isEmpty()) {
|
||||
auto ips = ipstr.split("\n", Qt::SkipEmptyParts);
|
||||
foreach(auto ip, ips) {
|
||||
if(gDevicePanel->mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "Specify IP write Failed." << ip;
|
||||
}
|
||||
foreach(auto ip, ips) if(mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "getInfo specify IP write failed." << ip;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,82 +312,21 @@ void DevicePanel::transUi() {
|
|||
bnSpecifyIP->setItemText(0,tr("Specify IP"));
|
||||
label_3->setText(tr("All"));
|
||||
|
||||
m_headerItem->setData(DeviceTable_Check, 0, "");
|
||||
m_headerItem->setData(DeviceTable_Online, 0, tr("Online"));
|
||||
m_headerItem->setData(DeviceTable_ID, 0, tr("Screen ID"));
|
||||
m_headerItem->setData(DeviceTable_IP, 0, tr("Screen IP"));
|
||||
m_headerItem->setData(DeviceTable_ScreenSize, 0, tr("Screen Size"));
|
||||
m_headerItem->setData(DeviceTable_Remark, 0, tr("Remark Name"));
|
||||
m_headerItem->setData(DeviceTable_Screenshot, 0, tr("readback pic"));
|
||||
m_headerItem->setData(DeviceTable_Brightness, 0, tr("Cur Brightness"));
|
||||
m_headerItem->setData(DeviceTable_Power, 0, tr("Power Status"));
|
||||
m_headerItem->setData(DeviceTable_Password, 0, tr("Security"));
|
||||
m_headerItem->setData(DeviceTable_Info, 0, tr("More Info"));
|
||||
m_headerItem->setText(DeviceTable_Online, tr("Online"));
|
||||
m_headerItem->setText(DeviceTable_ID, tr("Screen ID"));
|
||||
m_headerItem->setText(DeviceTable_IP, tr("Screen IP"));
|
||||
m_headerItem->setText(DeviceTable_ScreenSize, tr("Screen Size"));
|
||||
m_headerItem->setText(DeviceTable_Remark, tr("Remark Name"));
|
||||
m_headerItem->setText(DeviceTable_Screenshot, tr("readback pic"));
|
||||
m_headerItem->setText(DeviceTable_Brightness, tr("Cur Brightness"));
|
||||
m_headerItem->setText(DeviceTable_Power, tr("Power Status"));
|
||||
m_headerItem->setText(DeviceTable_Password, tr("Security"));
|
||||
m_headerItem->setText(DeviceTable_Info, tr("More Info"));
|
||||
|
||||
auto cnt = mDeviceTable->topLevelItemCount();
|
||||
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){
|
||||
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);
|
||||
|
@ -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) {
|
||||
DeviceItem *item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
|
||||
item->HttpPostByTypeJsonObject(json);
|
||||
QString strCardId=item->m_pLedCard->m_strCardId;
|
||||
QString strCardId=item->mCard->m_strCardId;
|
||||
mDeviceCtrlPanel->OnOutputInfo(strCardId+":"+tr("send")+"->"+strFanYi);
|
||||
}
|
||||
}
|
||||
|
@ -405,7 +348,7 @@ int DevicePanel::GetSelectDeviceNum() {
|
|||
mSelCards.clear();
|
||||
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) {
|
||||
iSelectCount++;
|
||||
mSelCards.append(static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->m_pLedCard);
|
||||
mSelCards.append(static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->mCard);
|
||||
}
|
||||
return iSelectCount;
|
||||
}
|
||||
|
@ -420,28 +363,35 @@ void DevicePanel::onCheckStateChanged(int f){
|
|||
emit sigSelectedDeviceList(&mSelCards);
|
||||
}
|
||||
}
|
||||
void DevicePanel::addLedCard(LedCard *p){
|
||||
void DevicePanel::addLedCard(LedCard *card) {
|
||||
int cnt = mDeviceTable->topLevelItemCount();
|
||||
for(int i=0; i<cnt; i++) {
|
||||
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
|
||||
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue;
|
||||
item->setData(DeviceTable_ID, 0, p->m_strCardId);
|
||||
item->setData(DeviceTable_IP, 0, p->m_strCardIp);
|
||||
item->setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(p->m_iWidth).arg(p->m_iHeight));
|
||||
if(item->mCard->m_strCardId != card->m_strCardId) continue;
|
||||
item->setData(DeviceTable_ID, 0, card->m_strCardId);
|
||||
item->setData(DeviceTable_IP, 0, card->m_strCardIp);
|
||||
item->setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(card->m_iWidth).arg(card->m_iHeight));
|
||||
return;
|
||||
}
|
||||
new DeviceItem(p, mDeviceTable, this);
|
||||
new DeviceItem(card, mDeviceTable, this);
|
||||
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) {
|
||||
int cnt = mDeviceTable->topLevelItemCount();
|
||||
for(int i=0; i<cnt; 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;
|
||||
if(item->m_ImageOnline) {
|
||||
item->m_pLedCard->m_bOnLine = true;
|
||||
item->m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png"));
|
||||
item->mCard->m_bOnLine = true;
|
||||
item->m_ImageOnline->setPixmap(QPixmap(":/res/device/O_Online.png"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -465,8 +415,8 @@ void DevicePanel::parseInfo(const QJsonObject &subObj, const QString &strIp) {
|
|||
pLedCard->androidWidth=subObj["androidWidth"].toInt();
|
||||
pLedCard->lastActive=subObj["lastActive"].toInt();
|
||||
|
||||
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) { //如果已经存在在列表中
|
||||
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针
|
||||
for(int i=0;i<mLedCards.count();i++) if(mLedCards.at(i)->m_strCardId==pLedCard->m_strCardId ) { //如果已经存在在列表中
|
||||
auto pOldLedCard = mLedCards.at(i);//获取到旧的对象指针
|
||||
pOldLedCard->m_bOnLine = true;
|
||||
if(! pOldLedCard->CompareHTTPGetParam(pLedCard)) {//如果ip地址变化了
|
||||
pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
|
||||
|
@ -478,7 +428,7 @@ void DevicePanel::parseInfo(const QJsonObject &subObj, const QString &strIp) {
|
|||
delete pLedCard;
|
||||
return;
|
||||
}
|
||||
LedCardList.append(pLedCard);
|
||||
mLedCards.append(pLedCard);
|
||||
addLedCard(pLedCard);//发送信号到界面
|
||||
}
|
||||
|
||||
|
@ -486,7 +436,7 @@ STREAM_PACKET LedOkMakeStreamPacket(int iComType,int iLen,unsigned char *ucBuf,Q
|
|||
STREAM_PACKET Temp;
|
||||
memset(&Temp, 0, sizeof(STREAM_PACKET));
|
||||
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);
|
||||
char* ch;
|
||||
QByteArray ba = str.toLatin1(); // must
|
||||
|
@ -521,11 +471,10 @@ void DevicePanel::RestoreLedCardIpByUdpCmd() {
|
|||
if(strGateway.length()<=20)
|
||||
memcpy(stTempIp.cDns,strGateway.toLatin1().data(),strGateway.length());
|
||||
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);
|
||||
if(!tempUdpSocket->bind(entry.ip())) break;
|
||||
tempUdpSocket->writeDatagram((char *)&tempStreadPacket,iLenPacket,broadcastAddress, 31296);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
void clearUdpHeartbeat(LedCard *);
|
||||
void parseInfo(const QJsonObject &subObj,const QString &strIp);
|
||||
void RestoreLedCardIpByUdpCmd();
|
||||
QList<LedCard *> LedCardList;
|
||||
QList<LedCard *> mLedCards;
|
||||
protected:
|
||||
void changeEvent(QEvent *) override;
|
||||
void transUi();
|
||||
|
@ -40,7 +40,6 @@ public slots:
|
|||
void ShowDevicesInfoOrControlWidget(int index);
|
||||
protected slots:
|
||||
void onCheckStateChanged(int f);
|
||||
void FilterProgram(const QString &strtemp);
|
||||
void OnControlSendJson(QJsonObject &json,QString strFanYi);
|
||||
void OnControlTcpSend(int iProgramIndex);
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@ using namespace std;
|
|||
|
||||
AVFmt::AVFmt(QByteArray url) {
|
||||
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) {
|
||||
err = "Open input fail: "+errStr(res);
|
||||
return;
|
||||
}
|
||||
res = avformat_find_stream_info(fmt_ctx, nullptr);
|
||||
res = avformat_find_stream_info(fmt_ctx, 0);
|
||||
if(res < 0) {
|
||||
err = "Find stream info fail: "+errStr(res);
|
||||
return;
|
||||
|
@ -31,28 +31,28 @@ AVFmt::AVFmt(QByteArray url) {
|
|||
auto decoder = avcodec_find_decoder(viStream->codecpar->codec_id);
|
||||
if(decoder==0) {
|
||||
vi.idx = -1;
|
||||
qInfo()<<"Couldn't found Video Decoder";
|
||||
qCritical()<<"avcodec_find_decoder fail";
|
||||
} else {
|
||||
vi.ctx = avcodec_alloc_context3(decoder);
|
||||
avcodec_parameters_to_context(vi.ctx, viStream->codecpar);
|
||||
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;
|
||||
qInfo()<<"Couldn't open Video Codec Ctx";
|
||||
qCritical()<<"avcodec_open2 fail:"<<errStr(res);
|
||||
} 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);
|
||||
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
|
||||
qInfo()<<"sws_setColorspaceDetails"<<res;
|
||||
if(res < 0) {
|
||||
err = "Colorspace not support";
|
||||
return;
|
||||
}
|
||||
if(res < 0) qInfo()<<"sws_setColorspaceDetails fail:"<<errStr(res);
|
||||
}
|
||||
vi.time_num = viStream->time_base.num * 1000000;
|
||||
vi.time_den = viStream->time_base.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;
|
||||
qWarning()<<"Couldn't open aCodecCtx";
|
||||
} else {
|
||||
#if(QT_VERSION_MAJOR < 6)
|
||||
out_ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
|
||||
out_ch_layout.nb_channels = 2;
|
||||
out_ch_layout.u.mask = AV_CH_LAYOUT_STEREO;
|
||||
#endif
|
||||
swr_alloc_set_opts2(&swr_ctx,
|
||||
&out_ch_layout, packed_sample_fmt, audioFmt.sampleRate(),
|
||||
&au.ctx->ch_layout, au.ctx->sample_fmt, au.ctx->sample_rate, 0, nullptr);
|
||||
|
@ -213,7 +215,7 @@ void AVFmt::mainRead() {
|
|||
lock.unlock();
|
||||
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') {
|
||||
if(au.idx!=-1) {
|
||||
unique_lock<mutex> lock(au.pkts.mtx);
|
||||
|
@ -249,7 +251,7 @@ void AVFmt::mainRead() {
|
|||
qInfo()<<"Read Packet End";
|
||||
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) {
|
||||
qCritical()<<"Seek Packet fail:"<<errStr(res_seek);
|
||||
wait = 500; continue;
|
||||
|
@ -270,7 +272,11 @@ void AVFmt::mainRead() {
|
|||
wait = 0;
|
||||
}
|
||||
}
|
||||
static void imgCleanupHandler(void *info) {
|
||||
delete [] (uchar*)info;
|
||||
}
|
||||
void AVFmt::mainViDecode() {
|
||||
uint8_t *dst[4]{0};
|
||||
while(true) {
|
||||
if(vi_frms.size >= 7) {
|
||||
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)) {
|
||||
if(res == AVERROR_EOF) break;
|
||||
else if(res < 0) {qCritical()<<"Video receive frame fail:"<<errStr(res); break;}
|
||||
QImage img(vi.ctx->width, vi.ctx->height, QImage::Format_ARGB32);
|
||||
uint8_t *dst[4]{img.bits()};
|
||||
int dstStride[4]{(int)img.bytesPerLine()};
|
||||
dst[0] = new uchar[dstStride[3]];
|
||||
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);
|
||||
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});
|
||||
}
|
||||
}
|
||||
|
@ -560,13 +566,13 @@ void FFPlayer::onClose() {
|
|||
void FFPlayer::onPlay() {
|
||||
if(ctx==0) return;
|
||||
status = Playing;
|
||||
ctx->sink->resume();
|
||||
if(ctx->sink) ctx->sink->resume();
|
||||
startAudioDaemon();
|
||||
}
|
||||
void FFPlayer::onPause() {
|
||||
if(ctx==0) return;
|
||||
status = Paused;
|
||||
ctx->sink->suspend();
|
||||
if(ctx->sink) ctx->sink->suspend();
|
||||
}
|
||||
void FFPlayer::onStop() {
|
||||
if(audioDaemonTimerId!=0) {
|
||||
|
|
|
@ -169,23 +169,28 @@ protected:
|
|||
void playAudio(Pcm *, FFPlayer *, qint64, qint64 lmt = INT64_MAX);
|
||||
void whiteAudio(Pcm *, FFPlayer *, bool, qint64 cur, qint64 lmt = INT64_MAX);
|
||||
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);
|
||||
}
|
||||
|
||||
QString err;
|
||||
const static int err_size{255};
|
||||
char err_str[err_size]{};
|
||||
char errbuf[AV_ERROR_MAX_STRING_SIZE]{};
|
||||
|
||||
AVFormatContext *fmt_ctx{0};
|
||||
std::thread *read_thd{0};
|
||||
qint64 start{0};
|
||||
Type vi, au;
|
||||
qint64 frmDur{0};
|
||||
qint64 viLmt{0};
|
||||
|
||||
SwsContext *sws_ctx{0};
|
||||
int dstStride[4]{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};
|
||||
QAudioSink *sink{0};
|
||||
QIODevice *sinkWriter{0};
|
||||
|
|
|
@ -12,14 +12,14 @@ bool gTextAntialiasing = false;
|
|||
bool gShowLoraScreen = 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};
|
||||
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
request.setTransferTimeout(timeout);
|
||||
if(contentType.isValid()) request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
|
||||
if(timeout) request.setTransferTimeout(timeout);
|
||||
if(! contentType.isEmpty()) request.setRawHeader("Content-Type", contentType);
|
||||
return request;
|
||||
}
|
||||
QString parseReplyJson(QNetworkReply *reply, QJsonDocument *outJson) {
|
||||
QString replyErr(QNetworkReply *reply) {
|
||||
reply->deleteLater();
|
||||
auto error = reply->error();
|
||||
if(error != QNetworkReply::NoError) {
|
||||
|
@ -29,41 +29,41 @@ QString parseReplyJson(QNetworkReply *reply, QJsonDocument *outJson) {
|
|||
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"+reply->readAll();
|
||||
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()+"\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) {
|
||||
auto data = reply->readAll();
|
||||
QJsonParseError jsonErr;
|
||||
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+":\n"+data;
|
||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *doc, QByteArray *outData) {
|
||||
reply->deleteLater();
|
||||
auto error = reply->error();
|
||||
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
|
||||
auto err = replyErr(reply);
|
||||
auto data = reply->readAll();
|
||||
if(outData) *outData = data;
|
||||
if(error != QNetworkReply::NoError) {
|
||||
auto errStr = reply->errorString();
|
||||
if(error!=QNetworkReply::InternalServerError || ! errStr.endsWith("replied: Unknown")) {
|
||||
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;
|
||||
}
|
||||
if(! err.isEmpty()) {
|
||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||
return err;
|
||||
}
|
||||
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;
|
||||
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(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+":\n"+data;
|
||||
if(doc) doc->swap(json);
|
||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||
if(outJson) outJson->swap(json);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -92,22 +92,13 @@ bool isFileExist(QString fullFileName)
|
|||
return false;
|
||||
}
|
||||
|
||||
quint64 dirFileSize(const QString &path)
|
||||
{
|
||||
quint64 dirFileSize(const QString &path) {
|
||||
QDir dir(path);
|
||||
quint64 size = 0;
|
||||
//dir.entryInfoList(QDir::Files)返回文件信息
|
||||
foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
|
||||
{
|
||||
//计算文件大小
|
||||
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);
|
||||
}
|
||||
auto infos = 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);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef GLOBALDEFINE_H
|
||||
#define GLOBALDEFINE_H
|
||||
#include <QString>
|
||||
#define MACRO_FENGEFU "/"
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
@ -15,47 +14,34 @@ enum {
|
|||
MainPage_End,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
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
|
||||
{
|
||||
struct RESTORE_IP {
|
||||
char cNewIp[20];
|
||||
char cMask[20];
|
||||
char cGateway[20];
|
||||
char cDns[20];
|
||||
// char cLocalIp[20];
|
||||
|
||||
}RESTORE_IP,*P_RESTORE_IP;
|
||||
typedef struct _STREAM_PACKET
|
||||
{
|
||||
unsigned char SyncHead[STREAM_SYNC_HEAD_NUM];
|
||||
};
|
||||
struct Packet {
|
||||
unsigned char SyncHead[3];
|
||||
unsigned char ucCommType;
|
||||
char serialCode[20];
|
||||
unsigned int iLength;
|
||||
};
|
||||
struct STREAM_PACKET {
|
||||
unsigned char SyncHead[3];
|
||||
unsigned char ucCommType;
|
||||
char ucSerialCode[20];
|
||||
unsigned int iLength;
|
||||
unsigned int iLength;
|
||||
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_ONLY_RESET_CARD_IP=0X43,
|
||||
COMMAND_SET_M31_DOUBLE_HUB=0X44,
|
||||
|
@ -78,7 +64,7 @@ enum _NET_COMMU_TYPE
|
|||
NET_COMMU_TYPE_LIMITE_TIME,
|
||||
NET_COMMU_TYPE_SYSTEM_BROADCAST,//0X90
|
||||
NET_COMMU_TYPE_REALTIME_INSERT_PLAY,
|
||||
//NET_COMMU_TYPE_SHANSUO_INSERT_PLAY,
|
||||
|
||||
NET_COMMU_TYPE_MODIFY_SERIAL_ID,
|
||||
NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM,
|
||||
NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT,
|
||||
|
@ -139,7 +125,6 @@ enum _NET_COMMU_TYPE
|
|||
NET_COMMU_TYPE_IO_CHECK_ANSWER,
|
||||
NET_COMMU_TYPE_LIMITE_TIME_ANSWER,
|
||||
|
||||
////
|
||||
NET_COMMU_TYPE_SYSTEM_BROADCAST_ANSWER,
|
||||
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_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_NUM_ANSWER,
|
||||
|
||||
|
||||
COMMAND_CONNECT_COLSE_ANSWER
|
||||
|
||||
};
|
||||
|
||||
extern bool gVideoCompress;
|
||||
extern bool gVideoTranscoding;
|
||||
extern bool gTextAntialiasing;
|
||||
|
@ -188,17 +172,24 @@ enum _ENUM_CONTRL_WIDGET {
|
|||
Setting_End,
|
||||
};
|
||||
|
||||
QNetworkRequest netReq(const QString &url, int = QNetworkRequest::DefaultTransferTimeoutConstant, const QVariant &contentType = QVariant::Invalid);
|
||||
inline QNetworkRequest reqForJson(const QString &url) {
|
||||
return netReq(url, 30000, "application/json");
|
||||
QNetworkRequest netReq(const QString &url, const QByteArray & = QByteArray(), int = QNetworkRequest::DefaultTransferTimeoutConstant);
|
||||
inline QNetworkRequest reqForJson(const QString &url, int timeout = QNetworkRequest::DefaultTransferTimeoutConstant) {
|
||||
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);
|
||||
|
||||
#define Def_CtrlReqPre \
|
||||
waitingDlg->show();\
|
||||
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 \
|
||||
QString err = checkReplyForJson(reply);\
|
||||
|
@ -220,78 +211,38 @@ QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0
|
|||
|
||||
#define Def_CtrlSetMulti(tip) \
|
||||
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);\
|
||||
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 \
|
||||
if(m_pLedlist!=nullptr) {\
|
||||
if(m_pLedlist->count()==0 || (m_pLedlist->count()==1 && m_pLedCard==nullptr)) {\
|
||||
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));\
|
||||
return;\
|
||||
}\
|
||||
if(gSelCards->isEmpty()) {\
|
||||
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));\
|
||||
return;\
|
||||
}
|
||||
|
||||
#define MACRO_DEFINE_TIPDLG_FUCN(TIP,SUCCESS,FAILED) \
|
||||
if(m_pLedlist!=nullptr) {\
|
||||
if(m_pLedlist->count()<=1) {\
|
||||
if(m_pLedCard!=nullptr) {\
|
||||
HttpPostByTypeJsonObject(pHpptClient,m_strUrl,json);\
|
||||
if(m_PostingDlg==nullptr) {\
|
||||
m_PostingDlg = new LoEmptyDialog(this);\
|
||||
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
|
||||
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
|
||||
m_PostingDlg->lock(TIP,SUCCESS,FAILED);\
|
||||
m_pGetAskTimer->start(5000);\
|
||||
m_PostingDlg->exec();\
|
||||
}\
|
||||
}\
|
||||
} else emit sigSend(json,TIP);\
|
||||
}
|
||||
if(gSelCards->count()==1) {\
|
||||
HttpPostByTypeJsonObject(pHpptClient, m_strUrl, json);\
|
||||
if(m_PostingDlg==nullptr) {\
|
||||
m_PostingDlg = new LoEmptyDialog(this);\
|
||||
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
|
||||
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
|
||||
m_PostingDlg->lock(TIP,SUCCESS,FAILED);\
|
||||
m_pGetAskTimer->start(5000);\
|
||||
m_PostingDlg->exec();\
|
||||
}\
|
||||
} else if(gSelCards->count() > 1) emit sigSend(json,TIP);
|
||||
|
||||
|
||||
#define MACRO_DEFINE_TIPDLG_ALL_FUCN(READBACK,SUCCESS,FAILED) \
|
||||
if(m_pLedCard!=nullptr)\
|
||||
{\
|
||||
if(m_PostingDlg==nullptr)\
|
||||
{\
|
||||
if(gSelCards->count()==1) {\
|
||||
if(m_PostingDlg==nullptr) {\
|
||||
m_PostingDlg = new LoEmptyDialog(this);\
|
||||
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
|
||||
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_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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "qcore.h"
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -1,7 +1,9 @@
|
|||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QStyleFactory>
|
||||
#include <QMessageBox>
|
||||
#include <QSplashScreen>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#ifdef _MSC_VER //MSVC编译器
|
||||
#include <Windows.h>
|
||||
|
@ -29,7 +31,7 @@ LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
|
|||
#endif
|
||||
|
||||
QString gFileHome;
|
||||
|
||||
QString css;
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
@ -38,12 +40,18 @@ int main(int argc, char *argv[]) {
|
|||
QApplication::setOrganizationDomain("www.ledok.cn");
|
||||
QApplication::setApplicationName("LedOK Express");
|
||||
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;
|
||||
font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"});
|
||||
font.setPixelSize(14);
|
||||
a.setFont(font);
|
||||
|
||||
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||
QSplashScreen splash(QPixmap(":/res/splash.png"));
|
||||
splash.show();
|
||||
splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "mainwindow.h"
|
||||
#include "base/aboutdlg.h"
|
||||
#include "base/softconfigdialog.h"
|
||||
#include "base/updaterdialog.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "cfg.h"
|
||||
#include "tools.h"
|
||||
#include "wDevicesManager/upgradeapkdialog.h"
|
||||
#include "device/upgradeapkdialog.h"
|
||||
#include <QColorDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QLabel>
|
||||
|
@ -14,6 +14,7 @@
|
|||
#include <QSettings>
|
||||
#include <QButtonGroup>
|
||||
#include <QHeaderView>
|
||||
#include "QSimpleUpdater.h"
|
||||
|
||||
QWidget *gMainWin;
|
||||
extern QPoint gPlayPos;
|
||||
|
@ -46,30 +47,36 @@ protected:
|
|||
};
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||
setAttribute(Qt::WA_AlwaysShowToolTips);
|
||||
gMainWin = this;
|
||||
QMenu *menuLang = new QMenu();
|
||||
QAction *actLan = nullptr;
|
||||
QAction *actCN = new QAction("中文");
|
||||
auto menuLang = new QMenu();
|
||||
|
||||
auto actCN = new QAction("中文");
|
||||
actCN->setCheckable(true);
|
||||
actCN->setObjectName("zh_CN");
|
||||
QAction *actTW = new QAction("中文繁体");
|
||||
menuLang->addAction(actCN);
|
||||
|
||||
auto actTW = new QAction("中文繁体");
|
||||
actTW->setCheckable(true);
|
||||
actTW->setObjectName("zh_TW");
|
||||
QAction *actEn = new QAction("English");
|
||||
menuLang->addAction(actTW);
|
||||
|
||||
auto actEn = new QAction("English");
|
||||
actEn->setCheckable(true);
|
||||
actEn->setObjectName("en");
|
||||
QAction *actJa = new QAction("日本語");
|
||||
menuLang->addAction(actEn);
|
||||
|
||||
auto actJa = new QAction("日本語");
|
||||
actJa->setCheckable(true);
|
||||
actJa->setObjectName("ja");
|
||||
menuLang->addAction(actCN);
|
||||
menuLang->addAction(actTW);
|
||||
menuLang->addAction(actEn);
|
||||
menuLang->addAction(actJa);
|
||||
|
||||
langGrp = new QActionGroup(menuLang);
|
||||
langGrp->addAction(actCN);
|
||||
langGrp->addAction(actTW);
|
||||
langGrp->addAction(actEn);
|
||||
langGrp->addAction(actJa);
|
||||
|
||||
connect(menuLang, &QMenu::triggered, this, [this](QAction* action) {
|
||||
auto lanName = action->objectName();
|
||||
translator.load("app_"+lanName, ":/i18n");
|
||||
|
@ -77,12 +84,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
});
|
||||
|
||||
QSettings settings;
|
||||
settings.remove("MainSetting");
|
||||
settings.remove("MainWindowMaximized");
|
||||
settings.remove("posMainWindow");
|
||||
settings.remove("sizeMainWindow");
|
||||
settings.remove("DirectlyConnectNetWork");
|
||||
QString langName = settings.value("Language").toString();
|
||||
QAction *actLan = nullptr;
|
||||
if(! langName.isEmpty()) {
|
||||
if(langName.endsWith("CN")) actLan = actCN;
|
||||
else if(langName.endsWith("TW")) actLan = actTW;
|
||||
|
@ -105,8 +108,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
QApplication::installTranslator(&transQt);
|
||||
|
||||
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);
|
||||
else resize(1280, 720);
|
||||
if(geo.width()>=800 && geo.height()>=500 && geo.x()>=-600 && geo.x()<=1280 && geo.y()>=-200 && geo.y()<=800) setGeometry(geo);
|
||||
else resize(1280, 800);
|
||||
if(settings.value("MainIsMax", false).toBool()) setWindowState(Qt::WindowMaximized);
|
||||
|
||||
gPlayPos = settings.value("PlayPos").toPoint();
|
||||
|
@ -115,7 +118,6 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
icon.load(":/res/Logo.png");
|
||||
titlePos = QPointF(26, 80);
|
||||
iconPos = QPointF(38, 20);
|
||||
setStyleSheet(Tools::styleSheet());
|
||||
auto plt = palette();
|
||||
plt.setBrush(QPalette::Window, QColor(0xdddddd));
|
||||
setPalette(plt);
|
||||
|
@ -146,33 +148,87 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
|
||||
bn_Setting = new QPushButton();
|
||||
bn_Setting->setIcon(QIcon(":/res/AppSetting.png"));
|
||||
bn_Setting->setToolTip(tr("Setting"));
|
||||
|
||||
pLayout->addWidget(bn_Setting);
|
||||
pLayout->addWidget(m_wTitle->bn_Minimize);
|
||||
pLayout->addWidget(m_wTitle->bn_Maximize);
|
||||
pLayout->addWidget(m_wTitle->bn_Close);
|
||||
|
||||
QMenu *menu_setting = new QMenu();
|
||||
auto menu_setting = new QMenu();
|
||||
act_lang = new QAction();
|
||||
act_lang->setMenu(menuLang);
|
||||
menu_setting->addAction(act_lang);
|
||||
|
||||
act_softconfiguration = new QAction(tr("Software Configuration"));
|
||||
act_softconfiguration->setObjectName("Software Configuration");
|
||||
act_softconfiguration = new QAction(tr("Software Config"));
|
||||
connect(act_softconfiguration, &QAction::triggered, this, [this] {
|
||||
SoftConfigDialog dlg(this);
|
||||
dlg.exec();
|
||||
mBtnGrp->button(MainPage_LoraScreen)->setVisible(gShowLoraScreen);
|
||||
});
|
||||
menu_setting->addAction(act_softconfiguration);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
auto actInfo = new QAction(tr("Info"));
|
||||
actInfo = new QAction;
|
||||
connect(actInfo, &QAction::triggered, this, [this] {
|
||||
QMessageBox::information(this, tr("Info"),
|
||||
QString("SupportsSsl: ").append(QSslSocket::supportsSsl()?"true":"false")
|
||||
|
@ -182,32 +238,12 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
menu_setting->addAction(actInfo);
|
||||
|
||||
act_about = new QAction(tr("About"));
|
||||
act_about->setObjectName("About");
|
||||
menu_setting->addAction(act_about);
|
||||
|
||||
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();
|
||||
mBtnGrp->button(MainPage_LoraScreen)->setVisible(gShowLoraScreen);
|
||||
}
|
||||
connect(act_about, &QAction::triggered, this, [this] {
|
||||
AboutDlg dlg(this);
|
||||
dlg.exec();
|
||||
});
|
||||
menu_setting->addAction(act_about);
|
||||
bn_Setting->setMenu(menu_setting);//按钮上添加下拉菜单
|
||||
|
||||
QSimpleUpdater *updater = QSimpleUpdater::getInstance();
|
||||
connect(updater, &QSimpleUpdater::checkingFinished, this, [this]() {
|
||||
|
@ -296,6 +332,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
hBox->addWidget(m_pOneKeyCheckCard);
|
||||
hBox->addStretch();
|
||||
|
||||
//hBox->addWidget(new QLabel("ver: " APP_VERSION ".2"));
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
gVideoCompress = settings.value("VideoCompress", true).toBool();
|
||||
|
@ -373,9 +411,7 @@ void MainWindow::test() {
|
|||
qDebug()<<"status"<<status;
|
||||
return;
|
||||
}
|
||||
auto req = reply->request();
|
||||
qDebug()<<"reply url"<<reply->url();
|
||||
qDebug()<<"req url"<<req.url();
|
||||
auto resp = reply->readAll();
|
||||
qDebug()<<"resp"<<resp;
|
||||
};
|
||||
|
@ -405,6 +441,7 @@ MainWindow::~MainWindow() {
|
|||
if(mDevicePanel->fdIP) {
|
||||
auto ipstr = mDevicePanel->fdIP->toPlainText();
|
||||
if(! ipstr.isEmpty()) settings.setValue("SpecifyIP", ipstr);
|
||||
else settings.remove("SpecifyIP");
|
||||
}
|
||||
if(m_pTimerSendResoreIpOneKey!=nullptr) {
|
||||
if(m_pTimerSendResoreIpOneKey->isActive()) m_pTimerSendResoreIpOneKey->stop();
|
||||
|
@ -426,9 +463,10 @@ void MainWindow::transUi() {
|
|||
m_pOneKeyCheckCard->setText(tr("Check card"));
|
||||
act_lang->setText(tr("Language"));
|
||||
act_help->setText(tr("Help"));
|
||||
actInfo->setText(tr("Info"));
|
||||
act_about->setText(tr("About"));
|
||||
act_update->setText(tr("Check for updates"));
|
||||
act_updatefirmware->setText(tr("firmware manager"));
|
||||
act_softconfiguration->setText(tr("Software Configuration"));
|
||||
act_softconfiguration->setText(tr("Software Config"));
|
||||
bn_Setting->setToolTip(tr("Setting"));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "mguangyingpinwidget.h"
|
||||
#include "progpanel.h"
|
||||
#include <QTranslator>
|
||||
#include <QActionGroup>
|
||||
|
||||
class MainWindow : public BaseWin {
|
||||
Q_OBJECT
|
||||
|
@ -23,7 +24,7 @@ private:
|
|||
LoQTitleBar *m_wTitle;
|
||||
QActionGroup *langGrp;
|
||||
QAction *act_lang;
|
||||
QAction *act_help;
|
||||
QAction *act_help, *actInfo;
|
||||
QAction *act_update;
|
||||
QAction *act_updatefirmware;
|
||||
QAction *act_softconfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "digiclock.h"
|
||||
#include "gqt.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QVBoxLayout>
|
||||
|
|
|
@ -1,72 +1,80 @@
|
|||
#include "eleanaclock.h"
|
||||
#include <QJsonObject>
|
||||
#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());
|
||||
img.load(path);
|
||||
pinHourColor = layer["pinHourColor"].toString();
|
||||
pinMinColor = layer["pinMinColor"].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() {
|
||||
QTime time = QDateTime::currentDateTime().toTimeZone(timeZone).time();
|
||||
double rad = time.second()*M_PI/30;
|
||||
double rsin = sin(rad);
|
||||
double rcos = cos(rad);
|
||||
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();
|
||||
auto time = QDateTime::currentDateTime().toTimeZone(timeZone).time();
|
||||
sAngle = time.second() * 6;
|
||||
mAngle = time.minute() * 6 + sAngle/60;
|
||||
hAngle = time.hour() * 30 + mAngle/12;
|
||||
}
|
||||
void EleAnaClock::paintEvent(QPaintEvent *) {
|
||||
if(timerId==0) {
|
||||
timerId = startTimer(1000, Qt::PreciseTimer);
|
||||
timerId = startTimer(500, Qt::PreciseTimer);
|
||||
cal();
|
||||
}
|
||||
QPainter painter(this);
|
||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||
if(! img.isNull()) painter.drawPixmap(0, 0, width(), height(), img);
|
||||
painter.translate(width()/2, height()/2);
|
||||
painter.fillPath(hPath, QBrush(pinHourColor));
|
||||
painter.fillPath(mPath, QBrush(pinMinColor));
|
||||
painter.fillPath(sPath, QBrush(pinSecColor));
|
||||
painter.translate(-width()/2, -height()/2);
|
||||
|
||||
pen.setColor(pinHourColor);
|
||||
painter.setPen(pen);
|
||||
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 *) {
|
||||
if(isVisible()) {
|
||||
cal();
|
||||
repaint();
|
||||
update();
|
||||
} else if(timerId!=0) {
|
||||
killTimer(timerId);
|
||||
timerId = 0;
|
||||
|
|
|
@ -3,18 +3,21 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QTimeZone>
|
||||
#include <QPainterPath>
|
||||
#include <QPen>
|
||||
|
||||
class EleAnaClock : public QWidget {
|
||||
Q_OBJECT
|
||||
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();
|
||||
QTimeZone timeZone;
|
||||
QPixmap img;
|
||||
QColor pinHourColor, pinMinColor, pinSecColor;
|
||||
QPainterPath sPath, mPath, hPath;
|
||||
int timerId = 0;
|
||||
QPointF hPoses[3]{}, mPoses[3]{}, sPoses[3]{};
|
||||
double hAngle, mAngle, sAngle;
|
||||
QPen pen;
|
||||
int timerId{0};
|
||||
bool showSecHand{true};
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
|
|
@ -11,10 +11,10 @@ public:
|
|||
int w;
|
||||
int h;
|
||||
int startTime;
|
||||
int timeSpan;
|
||||
int endTime;
|
||||
bool repeat;
|
||||
|
||||
QWidget* wgt = nullptr;
|
||||
QWidget *wgt{0};
|
||||
};
|
||||
|
||||
#endif // ELEBASE_H
|
||||
|
|
|
@ -24,7 +24,7 @@ void EleGif::sltNext(){
|
|||
if(isVisible()) {
|
||||
movie->jumpToNextFrame();
|
||||
timer->inter = movie->nextFrameDelay();
|
||||
repaint();
|
||||
update();
|
||||
} else if(timer!=nullptr) {
|
||||
timer->stop();
|
||||
timer = nullptr;
|
||||
|
|
|
@ -7,10 +7,9 @@ const QChar effTypes[] = {'l', 't', 'r', 'b'};
|
|||
|
||||
EleMultiPng::EleMultiPng(QString dirPre, QJsonArray maps, QWidget *parent) : QWidget{parent} {
|
||||
QJsonObject map = maps[0].toObject();
|
||||
EffDur = map["effectSpeed"].toInt()*1000;
|
||||
if(EffDur==0) return;
|
||||
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()));
|
||||
QString effStr = map["effect"].toString();
|
||||
if(effStr.isEmpty() || effStr=="no") EffDur = 0;
|
||||
|
@ -85,6 +84,7 @@ void EleMultiPng::timerEvent(QTimerEvent *e) {
|
|||
}
|
||||
}
|
||||
update();
|
||||
foreach(auto split, splits) split->update();
|
||||
} else {
|
||||
if(timerId!=0) {
|
||||
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]);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
class EleSplitPng;
|
||||
class EleMultiPng : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -16,9 +16,22 @@ public:
|
|||
QChar effType = 0;
|
||||
QRandomGenerator rand;
|
||||
bool needRand = false;
|
||||
QList<EleSplitPng*> splits;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) 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
|
||||
|
|
|
@ -33,12 +33,15 @@ EleScroll::EleScroll(QWidget *parent, QString imgPath, char effect, double effDu
|
|||
}
|
||||
|
||||
void EleScroll::paintEvent(QPaintEvent *) {
|
||||
paint(this);
|
||||
}
|
||||
void EleScroll::paint(QPaintDevice *that) {
|
||||
if(img.isNull()) return;
|
||||
if(timerId==0 && effect!=0 && interval!=0) {
|
||||
cur = 0;
|
||||
timerId = startTimer(interval, Qt::PreciseTimer);
|
||||
}
|
||||
QPainter painter(this);
|
||||
QPainter painter(that);
|
||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||
if(effect=='l') {
|
||||
painter.drawPixmap(cur, 0, img);
|
||||
|
@ -65,8 +68,13 @@ void EleScroll::timerEvent(QTimerEvent *) {
|
|||
else cur+=curAdd;
|
||||
}
|
||||
update();
|
||||
foreach(auto split, splits) split->update();
|
||||
} else if(timerId!=0) {
|
||||
killTimer(timerId);
|
||||
timerId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void EleSplitScroll::paintEvent(QPaintEvent *) {
|
||||
scroll->paint(this);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define ELESCROLL_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class EleSplitScroll;
|
||||
class EleScroll : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -11,10 +11,21 @@ public:
|
|||
QPixmap img;
|
||||
char effect = 0;
|
||||
int interval = 0, timerId = 0, cur = 0, end = 0, curAdd = 1;
|
||||
|
||||
QList<EleSplitScroll*> splits;
|
||||
void paint(QPaintDevice *);
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) 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
|
||||
|
|
|
@ -32,10 +32,10 @@ EleVideo::EleVideo(QString path, QWidget *parent) : QWidget{parent} {
|
|||
// qDebug()<<"viSize"<<player->viSize;
|
||||
//}
|
||||
void EleVideo::showEvent(QShowEvent *) {
|
||||
if(player!=nullptr) player->play();
|
||||
if(player) player->play();
|
||||
}
|
||||
void EleVideo::hideEvent(QHideEvent *) {
|
||||
if(player!=nullptr) player->stop();
|
||||
if(player) player->stop();
|
||||
}
|
||||
|
||||
void EleVideo::paintEvent(QPaintEvent *e) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "elescroll.h"
|
||||
#include "eletimer.h"
|
||||
#include "elevideo.h"
|
||||
#include "gqt.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "posdlg.h"
|
||||
#include <QFileInfo>
|
||||
#include <QJsonArray>
|
||||
|
@ -43,23 +43,24 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const QJsonOb
|
|||
setPalette(plt);
|
||||
connect(this, &PlayWin::sigSetVisible, this, &PlayWin::sltSetVisible);
|
||||
|
||||
QJsonObject prog = aprog["task"].toObject();
|
||||
QJsonArray pageMaps = prog["items"].toArray();
|
||||
const auto pageMaps = aprog["task"]["items"].toArray();
|
||||
int pageCnt = pageMaps.size();
|
||||
EleBase ele; Page *page;
|
||||
for(int p=0; p<pageCnt; p++) {
|
||||
QJsonObject pageMap = pageMaps[p].toObject()["_program"].toObject();
|
||||
QJsonArray layers = pageMap["layers"].toArray();
|
||||
auto _program = pageMaps[p]["_program"].toObject();
|
||||
auto layers = _program["layers"].toArray();
|
||||
if(layers.isEmpty()) continue;
|
||||
auto splitWidths = _program["splitWidths"].toArray();
|
||||
page = new Page(this);
|
||||
page->setGeometry(0, 0, width, height);
|
||||
page->setVisible(false);
|
||||
for(int ll=layers.size()-1; ll>=0; ll--) {
|
||||
QJsonObject layer = layers[ll].toObject();
|
||||
auto repeat = layer["repeat"].toBool();
|
||||
QJsonArray srcMaps = layer["sources"].toArray();
|
||||
QJsonValue border = layer["border"];
|
||||
EleBorder *bdEle = nullptr;
|
||||
int bdWidth = 0, startTime = 0xffff, endTime = 0;
|
||||
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
||||
if(! border.isNull()) {
|
||||
bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page);
|
||||
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) {
|
||||
ele.type = srcMap["_type"].toString();
|
||||
if(ele.type.isEmpty()) continue;
|
||||
ele.timeSpan = srcMap["timeSpan"].toInt()*1000;
|
||||
if(ele.timeSpan==0) continue;
|
||||
auto timeSpan = srcMap["timeSpan"].toInt()*1000;
|
||||
if(timeSpan==0) continue;
|
||||
ele.x = srcMap["left"].toInt()+bdWidth;
|
||||
ele.y = srcMap["top"].toInt()+bdWidth;
|
||||
ele.w = srcMap["width"].toInt()-bdWidth-bdWidth;
|
||||
ele.h = srcMap["height"].toInt()-bdWidth-bdWidth;
|
||||
bool notAudio = ele.type!="Audio";
|
||||
if((ele.w<=0 || ele.h<=0) && notAudio) continue;
|
||||
ele.repeat = repeat;
|
||||
ele.startTime = srcMap["playTime"].toInt()*1000;
|
||||
if(startTime > ele.startTime) startTime = ele.startTime;
|
||||
ele.endTime = ele.startTime + ele.timeSpan;
|
||||
if(endTime < ele.endTime) endTime = ele.endTime;
|
||||
if(ele.endTime > page->timeSpan && notAudio) page->timeSpan = ele.endTime;
|
||||
if(bdStart > ele.startTime) bdStart = ele.startTime;
|
||||
ele.endTime = ele.startTime + timeSpan;
|
||||
if(bdEnd < ele.endTime) bdEnd = ele.endTime;
|
||||
if(page->timeSpan < ele.endTime && notAudio) page->timeSpan = ele.endTime;
|
||||
ele.id = srcMap["id"].toString();
|
||||
ele.wgt = nullptr;
|
||||
ele.wgt = 0;
|
||||
if(ele.type=="Image") {
|
||||
if(srcMap["mime"].toString().endsWith("gif")) ele.wgt = new EleGif(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.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 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=="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") {
|
||||
auto video = new EleVideo(dir+"/"+ele.id, page);
|
||||
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 continue;
|
||||
if(ele.wgt==nullptr) continue;
|
||||
if(ele.wgt==0) continue;
|
||||
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);
|
||||
}
|
||||
if(bdEle!=nullptr && srcMaps.size()>0) {
|
||||
if(bdEle && ! srcMaps.isEmpty()) {
|
||||
QJsonArray geometry = border["geometry"].toArray();
|
||||
ele.x = geometry[0].toInt();
|
||||
ele.y = geometry[1].toInt();
|
||||
ele.w = geometry[2].toInt();
|
||||
ele.h = geometry[3].toInt();
|
||||
ele.startTime = startTime;
|
||||
ele.endTime = endTime;
|
||||
ele.timeSpan = endTime - startTime;
|
||||
ele.startTime = bdStart;
|
||||
ele.endTime = bdEnd;
|
||||
ele.wgt = bdEle;
|
||||
if(ele.startTime>0) ele.wgt->setVisible(false);
|
||||
ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
|
||||
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);
|
||||
if(! pages.isEmpty()) {
|
||||
|
@ -165,7 +196,7 @@ void PlayWin::sltNext() {
|
|||
if(cur+2 > pages.size()) cur = 0;
|
||||
else cur++;
|
||||
Page* page = pages[cur];
|
||||
if(timer!=nullptr) timer->inter = page->timeSpan;
|
||||
if(timer) timer->inter = page->timeSpan;
|
||||
EleBase* ele;
|
||||
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));
|
||||
|
@ -173,22 +204,22 @@ void PlayWin::sltNext() {
|
|||
timerMap.insert(startTimer(ele->endTime), TimerValue(ele->wgt, false));
|
||||
}
|
||||
page->setVisible(true);
|
||||
} else if(timer!=nullptr) {
|
||||
} else if(timer) {
|
||||
timer->stop();
|
||||
timer = nullptr;
|
||||
timer = 0;
|
||||
}
|
||||
}
|
||||
void PlayWin::timerEvent(QTimerEvent *e){
|
||||
int id = e->timerId();
|
||||
killTimer(id);
|
||||
TimerValue value = timerMap[id];
|
||||
if(value.ele!=nullptr){
|
||||
if(value.ele) {
|
||||
timerMap.remove(id);
|
||||
value.ele->setVisible(value.visible);
|
||||
}
|
||||
}
|
||||
void PlayWin::paintEvent(QPaintEvent *e){
|
||||
if(timer==nullptr && isVisible() && ! pages.isEmpty()) {
|
||||
if(timer==0 && isVisible() && ! pages.isEmpty()) {
|
||||
if(cur!=0) {
|
||||
pages[cur]->setVisible(false);
|
||||
cur = 0;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
class Page : public QWidget {
|
||||
public:
|
||||
explicit Page(QWidget *parent = nullptr);
|
||||
int timeSpan = 0;
|
||||
int timeSpan{0};
|
||||
QVector<EleBase> eles;
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
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);
|
||||
|
||||
SyncTimer* timer = nullptr;
|
||||
SyncTimer* timer = 0;
|
||||
int cur = 0;
|
||||
QVector<Page*> pages;
|
||||
QMap<int,TimerValue> timerMap;
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
#include "progpanel.h"
|
||||
#include "globaldefine.h"
|
||||
#include "tools.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "cfg.h"
|
||||
#include "player/playwin.h"
|
||||
#include "tipdialog.h"
|
||||
#include "program/progcreatedlg.h"
|
||||
#include "program/progeditorwin.h"
|
||||
#include "program/copydirthread.h"
|
||||
#include <QApplication>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QProgressBar>
|
||||
|
||||
ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -28,10 +33,27 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
|||
bnNew->setProperty("ssType", "progManageTool");
|
||||
hBox->addWidget(bnNew);
|
||||
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(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
|
||||
mProgTree->adjustCheckState();
|
||||
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)));
|
||||
|
||||
bnImport = new QPushButton(tr("Import"));
|
||||
bnImport->setFixedSize(QSize(88, 38));
|
||||
bnImport->setFixedSize(88, 38);
|
||||
bnImport->setProperty("ssType", "progManageTool");
|
||||
hBox->addWidget(bnImport);
|
||||
connect(bnImport, &QPushButton::clicked, this, [this] {
|
||||
auto dlg = new TipDialog(this, ENUM_IMPORT_DLG);
|
||||
connect(dlg, SIGNAL(sigAcceptData(QString,QString)), this, SLOT(onImportProgram(QString,QString)));
|
||||
dlg->exec();
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
if(dir.isEmpty()) return;
|
||||
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"));
|
||||
|
@ -67,7 +136,36 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
|||
bnExport->setEnabled(false);
|
||||
bnExport->setProperty("ssType", "progManageTool");
|
||||
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->setFixedSize(QSize(88, 38));
|
||||
|
@ -95,11 +193,8 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
|||
QJsonObject prog = QJsonDocument::fromJson(value.toUtf8(), &jsErr).object();
|
||||
if(jsErr.error) return;
|
||||
if(PlayWin::self!=nullptr) PlayWin::self->close();
|
||||
if(item->mSplitWidth==0) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog);
|
||||
else {
|
||||
int cnt = (item->mWidth+item->mSplitWidth-1) / item->mSplitWidth;
|
||||
PlayWin::self = PlayWin::newIns(item->mSplitWidth, item->mHeight*cnt, dir, prog);
|
||||
}
|
||||
if(item->mSplitWidths.isEmpty()) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog);
|
||||
else PlayWin::self = PlayWin::newIns(item->mMaxWidth, item->mHeight * item->mSplitWidths.size(), dir, prog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +206,7 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
|||
auto txtSearch = new QLineEdit(this);
|
||||
txtSearch->setFixedSize(QSize(240, 36));
|
||||
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->setClearButtonEnabled(true);
|
||||
txtSearch->setStyleSheet("border: 2px solid #aaaaaa;");
|
||||
|
@ -252,10 +347,10 @@ bool ProgPanel::checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip){
|
|||
}
|
||||
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;
|
||||
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
|
||||
mProgTree->adjustCheckState();
|
||||
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){
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,31 +1,12 @@
|
|||
#ifndef PROGPANEL_H
|
||||
#define PROGPANEL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStyleOption>
|
||||
#include <QPainter>
|
||||
#include <QFile>
|
||||
#include <QAction>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QCheckBox>
|
||||
#include "base/loqtreewidget.h"
|
||||
#include "program/progitem.h"
|
||||
#include "basedlg.h"
|
||||
#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 "cfg.h"
|
||||
#include <base/loqtreewidget.h>
|
||||
#include <wProgramManager/progcreatedlg.h>
|
||||
#include <wProgramManager/progeditorwin.h>
|
||||
#include "wProgramManager/progitem.h"
|
||||
#include <QTableWidget>
|
||||
|
||||
class ProgPanel : public QWidget {
|
||||
Q_OBJECT
|
||||
|
@ -42,9 +23,7 @@ protected:
|
|||
public slots:
|
||||
void onEditClicked(bool f);
|
||||
void onDeleteClicked(bool f);
|
||||
void onExportClicked(bool f);
|
||||
void onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, int);
|
||||
void onImportProgram(QString strImportDir,QString strTip1);
|
||||
void onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &, int);
|
||||
void FilterProgram(const QString &strtemp);
|
||||
|
||||
private slots:
|
||||
|
@ -60,4 +39,13 @@ private:
|
|||
QPushButton *bnSend, *btnPlay;
|
||||
};
|
||||
|
||||
class ProgPortDlg : public BaseDlg {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProgPortDlg(QWidget *parent, QString title);
|
||||
|
||||
QTableWidget *table{0};
|
||||
QPushButton *bnOK, *bnClose;
|
||||
};
|
||||
|
||||
#endif // PROGPANEL_H
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -1,39 +1,34 @@
|
|||
#include "eaclock.h"
|
||||
#include "cfg.h"
|
||||
#include "globaldefine.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "tools.h"
|
||||
#include "base/locolorselector.h"
|
||||
#include <QtMath>
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#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;
|
||||
m_attr.timeZoneId = QTimeZone::systemTimeZoneId();
|
||||
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.minHandColor = Qt::green;
|
||||
m_attr.secHandColor = Qt::red;
|
||||
m_attr.textFont = QFont("Arial", 9);
|
||||
m_attr.textColor = Qt::red;
|
||||
m_attr.playDuration = 10;
|
||||
m_attr.hasDialImg = false;
|
||||
init();
|
||||
m_attr.timeZone = QTimeZone::systemTimeZone();
|
||||
m_attr.hourHandColor = Qt::yellow;
|
||||
m_attr.minHandColor = Qt::green;
|
||||
m_attr.secHandColor = Qt::red;
|
||||
m_attr.textColor = Qt::red;
|
||||
}
|
||||
|
||||
eAClock::eAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
|
||||
EAClock::EAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
|
||||
mType = EBase::AClock;
|
||||
setBaseAttr(json);
|
||||
auto widget = json["widget"];
|
||||
m_attr.timeZoneId = QByteArray().append(widget["timeZone"].toString().toUtf8());
|
||||
m_attr.hourMark = widget["hourMark"].toInt();
|
||||
m_attr.hourMarkSize = widget["hourMarkSize"].toInt();
|
||||
m_attr.timeZone = QTimeZone(widget["timeZone"].toString().toUtf8());
|
||||
m_attr.hourMark = widget["hourMark"].toInt();
|
||||
m_attr.hourMarkSize = widget["hourMarkSize"].toInt();
|
||||
auto color = widget["hourMarkColor"];
|
||||
m_attr.hourMarkColor = color.isString() ? QColor(color.toString()) : Tools::int2Color(color.toInt());
|
||||
m_attr.minMark = widget["minMark"].toInt();
|
||||
|
@ -53,6 +48,13 @@ eAClock::eAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
|
|||
m_attr.textFont.setBold(widget["textFontBold"].toBool());
|
||||
m_attr.textFont.setItalic(widget["textFontItalics"].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.path = widget["path"].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);
|
||||
else dial_img.load(m_attr.path+"/"+m_attr.name);
|
||||
init();
|
||||
}
|
||||
|
||||
void eAClock::init() {
|
||||
connect(Tools::getInstance(), &Tools::sTick, this, [this]() {
|
||||
time = QDateTime::currentDateTime().toTimeZone(QTimeZone(m_attr.timeZoneId)).time();
|
||||
void EAClock::timerEvent(QTimerEvent *) {
|
||||
if(isVisible()) {
|
||||
cal();
|
||||
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() {
|
||||
auto time = QDateTime::currentDateTime().toTimeZone(m_attr.timeZone).time();
|
||||
sAngle = time.second() * 6;
|
||||
mAngle = time.minute() * 6 + sAngle/60;
|
||||
hAngle = time.hour() * 30 + mAngle/12;
|
||||
}
|
||||
|
||||
qreal eAClock::radiusMin() const {
|
||||
qreal r = (rect().width() < rect().height() ? rect().width() : rect().height()) / 2;
|
||||
return r - m_attr.minMarkSize / 2;
|
||||
}
|
||||
|
||||
void eAClock::paintDial(QPainter *painter) {
|
||||
void EAClock::paintDial(QPainter *painter) {
|
||||
if(! m_attr.hasDialImg || dial_img.isNull()) {
|
||||
auto inner = innerRect();
|
||||
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());
|
||||
qreal r = diameter / 2;
|
||||
painter->save();
|
||||
|
@ -161,7 +160,7 @@ void eAClock::drawMarkCircular(QPainter *painter, const QPointF &pos, const QCol
|
|||
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());
|
||||
QRectF rect(-len/2, -len/2, len, len);
|
||||
|
@ -175,7 +174,7 @@ void eAClock::drawMarkRectangle(QPainter *painter, const QPointF &pos, const QCo
|
|||
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);
|
||||
QFont font("Arial");
|
||||
|
@ -192,61 +191,72 @@ void eAClock::drawMarkNumber(QPainter *painter, const QPointF &pos, const QColor
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
void eAClock::drawHand(QPainter *painter, qreal angle, const QColor &color, qreal len, qreal base) {
|
||||
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){
|
||||
void EAClock::paintText(QPainter *painter){
|
||||
if(m_attr.text.isNull() || m_attr.text.isEmpty()) return;
|
||||
QRectF r(0, rect().height()/6, rect().width(), rect().height()/4);
|
||||
QTextOption opt;
|
||||
opt.setAlignment(Qt::AlignCenter);
|
||||
painter->save();
|
||||
auto inner = innerRect();
|
||||
painter->setPen(m_attr.textColor);
|
||||
m_attr.textFont.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||
painter->setFont(m_attr.textFont);
|
||||
painter->drawText(r, m_attr.text, opt);
|
||||
painter->restore();
|
||||
painter->drawText(QRectF(0, inner.height()/6, inner.width(), inner.height()/4), m_attr.text, QTextOption(Qt::AlignCenter));
|
||||
}
|
||||
|
||||
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->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||
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());
|
||||
paintDial(painter);
|
||||
paintText(painter);
|
||||
drawHand(painter, time.hour() * 30.0, m_attr.hourHandColor, radius()/2, radius() / 20);
|
||||
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);
|
||||
painter->translate(inner.width() / 2, inner.height() / 2);
|
||||
|
||||
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();
|
||||
EBase::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
QWidget* eAClock::attrWgt() {
|
||||
QWidget* EAClock::attrWgt() {
|
||||
auto wgtAttr = new QWidget();
|
||||
|
||||
auto vBox = new QVBoxLayout(wgtAttr);
|
||||
auto vBox = new VBox(wgtAttr);
|
||||
vBox->setContentsMargins(6, 0, 6, 0);
|
||||
if(mMultiWin!=nullptr) vBox->setSpacing(3);
|
||||
if(mMultiWin) vBox->setSpacing(3);
|
||||
|
||||
addBaseAttrWgt(vBox);
|
||||
|
||||
auto hBox = new QHBoxLayout();
|
||||
auto hBox = new HBox(vBox);
|
||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
||||
|
||||
auto line = new QFrame();
|
||||
|
@ -254,26 +264,24 @@ QWidget* eAClock::attrWgt() {
|
|||
line->setFrameShadow(QFrame::Sunken);
|
||||
hBox->addWidget(line, 1);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addSpacing(6);
|
||||
hBox->addWidget(new QLabel(tr("Time Zone")));
|
||||
|
||||
auto wTimeZone = new QComboBox();
|
||||
QList<QByteArray> ids = QTimeZone::availableTimeZoneIds();
|
||||
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) {
|
||||
m_attr.timeZoneId = text.toUtf8();
|
||||
m_attr.timeZone = QTimeZone(text.toUtf8());
|
||||
update();
|
||||
});
|
||||
hBox->addWidget(wTimeZone);
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
auto fdHasDialImg = new QCheckBox(tr("Custom Dial"));
|
||||
fdHasDialImg->setChecked(m_attr.hasDialImg);
|
||||
hBox->addWidget(fdHasDialImg);
|
||||
|
@ -283,11 +291,10 @@ QWidget* eAClock::attrWgt() {
|
|||
line->setFrameShadow(QFrame::Sunken);
|
||||
hBox->addWidget(line, 1);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
auto wgtDial = new QWidget();
|
||||
if(! m_attr.hasDialImg) wgtDial->setVisible(false);
|
||||
hBox = new QHBoxLayout(wgtDial);
|
||||
hBox = new HBox(wgtDial);
|
||||
hBox->setContentsMargins(0, 0, 0, 0);
|
||||
hBox->addSpacing(6);
|
||||
auto fdDialImg = new QLineEdit();
|
||||
|
@ -334,10 +341,10 @@ QWidget* eAClock::attrWgt() {
|
|||
update();
|
||||
});
|
||||
|
||||
auto vbMarks = new QVBoxLayout(wgtMarks);
|
||||
auto vbMarks = new VBox(wgtMarks);
|
||||
vbMarks->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vbMarks);
|
||||
hBox->addSpacing(6);
|
||||
hBox->addWidget(new QLabel(tr("Hour Mark")));
|
||||
|
||||
|
@ -370,9 +377,8 @@ QWidget* eAClock::attrWgt() {
|
|||
hBox->addWidget(fdHourMarkColor);
|
||||
hBox->addStretch();
|
||||
|
||||
vbMarks->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vbMarks);
|
||||
hBox->addSpacing(6);
|
||||
hBox->addWidget(new QLabel(tr("Min Mark")));
|
||||
|
||||
|
@ -404,40 +410,108 @@ QWidget* eAClock::attrWgt() {
|
|||
hBox->addWidget(fdMinMarkColor);
|
||||
hBox->addStretch();
|
||||
|
||||
vbMarks->addLayout(hBox);
|
||||
|
||||
vBox->addWidget(wgtMarks);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox->addSpacing(6);
|
||||
hBox->addWidget(new QLabel(tr("Hand Color")));
|
||||
auto grid = new QGridLayout;
|
||||
grid->setColumnStretch(4, 1);
|
||||
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);
|
||||
connect(fdHourHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||
m_attr.hourHandColor = color;
|
||||
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);
|
||||
connect(fdMinHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||
m_attr.minHandColor = color;
|
||||
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);
|
||||
connect(fdSecHandColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||
m_attr.secHandColor = color;
|
||||
update();
|
||||
});
|
||||
hBox->addWidget(fdSecHandColor);
|
||||
hBox->addStretch();
|
||||
grid->addWidget(fdSecHandColor, 3, 1);
|
||||
|
||||
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->setFrameShape(QFrame::HLine);
|
||||
|
@ -452,7 +526,7 @@ QWidget* eAClock::attrWgt() {
|
|||
});
|
||||
vBox->addWidget(fdText);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addSpacing(6);
|
||||
|
||||
auto fdFontFamily = new QFontComboBox();
|
||||
|
@ -478,20 +552,14 @@ QWidget* eAClock::attrWgt() {
|
|||
hBox->addWidget(fdFontSize);
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
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);
|
||||
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->setFlat(true);
|
||||
fdBold->setChecked(m_attr.textFont.bold());
|
||||
connect(fdBold, &QPushButton::toggled, this, [this](bool checked) {
|
||||
m_attr.textFont.setBold(checked);
|
||||
|
@ -499,15 +567,10 @@ QWidget* eAClock::attrWgt() {
|
|||
});
|
||||
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);
|
||||
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->setFlat(true);
|
||||
fdItalic->setChecked(m_attr.textFont.italic());
|
||||
connect(fdItalic, &QPushButton::toggled, this, [this](bool checked) {
|
||||
m_attr.textFont.setItalic(checked);
|
||||
|
@ -515,15 +578,10 @@ QWidget* eAClock::attrWgt() {
|
|||
});
|
||||
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);
|
||||
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->setFlat(true);
|
||||
fdUnderline->setChecked(m_attr.textFont.underline());
|
||||
connect(fdUnderline, &QPushButton::toggled, this, [this](bool checked) {
|
||||
m_attr.textFont.setUnderline(checked);
|
||||
|
@ -541,9 +599,8 @@ QWidget* eAClock::attrWgt() {
|
|||
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
||||
|
||||
line = new QFrame();
|
||||
|
@ -551,9 +608,8 @@ QWidget* eAClock::attrWgt() {
|
|||
line->setFrameShadow(QFrame::Sunken);
|
||||
hBox->addWidget(line, 1);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addSpacing(6);
|
||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
||||
|
||||
|
@ -568,12 +624,11 @@ QWidget* eAClock::attrWgt() {
|
|||
hBox->addWidget(new QLabel(tr("s")));
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
vBox->addStretch();
|
||||
return wgtAttr;
|
||||
}
|
||||
|
||||
bool eAClock::save(const QString &pRoot){
|
||||
bool EAClock::save(const QString &pRoot){
|
||||
if(m_attr.hasDialImg) {
|
||||
QString file0 = m_attr.path + PAGEDEL_SUFFIX + "/" + 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.path = pRoot;
|
||||
QRectF inner = innerRect();
|
||||
QPixmap *tempPixamp = new QPixmap(inner.width(), inner.height());
|
||||
tempPixamp->fill(Qt::transparent);
|
||||
QPainter painter;
|
||||
painter.begin(tempPixamp);
|
||||
this->paintDial(&painter);
|
||||
this->paintText(&painter);
|
||||
painter.end();
|
||||
tempPixamp->save(pRoot+"/"+m_attr.selfCreateDialName, "PNG");
|
||||
delete tempPixamp;
|
||||
//生成表盘背景图
|
||||
QImage img(inner.width(), inner.height(), QImage::Format_ARGB32);
|
||||
img.fill(Qt::transparent);
|
||||
{
|
||||
QPainter painter(&img);
|
||||
paintDial(&painter);
|
||||
paintText(&painter);
|
||||
}
|
||||
img.save(pRoot+"/"+m_attr.selfCreateDialName, "PNG");
|
||||
return true;
|
||||
}
|
||||
QJsonObject eAClock::attrJson() const {
|
||||
QJsonObject oRoot;
|
||||
addBaseAttr(oRoot);
|
||||
oRoot["elementType"] = "AClock";
|
||||
QJsonObject oWidget;
|
||||
oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId);
|
||||
oWidget["hourMark"] = m_attr.hourMark;
|
||||
oWidget["hourMarkSize"] = m_attr.hourMarkSize;
|
||||
oWidget["hourMarkColor"] = m_attr.hourMarkColor.name();
|
||||
oWidget["minMark"] = m_attr.minMark;
|
||||
oWidget["minMarkSize"] = m_attr.minMarkSize;
|
||||
oWidget["minMarkColor"] = m_attr.minMarkColor.name();
|
||||
oWidget["hourHandColor"] = m_attr.hourHandColor.name();
|
||||
oWidget["minHandColor"] = m_attr.minHandColor.name();
|
||||
oWidget["secHandColor"] = m_attr.secHandColor.name();
|
||||
oWidget["text"] = m_attr.text;
|
||||
oWidget["textFontFamily"] = m_attr.textFont.family();
|
||||
oWidget["textFontSize"] = m_attr.textFont.pointSize();
|
||||
oWidget["textFontBold"] = m_attr.textFont.bold();
|
||||
oWidget["textFontItalics"] = m_attr.textFont.italic();
|
||||
oWidget["textFontUnderline"] = m_attr.textFont.underline();
|
||||
oWidget["textColor"] = m_attr.textColor.name();
|
||||
oWidget["path"] = m_attr.path;
|
||||
oWidget["name"] = m_attr.name;
|
||||
oWidget["selfCreateDialName"] = m_attr.selfCreateDialName;
|
||||
oWidget["bCustomDial"] = m_attr.hasDialImg;
|
||||
oRoot["widget"] = oWidget;
|
||||
oRoot["play"] = QJsonObject{{"duration", m_attr.playDuration}};
|
||||
return oRoot;
|
||||
QJsonObject EAClock::attrJson() const {
|
||||
QJsonObject json;
|
||||
addBaseAttr(json);
|
||||
json["elementType"] = "AClock";
|
||||
QJsonObject widget;
|
||||
widget["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
|
||||
widget["hourMark"] = m_attr.hourMark;
|
||||
widget["hourMarkSize"] = m_attr.hourMarkSize;
|
||||
widget["hourMarkColor"] = m_attr.hourMarkColor.name();
|
||||
widget["minMark"] = m_attr.minMark;
|
||||
widget["minMarkSize"] = m_attr.minMarkSize;
|
||||
widget["minMarkColor"] = m_attr.minMarkColor.name();
|
||||
widget["hourHandColor"] = m_attr.hourHandColor.name();
|
||||
widget["minHandColor"] = m_attr.minHandColor.name();
|
||||
widget["secHandColor"] = m_attr.secHandColor.name();
|
||||
widget["text"] = m_attr.text;
|
||||
widget["textFontFamily"] = m_attr.textFont.family();
|
||||
widget["textFontSize"] = m_attr.textFont.pointSize();
|
||||
widget["textFontBold"] = m_attr.textFont.bold();
|
||||
widget["textFontItalics"] = m_attr.textFont.italic();
|
||||
widget["textFontUnderline"] = m_attr.textFont.underline();
|
||||
widget["textColor"] = m_attr.textColor.name();
|
||||
widget["hhLen"] = m_attr.hhLen;
|
||||
widget["mhLen"] = m_attr.mhLen;
|
||||
widget["shLen"] = m_attr.shLen;
|
||||
widget["hhWidth"] = m_attr.hhWidth;
|
||||
widget["mhWidth"] = m_attr.mhWidth;
|
||||
widget["shWidth"] = m_attr.shWidth;
|
||||
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;
|
||||
}
|
|
@ -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
|
|
@ -1,6 +1,7 @@
|
|||
#include "eaudio.h"
|
||||
#include "cfg.h"
|
||||
#include "tools.h"
|
||||
#include "base/ffutil.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QDir>
|
||||
#include <QLabel>
|
||||
|
@ -13,7 +14,7 @@
|
|||
|
||||
EAudio *EAudio::create(const QString &file, PageListItem *pageItem, EBase *multiWin) {
|
||||
int64_t dur;
|
||||
QString err = Tools::audioInfo(file.toUtf8(), &dur);
|
||||
QString err = audioInfo(file.toUtf8(), &dur);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, "Audio Error", err+"\n"+file);
|
||||
return nullptr;
|
||||
|
@ -79,7 +80,7 @@ bool EAudio::save(const QString &pageDir) {
|
|||
|
||||
void EAudio::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
|
||||
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();
|
||||
if(inner.width() > inner.height()) inner.setWidth(inner.height());
|
||||
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());
|
||||
if(file.isEmpty()) return;
|
||||
int64_t dur;
|
||||
QString err = Tools::audioInfo(file.toUtf8(), &dur);
|
||||
QString err = audioInfo(file.toUtf8(), &dur);
|
||||
if(! err.isEmpty()) {
|
||||
QMessageBox::critical(gMainWin, "Audio Error", err+"\n"+file);
|
||||
return;
|
|
@ -1,5 +1,5 @@
|
|||
#include "ebase.h"
|
||||
#include "gqt.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "tools.h"
|
||||
#include <QDirIterator>
|
||||
#include <QGraphicsScene>
|
||||
|
@ -90,7 +90,7 @@ void EBase::addBaseAttr(QJsonObject &obj) 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;
|
||||
return QRectF(bdWidth, bdWidth, ele->mWidth-bdWidth-bdWidth, ele->mHeight-bdWidth-bdWidth);
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ void EBase::clearSnap() {
|
|||
update();
|
||||
}
|
||||
|
||||
void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
|
||||
void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||
if(mMultiWin!=nullptr) return;
|
||||
auto hBox = new QHBoxLayout();
|
||||
hBox->addWidget(new QLabel(tr("Area")));
|
||||
|
@ -648,10 +648,11 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
|
|||
hBox->setSpacing(0);
|
||||
|
||||
hBox->addStretch();
|
||||
auto borderFd = new QComboBox();
|
||||
auto borderFd = new QComboBox;
|
||||
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);
|
||||
borderFd->setIconSize(QSize(borderImgMaxWidth, borderImgMaxHeight));
|
||||
if(bdImgIdx>-1) borderFd->setCurrentIndex(bdImgIdx+1);
|
||||
connect(borderFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int idx){
|
||||
bdImgIdx = idx-1;
|
||||
if(bdImgIdx==-1 && bdTimerId>0) {
|
||||
|
@ -670,6 +671,7 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
|
|||
borderEffFd->addItem(tr("Rotate"), "rotate");
|
||||
borderEffFd->addItem(tr("Blink"), "blink");
|
||||
borderEffFd->addItem(tr("None"), "");
|
||||
if(bdImgIdx>-1) setCurrentData(borderEffFd, bdEff);
|
||||
connect(borderEffFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, borderEffFd] {
|
||||
bdEff = borderEffFd->currentData().toString();
|
||||
if(bdTimerId>0) {
|
||||
|
@ -687,7 +689,7 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
|
|||
borderSpeedFd->addItem(tr("Slow"), 1);
|
||||
borderSpeedFd->addItem(tr("Moderate"), 2);
|
||||
borderSpeedFd->addItem(tr("Fast"), 3);
|
||||
borderSpeedFd->setCurrentIndex(1);
|
||||
if(bdImgIdx>-1) setCurrentData(borderSpeedFd, bdSpeed);
|
||||
connect(borderSpeedFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, borderSpeedFd] {
|
||||
bdSpeed = borderSpeedFd->currentData().toInt();
|
||||
if(bdTimerId>0) {
|
||||
|
@ -700,10 +702,4 @@ void EBase::addBaseAttrWgt(QVBoxLayout *vBox) {
|
|||
hBox->addStretch();
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
if(bdImgIdx>-1) {
|
||||
borderFd->setCurrentIndex(bdImgIdx+1);
|
||||
select(borderEffFd, bdEff);
|
||||
select(borderSpeedFd, bdSpeed);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ public:
|
|||
virtual bool save(const QString &) {return true;}
|
||||
virtual QWidget* attrWgt() = 0;
|
||||
|
||||
void addBaseAttrWgt(QVBoxLayout *vBox);
|
||||
void addBaseAttrWgt(QBoxLayout *vBox);
|
||||
inline void setSize(qreal width, qreal height) {
|
||||
prepareGeometryChange();
|
||||
mWidth = width;
|
|
@ -7,8 +7,9 @@
|
|||
#include <QFontComboBox>
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
#include <QToolButton>
|
||||
|
||||
eDClock::eDClock(EBase *multiWin) : EBase(multiWin) {
|
||||
EDClock::EDClock(EBase *multiWin) : EBase(multiWin) {
|
||||
mType = EBase::DClock;
|
||||
m_attr.timeZoneId = QTimeZone::systemTimeZoneId();
|
||||
m_attr.font = QFont("Arial", 9);
|
||||
|
@ -29,7 +30,7 @@ eDClock::eDClock(EBase *multiWin) : EBase(multiWin) {
|
|||
init();
|
||||
}
|
||||
|
||||
eDClock::eDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
|
||||
EDClock::EDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
|
||||
mType = EBase::DClock;
|
||||
setBaseAttr(json);
|
||||
auto widget = json["widget"];
|
||||
|
@ -58,14 +59,14 @@ eDClock::eDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
|
|||
init();
|
||||
}
|
||||
|
||||
void eDClock::init() {
|
||||
void EDClock::init() {
|
||||
connect(Tools::getInstance(), &Tools::sTick, this, [this]() {
|
||||
datetime = QDateTime::currentDateTime().toTimeZone(QTimeZone(m_attr.timeZoneId));
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void eDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||
void EDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||
QString text;
|
||||
QDate date = datetime.date();
|
||||
QTime time = datetime.time();
|
||||
|
@ -133,7 +134,7 @@ void eDClock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
|||
EBase::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
QWidget* eDClock::attrWgt() {
|
||||
QWidget* EDClock::attrWgt() {
|
||||
auto wgtAttr = new QWidget();
|
||||
auto vBox = new QVBoxLayout(wgtAttr);
|
||||
vBox->setContentsMargins(6, 0, 6, 0);
|
||||
|
@ -378,15 +379,10 @@ QWidget* eDClock::attrWgt() {
|
|||
hBox = new QHBoxLayout();
|
||||
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);
|
||||
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->setFlat(true);
|
||||
fdBold->setChecked(m_attr.font.bold());
|
||||
connect(fdBold, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
m_attr.font.setBold(checked);
|
||||
|
@ -394,15 +390,10 @@ QWidget* eDClock::attrWgt() {
|
|||
});
|
||||
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);
|
||||
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->setFlat(true);
|
||||
fdItalic->setChecked(m_attr.font.italic());
|
||||
connect(fdItalic, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
m_attr.font.setItalic(checked);
|
||||
|
@ -410,21 +401,16 @@ QWidget* eDClock::attrWgt() {
|
|||
});
|
||||
hBox->addWidget(fdItalic);
|
||||
|
||||
auto fdUnderline = new QPushButton();
|
||||
fdUnderline->setFixedSize(30, 30);
|
||||
QIcon icon2;
|
||||
icon2.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontUnderline_u.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
icon2.addFile(QString::fromUtf8(":/res/ProgramManager/EditProgram/FontUnderline_s.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
fdUnderline->setIcon(icon2);
|
||||
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) {
|
||||
auto fdFontUnderline = new QPushButton("U");
|
||||
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontUnderline->setFixedSize(30, 30);
|
||||
fdFontUnderline->setCheckable(true);
|
||||
fdFontUnderline->setChecked(m_attr.font.underline());
|
||||
connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
m_attr.font.setUnderline(checked);
|
||||
update();
|
||||
});
|
||||
hBox->addWidget(fdUnderline);
|
||||
hBox->addWidget(fdFontUnderline);
|
||||
|
||||
auto fdColor = new LoColorSelector("T", m_attr.textColor);
|
||||
fdColor->setFixedWidth(30);
|
||||
|
@ -467,7 +453,7 @@ QWidget* eDClock::attrWgt() {
|
|||
return wgtAttr;
|
||||
}
|
||||
|
||||
QJsonObject eDClock::attrJson() const{
|
||||
QJsonObject EDClock::attrJson() const{
|
||||
QJsonObject oWidget;
|
||||
oWidget["timeZone"] = QString::fromUtf8(m_attr.timeZoneId);
|
||||
oWidget["year"] = m_attr.year;
|
|
@ -9,7 +9,7 @@
|
|||
#include <QTimer>
|
||||
#include "ebase.h"
|
||||
|
||||
class eDClock : public EBase {
|
||||
class EDClock : public EBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct Data {
|
||||
|
@ -32,8 +32,8 @@ public:
|
|||
int playDuration = 10;
|
||||
};
|
||||
|
||||
explicit eDClock(EBase *multiWin = nullptr);
|
||||
explicit eDClock(const QJsonObject &json, EBase *multiWin = nullptr);
|
||||
explicit EDClock(EBase *multiWin = nullptr);
|
||||
explicit EDClock(const QJsonObject &json, EBase *multiWin = nullptr);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
int type() const override { return EBase::DClock; }
|
|
@ -13,6 +13,7 @@
|
|||
#include <QSpinBox>
|
||||
#include <QTextOption>
|
||||
#include <QJsonArray>
|
||||
#include <QToolButton>
|
||||
|
||||
QJsonObject EEnviron::genProg(const QJsonObject &json, const QString &dstDir, const QString &srcPageDir) {
|
||||
auto widget = json["widget"];
|
||||
|
@ -602,54 +603,41 @@ QWidget* EEnviron::attrWgt() {
|
|||
hBox = new QHBoxLayout();
|
||||
hBox->addSpacing(6);
|
||||
|
||||
auto fdBold = new QPushButton();
|
||||
fdBold->setFixedSize(QSize(30, 30));
|
||||
fdBold->setIconSize(QSize(30, 30));
|
||||
QIcon icon(":/res/ProgramManager/EditProgram/FontBold_u.png");
|
||||
icon.addFile(":/res/ProgramManager/EditProgram/FontBold_s.png", QSize(), QIcon::Normal, QIcon::On);
|
||||
fdBold->setIcon(icon);
|
||||
fdBold->setCheckable(true);
|
||||
fdBold->setFlat(true);
|
||||
fdBold->setChecked(m_attr.font.bold());
|
||||
connect(fdBold, &QPushButton::toggled, this, [this](bool checked) {
|
||||
auto fdFontBold = new QPushButton("B");
|
||||
fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontBold->setFixedSize(30, 30);
|
||||
fdFontBold->setCheckable(true);
|
||||
fdFontBold->setChecked(m_attr.font.bold());
|
||||
connect(fdFontBold, &QPushButton::toggled, this, [this](bool checked) {
|
||||
m_attr.font.setBold(checked);
|
||||
calAttr();
|
||||
update();
|
||||
});
|
||||
hBox->addWidget(fdBold);
|
||||
hBox->addWidget(fdFontBold);
|
||||
|
||||
auto fdItalic = new QPushButton();
|
||||
fdItalic->setFixedSize(QSize(30, 30));
|
||||
fdItalic->setIconSize(QSize(30, 30));
|
||||
QIcon icon1(":/res/ProgramManager/EditProgram/FontItalics_u.png");
|
||||
icon1.addFile(":/res/ProgramManager/EditProgram/FontItalics_s.png", QSize(), QIcon::Normal, QIcon::On);
|
||||
fdItalic->setIcon(icon1);
|
||||
fdItalic->setCheckable(true);
|
||||
fdItalic->setFlat(true);
|
||||
fdItalic->setChecked(m_attr.font.italic());
|
||||
connect(fdItalic, &QPushButton::toggled, this, [this](bool checked) {
|
||||
auto fdFontItalic = new QPushButton("I");
|
||||
fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontItalic->setFixedSize(30, 30);
|
||||
fdFontItalic->setCheckable(true);
|
||||
fdFontItalic->setChecked(m_attr.font.italic());
|
||||
connect(fdFontItalic, &QPushButton::toggled, this, [this](bool checked) {
|
||||
m_attr.font.setItalic(checked);
|
||||
calAttr();
|
||||
update();
|
||||
});
|
||||
hBox->addWidget(fdItalic);
|
||||
hBox->addWidget(fdFontItalic);
|
||||
|
||||
auto fdUnderline = new QPushButton();
|
||||
fdUnderline->setFixedSize(QSize(30, 30));
|
||||
fdUnderline->setIconSize(QSize(30, 30));
|
||||
QIcon icon2(":/res/ProgramManager/EditProgram/FontUnderline_u.png");
|
||||
icon2.addFile(":/res/ProgramManager/EditProgram/FontUnderline_s.png", QSize(), QIcon::Normal, QIcon::On);
|
||||
fdUnderline->setIcon(icon2);
|
||||
fdUnderline->setCheckable(true);
|
||||
fdUnderline->setFlat(true);
|
||||
fdUnderline->setChecked(m_attr.font.underline());
|
||||
connect(fdUnderline, &QPushButton::toggled, this, [this](bool checked) {
|
||||
auto fdFontUnderline = new QPushButton("U");
|
||||
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontUnderline->setFixedSize(30, 30);
|
||||
fdFontUnderline->setCheckable(true);
|
||||
fdFontUnderline->setChecked(m_attr.font.underline());
|
||||
connect(fdFontUnderline, &QPushButton::toggled, this, [this](bool checked) {
|
||||
m_attr.font.setUnderline(checked);
|
||||
calAttr();
|
||||
update();
|
||||
});
|
||||
hBox->addWidget(fdUnderline);
|
||||
|
||||
hBox->addWidget(fdFontUnderline);
|
||||
|
||||
auto fdColor = new LoColorSelector("T", m_attr.textColor);
|
||||
fdColor->setFixedWidth(30);
|
|
@ -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=="Gif") inner = EGif::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=="AClock") inner = new eAClock(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=="Temp") inner = new EEnviron(element.toObject(), this);
|
||||
else if(type=="Web") inner = new EWeb(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 btnAdd = new QPushButton();
|
||||
btnAdd->setIcon(QIcon(":/res/ProgramManager/EditProgram/Add.png"));
|
||||
btnAdd->setIcon(QIcon(":/res/program/Add.png"));
|
||||
btnAdd->setProperty("style","multiTool");
|
||||
|
||||
auto menu = new QMenu();
|
||||
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Text.png"), tr("Text"))->setData(EBase::Text);
|
||||
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Photo.png"), tr("Photo"))->setData(EBase::Photo);
|
||||
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Movie.png"), tr("Video"))->setData(EBase::Video);
|
||||
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/Gif.png"), tr("Gif"))->setData(EBase::Gif);
|
||||
menu->addAction(QIcon(":/res/ProgramManager/EditProgram/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/Text.png"), tr("Text"))->setData(EBase::Text);
|
||||
menu->addAction(QIcon(":/res/program/Photo.png"), tr("Photo"))->setData(EBase::Photo);
|
||||
menu->addAction(QIcon(":/res/program/Movie.png"), tr("Video"))->setData(EBase::Video);
|
||||
menu->addAction(QIcon(":/res/program/Gif.png"), tr("Gif"))->setData(EBase::Gif);
|
||||
menu->addAction(QIcon(":/res/program/DClock.png"), tr("DClock"))->setData(EBase::DClock);
|
||||
menu->addAction(QIcon(":/res/program/AClock.png"), tr("AClock"))->setData(EBase::AClock);
|
||||
auto listWgt = new MListWidget();
|
||||
connect(menu, &QMenu::triggered, this, [this, listWgt](QAction *act) {
|
||||
int type = act->data().toInt();
|
||||
|
@ -148,7 +148,7 @@ QWidget* EMultiWin::attrWgt() {
|
|||
ePhoto->setZValue(order++);
|
||||
ePhoto->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||
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)));
|
||||
listWgt->addItem(item);
|
||||
if(i==files.count()-1) {
|
||||
|
@ -165,7 +165,7 @@ QWidget* EMultiWin::attrWgt() {
|
|||
eGif->setZValue(order++);
|
||||
eGif->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||
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)));
|
||||
listWgt->addItem(item);
|
||||
if(i == files.count()-1) {
|
||||
|
@ -178,25 +178,25 @@ QWidget* EMultiWin::attrWgt() {
|
|||
if(! file.isEmpty()) {
|
||||
auto eVideo = EVideo::create(file, mPageItem, this);
|
||||
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;
|
||||
ele = eVideo;
|
||||
}
|
||||
} else if(type==EBase::Text) {
|
||||
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) {
|
||||
ele = new eDClock(this);
|
||||
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/DClock.png"), tr("DClock"));
|
||||
ele = new EDClock(this);
|
||||
item = new QListWidgetItem(QIcon(":/res/program/DClock.png"), tr("DClock"));
|
||||
} else if(type==EBase::AClock) {
|
||||
ele = new eAClock(this);
|
||||
item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/AClock.png"), tr("AClock"));
|
||||
ele = new EAClock(this);
|
||||
item = new QListWidgetItem(QIcon(":/res/program/AClock.png"), tr("AClock"));
|
||||
} else if(type==EBase::Environ) {
|
||||
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) {
|
||||
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) {
|
||||
ele->setSize(mWidth, mHeight);
|
||||
|
@ -212,7 +212,7 @@ QWidget* EMultiWin::attrWgt() {
|
|||
hBox->addWidget(btnAdd);
|
||||
|
||||
auto btnDel = new QPushButton();
|
||||
btnDel->setIcon(QIcon(":/res/ProgramManager/EditProgram/Delete.png"));
|
||||
btnDel->setIcon(QIcon(":/res/program/Delete.png"));
|
||||
btnDel->setProperty("style","multiTool");
|
||||
connect(btnDel, &QPushButton::clicked, this, [this, listWgt] {
|
||||
auto row = listWgt->currentRow();
|
||||
|
@ -229,7 +229,7 @@ QWidget* EMultiWin::attrWgt() {
|
|||
hBox->addWidget(btnDel);
|
||||
|
||||
auto btnClean = new QPushButton();
|
||||
btnClean->setIcon(QIcon(":/res/ProgramManager/EditProgram/Clean.png"));
|
||||
btnClean->setIcon(QIcon(":/res/program/Clean.png"));
|
||||
btnClean->setProperty("style","multiTool");
|
||||
connect(btnClean, &QPushButton::clicked, this, [this, listWgt] {
|
||||
listWgt->clear();
|
||||
|
@ -239,7 +239,7 @@ QWidget* EMultiWin::attrWgt() {
|
|||
hBox->addWidget(btnClean);
|
||||
|
||||
auto btnGoUp = new QPushButton();
|
||||
btnGoUp->setIcon(QIcon(":/res/ProgramManager/EditProgram/GoUp.png"));
|
||||
btnGoUp->setIcon(QIcon(":/res/program/GoUp.png"));
|
||||
btnGoUp->setProperty("style","multiTool");
|
||||
connect(btnGoUp, &QPushButton::clicked, this, [this, listWgt] {
|
||||
int row = listWgt->currentRow();
|
||||
|
@ -253,7 +253,7 @@ QWidget* EMultiWin::attrWgt() {
|
|||
hBox->addWidget(btnGoUp);
|
||||
|
||||
auto btnGoDown = new QPushButton();
|
||||
btnGoDown->setIcon(QIcon(":/res/ProgramManager/EditProgram/GoDown.png"));
|
||||
btnGoDown->setIcon(QIcon(":/res/program/GoDown.png"));
|
||||
btnGoDown->setProperty("style","multiTool");
|
||||
connect(btnGoDown, &QPushButton::clicked, this, [this, listWgt] {
|
||||
int row = listWgt->currentRow();
|
||||
|
@ -273,14 +273,14 @@ QWidget* EMultiWin::attrWgt() {
|
|||
foreach(auto inner, inners) {
|
||||
QListWidgetItem *item = nullptr;
|
||||
int type = inner->type();
|
||||
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/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::Video) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/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::DClock) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/DClock.png"), tr("DClock"));
|
||||
else if(type==EBase::AClock) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/AClock.png"), tr("AClock"));
|
||||
else if(type==EBase::Environ) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Temp.png"), tr("Environment"));
|
||||
else if(type==EBase::Timer) item = new QListWidgetItem(QIcon(":/res/ProgramManager/EditProgram/Timer.png"), tr("Timer"));
|
||||
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
|
||||
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/program/Movie.png"), tr("Video")+" "+static_cast<EVideo*>(inner)->mRawName);
|
||||
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/program/DClock.png"), tr("DClock"));
|
||||
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/program/Temp.png"), tr("Environment"));
|
||||
else if(type==EBase::Timer) item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
||||
if(item != nullptr) {
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(inner)));
|
||||
listWgt->addItem(item);
|
|
@ -76,14 +76,14 @@ void EPhoto::loadFiles() {
|
|||
if(! img.isNull()) return;
|
||||
if(! QFileInfo::exists(mDir + "/" + mName)) return;
|
||||
img = QImage(mDir + "/" + mName);
|
||||
if(gProgItem->mSplitWidth) {
|
||||
int cnt = (gProgItem->mWidth+gProgItem->mSplitWidth-1) / gProgItem->mSplitWidth;
|
||||
QImage square(gProgItem->mSplitWidth, gProgItem->mHeight*cnt, QImage::Format_ARGB32);
|
||||
if(gProgItem->mMaxWidth) {
|
||||
QImage square(gProgItem->mMaxWidth, gProgItem->mHeight*gProgItem->mSplitWidths.size(), QImage::Format_ARGB32);
|
||||
QPainter painter(&square);
|
||||
auto rect = innerRect();
|
||||
QRectF rect(x(), y(), mWidth, mHeight);
|
||||
painter.drawImage(rect, img);
|
||||
for(int i=1; i<cnt; i++) {
|
||||
rect.moveTo(rect.x() - gProgItem->mSplitWidth, rect.y() + gProgItem->mHeight);
|
||||
auto end = gProgItem->mSplitWidths.size() - 1;
|
||||
for(int i=0; i<end; i++) {
|
||||
rect.moveTo(rect.x() - gProgItem->mSplitWidths[i], rect.y() + gProgItem->mHeight);
|
||||
painter.drawImage(rect, img);
|
||||
}
|
||||
square.save(mDir + "/" + mName+"-square.png", "PNG");
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user