This commit is contained in:
gangphon 2023-04-27 15:06:24 +08:00
parent e92dac27a7
commit 38b63542f3
23 changed files with 958 additions and 913 deletions

View File

@ -35,17 +35,9 @@ SwitchControl::SwitchControl(QWidget *parent): QWidget(parent)
timer = new QTimer(this);
timer->setInterval(5);
connect(timer, SIGNAL(timeout()), this, SLOT(updateValue()));
setFont(QFont("Microsoft Yahei", 10));
}
SwitchControl::~SwitchControl()
{
}
void SwitchControl::mousePressEvent(QMouseEvent *)
{
void SwitchControl::mousePressEvent(QMouseEvent *) {
checked = !checked;
//每次移动的步长为宽度的 50分之一

View File

@ -24,9 +24,7 @@ public:
ButtonStyle_CircleOut = 2,//外圆形
ButtonStyle_Image = 3 //图片
};
SwitchControl(QWidget *parent = 0);
~SwitchControl();
protected:
void mousePressEvent(QMouseEvent *);

View File

@ -55,26 +55,34 @@ CtrlHdmiPanel::CtrlHdmiPanel(QWidget *parent) : QWidget(parent) {
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;
vBox->addSpacing(20);
hBox = new HBox(vBox);
hBox->addStretch();
btnSyncSet = new QPushButton;
btnSyncSet->setMinimumSize(60, 30);
btnSyncSet->setProperty("ssType", "progManageTool");
connect(btnSyncSet, &QPushButton::clicked, this, [=] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
}
auto id = btnGroup->checkedId();
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"));
auto waitingDlg = new WaitingDlg(this, id ? tr("SyncSwitch") : tr("AnSyncSwitch"));
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, *gSelCards) {
if(checked){
if(id) {
Def_CtrlSetMulti(tr("SyncSwitch"))
} else {
Def_CtrlSetMulti(tr("AnSyncSwitch"))
@ -82,15 +90,13 @@ CtrlHdmiPanel::CtrlHdmiPanel(QWidget *parent) : QWidget(parent) {
}
}
});
hBox->addWidget(btnSyncSet);
hBox->addSpacing(20);
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] {
btnSyncGet = new QPushButton;
btnSyncGet->setMinimumSize(60, 30);
btnSyncGet->setProperty("ssType", "progManageTool");
connect(btnSyncGet, &QPushButton::clicked, this, [this] {
if(gSelCards->isEmpty()) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return;
@ -132,7 +138,7 @@ CtrlHdmiPanel::CtrlHdmiPanel(QWidget *parent) : QWidget(parent) {
}
}
});
hBox->addWidget(btnGetSync);
hBox->addWidget(btnSyncGet);
hBox->addStretch();
vBox->addStretch();
@ -294,7 +300,7 @@ CtrlHdmiPanel::CtrlHdmiPanel(QWidget *parent) : QWidget(parent) {
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)));
connect(m_buttonGroup, &QButtonGroup::idClicked, stacked, &QStackedLayout::setCurrentIndex);
fdManual->setChecked(true);
stacked->setCurrentIndex(0);
@ -344,7 +350,8 @@ void CtrlHdmiPanel::transUi() {
fdSchedule->setText(tr("Schedule"));
fdAsync->setText(tr("Async"));
btnGetSync->setText(tr("Readback"));
btnSyncSet->setText(tr("Set"));
btnSyncGet->setText(tr("Readback"));
tableSche->setHeaderText("start", tr("Start Time"));
tableSche->setHeaderText("end", tr("End Time"));

View File

@ -22,7 +22,7 @@ protected:
private:
QLabel *lbHdmiCfg;
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
QPushButton *btnGetSync;
QPushButton *btnSyncSet, *btnSyncGet;
Table *tableSche;
QPushButton *btnScheAdd;

View File

@ -13,9 +13,9 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
auto vBox = new VBox(this);
lbLanCfg = new QLabel;
QFont font = lbLanCfg->font();
font.setPixelSize(16);
lbLanCfg->setFont(font);
auto ftTitle = lbLanCfg->font();
ftTitle.setPixelSize(16);
lbLanCfg->setFont(ftTitle);
lbLanCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbLanCfg);
@ -210,7 +210,7 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
vBox->addWidget(line);
label_5 = new QLabel;
label_5->setFont(font);
label_5->setFont(ftTitle);
label_5->setAlignment(Qt::AlignCenter);
vBox->addWidget(label_5);
@ -445,7 +445,7 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
vBox->addWidget(line_3);
lbCellularConfig = new QLabel;
lbCellularConfig->setFont(font);
lbCellularConfig->setFont(ftTitle);
vBox->addWidget(lbCellularConfig, 0, Qt::AlignHCenter);

View File

@ -63,6 +63,14 @@ public:
};
};
inline QFont qfont(const QString &family, int pixelSize, bool bold = false, bool italic = false) {
QFont font(family);
font.setPixelSize(pixelSize);
if(bold) font.setBold(true);
if(italic) font.setItalic(true);
return font;
}
class NumTable : public QTableWidget {
Q_OBJECT
public:

View File

@ -13,11 +13,13 @@ EleTimer::EleTimer(const QJsonObject &json, QWidget *parent) : QWidget{parent} {
hasSec = json["hasSec"].toBool();
text = json["text"].toString();
isMultiline = json["isMultiline"].toBool();
font = json["font"].toString();
fontSize = json["fontSize"].toInt();
fontBold = json["fontBold"].toBool();
fontItalic = json["fontItalic"].toBool();
fontUnderline = json["fontUnderline"].toBool();
font = QFont(json["font"].toString());
font.setPixelSize(json["fontSize"].toInt());
font.setBold(json["fontBold"].toBool());
font.setItalic(json["fontItalic"].toBool());
font.setUnderline(json["fontUnderline"].toBool());
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
textColor = json["textColor"].toString();
auto color = json["backColor"].toString();
backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
@ -52,11 +54,6 @@ void EleTimer::paintEvent(QPaintEvent *){
}
if(hasSec) text.append(QString::asprintf("%02d ", secs)).append(tr("sec")).append(" ");
text = text.trimmed();
QFont font(this->font, fontSize);
font.setBold(fontBold);
font.setItalic(fontItalic);
font.setUnderline(fontUnderline);
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
QPainter painter(this);
if(backColor.alpha() != 0) painter.fillRect(rect(), backColor);
painter.setFont(font);

View File

@ -7,16 +7,12 @@
class EleTimer : public QWidget {
Q_OBJECT
public:
explicit EleTimer(const QJsonObject&, QWidget *parent = nullptr);
explicit EleTimer(const QJsonObject&, QWidget *parent = 0);
QDateTime targetTime;
QString text;
QColor textColor;
QColor backColor;
QString font;
int fontSize;
bool fontBold;
bool fontItalic;
bool fontUnderline;
QFont font;
bool isDown;
bool isMultiline;
bool hasDay;

View File

@ -328,8 +328,8 @@ void ProgPanel::onEditClicked(bool){
for(int i=0; i<cnt; i++) {
if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
auto editor = new ProgEditorWin(item, gMainWin);
editor->show();
ProgEditorWin editor(item, gMainWin);
editor.exec();
break;
}
}
@ -353,8 +353,8 @@ void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize re
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);
editor->show();
ProgEditorWin editor(item, gMainWin);
editor.exec();
}
void ProgPanel::onDeleteClicked(bool){
auto res = QMessageBox::information(this, tr("Tip Info"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);

View File

@ -44,7 +44,8 @@ EAClock::EAClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
color = widget["textColor"];
m_attr.textColor = color.isString() ? QColor(color.toString()) : Tools::int2Color(color.toInt());
m_attr.text = widget["text"].toString();
m_attr.textFont = QFont(widget["textFontFamily"].toString(), widget["textFontSize"].toInt());
m_attr.textFont = QFont(widget["textFontFamily"].toString());
m_attr.textFont.setPixelSize(widget["textFontSize"].toInt());
m_attr.textFont.setBold(widget["textFontBold"].toBool());
m_attr.textFont.setItalic(widget["textFontItalics"].toBool());
m_attr.textFont.setUnderline(widget["textFontUnderline"].toBool());

View File

@ -3,7 +3,7 @@
#include "ebase.h"
#include <QTimeZone>
#include <QFont>
#include "gutil/qgui.h"
class EAClock : public EBase {
Q_OBJECT
@ -25,7 +25,7 @@ public:
// r*3/4, r / 30
// r, r / 40
QString text;//标题
QFont textFont{"Arial", 9};//标题字体
QFont textFont = qfont("Arial", 12);//标题字体
QColor textColor;//标题字体颜色
int playDuration{10};//
QString path;

View File

@ -2,17 +2,16 @@
#include "base/locolorselector.h"
#include "globaldefine.h"
#include "tools.h"
#include <QBoxLayout>
#include "gutil/qgui.h"
#include <QCheckBox>
#include <QFontComboBox>
#include <QLabel>
#include <QSpinBox>
#include <QToolButton>
EDClock::EDClock(EBase *multiWin) : EBase(multiWin) {
mType = EBase::DClock;
m_attr.timeZoneId = QTimeZone::systemTimeZoneId();
m_attr.font = QFont("Arial", 9);
m_attr.font = qfont("Arial", 12);
m_attr.year = true;
m_attr.month = true;
m_attr.day = true;
@ -35,9 +34,7 @@ EDClock::EDClock(const QJsonObject &json, EBase *multiWin) : EBase(multiWin) {
setBaseAttr(json);
auto widget = json["widget"];
auto font = widget["font"];
m_attr.font = QFont(font["family"].toString(), font["size"].toInt());
m_attr.font.setBold(font["bold"].toBool());
m_attr.font.setItalic(font["italics"].toBool());
m_attr.font = qfont(font["family"].toString(), font["size"].toInt(), font["bold"].toBool(), font["italics"].toBool());
m_attr.font.setUnderline(font["underline"].toBool());
m_attr.textColor = Tools::int2Color(font["color"].toInt());
m_attr.timeZoneId = widget["timeZone"].toString().toUtf8();

View File

@ -2,7 +2,7 @@
#include "base/locolorselector.h"
#include "globaldefine.h"
#include "tools.h"
#include <QBoxLayout>
#include "gutil/qgui.h"
#include <QButtonGroup>
#include <QCheckBox>
#include <QFontComboBox>
@ -39,11 +39,8 @@ QJsonObject EEnviron::genProg(const QJsonObject &json, const QString &dstDir, co
oRes["iScrollSpeed"] = widget["scrollSpeed"].toInt();
auto textColor = Tools::int2Color(widget["textColor"].toInt());
auto font = QFont(widget["fontFamily"].toString(), widget["fontSize"].toInt());
font.setBold(widget["fontBold"].toBool());
font.setItalic(widget["fontItalics"].toBool());
auto font = qfont(widget["fontFamily"].toString(), widget["fontSize"].toInt(), widget["fontBold"].toBool(), widget["fontItalics"].toBool());
font.setUnderline(widget["fontUnderline"].toBool());
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
QFontMetricsF metricF(font);
oRes["spaceWidth"] = metricF.horizontalAdvance(" ");
@ -136,9 +133,7 @@ EEnviron::EEnviron(const QJsonObject &json, EBase *multiWin): EBase(multiWin){
m_attr.scrollSpeed = widget["scrollSpeed"].toInt();
m_attr.backColor = Tools::int2Color(widget["cBackground"].toInt());
m_attr.align = widget["alignType"].toInt();
m_attr.font = QFont(widget["fontFamily"].toString(), widget["fontSize"].toInt());
m_attr.font.setBold(widget["fontBold"].toBool());
m_attr.font.setItalic(widget["fontItalics"].toBool());
m_attr.font = qfont(widget["fontFamily"].toString(), widget["fontSize"].toInt(), widget["fontBold"].toBool(), widget["fontItalics"].toBool());
m_attr.font.setUnderline(widget["fontUnderline"].toBool());
m_attr.textColor = Tools::int2Color(widget["textColor"].toInt());
m_attr.playRefresh = json["play"]["refresh"].toInt();
@ -577,9 +572,7 @@ QWidget* EEnviron::attrWgt() {
fdFontFamily->setEditable(false);
fdFontFamily->setCurrentText(m_attr.font.family());
connect(fdFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &f) {
QFont font(f.family(), m_attr.font.pixelSize());
font.setBold(m_attr.font.bold());
font.setItalic(m_attr.font.italic());
auto font = qfont(f.family(), m_attr.font.pixelSize(), m_attr.font.bold(), m_attr.font.italic());
font.setUnderline(m_attr.font.underline());
m_attr.font = font;
calAttr();

View File

@ -1,7 +1,7 @@
#ifndef EENVIRON_H
#define EENVIRON_H
#include "ebase.h"
#include <QFont>
#include "gutil/qgui.h"
class EEnviron : public EBase {
Q_OBJECT
@ -18,7 +18,7 @@ public:
int tempType = 0;
int compensation = 0;
QFont font = QFont("Arial", 9);
QFont font = qfont("Arial", 12);
QColor textColor = Qt::red;
QColor backColor = Qt::transparent;
int align = 0;

View File

@ -15,7 +15,8 @@ EGif *EGif::create(const QString &file, PageListItem *pageItem, EBase *multiWin)
auto movie = new QMovie(file);
if(! movie->isValid()) {
QMessageBox::critical(gMainWin, "Gif Error", Tools::readErrStr(movie->lastError())+": "+movie->lastErrorString()+"\n"+file);
return nullptr;
delete movie;
return 0;
}
movie->setCacheMode(QMovie::CacheAll);
movie->jumpToFrame(0);
@ -32,7 +33,10 @@ EGif *EGif::create(const QJsonObject &json, PageListItem *pageItem, EBase *multi
else if(QFileInfo::exists(file = pageItem->mPageDir + "/" + name)) dir = pageItem->mPageDir;
else return nullptr;
auto movie = new QMovie(file);
if(! movie->isValid()) return nullptr;
if(! movie->isValid()) {
delete movie;
return 0;
}
movie->setCacheMode(QMovie::CacheAll);
movie->jumpToFrame(0);
auto ins = new EGif(movie, dir, name, pageItem, multiWin);
@ -47,15 +51,15 @@ EGif::EGif(QMovie *movie, const QString &dir, const QString &name, PageListItem
mType = EBase::Gif;
}
EGif::~EGif() {
if(mMovie!=nullptr) delete mMovie;
if(mMovie) delete mMovie;
}
void EGif::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
if(mMovie!=nullptr) {
if(mMovie) {
painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
painter->drawPixmap(innerRect(), mMovie->currentPixmap(), QRectF());
if(timer==nullptr) {
if(timer==0) {
auto delay = mMovie->nextFrameDelay();
if(delay!=0) {
if(delay) {
timer = new SyncTimer(delay);
connect(timer, &SyncTimer::timeout, this, &EGif::sltNext, Qt::BlockingQueuedConnection);
timer->start();
@ -65,33 +69,33 @@ void EGif::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *
EBase::paint(painter, a, b);
}
void EGif::sltNext() {
if(isVisible() && mMovie!=nullptr) {
if(isVisible() && mMovie) {
mMovie->jumpToNextFrame();
timer->inter = mMovie->nextFrameDelay();
update();
} else if(timer!=nullptr) {
} else if(timer) {
timer->stop();
timer = nullptr;
timer = 0;
}
}
void EGif::loadFiles() {
if(mMovie!=nullptr) return;
if(mMovie) return;
if(! QFileInfo::exists(mDir + "/" + mName)) return;
mMovie = new QMovie(mDir + "/" + mName, QByteArray());
mMovie->setCacheMode(QMovie::CacheAll);
mMovie->jumpToFrame(0);
}
void EGif::freeFiles() {
if(mMovie==nullptr) return;
if(mMovie==0) return;
delete mMovie;
mMovie = nullptr;
mMovie = 0;
}
QWidget* EGif::attrWgt() {
auto wgtAttr = new QWidget();
auto wgtAttr = new QWidget;
auto vBox = new QVBoxLayout(wgtAttr);
vBox->setContentsMargins(6, 0, 6, 0);
if(mMultiWin!=nullptr) vBox->setSpacing(3);
if(mMultiWin) vBox->setSpacing(3);
addBaseAttrWgt(vBox);
@ -122,6 +126,7 @@ QWidget* EGif::attrWgt() {
auto movie = new QMovie(file);
if(! movie->isValid()) {
QMessageBox::critical(gMainWin, "Gif Error", Tools::readErrStr(movie->lastError())+": "+movie->lastErrorString()+"\n"+file);
delete movie;
return;
}
movie->setCacheMode(QMovie::CacheAll);
@ -131,7 +136,7 @@ QWidget* EGif::attrWgt() {
wFile->setText(mName);
mDir = fileInfo.absolutePath();
gFileHome = mDir;
if(mMovie!=nullptr) delete mMovie;
if(mMovie) delete mMovie;
mMovie = movie;
});
hBox->addWidget(bnSelectFile);

View File

@ -55,11 +55,10 @@ EMultiWin::~EMultiWin() {
void EMultiWin::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
if(inners.isEmpty()) {
QFont font("Arial", 12);
QTextOption opt(Qt::AlignCenter);
painter->save();
painter->fillRect(rect(),QColor(0, 0, 0));
painter->setFont(font);
painter->setFont(qfont("Arial", 12));
painter->setPen(QColor(100, 100, 100));
painter->drawText(rect(), tr("Please add media on the right"), opt);
painter->restore();

View File

@ -3,7 +3,7 @@
#include "globaldefine.h"
#include "base/lodateselector.h"
#include "base/locolorselector.h"
#include <QBoxLayout>
#include "gutil/qgui.h"
#include <QLabel>
#include <QRadioButton>
#include <QCheckBox>
@ -26,7 +26,7 @@ ETimer::ETimer(EBase *multiWin) : EBase(multiWin) {
attr.hasMin = true;
attr.hasSec = true;
attr.isMultiline = true;
attr.font = QFont("Arial", 9);
attr.font = qfont("Arial", 12);
attr.textColor = Qt::red;
attr.backColor = Qt::transparent;
attr.duration = 10;
@ -44,9 +44,7 @@ ETimer::ETimer(const QJsonObject &json, EBase *multiWin) : EBase(multiWin){
attr.hasSec = json["hasSec"].toBool();
attr.text = json["text"].toString();
attr.isMultiline = json["isMultiline"].toBool();
attr.font = QFont(json["font"].toString(), json["fontSize"].toInt());
attr.font.setBold(json["fontBold"].toBool());
attr.font.setItalic(json["fontItalic"].toBool());
attr.font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
attr.font.setUnderline(json["fontUnderline"].toBool());
attr.textColor = json["textColor"].toString();
auto color = json["backColor"].toString();

View File

@ -463,7 +463,8 @@ QJsonObject GenTmpThread::convertDClock(const QJsonObject &json){
auto fontVal = widget["font"];
auto textColor = Tools::int2Color(fontVal["color"].toInt());
QFont font(fontVal["family"].toString(), fontVal["size"].toInt());
QFont font(fontVal["family"].toString());
font.setPixelSize(fontVal["size"].toInt());
font.setBold(fontVal["bold"].toBool());
font.setItalic(fontVal["italics"].toBool());
font.setUnderline(fontVal["underline"].toBool());
@ -565,7 +566,8 @@ QJsonObject GenTmpThread::convertTimer(const QJsonObject &json) {
oRes["isMultiline"] = json["isMultiline"];
auto text = json["text"].toString();
oRes["text"] = text;
QFont font(json["font"].toString(), json["fontSize"].toInt());
QFont font(json["font"].toString());
font.setPixelSize(json["fontSize"].toInt());
font.setBold(json["fontBold"].toBool());
font.setItalic(json["fontItalic"].toBool());
font.setUnderline(json["fontUnderline"].toBool());

View File

@ -63,8 +63,8 @@ QPushButton:hover {
m_bnName->setCursor(QCursor(Qt::PointingHandCursor));
mTree->setItemWidget(this, ENUM_PROGRAMLISTHEADERITEM_NAME, m_bnName);
connect(m_bnName, &QPushButton::clicked, this, [this] {
auto editor = new ProgEditorWin(this, gMainWin);
editor->show();
ProgEditorWin editor(this, gMainWin);
editor.exec();
});
m_bnExport = new QPushButton();
m_bnExport->setCursor(QCursor(Qt::PointingHandCursor));

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