This commit is contained in:
gangphon 2023-04-25 16:30:58 +08:00
parent 78549a6307
commit 377842f83e
25 changed files with 3253 additions and 3958 deletions

View File

@ -55,7 +55,6 @@ SOURCES += \
base/changepasswordform.cpp \ base/changepasswordform.cpp \
base/customprogressindicator.cpp \ base/customprogressindicator.cpp \
base/loemptydialog.cpp \ base/loemptydialog.cpp \
base/pixbmpshowdialog.cpp \
base/softconfigdialog.cpp \ base/softconfigdialog.cpp \
base/switchcontrol.cpp \ base/switchcontrol.cpp \
base/taesclass.cpp \ base/taesclass.cpp \
@ -147,7 +146,6 @@ HEADERS += \
base/changepasswordform.h \ base/changepasswordform.h \
base/customprogressindicator.h \ base/customprogressindicator.h \
base/loemptydialog.h \ base/loemptydialog.h \
base/pixbmpshowdialog.h \
base/softconfigdialog.h \ base/softconfigdialog.h \
base/switchcontrol.h \ base/switchcontrol.h \
base/taesclass.h \ base/taesclass.h \
@ -234,14 +232,12 @@ HEADERS += \
program/wprogrampublishitem.h \ program/wprogrampublishitem.h \
FORMS += \ FORMS += \
base/pixbmpshowdialog.ui \
base/updateledset3dialog.ui \ base/updateledset3dialog.ui \
base/x_uimsgboxok.ui \ base/x_uimsgboxok.ui \
mguangyingpinwidget.ui \ mguangyingpinwidget.ui \
device/controlpowerschedule.ui \ device/controlpowerschedule.ui \
device/controltestwidget.ui \ device/controltestwidget.ui \
device/controlvolumeschedule.ui \ device/controlvolumeschedule.ui \
program/wplanitem.ui \
TRANSLATIONS += \ TRANSLATIONS += \
translations/app_zh_CN.ts \ translations/app_zh_CN.ts \

View File

@ -1,41 +0,0 @@
#include "pixbmpshowdialog.h"
#include "ui_pixbmpshowdialog.h"
#include <QPainter>
PixbmpShowDialog::PixbmpShowDialog(QWidget *parent) :
BaseDlg(parent),
ui(new Ui::PixbmpShowDialog)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
}
PixbmpShowDialog::~PixbmpShowDialog()
{
delete ui;
}
void PixbmpShowDialog::ResizeByPixmap(int w,int h)
{
m_iWidth=w;
m_iHeight=h;
int iWidth=w;
int iHeight=h;
if(iWidth<rect().width()&&iHeight<rect().height())
this->resize(iWidth,iHeight);
else {
if(iWidth>iHeight)
this->resize(rect().height()*iWidth/iHeight,rect().height());
else
this->resize(rect().width(),rect().width()*iHeight/iWidth);
}
}
void PixbmpShowDialog::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event);
QPainter painter(this);
//painter.eraseRect(rect());
// painter.scale(m_PixMap.width(), m_PixMap.height());
QRectF sourceRt(0,0,m_iWidth,m_iHeight);
painter.drawPixmap(rect(), m_PixMap,sourceRt);
}

View File

@ -1,30 +0,0 @@
#ifndef PIXBMPSHOWDIALOG_H
#define PIXBMPSHOWDIALOG_H
#include <basedlg.h>
namespace Ui {
class PixbmpShowDialog;
}
class PixbmpShowDialog : public BaseDlg
{
Q_OBJECT
public:
explicit PixbmpShowDialog(QWidget *parent = nullptr);
~PixbmpShowDialog();
QPixmap m_PixMap;
void ResizeByPixmap(int w,int h);
int m_iWidth;
int m_iHeight;
public:
virtual void paintEvent(QPaintEvent *);
private:
Ui::PixbmpShowDialog *ui;
};
#endif // PIXBMPSHOWDIALOG_H

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PixbmpShowDialog</class>
<widget class="QDialog" name="PixbmpShowDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>PixbmpShowDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -6,16 +6,12 @@
#include <QPushButton> #include <QPushButton>
#include <QSettings> #include <QSettings>
SoftConfigDialog::SoftConfigDialog(QWidget *parent) : BaseDlg(parent) { SoftConfigDialog::SoftConfigDialog(QWidget *parent) : QDialog(parent) {
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
resize(400, 300); resize(400, 300);
setWindowTitle(tr("Software Config")); setWindowTitle(tr("Software Config"));
auto vbox = new QVBoxLayout(this); auto vbox = new QVBoxLayout(this);
auto pushButton = new QPushButton("X");
pushButton->setMinimumSize(30, 24);
connect(pushButton, &QPushButton::clicked, this, &QWidget::close);
vbox->addWidget(pushButton, 0, Qt::AlignRight);
press_fd = new QCheckBox(tr("Video compress to")+" 720p"); press_fd = new QCheckBox(tr("Video compress to")+" 720p");
press_fd->setChecked(gVideoCompress); press_fd->setChecked(gVideoCompress);
vbox->addWidget(press_fd); vbox->addWidget(press_fd);
@ -31,7 +27,7 @@ SoftConfigDialog::SoftConfigDialog(QWidget *parent) : BaseDlg(parent) {
hbox->addWidget(anti_fd, 0, Qt::AlignTop); hbox->addWidget(anti_fd, 0, Qt::AlignTop);
auto anti_tip = new QLabel(tr("TextAntilaTip")); auto anti_tip = new QLabel(tr("TextAntilaTip"));
anti_tip->setStyleSheet("color:#FF0000;"); anti_tip->setStyleSheet("QLabel{color: #f00;}");
anti_tip->setWordWrap(true); anti_tip->setWordWrap(true);
hbox->addWidget(anti_tip); hbox->addWidget(anti_tip);

View File

@ -1,13 +1,13 @@
#ifndef SOFTCONFIGDIALOG_H #ifndef SOFTCONFIGDIALOG_H
#define SOFTCONFIGDIALOG_H #define SOFTCONFIGDIALOG_H
#include "basedlg.h" #include <QDialog>
#include <QCheckBox> #include <QCheckBox>
class SoftConfigDialog : public BaseDlg { class SoftConfigDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit SoftConfigDialog(QWidget *parent = nullptr); explicit SoftConfigDialog(QWidget *parent = 0);
QCheckBox *press_fd, *trans_fd, *anti_fd, *guangying_fd, *fdWidthSplit; QCheckBox *press_fd, *trans_fd, *anti_fd, *guangying_fd, *fdWidthSplit;
}; };

View File

@ -1216,21 +1216,29 @@ CtrlAdvancedPanel::CtrlAdvancedPanel(QWidget *parent) : QWidget(parent) {
json.insert("_id", "GetMinBrightness"); json.insert("_id", "GetMinBrightness");
json.insert("_type", "GetMinBrightness"); json.insert("_type", "GetMinBrightness");
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")); auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
fdMinBright->setText(QString::number(json["minBrightnessPercentage"].toInt())); auto value = json["minBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
fdMinBright->setText(QString::number(value));
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json);
auto cardId = card->m_strCardId; auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = QString::number(json["minBrightnessPercentage"].toInt()); 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); gFdResInfo->append(cardId+" "+tr("GetMinBrightness")+" "+err);
}); });
} }
@ -1285,21 +1293,29 @@ CtrlAdvancedPanel::CtrlAdvancedPanel(QWidget *parent) : QWidget(parent) {
json.insert("_id", "GetMaxBrightness"); json.insert("_id", "GetMaxBrightness");
json.insert("_type", "GetMaxBrightness"); json.insert("_type", "GetMaxBrightness");
if(gSelCards->count() == 1) { if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("GetMaxBrightness")); auto waitingDlg = new WaitingDlg(this, tr("GetMaxBrightness")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] { auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
fdMaxBright->setText(QString::number(json["maxBrightnessPercentage"].toInt())); auto value = json["maxBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
fdMaxBright->setText(QString::number(value));
}); });
} else { } else {
foreach(auto card, *gSelCards) { foreach(auto card, *gSelCards) {
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json);
auto cardId = card->m_strCardId; auto cardId = card->m_strCardId;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) err = QString::number(json["maxBrightnessPercentage"].toInt()); if(err.isEmpty()) {
auto value = json["maxBrightnessPercentage"].toInt(-1);
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
err = QString::number(value)+"%";
}
gFdResInfo->append(cardId+" "+tr("GetMaxBrightness")+" "+err); gFdResInfo->append(cardId+" "+tr("GetMaxBrightness")+" "+err);
}); });
} }

View File

@ -209,7 +209,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")+" ..."); auto waitingDlg = new WaitingDlg(this, tr("GetMinBrightness")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
auto brightLevel = card->BrightnessLevel; auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg, brightLevel] { connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
auto value = json["minBrightnessPercentage"].toInt(-1); auto value = json["minBrightnessPercentage"].toInt(-1);
@ -221,7 +221,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json);
auto cardId = card->m_strCardId; auto cardId = card->m_strCardId;
auto brightLevel = card->BrightnessLevel; auto brightLevel = card->BrightnessLevel;
connect(reply, &QNetworkReply::finished, this, [reply, cardId, brightLevel] { connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json; QJsonDocument json;
QString err = checkReplyForJson(reply, &json); QString err = checkReplyForJson(reply, &json);
if(err.isEmpty()) { if(err.isEmpty()) {

View File

@ -326,56 +326,65 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
return; return;
} }
auto isWifi = fdIsWifi->isChecked(); auto isWifi = fdIsWifi->isChecked();
QJsonObject json;
json.insert("_id", "SetSwitchWiFi");
json.insert("_type", "SetSwitchWiFi");
json.insert("enable", isWifi);
QString tip;
QJsonObject json2;
if(isWifi) { if(isWifi) {
tip = tr("ConfigurationWiFi"); QJsonObject json;
json.insert("_id", "SetSwitchWiFi");
json.insert("_type", "SetSwitchWiFi");
json.insert("enable", true);
QJsonObject json2;
json2.insert("_id", "ConfigurationWiFi"); json2.insert("_id", "ConfigurationWiFi");
json2.insert("_type", "ConfigurationWiFi"); json2.insert("_type", "ConfigurationWiFi");
json2.insert("ssid", fdWifiName->currentText()); json2.insert("ssid", fdWifiName->currentText());
json2.insert("password", fdWifiPassword->text()); json2.insert("password", fdWifiPassword->text());
} else if(fdIsHotspot->isChecked()) { if(gSelCards->count() == 1) {
tip = tr("ConfigurationHotSpot"); auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
json2.insert("_id", "ConfigurationHotSpot"); Def_CtrlReqPre
json2.insert("_type", "ConfigurationHotSpot");
json2.insert("apName", fdHotspotName->text());
json2.insert("password", fdHotspotPassword->text());
}
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tip+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, card, [=] {
QString err = checkReplyForJson(reply);
if(! err.isEmpty()) {
waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Error"), err);
return;
}
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json2);
waitingDlg->connAbort(reply);
connect(reply, &QNetworkReply::finished, card, [reply, waitingDlg] {
Def_CtrlSetReqAfter
});
});
} else {
foreach(auto card, *gSelCards) {
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, card, [=] { connect(reply, &QNetworkReply::finished, card, [=] {
QString err = checkReplyForJson(reply); QString err = checkReplyForJson(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
gFdResInfo->append(card->m_strCardId+" "+tip+" "+err); waitingDlg->close();
QMessageBox::critical(gMainWin, tr("Error"), err);
return; return;
} }
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json2); auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json2);
connect(reply, &QNetworkReply::finished, card, [=] { waitingDlg->connAbort(reply);
QString err = checkReplyForJson(reply); connect(reply, &QNetworkReply::finished, card, [reply, waitingDlg] {
gFdResInfo->append(card->m_strCardId+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err)); Def_CtrlSetReqAfter
}); });
}); });
} else {
foreach(auto card, *gSelCards) {
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, card, [=] {
QString err = checkReplyForJson(reply);
if(! err.isEmpty()) {
gFdResInfo->append(card->m_strCardId+" "+tr("ConfigurationWiFi")+" "+err);
return;
}
auto reply = NetReq("http://"+card->m_strCardIp+":2016/settings").timeout(120000).post(json2);
connect(reply, &QNetworkReply::finished, card, [=] {
QString err = checkReplyForJson(reply);
gFdResInfo->append(card->m_strCardId+" "+tr("ConfigurationWiFi")+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));
});
});
}
}
} else {
QJsonObject json;
json.insert("_id", "ConfigurationHotSpot");
json.insert("_type", "ConfigurationHotSpot");
json.insert("apName", fdHotspotName->text());
json.insert("password", fdHotspotPassword->text());
if(gSelCards->count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationHotSpot")+" ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, card, [=] {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, *gSelCards) {
Def_CtrlSetMulti(tr("ConfigurationHotSpot"));
}
} }
} }
}); });

View File

@ -12,7 +12,6 @@
#include <QHttpMultiPart> #include <QHttpMultiPart>
#include <QUuid> #include <QUuid>
#include <QBuffer> #include <QBuffer>
#include "base/pixbmpshowdialog.h"
#include <QThread> #include <QThread>
#include <QTcpSocket> #include <QTcpSocket>
#include <QHostAddress> #include <QHostAddress>
@ -428,19 +427,8 @@ void DeviceItem::OnProHttpResponse(QString url, QString postMD5, QByteArray data
} else if(strType == "GetScreenshotFull") { } else if(strType == "GetScreenshotFull") {
MACRO_ASKTIME_STOP MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK MACRO_POSTING_DLG_UNLOCK
ImgDlg dlg(QByteArray::fromBase64(jsonObject["data"].toString().toLatin1()), m_pWnd);
qDebug()<<"GetScreenshotFull"; dlg.exec();
QString iTemp=jsonObject["data"].toString();
QByteArray byte_array =iTemp.toLatin1();
QByteArray Ret_bytearray = QByteArray::fromBase64(byte_array);
//QBuffer buffer(&Ret_bytearray);
//buffer.open(QIODevice::WriteOnly);
//QPixmap imageresult;
//imageresult.loadFromData(Ret_bytearray);
PixbmpShowDialog *dlg=new PixbmpShowDialog(m_pWnd);
dlg->m_PixMap.loadFromData(Ret_bytearray);
dlg->ResizeByPixmap(mCard->m_iWidth,mCard->m_iHeight);
dlg->exec();
} }
} }
} }
@ -469,3 +457,18 @@ void DeviceItem::DeletePostingDlg()
m_PostingDlg=nullptr; m_PostingDlg=nullptr;
} }
} }
ImgDlg::ImgDlg(const QByteArray &data, QWidget *parent) : QDialog(parent) {
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
setWindowTitle(tr("Screenshot"));
mImg.loadFromData(data);
auto www = mImg.width();
auto hhh = mImg.height();
if(www <= 1600 && hhh <= 900) resize(www, hhh);
else if(www > hhh) resize(900 * www / hhh, 900);
else resize(1600, 1600 * hhh / www);
}
void ImgDlg::paintEvent(QPaintEvent *) {
QPainter painter(this);
painter.drawImage(rect(), mImg);
}

View File

@ -75,4 +75,11 @@ private:
QTimer *m_pGetAskTimer=nullptr; QTimer *m_pGetAskTimer=nullptr;
}; };
class ImgDlg : public QDialog {
public:
explicit ImgDlg(const QByteArray &, QWidget *parent = 0);
QImage mImg;
public:
void paintEvent(QPaintEvent *) override;
};
#endif // DEVICEITEM_H #endif // DEVICEITEM_H

View File

@ -419,29 +419,13 @@ void ProgPanel::FilterProgram(const QString &strtemp){
} }
ProgPortDlg::ProgPortDlg(QWidget *parent, QString title) : BaseDlg(parent) { ProgPortDlg::ProgPortDlg(QWidget *parent, QString title) : QDialog(parent) {
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
resize(600, 400); resize(600, 400);
setWindowTitle(title);
auto vBox = new VBox(this); auto vBox = new VBox(this);
auto hBox = new HBox(vBox); vBox->setContentsMargins(0, 0, 0, 6);
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 = new QTableWidget(0, 2);
table->setSelectionMode(QTableWidget::NoSelection); table->setSelectionMode(QTableWidget::NoSelection);
@ -453,7 +437,7 @@ ProgPortDlg::ProgPortDlg(QWidget *parent, QString title) : BaseDlg(parent) {
table->setHorizontalHeaderLabels({tr("Solution Name"), tr("Progress")}); table->setHorizontalHeaderLabels({tr("Solution Name"), tr("Progress")});
vBox->addWidget(table); vBox->addWidget(table);
hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
bnOK = new QPushButton(title); bnOK = new QPushButton(title);

View File

@ -3,10 +3,10 @@
#include "base/loqtreewidget.h" #include "base/loqtreewidget.h"
#include "program/progitem.h" #include "program/progitem.h"
#include "basedlg.h"
#include <QPushButton> #include <QPushButton>
#include <QSettings> #include <QSettings>
#include <QTableWidget> #include <QTableWidget>
#include <QDialog>
class ProgPanel : public QWidget { class ProgPanel : public QWidget {
Q_OBJECT Q_OBJECT
@ -39,13 +39,12 @@ private:
QPushButton *bnSend, *btnPlay; QPushButton *bnSend, *btnPlay;
}; };
class ProgPortDlg : public BaseDlg { class ProgPortDlg : public QDialog {
Q_OBJECT
public: public:
ProgPortDlg(QWidget *parent, QString title); ProgPortDlg(QWidget *parent, QString title);
QTableWidget *table{0}; QTableWidget *table{0};
QPushButton *bnOK, *bnClose; QPushButton *bnOK;
}; };
#endif // PROGPANEL_H #endif // PROGPANEL_H

View File

@ -4,30 +4,13 @@
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remarks, QString widths, QWidget *parent) : BaseDlg(parent) { ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remarks, QString widths, QWidget *parent) : QDialog(parent) {
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
setWindowTitle(tr("Solution Information"));
auto vBox = new VBox(this); auto vBox = new VBox(this);
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->setContentsMargins(0, 0, 0, 0);
hBox->addStretch();
auto label = new QLabel(tr("Solution Information")); auto label = new QLabel(tr("Solution Name"));
hBox->addWidget(label);
hBox->addStretch();
auto btnClose = new QPushButton("X");
btnClose->setProperty("ssType", "progManageTool");
connect(btnClose, &QPushButton::clicked, this, &QDialog::close);
hBox->addWidget(btnClose);
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
hBox = new HBox(vBox);
label = new QLabel(tr("Solution Name"));
label->setMinimumWidth(90); label->setMinimumWidth(90);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
hBox->addWidget(label); hBox->addWidget(label);
@ -77,11 +60,6 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
fdRemark->setFixedSize(300, 80); fdRemark->setFixedSize(300, 80);
hBox->addWidget(fdRemark); hBox->addWidget(fdRemark);
line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
hBox = new HBox(vBox); hBox = new HBox(vBox);
auto lbSplitWidth = new QLabel(tr("每段打折宽度 (用空格分隔)")); auto lbSplitWidth = new QLabel(tr("每段打折宽度 (用空格分隔)"));
@ -95,6 +73,8 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
fdSplitWidths->setVisible(false); fdSplitWidths->setVisible(false);
} }
vBox->addSpacing(6);
hBox = new HBox(vBox); hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();

View File

@ -1,12 +1,12 @@
#ifndef PROGCREATEDLG_H #ifndef PROGCREATEDLG_H
#define PROGCREATEDLG_H #define PROGCREATEDLG_H
#include "basedlg.h" #include <QDialog>
#include <QLineEdit> #include <QLineEdit>
#include <QTextEdit> #include <QTextEdit>
#include <QSpinBox> #include <QSpinBox>
class ProgCreateDlg : public BaseDlg { class ProgCreateDlg : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
ProgCreateDlg(QString name, int width, int height, QString remarks, QString, QWidget *parent = nullptr); ProgCreateDlg(QString name, int width, int height, QString remarks, QString, QWidget *parent = nullptr);

View File

@ -40,6 +40,8 @@ QWidget *gProgEditorWin;
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QDialog(parent), mProgItem(progItem) { ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QDialog(parent), mProgItem(progItem) {
gProgEditorWin = this; gProgEditorWin = this;
gProgItem = progItem; gProgItem = progItem;
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
setWindowFlag(Qt::WindowMaximizeButtonHint);
setAttribute(Qt::WA_AlwaysShowToolTips); setAttribute(Qt::WA_AlwaysShowToolTips);
if(parent && ! parent->isMaximized()) resize(parent->size()); if(parent && ! parent->isMaximized()) resize(parent->size());
else resize(1280, 720); else resize(1280, 720);
@ -244,7 +246,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QDialog(pare
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EPhoto::filters()); auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EPhoto::filters());
for(int i=0; i<files.count(); i++) { for(int i=0; i<files.count(); i++) {
auto ePhoto = EPhoto::create(files[i], mPageItem); auto ePhoto = EPhoto::create(files[i], mPageItem);
if(ePhoto==nullptr) continue; if(ePhoto==0) continue;
auto rect = Tools::centerRect(ePhoto->img.width(), ePhoto->img.height(), mProgItem->mWidth, mProgItem->mHeight); auto rect = Tools::centerRect(ePhoto->img.width(), ePhoto->img.height(), mProgItem->mWidth, mProgItem->mHeight);
ePhoto->setPos(rect.topLeft()); ePhoto->setPos(rect.topLeft());
ePhoto->setSize(rect.width(), rect.height()); ePhoto->setSize(rect.width(), rect.height());

View File

@ -1,115 +1,125 @@
#include "wplanitem.h" #include "wplanitem.h"
#include "ui_wplanitem.h" #include "gutil/qgui.h"
#include <QJsonArray>
wPlanItem::wPlanItem(QListWidgetItem *item, QWidget *parent) : wPlanItem::wPlanItem(QListWidgetItem *item, const QJsonObject *json) : m_item(item) {
QWidget(parent),
ui(new Ui::wPlanItem),
m_item(item)
{
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
initBegin(); auto vBox = new VBox(this);
ui->sMon ->setChecked(true); vBox->setContentsMargins(6, 6, 0, 6);
ui->sTues->setChecked(true); auto hBox = new HBox(vBox);
ui->sWed ->setChecked(true);
ui->sThur->setChecked(true); fdIdx = new QLabel("1");
ui->sFri ->setChecked(true); hBox->addWidget(fdIdx);
ui->sSat ->setChecked(true);
ui->sSun ->setChecked(true); tStart = new QTimeEdit;
initEnd(); tStart->setDisplayFormat("HH:mm");
hBox->addWidget(tStart);
tEnd = new QTimeEdit;
tEnd->setDisplayFormat("HH:mm");
tEnd->setTime(QTime(23, 59, 59));
hBox->addWidget(tEnd);
bnDel = new QPushButton;
hBox->addWidget(bnDel);
hBox = new HBox(vBox);
sMon = new QPushButton(tr("M"));
sMon ->setCheckable(true);
sMon ->setProperty("ssName", "weeklySelector");
hBox->addWidget(sMon);
hBox->addStretch();
sTues = new QPushButton(tr("Tu"));
sTues->setCheckable(true);
sTues->setProperty("ssName", "weeklySelector");
hBox->addWidget(sTues);
hBox->addStretch();
sWed = new QPushButton(tr("W"));
sWed ->setCheckable(true);
sWed ->setProperty("ssName", "weeklySelector");
hBox->addWidget(sWed);
hBox->addStretch();
sThur = new QPushButton(tr("Th"));
sThur->setCheckable(true);
sThur->setProperty("ssName", "weeklySelector");
hBox->addWidget(sThur);
hBox->addStretch();
sFri = new QPushButton(tr("F"));
sFri ->setCheckable(true);
sFri ->setProperty("ssName", "weeklySelector");
hBox->addWidget(sFri);
hBox->addStretch();
sSat = new QPushButton(tr("Sa"));
sSat ->setCheckable(true);
sSat ->setProperty("ssName", "weeklySelector");
hBox->addWidget(sSat);
hBox->addStretch();
sSun = new QPushButton(tr("Su"));
sSun ->setCheckable(true);
sSun ->setProperty("ssName", "weeklySelector");
hBox->addWidget(sSun);
if(json==0) {
sMon ->setChecked(true);
sTues->setChecked(true);
sWed ->setChecked(true);
sThur->setChecked(true);
sFri ->setChecked(true);
sSat ->setChecked(true);
sSun ->setChecked(true);
} else {
tStart->setTime(QTime::fromString(json->value("start").toString(), "hh:mm"));
tEnd->setTime(QTime::fromString(json->value("end").toString(), "hh:mm"));
auto oWeekly = json->value("weekly").toArray();
sMon ->setChecked(oWeekly.contains(1));
sTues->setChecked(oWeekly.contains(2));
sWed ->setChecked(oWeekly.contains(3));
sThur->setChecked(oWeekly.contains(4));
sFri ->setChecked(oWeekly.contains(5));
sSat ->setChecked(oWeekly.contains(6));
sSun ->setChecked(oWeekly.contains(7));
}
connect(tStart, SIGNAL(timeChanged(const QTime&)), this, SLOT(onItemChanged()));
connect(tEnd, SIGNAL(timeChanged(const QTime&)), this, SLOT(onItemChanged()));
connect(sMon, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(sTues, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(sWed, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(sThur, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(sFri, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(sSat, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(sSun, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(bnDel, SIGNAL(clicked(bool)), this, SLOT(onDelete(bool)));
} }
wPlanItem::wPlanItem(const QJsonObject &oRoot, QListWidgetItem *item, QWidget *parent) : void wPlanItem::onItemChanged(){
QWidget(parent),
ui(new Ui::wPlanItem),
m_item(item)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
initBegin();
setPlan(oRoot);
initEnd();
}
void wPlanItem::initBegin()
{
ui->sMon ->setCheckable(true);
ui->sTues->setCheckable(true);
ui->sWed ->setCheckable(true);
ui->sThur->setCheckable(true);
ui->sFri ->setCheckable(true);
ui->sSat ->setCheckable(true);
ui->sSun ->setCheckable(true);
ui->sMon ->setProperty("ssName", "weeklySelector");
ui->sTues->setProperty("ssName", "weeklySelector");
ui->sWed ->setProperty("ssName", "weeklySelector");
ui->sThur->setProperty("ssName", "weeklySelector");
ui->sFri ->setProperty("ssName", "weeklySelector");
ui->sSat ->setProperty("ssName", "weeklySelector");
ui->sSun ->setProperty("ssName", "weeklySelector");
}
void wPlanItem::initEnd()
{
connect(ui->tStart, SIGNAL(timeChanged(const QTime&)), this, SLOT(onItemChanged()));
connect(ui->tEnd, SIGNAL(timeChanged(const QTime&)), this, SLOT(onItemChanged()));
connect(ui->sMon, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->sTues, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->sWed, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->sThur, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->sFri, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->sSat, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->sSun, SIGNAL(toggled(bool)), this, SLOT(onItemChanged()));
connect(ui->bnDel, SIGNAL(clicked(bool)), this, SLOT(onDelete(bool)));
}
wPlanItem::~wPlanItem()
{
delete ui;
}
void wPlanItem::onItemChanged()
{
emit sigItemChanged(m_item); emit sigItemChanged(m_item);
} }
void wPlanItem::onDelete(bool) void wPlanItem::onDelete(bool){
{
emit sigDelete(m_item); emit sigDelete(m_item);
} }
void wPlanItem::setNum(int n) QJsonObject wPlanItem::planJson() const {
{
ui->wNum->setText(QString("%1").arg(n));
}
void wPlanItem::setPlan(const QJsonObject &oRoot)
{
QJsonArray oWeekly = oRoot["weekly"].toArray();
ui->tStart->setTime(QTime::fromString(oRoot["start"].toString(), "hh:mm"));
ui->tEnd->setTime(QTime::fromString(oRoot["end"].toString(), "hh:mm"));
ui->sMon ->setChecked(oWeekly.contains(QJsonValue(1)));
ui->sTues->setChecked(oWeekly.contains(QJsonValue(2)));
ui->sWed ->setChecked(oWeekly.contains(QJsonValue(3)));
ui->sThur->setChecked(oWeekly.contains(QJsonValue(4)));
ui->sFri ->setChecked(oWeekly.contains(QJsonValue(5)));
ui->sSat ->setChecked(oWeekly.contains(QJsonValue(6)));
ui->sSun ->setChecked(oWeekly.contains(QJsonValue(7)));
}
QJsonObject wPlanItem::planJson() const
{
QJsonObject oRoot; QJsonObject oRoot;
QJsonArray oWeekly; QJsonArray oWeekly;
if(ui->sMon ->isChecked()) oWeekly.append(QJsonValue(1)); if(sMon ->isChecked()) oWeekly.append(QJsonValue(1));
if(ui->sTues->isChecked()) oWeekly.append(QJsonValue(2)); if(sTues->isChecked()) oWeekly.append(QJsonValue(2));
if(ui->sWed ->isChecked()) oWeekly.append(QJsonValue(3)); if(sWed ->isChecked()) oWeekly.append(QJsonValue(3));
if(ui->sThur->isChecked()) oWeekly.append(QJsonValue(4)); if(sThur->isChecked()) oWeekly.append(QJsonValue(4));
if(ui->sFri ->isChecked()) oWeekly.append(QJsonValue(5)); if(sFri ->isChecked()) oWeekly.append(QJsonValue(5));
if(ui->sSat ->isChecked()) oWeekly.append(QJsonValue(6)); if(sSat ->isChecked()) oWeekly.append(QJsonValue(6));
if(ui->sSun ->isChecked()) oWeekly.append(QJsonValue(7)); if(sSun ->isChecked()) oWeekly.append(QJsonValue(7));
oRoot["start"] = ui->tStart->time().toString("hh:mm"); oRoot["start"] = tStart->time().toString("hh:mm");
oRoot["end"] = ui->tEnd->time().toString("hh:mm"); oRoot["end"] = tEnd->time().toString("hh:mm");
oRoot["weekly"] = oWeekly; oRoot["weekly"] = oWeekly;
return oRoot; return oRoot;
} }

View File

@ -1,33 +1,19 @@
#ifndef WPLANITEM_H #ifndef WPLANITEM_H
#define WPLANITEM_H #define WPLANITEM_H
#include <QWidget> #include <QPushButton>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QJsonValue> #include <QLabel>
#include <QJsonArray> #include <QTimeEdit>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonDocument>
namespace Ui { class wPlanItem : public QWidget {
class wPlanItem;
}
class wPlanItem : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
explicit wPlanItem(QListWidgetItem *item, QWidget *parent = nullptr); explicit wPlanItem(QListWidgetItem *item, const QJsonObject * = 0);
explicit wPlanItem(const QJsonObject &oRoot, QListWidgetItem *item, QWidget *parent = nullptr);
~wPlanItem();
void setNum(int n);
void setPlan(const QJsonObject &oRoot);
QJsonObject planJson() const; QJsonObject planJson() const;
QLabel *fdIdx;
private:
void initBegin();
void initEnd();
signals: signals:
void sigItemChanged(QListWidgetItem *); void sigItemChanged(QListWidgetItem *);
@ -38,8 +24,18 @@ protected slots:
void onDelete(bool); void onDelete(bool);
private: private:
Ui::wPlanItem *ui;
QListWidgetItem *m_item; QListWidgetItem *m_item;
QTimeEdit *tStart;
QTimeEdit *tEnd;
QPushButton *bnDel;
QPushButton *sMon;
QPushButton *sTues;
QPushButton *sWed;
QPushButton *sThur;
QPushButton *sFri;
QPushButton *sSat;
QPushButton *sSun;
}; };
#endif // WPLANITEM_H #endif // WPLANITEM_H

View File

@ -1,351 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>wPlanItem</class>
<widget class="QWidget" name="wPlanItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<height>80</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>12</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="wNum">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="tStart">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="displayFormat">
<string notr="true">HH:mm</string>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="tEnd">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="displayFormat">
<string notr="true">HH:mm</string>
</property>
<property name="time">
<time>
<hour>23</hour>
<minute>59</minute>
<second>59</second>
</time>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnDel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Every week:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="sMon">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>M</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sTues">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Tu</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sWed">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>W</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sThur">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Th</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sFri">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>F</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sSat">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Sa</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sSun">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Su</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,23 +1,18 @@
#include "wplanlist.h" #include "wplanlist.h"
#include "wplanitem.h" #include "wplanitem.h"
#include <QJsonArray>
wPlanList::wPlanList(QWidget *parent) : QListWidget(parent) wPlanList::wPlanList(QWidget *parent) : QListWidget(parent) {
{
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setFrameShape(QListWidget::NoFrame); setFrameShape(QListWidget::NoFrame);
} }
void wPlanList::adjustItemNum() void wPlanList::adjustItemNum() {
{
int n = count(); int n = count();
for(int i=0; i<n; i++) { for(int i=0; i<n; i++) static_cast<wPlanItem*>(itemWidget(item(i)))->fdIdx->setNum(i+1);
wPlanItem *w = static_cast<wPlanItem*>(itemWidget(item(i)));
w->setNum(i+1);
}
} }
QJsonArray wPlanList::plansJson() QJsonArray wPlanList::plansJson() {
{
QJsonArray oRoot; QJsonArray oRoot;
int n = count(); int n = count();
for(int i=0; i<n; i++) { for(int i=0; i<n; i++) {
@ -48,7 +43,8 @@ void wPlanList::onRestorePlan(const QJsonArray &jRoot)
for(int i=0; i<n; i++) { for(int i=0; i<n; i++) {
QListWidgetItem *item = new QListWidgetItem(); QListWidgetItem *item = new QListWidgetItem();
item->setFlags(item->flags() & ~Qt::ItemIsSelectable); item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
wPlanItem *widget = new wPlanItem(jRoot.at(i).toObject(), item); auto json = jRoot.at(i).toObject();
wPlanItem *widget = new wPlanItem(item, &json);
addItem(item); addItem(item);
setItemWidget(item, widget); setItemWidget(item, widget);
setCurrentItem(item); setCurrentItem(item);

View File

@ -4,8 +4,7 @@
#include <QListWidget> #include <QListWidget>
#include <QListWidgetItem> #include <QListWidgetItem>
class wPlanList : public QListWidget class wPlanList : public QListWidget {
{
Q_OBJECT Q_OBJECT
public: public:
explicit wPlanList(QWidget *parent = nullptr); explicit wPlanList(QWidget *parent = nullptr);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff