增加 demo 图片
This commit is contained in:
parent
a711980263
commit
b3ebcb885d
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
Binary file not shown.
|
@ -5,10 +5,14 @@ QT += concurrent
|
||||||
QT += serialport
|
QT += serialport
|
||||||
QT += opengl
|
QT += opengl
|
||||||
QT += webenginewidgets
|
QT += webenginewidgets
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||||
QT += openglwidgets
|
QT += openglwidgets
|
||||||
|
CONFIG += c++20
|
||||||
|
} else {
|
||||||
|
CONFIG += c++17
|
||||||
}
|
}
|
||||||
CONFIG += c++17
|
|
||||||
CONFIG += lrelease
|
CONFIG += lrelease
|
||||||
CONFIG += embed_translations
|
CONFIG += embed_translations
|
||||||
|
|
||||||
|
@ -19,18 +23,16 @@ CONFIG += embed_translations
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
TARGET = $$quote(LedOK Express)
|
VERSION = 1.4.2
|
||||||
VERSION = 1.4.1
|
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
msvc {
|
msvc {
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
QMAKE_LFLAGS += /LARGEADDRESSAWARE
|
QMAKE_LFLAGS += /LARGEADDRESSAWARE
|
||||||
#QMAKE_LFLAGS += -Wl,--large-address-aware
|
|
||||||
}
|
|
||||||
lessThan(QT_MAJOR_VERSION, 6) {
|
|
||||||
QMAKE_CXXFLAGS += -execution-charset:utf-8
|
|
||||||
QMAKE_CXXFLAGS += -source-charset:utf-8
|
|
||||||
}
|
}
|
||||||
|
# lessThan(QT_MAJOR_VERSION, 6) {
|
||||||
|
# QMAKE_CXXFLAGS += -execution-charset:utf-8
|
||||||
|
# QMAKE_CXXFLAGS += -source-charset:utf-8
|
||||||
|
# }
|
||||||
|
|
||||||
CONFIG += force_debug_info
|
CONFIG += force_debug_info
|
||||||
CONFIG += separate_debug_info
|
CONFIG += separate_debug_info
|
||||||
|
@ -49,17 +51,21 @@ osx {
|
||||||
|
|
||||||
copydir.files += AClock
|
copydir.files += AClock
|
||||||
copydir.files += borders
|
copydir.files += borders
|
||||||
|
copydir.files += Demos
|
||||||
copydir.files += translations
|
copydir.files += translations
|
||||||
copydir.files += $$quote(y50 param)
|
copydir.files += $$quote(y50 param)
|
||||||
copydir.files += $$quote(files)
|
copydir.files += $$quote(files)
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
EXE_SUFFIX = .exe
|
EXE_SUFFIX = .exe
|
||||||
|
contains(QT_ARCH, i386) {
|
||||||
|
DIR_SUFFIX = -32
|
||||||
|
copy.files += $$files(OpenSSL/*.dll) # for https requests
|
||||||
|
}
|
||||||
|
|
||||||
copy.files += $$files(ffmpeg/bin/*.dll)
|
copy.files += $$files(ffmpeg$$DIR_SUFFIX/bin/*.dll)
|
||||||
copy.files += 7z/7z.dll
|
copy.files += 7z/7z.dll
|
||||||
copy.files += 7z/7z.exe
|
copy.files += 7z/7z.exe
|
||||||
copy.files += $$files(OpenSSL/*.dll) # for https requests
|
|
||||||
|
|
||||||
copy.path = $$OUT_PWD
|
copy.path = $$OUT_PWD
|
||||||
copydir.path = $$OUT_PWD
|
copydir.path = $$OUT_PWD
|
||||||
|
@ -124,12 +130,10 @@ SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
mguangyingpinwidget.cpp \
|
mguangyingpinwidget.cpp \
|
||||||
player/digiclock.cpp \
|
|
||||||
player/eleanaclock.cpp \
|
player/eleanaclock.cpp \
|
||||||
player/elebase.cpp \
|
|
||||||
player/eleborder.cpp \
|
player/eleborder.cpp \
|
||||||
|
player/eledigiclock.cpp \
|
||||||
player/elegif.cpp \
|
player/elegif.cpp \
|
||||||
player/eleimg.cpp \
|
|
||||||
player/elemultipng.cpp \
|
player/elemultipng.cpp \
|
||||||
player/elescroll.cpp \
|
player/elescroll.cpp \
|
||||||
player/eletimer.cpp \
|
player/eletimer.cpp \
|
||||||
|
@ -192,12 +196,10 @@ HEADERS += \
|
||||||
gutil/qnetwork.h \
|
gutil/qnetwork.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
mguangyingpinwidget.h \
|
mguangyingpinwidget.h \
|
||||||
player/digiclock.h \
|
|
||||||
player/eleanaclock.h \
|
player/eleanaclock.h \
|
||||||
player/elebase.h \
|
|
||||||
player/eleborder.h \
|
player/eleborder.h \
|
||||||
|
player/eledigiclock.h \
|
||||||
player/elegif.h \
|
player/elegif.h \
|
||||||
player/eleimg.h \
|
|
||||||
player/elemultipng.h \
|
player/elemultipng.h \
|
||||||
player/elescroll.h \
|
player/elescroll.h \
|
||||||
player/eletimer.h \
|
player/eletimer.h \
|
|
@ -1,143 +0,0 @@
|
||||||
#include "wupgradeapkitem.h"
|
|
||||||
#include "base/waitingdlg.h"
|
|
||||||
#include "deviceitem.h"
|
|
||||||
#include "gutil/qgui.h"
|
|
||||||
#include "gutil/qnetwork.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QProgressBar>
|
|
||||||
#include <globaldefine.h>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QInputDialog>
|
|
||||||
|
|
||||||
wUpgradeApkItem::wUpgradeApkItem(LedCard pLedCard, LoQTreeWidget *parent) : QTreeWidgetItem(UserType), mCard(pLedCard), m_parent(parent) {
|
|
||||||
setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
|
||||||
setCheckState(0, Qt::Unchecked);
|
|
||||||
m_parent->addTopLevelItem(this);
|
|
||||||
m_ImageOnline = new QLabel();
|
|
||||||
m_ImageOnline->setAlignment(Qt::AlignCenter);
|
|
||||||
m_parent->setItemWidget(this, Upgrade_ONLINE, m_ImageOnline);
|
|
||||||
for(int i=1; i<Upgrade_END; i++) setTextAlignment(i, Qt::AlignCenter);
|
|
||||||
mProgress = new QProgressBar;
|
|
||||||
mProgress->setAlignment(Qt::AlignCenter);
|
|
||||||
mProgress->setStyleSheet("margin-top:8px; margin-bottom:8px; ");
|
|
||||||
m_parent->setItemWidget(this, Upgrade_PROGRESS, mProgress);
|
|
||||||
|
|
||||||
btnUnlock = new QPushButton;
|
|
||||||
btnUnlock->setMaximumHeight(40);
|
|
||||||
auto wgt = new QWidget;
|
|
||||||
auto vBox = new VBox(wgt);
|
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
|
||||||
vBox->addWidget(btnUnlock);
|
|
||||||
m_parent->setItemWidget(this, Upgrade_ENCRYPT, wgt);
|
|
||||||
QObject::connect(btnUnlock, &QPushButton::clicked, mProgress, [this] {
|
|
||||||
if(! mCard.isLocked) return;
|
|
||||||
bool ok;
|
|
||||||
auto pwd = QInputDialog::getText(treeWidget(), QObject::tr("Input password"), QObject::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 waitingDlg = new WaitingDlg(treeWidget(), QObject::tr("VerifyPassword")+" ...");
|
|
||||||
waitingDlg->show();
|
|
||||||
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(120000).post(json);
|
|
||||||
waitingDlg->connAbort(reply);
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, mProgress, [=] {
|
|
||||||
QJsonDocument json;
|
|
||||||
QString err = checkReplyForJson(reply, &json);
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::critical(treeWidget(), QObject::tr("Error"), err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(! json["result"].toBool()) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::critical(treeWidget(), QObject::tr("Tip Info"), QObject::tr("password is wrong"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
waitingDlg->success();
|
|
||||||
mCard.isLocked = false;
|
|
||||||
btnUnlock->setIcon(QIcon(":/res/UnLock.png"));
|
|
||||||
auto item = findItem(mCard.id);
|
|
||||||
if(item) {
|
|
||||||
item->mCard.isLocked = false;
|
|
||||||
item->btnUnlock->setIcon(QIcon(":/res/UnLock.png"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
SetItemParam(mCard);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wUpgradeApkItem::OnCheckFpgaVersions() {
|
|
||||||
QJsonObject json;
|
|
||||||
json.insert("_id", "CheckHardwareVersions");
|
|
||||||
json.insert("_type", "CheckHardwareVersions");
|
|
||||||
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(120000).post(json);
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, mProgress, [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) strBuf += "\n";
|
|
||||||
strBuf += "["+QString::number(i)+"]:"+vers[i].toString();
|
|
||||||
}
|
|
||||||
setData(Upgrade_FPAG_VERSION, 0, strBuf);
|
|
||||||
auto item = findItem(mCard.id);
|
|
||||||
if(item) {
|
|
||||||
item->mCard.HardVersion = strBuf;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
void wUpgradeApkItem::OnCheckSoftVersions() {
|
|
||||||
QJsonObject json;
|
|
||||||
json.insert("_id", "CheckSoftVersions");
|
|
||||||
json.insert("_type", "CheckSoftVersions");
|
|
||||||
auto reply = NetReq("http://"+mCard.ip+":2016/settings").timeout(120000).post(json);
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, mProgress, [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::setResult(QString tip, QColor color) {
|
|
||||||
setText(Upgrade_Remark, tip);
|
|
||||||
setToolTip(Upgrade_Remark, tip);
|
|
||||||
setForeground(Upgrade_Remark, color);
|
|
||||||
}
|
|
||||||
void wUpgradeApkItem::SetItemParam(LedCard card) {
|
|
||||||
mCard.id = card.id;
|
|
||||||
mCard.ip = card.ip;
|
|
||||||
mCard.isOnline = card.isOnline;
|
|
||||||
setData(Upgrade_SCREEN_ID, 0, card.id);
|
|
||||||
setData(Upgrade_SCREEN_IP, 0, card.ip);
|
|
||||||
setData(Upgrade_REMARK_NAME, 0, card.alias);
|
|
||||||
m_ImageOnline->setPixmap(QPixmap(mCard.isOnline ? ":/res/O_Online.png" : ":/res/O_Offline.png"));
|
|
||||||
OnCheckSoftVersions();
|
|
||||||
OnCheckFpgaVersions();
|
|
||||||
if(! card.hasPassword) btnUnlock->hide();
|
|
||||||
else {
|
|
||||||
if(! btnUnlock->isVisible()) btnUnlock->show();
|
|
||||||
btnUnlock->setIcon(QIcon(card.isLocked ? ":/res/Lock.png" : ":/res/UnLock.png")); //如果已经验证通过密码显示绿色图标 没有验证显示蓝色锁图标
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
#ifndef WUPGRADEAPKITEM_H
|
|
||||||
#define WUPGRADEAPKITEM_H
|
|
||||||
|
|
||||||
#include "globaldefine.h"
|
|
||||||
#include <QDir>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <base/loqtreewidget.h>
|
|
||||||
#include <QProgressBar>
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
class wUpgradeApkItem : public QTreeWidgetItem {
|
|
||||||
public:
|
|
||||||
explicit wUpgradeApkItem(LedCard card, LoQTreeWidget *parent);
|
|
||||||
void SetItemParam(LedCard p);
|
|
||||||
void setResult(QString, QColor cr = Qt::blue);
|
|
||||||
|
|
||||||
LedCard mCard;
|
|
||||||
bool isUpdating{false};
|
|
||||||
bool m_lockFlag=true;
|
|
||||||
QLabel *m_ImageOnline=nullptr;
|
|
||||||
LoQTreeWidget *m_parent = nullptr;
|
|
||||||
QProgressBar *mProgress=nullptr;
|
|
||||||
QPushButton *btnUnlock = nullptr;
|
|
||||||
|
|
||||||
void OnCheckSoftVersions();
|
|
||||||
void OnCheckFpgaVersions();
|
|
||||||
|
|
||||||
private:
|
|
||||||
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,14 +0,0 @@
|
||||||
#include "importbninprogramdlg.h"
|
|
||||||
#include "ui_importbninprogramdlg.h"
|
|
||||||
|
|
||||||
ImportBnInProgramDlg::ImportBnInProgramDlg(QWidget *parent) :
|
|
||||||
LoQDialog(parent),
|
|
||||||
ui(new Ui::ImportBnInProgramDlg)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImportBnInProgramDlg::~ImportBnInProgramDlg()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
#ifndef IMPORTBNINPROGRAMDLG_H
|
|
||||||
#define IMPORTBNINPROGRAMDLG_H
|
|
||||||
|
|
||||||
#include <LoQClass/loqdialog.h>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class ImportBnInProgramDlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ImportBnInProgramDlg : public LoQDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ImportBnInProgramDlg(QWidget *parent = nullptr);
|
|
||||||
~ImportBnInProgramDlg();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::ImportBnInProgramDlg *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // IMPORTBNINPROGRAMDLG_H
|
|
|
@ -1,68 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ImportBnInProgramDlg</class>
|
|
||||||
<widget class="QDialog" name="ImportBnInProgramDlg">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>638</width>
|
|
||||||
<height>296</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>210</y>
|
|
||||||
<width>621</width>
|
|
||||||
<height>32</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>ImportBnInProgramDlg</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>ImportBnInProgramDlg</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,80 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog</class>
|
|
||||||
<widget class="QDialog" name="Dialog">
|
|
||||||
<property name="windowModality">
|
|
||||||
<enum>Qt::NonModal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>320</width>
|
|
||||||
<height>240</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>320</width>
|
|
||||||
<height>240</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<property name="sizeGripEnabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>200</y>
|
|
||||||
<width>301</width>
|
|
||||||
<height>32</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,239 +0,0 @@
|
||||||
#include "digiclock.h"
|
|
||||||
#include "gutil/qgui.h"
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonArray>
|
|
||||||
|
|
||||||
DigiClock::DigiClock(QString prefix, const QJsonObject &layer, QWidget *parent) : QWidget{parent} {
|
|
||||||
timeZone = QTimeZone(layer["timezone"].toString().toUtf8());
|
|
||||||
auto spaceWidth = layer["spaceWidth"].toDouble();
|
|
||||||
auto pics = layer["arrayPics"].toArray();
|
|
||||||
foreach(QJsonValue pic, pics) imgs.insert(pic["name"].toString(), QPixmap(prefix+pic["id"].toString()));
|
|
||||||
int dateStyle = layer["dateStyle"].toInt();
|
|
||||||
isSingleMonth = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12;
|
|
||||||
QPixmap& timeSep = imgs["maohao"];
|
|
||||||
weekly = layer["weekly"].toBool();
|
|
||||||
bool hour12 = layer["hour12"].toBool();
|
|
||||||
bool AmPm = hour12 ? layer["AmPm"].toBool() : false;
|
|
||||||
timeptn = hour12 ? "hhmmssa" : "HHmmss";
|
|
||||||
bool hour = layer["hour"].toBool();
|
|
||||||
bool min = layer["min"].toBool();
|
|
||||||
bool sec = layer["sec"].toBool();
|
|
||||||
multiline = layer["multiline"].toBool();
|
|
||||||
if(multiline) {
|
|
||||||
QVBoxLayout *vBox = new QVBoxLayout(this);
|
|
||||||
vBox->setAlignment(Qt::AlignCenter);
|
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
|
||||||
vBox->setSpacing(0);
|
|
||||||
vBox->addStretch();
|
|
||||||
QHBoxLayout *hBox = new QHBoxLayout();
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
hBox->addStretch();
|
|
||||||
addDate(dateStyle, layer, hBox);
|
|
||||||
hBox->addStretch();
|
|
||||||
if(weekly) {
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
hBox->addStretch();
|
|
||||||
hBox->addWidget((QWidget*)weekComp);
|
|
||||||
hBox->addStretch();
|
|
||||||
}
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
hBox->addStretch();
|
|
||||||
if(AmPm) {
|
|
||||||
hBox->addWidget((QWidget*)ampmComp);
|
|
||||||
hBox->addSpacing(spaceWidth);
|
|
||||||
}
|
|
||||||
if(hour) {
|
|
||||||
hBox->addWidget((QWidget*)hourComps[0]);
|
|
||||||
hBox->addWidget((QWidget*)hourComps[1]);
|
|
||||||
}
|
|
||||||
if(hour&&min) hBox->addWidget((QWidget*)new ImgWgt(timeSep));
|
|
||||||
if(min) {
|
|
||||||
hBox->addWidget((QWidget*)minComps[0]);
|
|
||||||
hBox->addWidget((QWidget*)minComps[1]);
|
|
||||||
}
|
|
||||||
if(min&&sec) hBox->addWidget((QWidget*)new ImgWgt(timeSep));
|
|
||||||
if(sec) {
|
|
||||||
hBox->addWidget((QWidget*)secComps[0]);
|
|
||||||
hBox->addWidget((QWidget*)secComps[1]);
|
|
||||||
}
|
|
||||||
hBox->addStretch();
|
|
||||||
vBox->addStretch();
|
|
||||||
} else {
|
|
||||||
QHBoxLayout *hBox = new QHBoxLayout(this);
|
|
||||||
hBox->setContentsMargins(0,0,0,0);
|
|
||||||
hBox->setSpacing(0);
|
|
||||||
hBox->addStretch();
|
|
||||||
addDate(dateStyle, layer, hBox);
|
|
||||||
if(hBox->count()>1) hBox->addSpacing(spaceWidth*2);
|
|
||||||
if(weekly) {
|
|
||||||
hBox->addWidget((QWidget*)weekComp);
|
|
||||||
hBox->addSpacing(spaceWidth*2);
|
|
||||||
}
|
|
||||||
if(AmPm) {
|
|
||||||
hBox->addWidget((QWidget*)ampmComp);
|
|
||||||
hBox->addSpacing(spaceWidth);
|
|
||||||
}
|
|
||||||
if(hour) {
|
|
||||||
hBox->addWidget((QWidget*)hourComps[0]);
|
|
||||||
hBox->addWidget((QWidget*)hourComps[1]);
|
|
||||||
}
|
|
||||||
if(hour&&min) hBox->addWidget((QWidget*)new ImgWgt(timeSep));
|
|
||||||
if(min) {
|
|
||||||
hBox->addWidget((QWidget*)minComps[0]);
|
|
||||||
hBox->addWidget((QWidget*)minComps[1]);
|
|
||||||
}
|
|
||||||
if(min&&sec) hBox->addWidget((QWidget*)new ImgWgt(timeSep));
|
|
||||||
if(sec) {
|
|
||||||
hBox->addWidget((QWidget*)secComps[0]);
|
|
||||||
hBox->addWidget((QWidget*)secComps[1]);
|
|
||||||
}
|
|
||||||
hBox->addStretch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void DigiClock::addDate(int dateStyle, QJsonObject layer, QHBoxLayout* tar) {
|
|
||||||
if(dateStyle==0 || dateStyle==1) {
|
|
||||||
addYear(layer, tar, imgs["YEAR"]);
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(imgs["MONTH"]));
|
|
||||||
}
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(imgs["DAY"]));
|
|
||||||
}
|
|
||||||
} else if(dateStyle==2 || dateStyle==3) {
|
|
||||||
QPixmap sep = imgs["xiegang"];
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, QPixmap());
|
|
||||||
} else if(dateStyle==4 || dateStyle==5) {
|
|
||||||
QPixmap sep = imgs["xiegang"];
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, QPixmap());
|
|
||||||
} else if(dateStyle==6 || dateStyle==7) {
|
|
||||||
QPixmap sep = imgs["xiegang"];
|
|
||||||
addYear(layer, tar, sep);
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
}
|
|
||||||
} else if(dateStyle==8 || dateStyle==9) {
|
|
||||||
QPixmap sep = imgs["hengxian"];
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, QPixmap());
|
|
||||||
} else if(dateStyle==10 || dateStyle==11) {
|
|
||||||
QPixmap sep = imgs["hengxian"];
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
addYear(layer, tar, QPixmap());
|
|
||||||
} else if(dateStyle==12 || dateStyle==13) {
|
|
||||||
QPixmap sep = imgs["hengxian"];
|
|
||||||
addYear(layer, tar, sep);
|
|
||||||
if(layer["month"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)monthComps[0]);
|
|
||||||
tar->addWidget((QWidget*)monthComps[1]);
|
|
||||||
tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
if(layer["day"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)dayComps[0]);
|
|
||||||
tar->addWidget((QWidget*)dayComps[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void DigiClock::addYear(QJsonObject layer, QHBoxLayout* tar, QPixmap sep) {
|
|
||||||
if(layer["year"].toBool()) {
|
|
||||||
if(layer["fullYear"].toBool()) {
|
|
||||||
tar->addWidget((QWidget*)yearComps[0]);
|
|
||||||
tar->addWidget((QWidget*)yearComps[1]);
|
|
||||||
}
|
|
||||||
tar->addWidget((QWidget*)yearComps[2]);
|
|
||||||
tar->addWidget((QWidget*)yearComps[3]);
|
|
||||||
if(!sep.isNull()) tar->addWidget((QWidget*)new ImgWgt(sep));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void DigiClock::cal() {
|
|
||||||
QDateTime dt = QDateTime::currentDateTime().toTimeZone(timeZone);
|
|
||||||
QTime time = dt.time();
|
|
||||||
QString hms = time.toString(timeptn);
|
|
||||||
*ampmComp = imgs[time.hour()<12?"AM":"PM"];
|
|
||||||
*hourComps[0] = imgs[hms.mid(0,1)];
|
|
||||||
*hourComps[1] = imgs[hms.mid(1,1)];
|
|
||||||
*minComps[0] = imgs[hms.mid(2,1)];
|
|
||||||
*minComps[1] = imgs[hms.mid(3,1)];
|
|
||||||
*secComps[0] = imgs[hms.mid(4,1)];
|
|
||||||
*secComps[1] = imgs[hms.mid(5,1)];
|
|
||||||
if(yearComps[0]->img.isNull() || (time.hour()==0 && time.second()==0)) {
|
|
||||||
QDate date = dt.date();
|
|
||||||
if(weekly) *weekComp = imgs[weeks[date.dayOfWeek()-1]];
|
|
||||||
QString ymd = date.toString("yyyyMMdd");
|
|
||||||
*yearComps[0] = imgs[ymd.mid(0,1)];
|
|
||||||
*yearComps[1] = imgs[ymd.mid(1,1)];
|
|
||||||
*yearComps[2] = imgs[ymd.mid(2,1)];
|
|
||||||
*yearComps[3] = imgs[ymd.mid(3,1)];
|
|
||||||
QChar ch = ymd.at(4);
|
|
||||||
if(isSingleMonth && ch=='0') *monthComps[0] = QPixmap();
|
|
||||||
else *monthComps[0] = imgs[ymd.mid(4,1)];
|
|
||||||
*monthComps[1] = imgs[ymd.mid(5,1)];
|
|
||||||
*dayComps[0] = imgs[ymd.mid(6,1)];
|
|
||||||
*dayComps[1] = imgs[ymd.mid(7,1)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void DigiClock::showEvent(QShowEvent *) {
|
|
||||||
if(timerId==0) {
|
|
||||||
timerId = startTimer(1000, Qt::PreciseTimer);
|
|
||||||
cal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigiClock::timerEvent(QTimerEvent *) {
|
|
||||||
if(isVisible()) {
|
|
||||||
cal();
|
|
||||||
update();
|
|
||||||
} else if(timerId!=0) {
|
|
||||||
killTimer(timerId);
|
|
||||||
timerId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
//#include "elebase.h"
|
|
|
@ -1,20 +0,0 @@
|
||||||
#ifndef ELEBASE_H
|
|
||||||
#define ELEBASE_H
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
class EleBase {
|
|
||||||
public:
|
|
||||||
QString id;
|
|
||||||
QString type;
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
int startTime;
|
|
||||||
int endTime;
|
|
||||||
bool repeat;
|
|
||||||
|
|
||||||
QWidget *wgt{0};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ELEBASE_H
|
|
|
@ -0,0 +1,231 @@
|
||||||
|
#include "eledigiclock.h"
|
||||||
|
|
||||||
|
EleDigiClock::EleDigiClock(QString prefix, const JValue &layer, QWidget *parent) : QWidget{parent} {
|
||||||
|
timeZone = QTimeZone(layer["timeZone"].toString().toUtf8());
|
||||||
|
auto spaceWidth = layer["spaceWidth"].toDouble();
|
||||||
|
auto pics = layer["arrayPics"];
|
||||||
|
for(auto &pic : pics) imgs[pic["name"].toString()] = QPixmap(prefix+pic["id"].toString());
|
||||||
|
int dateStyle = layer["dateStyle"].toInt();
|
||||||
|
isSingleMonth = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12;
|
||||||
|
auto& timeSep = imgs["maohao"];
|
||||||
|
weekly = layer["weekly"].toBool();
|
||||||
|
auto hour12 = layer["hour12"].toBool();
|
||||||
|
auto AmPm = hour12 ? layer["AmPm"].toBool() : false;
|
||||||
|
timeptn = hour12 ? "hhmmssa" : "HHmmss";
|
||||||
|
auto hour = layer["hour"].toBool();
|
||||||
|
auto min = layer["min"].toBool();
|
||||||
|
auto sec = layer["sec"].toBool();
|
||||||
|
multiline = layer["multiline"].toBool();
|
||||||
|
if(multiline) {
|
||||||
|
auto vBox = new VBox(this);
|
||||||
|
vBox->setAlignment(Qt::AlignCenter);
|
||||||
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
vBox->setSpacing(0);
|
||||||
|
vBox->addStretch();
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
addDate(dateStyle, layer, hBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
if(weekly) {
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
hBox->addWidget(weekComp);
|
||||||
|
hBox->addStretch();
|
||||||
|
}
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
if(AmPm) {
|
||||||
|
hBox->addWidget(ampmComp);
|
||||||
|
hBox->addSpacing(spaceWidth);
|
||||||
|
}
|
||||||
|
if(hour) {
|
||||||
|
hBox->addWidget(hourComps[0]);
|
||||||
|
hBox->addWidget(hourComps[1]);
|
||||||
|
}
|
||||||
|
if(hour&&min) hBox->addWidget(new ImgWgt(timeSep));
|
||||||
|
if(min) {
|
||||||
|
hBox->addWidget(minComps[0]);
|
||||||
|
hBox->addWidget(minComps[1]);
|
||||||
|
}
|
||||||
|
if(min&&sec) hBox->addWidget(new ImgWgt(timeSep));
|
||||||
|
if(sec) {
|
||||||
|
hBox->addWidget(secComps[0]);
|
||||||
|
hBox->addWidget(secComps[1]);
|
||||||
|
}
|
||||||
|
hBox->addStretch();
|
||||||
|
vBox->addStretch();
|
||||||
|
} else {
|
||||||
|
auto hBox = new HBox(this);
|
||||||
|
hBox->setContentsMargins(0,0,0,0);
|
||||||
|
hBox->setSpacing(0);
|
||||||
|
hBox->addStretch();
|
||||||
|
addDate(dateStyle, layer, hBox);
|
||||||
|
if(hBox->count()>1) hBox->addSpacing(spaceWidth*2);
|
||||||
|
if(weekly) {
|
||||||
|
hBox->addWidget(weekComp);
|
||||||
|
hBox->addSpacing(spaceWidth*2);
|
||||||
|
}
|
||||||
|
if(AmPm) {
|
||||||
|
hBox->addWidget(ampmComp);
|
||||||
|
hBox->addSpacing(spaceWidth);
|
||||||
|
}
|
||||||
|
if(hour) {
|
||||||
|
hBox->addWidget(hourComps[0]);
|
||||||
|
hBox->addWidget(hourComps[1]);
|
||||||
|
}
|
||||||
|
if(hour&&min) hBox->addWidget(new ImgWgt(timeSep));
|
||||||
|
if(min) {
|
||||||
|
hBox->addWidget(minComps[0]);
|
||||||
|
hBox->addWidget(minComps[1]);
|
||||||
|
}
|
||||||
|
if(min&&sec) hBox->addWidget(new ImgWgt(timeSep));
|
||||||
|
if(sec) {
|
||||||
|
hBox->addWidget(secComps[0]);
|
||||||
|
hBox->addWidget(secComps[1]);
|
||||||
|
}
|
||||||
|
hBox->addStretch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void EleDigiClock::addDate(int dateStyle, const JValue &layer, HBox *tar) {
|
||||||
|
if(dateStyle==0 || dateStyle==1) {
|
||||||
|
addYear(layer, tar, imgs["YEAR"]);
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(imgs["MONTH"]));
|
||||||
|
}
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(imgs["DAY"]));
|
||||||
|
}
|
||||||
|
} else if(dateStyle==2 || dateStyle==3) {
|
||||||
|
auto& sep = imgs["xiegang"];
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
addYear(layer, tar, QPixmap());
|
||||||
|
} else if(dateStyle==4 || dateStyle==5) {
|
||||||
|
auto& sep = imgs["xiegang"];
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
addYear(layer, tar, QPixmap());
|
||||||
|
} else if(dateStyle==6 || dateStyle==7) {
|
||||||
|
auto& sep = imgs["xiegang"];
|
||||||
|
addYear(layer, tar, sep);
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
}
|
||||||
|
} else if(dateStyle==8 || dateStyle==9) {
|
||||||
|
auto& sep = imgs["hengxian"];
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
addYear(layer, tar, QPixmap());
|
||||||
|
} else if(dateStyle==10 || dateStyle==11) {
|
||||||
|
auto& sep = imgs["hengxian"];
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
addYear(layer, tar, QPixmap());
|
||||||
|
} else if(dateStyle==12 || dateStyle==13) {
|
||||||
|
auto& sep = imgs["hengxian"];
|
||||||
|
addYear(layer, tar, sep);
|
||||||
|
if(layer["month"].toBool()) {
|
||||||
|
tar->addWidget(monthComps[0]);
|
||||||
|
tar->addWidget(monthComps[1]);
|
||||||
|
tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
if(layer["day"].toBool()) {
|
||||||
|
tar->addWidget(dayComps[0]);
|
||||||
|
tar->addWidget(dayComps[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void EleDigiClock::addYear(const JValue &layer, HBox *tar, const QPixmap &sep) {
|
||||||
|
if(layer["year"].toBool()) {
|
||||||
|
if(layer["fullYear"].toBool()) {
|
||||||
|
tar->addWidget(yearComps[0]);
|
||||||
|
tar->addWidget(yearComps[1]);
|
||||||
|
}
|
||||||
|
tar->addWidget(yearComps[2]);
|
||||||
|
tar->addWidget(yearComps[3]);
|
||||||
|
if(!sep.isNull()) tar->addWidget(new ImgWgt(sep));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void EleDigiClock::cal() {
|
||||||
|
auto dt = QDateTime::currentDateTime().toTimeZone(timeZone);
|
||||||
|
auto time = dt.time();
|
||||||
|
auto hms = time.toString(timeptn);
|
||||||
|
*ampmComp = imgs[time.hour()<12?"AM":"PM"];
|
||||||
|
*hourComps[0] = imgs[hms.mid(0,1)];
|
||||||
|
*hourComps[1] = imgs[hms.mid(1,1)];
|
||||||
|
*minComps[0] = imgs[hms.mid(2,1)];
|
||||||
|
*minComps[1] = imgs[hms.mid(3,1)];
|
||||||
|
*secComps[0] = imgs[hms.mid(4,1)];
|
||||||
|
*secComps[1] = imgs[hms.mid(5,1)];
|
||||||
|
if(yearComps[0]->img.isNull() || (time.hour()==0 && time.second()==0)) {
|
||||||
|
auto date = dt.date();
|
||||||
|
if(weekly) *weekComp = imgs[weeks[date.dayOfWeek()-1]];
|
||||||
|
auto ymd = date.toString("yyyyMMdd");
|
||||||
|
*yearComps[0] = imgs[ymd.mid(0,1)];
|
||||||
|
*yearComps[1] = imgs[ymd.mid(1,1)];
|
||||||
|
*yearComps[2] = imgs[ymd.mid(2,1)];
|
||||||
|
*yearComps[3] = imgs[ymd.mid(3,1)];
|
||||||
|
*monthComps[0] = isSingleMonth && ymd.at(4)=='0' ? QPixmap() : imgs[ymd.mid(4,1)];
|
||||||
|
*monthComps[1] = imgs[ymd.mid(5,1)];
|
||||||
|
*dayComps[0] = isSingleMonth && ymd.at(6)=='0' ? QPixmap() : imgs[ymd.mid(6,1)];
|
||||||
|
*dayComps[1] = imgs[ymd.mid(7,1)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void EleDigiClock::showEvent(QShowEvent *) {
|
||||||
|
if(timerId==0) {
|
||||||
|
timerId = startTimer(1000, Qt::PreciseTimer);
|
||||||
|
cal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EleDigiClock::timerEvent(QTimerEvent *) {
|
||||||
|
if(isVisible()) {
|
||||||
|
cal();
|
||||||
|
update();
|
||||||
|
} else if(timerId) {
|
||||||
|
killTimer(timerId);
|
||||||
|
timerId = 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef DIGICLOCK_H
|
#ifndef ELEDIGICLOCK_H
|
||||||
#define DIGICLOCK_H
|
#define ELEDIGICLOCK_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include "gutil/qjson.h"
|
||||||
|
#include "gutil/qgui.h"
|
||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QHBoxLayout>
|
|
||||||
|
|
||||||
class ImgWgt : public QWidget {
|
class ImgWgt : public QWidget {
|
||||||
public:
|
public:
|
||||||
|
@ -38,13 +38,13 @@ protected:
|
||||||
|
|
||||||
const QString weeks[7]{"MON","TUE","WED","THU","FRI","SAT","SUN"};
|
const QString weeks[7]{"MON","TUE","WED","THU","FRI","SAT","SUN"};
|
||||||
|
|
||||||
class DigiClock : public QWidget {
|
class EleDigiClock : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DigiClock(QString path, const QJsonObject &layer, QWidget *parent = nullptr);
|
EleDigiClock(QString path, const JValue &layer, QWidget *parent = nullptr);
|
||||||
void cal();
|
void cal();
|
||||||
void addDate(int, QJsonObject, QHBoxLayout*);
|
void addDate(int, const JValue &, HBox*);
|
||||||
void addYear(QJsonObject layer, QHBoxLayout* tar, QPixmap sep);
|
void addYear(const JValue &layer, HBox* tar, const QPixmap &sep);
|
||||||
QTimeZone timeZone;
|
QTimeZone timeZone;
|
||||||
ImgWgt *yearComps[4] {new ImgWgt(), new ImgWgt(), new ImgWgt(), new ImgWgt()};
|
ImgWgt *yearComps[4] {new ImgWgt(), new ImgWgt(), new ImgWgt(), new ImgWgt()};
|
||||||
ImgWgt *monthComps[2] {new ImgWgt(), new ImgWgt()};
|
ImgWgt *monthComps[2] {new ImgWgt(), new ImgWgt()};
|
||||||
|
@ -64,4 +64,4 @@ protected:
|
||||||
void showEvent(QShowEvent *) override;
|
void showEvent(QShowEvent *) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIGICLOCK_H
|
#endif // ELEDIGICLOCK_H
|
|
@ -1,14 +0,0 @@
|
||||||
#include "eleimg.h"
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
EleImg::EleImg(QString path, QWidget *parent) : QWidget{parent} {
|
|
||||||
img.load(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EleImg::paintEvent(QPaintEvent *){
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
|
||||||
if(! img.isNull()) painter.drawPixmap(0, 0, width(), height(), img);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
#ifndef ELEIMG_H
|
|
||||||
#define ELEIMG_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
class EleImg : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit EleImg(QString, QWidget *parent = nullptr);
|
|
||||||
QPixmap img;
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ELEIMG_H
|
|
|
@ -1,14 +0,0 @@
|
||||||
#include "x_uimsgonlyclosebtn.h"
|
|
||||||
#include "ui_x_uimsgonlyclosebtn.h"
|
|
||||||
|
|
||||||
x_uiMsgOnlyCloseBtn::x_uiMsgOnlyCloseBtn(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::x_uiMsgOnlyCloseBtn)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
x_uiMsgOnlyCloseBtn::~x_uiMsgOnlyCloseBtn()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
#ifndef X_UIMSGONLYCLOSEBTN_H
|
|
||||||
#define X_UIMSGONLYCLOSEBTN_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class x_uiMsgOnlyCloseBtn;
|
|
||||||
}
|
|
||||||
|
|
||||||
class x_uiMsgOnlyCloseBtn : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit x_uiMsgOnlyCloseBtn(QWidget *parent = nullptr);
|
|
||||||
~x_uiMsgOnlyCloseBtn();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::x_uiMsgOnlyCloseBtn *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // X_UIMSGONLYCLOSEBTN_H
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>x_uiMsgOnlyCloseBtn</class>
|
|
||||||
<widget class="QDialog" name="x_uiMsgOnlyCloseBtn">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
Loading…
Reference in New Issue
Block a user