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 = new QTimer(this);
timer->setInterval(5); timer->setInterval(5);
connect(timer, SIGNAL(timeout()), this, SLOT(updateValue())); connect(timer, SIGNAL(timeout()), this, SLOT(updateValue()));
setFont(QFont("Microsoft Yahei", 10));
} }
SwitchControl::~SwitchControl() void SwitchControl::mousePressEvent(QMouseEvent *) {
{
}
void SwitchControl::mousePressEvent(QMouseEvent *)
{
checked = !checked; checked = !checked;
//每次移动的步长为宽度的 50分之一 //每次移动的步长为宽度的 50分之一

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -328,8 +328,8 @@ void ProgPanel::onEditClicked(bool){
for(int i=0; i<cnt; i++) { for(int i=0; i<cnt; i++) {
if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) { if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i)); auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
auto editor = new ProgEditorWin(item, gMainWin); ProgEditorWin editor(item, gMainWin);
editor->show(); editor.exec();
break; 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); auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, splitWidths, max, mProgTree, this);
item->save();//保存pro.json item->save();//保存pro.json
mProgTree->adjustCheckState(); mProgTree->adjustCheckState();
auto editor = new ProgEditorWin(item, gMainWin); ProgEditorWin editor(item, gMainWin);
editor->show(); editor.exec();
} }
void ProgPanel::onDeleteClicked(bool){ 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); 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"]; color = widget["textColor"];
m_attr.textColor = color.isString() ? QColor(color.toString()) : Tools::int2Color(color.toInt()); m_attr.textColor = color.isString() ? QColor(color.toString()) : Tools::int2Color(color.toInt());
m_attr.text = widget["text"].toString(); 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.setBold(widget["textFontBold"].toBool());
m_attr.textFont.setItalic(widget["textFontItalics"].toBool()); m_attr.textFont.setItalic(widget["textFontItalics"].toBool());
m_attr.textFont.setUnderline(widget["textFontUnderline"].toBool()); m_attr.textFont.setUnderline(widget["textFontUnderline"].toBool());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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