ledok
This commit is contained in:
parent
dc2a505a35
commit
c1b21b55af
|
@ -1,5 +1,4 @@
|
||||||
#include "emultiwin.h"
|
#include "emultiwin.h"
|
||||||
#include "cfg.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "base/extendedgroupbox.h"
|
#include "base/extendedgroupbox.h"
|
||||||
#include "ebase.h"
|
#include "ebase.h"
|
||||||
|
@ -39,7 +38,7 @@ EMultiWin::EMultiWin(const QJsonObject &json, PageListItem *pageItem) : mPageIte
|
||||||
else if(type=="Temp") inner = new EEnviron(element.toObject(), this);
|
else if(type=="Temp") inner = new EEnviron(element.toObject(), this);
|
||||||
else if(type=="Web") inner = new EWeb(element.toObject(), this);
|
else if(type=="Web") inner = new EWeb(element.toObject(), this);
|
||||||
else if(type=="Timer") inner = new ETimer(element.toObject(), this);
|
else if(type=="Timer") inner = new ETimer(element.toObject(), this);
|
||||||
if(inner==nullptr) continue;
|
if(inner==0) continue;
|
||||||
inner->setPos(0, 0);
|
inner->setPos(0, 0);
|
||||||
inner->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
inner->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
if(index != inners.size()) inner->freeFiles();
|
if(index != inners.size()) inner->freeFiles();
|
||||||
|
@ -133,22 +132,22 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
menu->addAction(QIcon(":/res/program/DClock.png"), tr("DClock"))->setData(EBase::DClock);
|
menu->addAction(QIcon(":/res/program/DClock.png"), tr("DClock"))->setData(EBase::DClock);
|
||||||
menu->addAction(QIcon(":/res/program/AClock.png"), tr("AClock"))->setData(EBase::AClock);
|
menu->addAction(QIcon(":/res/program/AClock.png"), tr("AClock"))->setData(EBase::AClock);
|
||||||
auto listWgt = new MListWidget();
|
auto listWgt = new MListWidget();
|
||||||
connect(menu, &QMenu::triggered, this, [this, listWgt](QAction *act) {
|
connect(menu, &QMenu::triggered, this, [=](QAction *act) {
|
||||||
int type = act->data().toInt();
|
int type = act->data().toInt();
|
||||||
int order = listWgt->count();
|
int order = listWgt->count();
|
||||||
EBase *ele = nullptr;
|
EBase *ele = 0;
|
||||||
QListWidgetItem *item = nullptr;
|
QListWidgetItem *item = 0;
|
||||||
if(type==EBase::Photo) {
|
if(type==EBase::Photo) {
|
||||||
auto files = QFileDialog::getOpenFileNames(gMainWin, tr("Select File"), gFileHome, EPhoto::filters());
|
auto files = QFileDialog::getOpenFileNames(gMainWin, 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, this);
|
auto ePhoto = EPhoto::create(files[i], mPageItem, this);
|
||||||
if(ePhoto==nullptr) continue;
|
if(ePhoto==0) continue;
|
||||||
ePhoto->setSize(mWidth, mHeight);
|
ePhoto->setSize(mWidth, mHeight);
|
||||||
ePhoto->setZValue(order++);
|
ePhoto->setZValue(order++);
|
||||||
ePhoto->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
ePhoto->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
inners.append(ePhoto);
|
inners.append(ePhoto);
|
||||||
auto item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+ePhoto->mName);
|
auto item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+ePhoto->mName);
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(ePhoto)));
|
item->setData(Qt::UserRole, QVariant::fromValue((void*) ePhoto));
|
||||||
listWgt->addItem(item);
|
listWgt->addItem(item);
|
||||||
if(i==files.count()-1) {
|
if(i==files.count()-1) {
|
||||||
listWgt->setCurrentItem(item);
|
listWgt->setCurrentItem(item);
|
||||||
|
@ -159,13 +158,13 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
auto files = QFileDialog::getOpenFileNames(gMainWin, tr("Select File"), gFileHome, EGif::filters());
|
auto files = QFileDialog::getOpenFileNames(gMainWin, tr("Select File"), gFileHome, EGif::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto eGif = EGif::create(files[i], mPageItem, this);
|
auto eGif = EGif::create(files[i], mPageItem, this);
|
||||||
if(eGif==nullptr) continue;
|
if(eGif==0) continue;
|
||||||
eGif->setSize(mWidth, mHeight);
|
eGif->setSize(mWidth, mHeight);
|
||||||
eGif->setZValue(order++);
|
eGif->setZValue(order++);
|
||||||
eGif->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
eGif->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
inners.append(eGif);
|
inners.append(eGif);
|
||||||
auto item = new QListWidgetItem(QIcon(":/res/program/Gif.png"), tr("Gif")+" "+eGif->mName);
|
auto item = new QListWidgetItem(QIcon(":/res/program/Gif.png"), tr("Gif")+" "+eGif->mName);
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(eGif)));
|
item->setData(Qt::UserRole, QVariant::fromValue((void*) eGif));
|
||||||
listWgt->addItem(item);
|
listWgt->addItem(item);
|
||||||
if(i == files.count()-1) {
|
if(i == files.count()-1) {
|
||||||
listWgt->setCurrentItem(item);
|
listWgt->setCurrentItem(item);
|
||||||
|
@ -176,7 +175,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
auto file = QFileDialog::getOpenFileName(gMainWin, tr("Select File"), gFileHome, EVideo::filters());
|
auto file = QFileDialog::getOpenFileName(gMainWin, tr("Select File"), gFileHome, EVideo::filters());
|
||||||
if(! file.isEmpty()) {
|
if(! file.isEmpty()) {
|
||||||
auto eVideo = EVideo::create(file, mPageItem, this);
|
auto eVideo = EVideo::create(file, mPageItem, this);
|
||||||
if(eVideo==nullptr) return;
|
if(eVideo==0) return;
|
||||||
item = new QListWidgetItem(QIcon(":/res/program/Movie.png"), tr("Video")+" "+eVideo->mRawName);
|
item = new QListWidgetItem(QIcon(":/res/program/Movie.png"), tr("Video")+" "+eVideo->mRawName);
|
||||||
gFileHome = eVideo->mRawDir;
|
gFileHome = eVideo->mRawDir;
|
||||||
ele = eVideo;
|
ele = eVideo;
|
||||||
|
@ -197,12 +196,12 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
ele = new ETimer(this);
|
ele = new ETimer(this);
|
||||||
item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
||||||
}
|
}
|
||||||
if(ele != nullptr) {
|
if(ele) {
|
||||||
ele->setSize(mWidth, mHeight);
|
ele->setSize(mWidth, mHeight);
|
||||||
ele->setZValue(order);
|
ele->setZValue(order);
|
||||||
ele->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
ele->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
inners.append(ele);
|
inners.append(ele);
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(ele)));
|
item->setData(Qt::UserRole, QVariant::fromValue((void*)ele));
|
||||||
listWgt->addItem(item);
|
listWgt->addItem(item);
|
||||||
listWgt->setCurrentItem(item);
|
listWgt->setCurrentItem(item);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +269,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
listWgt->setMinimumHeight(120);
|
listWgt->setMinimumHeight(120);
|
||||||
listWgt->setIconSize(QSize(20, 20));
|
listWgt->setIconSize(QSize(20, 20));
|
||||||
foreach(auto inner, inners) {
|
foreach(auto inner, inners) {
|
||||||
QListWidgetItem *item = nullptr;
|
QListWidgetItem *item = 0;
|
||||||
int type = inner->type();
|
int type = inner->type();
|
||||||
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
|
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
|
||||||
else if(type==EBase::Photo) item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+static_cast<EPhoto*>(inner)->mName);
|
else if(type==EBase::Photo) item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+static_cast<EPhoto*>(inner)->mName);
|
||||||
|
@ -281,33 +280,33 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
else if(type==EBase::Environ) item = new QListWidgetItem(QIcon(":/res/program/Temp.png"), tr("Environment"));
|
else if(type==EBase::Environ) item = new QListWidgetItem(QIcon(":/res/program/Temp.png"), tr("Environment"));
|
||||||
else if(type==EBase::Timer) item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
else if(type==EBase::Timer) item = new QListWidgetItem(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
||||||
if(item != nullptr) {
|
if(item != nullptr) {
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(inner)));
|
item->setData(Qt::UserRole, QVariant::fromValue((void*) inner));
|
||||||
listWgt->addItem(item);
|
listWgt->addItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(listWgt, &QListWidget::currentItemChanged, this, [this, vBox, listWgt, groupBox](QListWidgetItem *current, QListWidgetItem *previous) {
|
connect(listWgt, &QListWidget::currentItemChanged, this, [=](QListWidgetItem *current, QListWidgetItem *previous) {
|
||||||
if(previous != nullptr) {
|
if(previous) {
|
||||||
auto eLast = static_cast<EBase*>(previous->data(Qt::UserRole).value<void*>());
|
auto eLast = static_cast<EBase*>(previous->data(Qt::UserRole).value<void*>());
|
||||||
if(eLast != nullptr) {
|
if(eLast) {
|
||||||
if(scene() != nullptr) scene()->removeItem(eLast);
|
if(scene()) scene()->removeItem(eLast);
|
||||||
disconnect(this, &EMultiWin::sizeChanged, eLast, 0);
|
disconnect(this, &EMultiWin::sizeChanged, eLast, 0);
|
||||||
eLast->freeFiles();
|
eLast->freeFiles();
|
||||||
}
|
}
|
||||||
auto itemLast = vBox->itemAt(vBox->count()-1);
|
auto itemLast = vBox->itemAt(vBox->count()-1);
|
||||||
if(itemLast != nullptr && itemLast->widget() != groupBox) {
|
if(itemLast && itemLast->widget() != groupBox) {
|
||||||
vBox->takeAt(vBox->count()-1);
|
vBox->takeAt(vBox->count()-1);
|
||||||
if(itemLast->widget() != nullptr) delete itemLast->widget();
|
if(itemLast->widget()) delete itemLast->widget();
|
||||||
delete itemLast;
|
delete itemLast;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EBase *eCur = nullptr;
|
EBase *eCur = 0;
|
||||||
if(current != nullptr) {
|
if(current) {
|
||||||
eCur = static_cast<EBase*>(current->data(Qt::UserRole).value<void*>());
|
eCur = (EBase*) current->data(Qt::UserRole).value<void*>();
|
||||||
auto attr = eCur->attrWgt();
|
auto attr = eCur->attrWgt();
|
||||||
if(attr != nullptr) vBox->addWidget(attr);
|
if(attr) vBox->addWidget(attr);
|
||||||
}
|
}
|
||||||
index = listWgt->currentRow();
|
index = listWgt->currentRow();
|
||||||
if(eCur != nullptr) setCur(eCur);
|
if(eCur) setCur(eCur);
|
||||||
});
|
});
|
||||||
vBoxGroup->addWidget(listWgt);
|
vBoxGroup->addWidget(listWgt);
|
||||||
|
|
||||||
|
|
|
@ -230,6 +230,9 @@ bool EVideo::save(const QString &pageDir) {
|
||||||
QFile(oldFile).copy(saveFile);
|
QFile(oldFile).copy(saveFile);
|
||||||
mDir = pageDir;
|
mDir = pageDir;
|
||||||
if(gProgItem->mMaxWidth) {
|
if(gProgItem->mMaxWidth) {
|
||||||
|
QWidget *paren;
|
||||||
|
QObject obj;
|
||||||
|
scene()->parent();
|
||||||
auto waitingDlg = new WaitingDlg(gProgEditorWin, "正在转码视频 ...");
|
auto waitingDlg = new WaitingDlg(gProgEditorWin, "正在转码视频 ...");
|
||||||
auto thread = new VideoSplitThread(mWidth, mHeight, gProgItem->mMaxWidth, gProgItem->mHeight, gProgItem->mSplitWidths, pos(), saveFile.toUtf8());
|
auto thread = new VideoSplitThread(mWidth, mHeight, gProgItem->mMaxWidth, gProgItem->mHeight, gProgItem->mSplitWidths, pos(), saveFile.toUtf8());
|
||||||
connect(thread, &VideoSplitThread::emErr, this, [saveFile, waitingDlg](QString err) {
|
connect(thread, &VideoSplitThread::emErr, this, [saveFile, waitingDlg](QString err) {
|
||||||
|
|
|
@ -97,10 +97,9 @@ PageEditor::PageEditor(QWidget *parent) : QWidget(parent) {
|
||||||
connect(actArrayRight, SIGNAL(triggered(bool)), this, SLOT(onArrayRight()));
|
connect(actArrayRight, SIGNAL(triggered(bool)), this, SLOT(onArrayRight()));
|
||||||
vBox->addWidget(toolBar);
|
vBox->addWidget(toolBar);
|
||||||
|
|
||||||
graphicsView = new QGraphicsView(this);
|
graphicsView = new QGraphicsView;
|
||||||
pal = graphicsView->palette();
|
pal = graphicsView->palette();
|
||||||
pal.setBrush(QPalette::Base, QColor(0xbbbbbb));
|
pal.setBrush(QPalette::Base, QColor(0xbbbbbb));
|
||||||
graphicsView->setAutoFillBackground(true);
|
|
||||||
graphicsView->setPalette(pal);
|
graphicsView->setPalette(pal);
|
||||||
vBox->addWidget(graphicsView);
|
vBox->addWidget(graphicsView);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ class PageEditor : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PageEditor(QWidget *parent = nullptr);
|
explicit PageEditor(QWidget *parent = nullptr);
|
||||||
|
|
||||||
virtual void keyReleaseEvent(QKeyEvent *event) override;
|
virtual void keyReleaseEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
QList<EBase*> sortedEles();
|
QList<EBase*> sortedEles();
|
||||||
|
|
|
@ -1,32 +1,33 @@
|
||||||
#include "pagelistitem.h"
|
#include "pagelistitem.h"
|
||||||
#include "cfg.h"
|
|
||||||
#include "tools.h"
|
|
||||||
#include "base/ffutil.h"
|
#include "base/ffutil.h"
|
||||||
#include "program/wplanlist.h"
|
|
||||||
#include "base/lodateselector.h"
|
#include "base/lodateselector.h"
|
||||||
#include "program/ebase.h"
|
#include "cfg.h"
|
||||||
#include "program/etext.h"
|
|
||||||
#include "program/ephoto.h"
|
|
||||||
#include "program/evideo.h"
|
|
||||||
#include "program/eaudio.h"
|
|
||||||
#include "program/egif.h"
|
|
||||||
#include "program/edclock.h"
|
|
||||||
#include "program/eaclock.h"
|
#include "program/eaclock.h"
|
||||||
|
#include "program/eaudio.h"
|
||||||
|
#include "program/ebase.h"
|
||||||
|
#include "program/edclock.h"
|
||||||
#include "program/eenviron.h"
|
#include "program/eenviron.h"
|
||||||
#include "program/eweb.h"
|
#include "program/egif.h"
|
||||||
#include "program/etimer.h"
|
|
||||||
#include "program/emultiwin.h"
|
#include "program/emultiwin.h"
|
||||||
#include <QMessageBox>
|
#include "program/ephoto.h"
|
||||||
#include <QJsonArray>
|
#include "program/etext.h"
|
||||||
#include <QDir>
|
#include "program/etimer.h"
|
||||||
|
#include "program/evideo.h"
|
||||||
|
#include "program/eweb.h"
|
||||||
|
#include "program/wplanlist.h"
|
||||||
|
#include "tools.h"
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QSpinBox>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QDateEdit>
|
#include <QDateEdit>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
class PageScene : public QGraphicsScene {
|
class PageScene : public QGraphicsScene {
|
||||||
public:
|
public:
|
||||||
PageScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = nullptr) : QGraphicsScene(x, y, width, height, parent) {};
|
using QGraphicsScene::QGraphicsScene;
|
||||||
void drawBackground(QPainter *painter, const QRectF &rect) {
|
void drawBackground(QPainter *painter, const QRectF &rect) {
|
||||||
QGraphicsScene::drawBackground(painter, rect);
|
QGraphicsScene::drawBackground(painter, rect);
|
||||||
painter->fillRect(sceneRect(), Qt::black);
|
painter->fillRect(sceneRect(), Qt::black);
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#ifndef PAGELISTITEM_H
|
#ifndef PAGELISTITEM_H
|
||||||
#define PAGELISTITEM_H
|
#define PAGELISTITEM_H
|
||||||
|
|
||||||
#include "pageeditor.h"
|
#include <QGraphicsScene>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QLabel>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
|
||||||
class PageListItem : public QObject, public QListWidgetItem {
|
class PageListItem : public QObject, public QListWidgetItem {
|
||||||
|
@ -10,7 +11,7 @@ class PageListItem : public QObject, public QListWidgetItem {
|
||||||
public:
|
public:
|
||||||
explicit PageListItem(const QJsonObject &attr, const QString &pageDir);
|
explicit PageListItem(const QJsonObject &attr, const QString &pageDir);
|
||||||
~PageListItem() {
|
~PageListItem() {
|
||||||
if(mAttrWgt!=0) delete mAttrWgt;
|
if(mAttrWgt) delete mAttrWgt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateJson();
|
void updateJson();
|
||||||
|
|
|
@ -41,20 +41,18 @@ QWidget *gProgEditorWin;
|
||||||
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
||||||
gProgEditorWin = this;
|
gProgEditorWin = this;
|
||||||
gProgItem = progItem;
|
gProgItem = progItem;
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
setWindowFlag(Qt::Window);
|
setWindowFlag(Qt::Window);
|
||||||
setWindowModality(Qt::WindowModal);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
#else
|
|
||||||
setWindowFlag(Qt::Dialog);
|
|
||||||
#endif
|
|
||||||
setAttribute(Qt::WA_AlwaysShowToolTips);
|
|
||||||
if(! parent->isMaximized()) resize(parent->size());
|
if(! parent->isMaximized()) resize(parent->size());
|
||||||
else resize(1280, 720);
|
else resize(1280, 720);
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
setWindowModality(Qt::WindowModal);
|
||||||
|
#else
|
||||||
|
parentWidget()->hide();
|
||||||
|
#endif
|
||||||
|
setAttribute(Qt::WA_AlwaysShowToolTips);
|
||||||
setWindowTitle(progItem->mName);
|
setWindowTitle(progItem->mName);
|
||||||
|
|
||||||
parent->setVisible(false);
|
|
||||||
|
|
||||||
auto vBox = new QVBoxLayout(this);
|
auto vBox = new QVBoxLayout(this);
|
||||||
vBox->setContentsMargins(0, 0, 0, 0);
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
vBox->setSpacing(0);
|
vBox->setSpacing(0);
|
||||||
|
@ -74,15 +72,15 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
});
|
});
|
||||||
connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
||||||
connect(saveThread, &QThread::finished, this, [this] {
|
connect(saveThread, &QThread::finished, this, [this] {
|
||||||
this->mProgItem->m_last = QDateTime::currentDateTime();
|
mProgItem->m_last = QDateTime::currentDateTime();
|
||||||
this->mProgItem->m_fsize = dirFileSize(this->mProgItem->mProgDir);
|
mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
||||||
this->mProgItem->onSetProgram();
|
mProgItem->onSetProgram();
|
||||||
});
|
});
|
||||||
saveThread->start();
|
saveThread->start();
|
||||||
bool isOK;
|
bool isOK;
|
||||||
QString progName = QInputDialog::getText(this, tr("Save as"), tr("Save as"), QLineEdit::Normal, QString(), &isOK, Qt::Dialog | Qt::WindowCloseButtonHint);
|
QString progName = QInputDialog::getText(this, tr("Save as"), tr("Save as"), QLineEdit::Normal, QString(), &isOK, Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||||
if(! isOK || progName.isEmpty()) return;
|
if(! isOK || progName.isEmpty()) return;
|
||||||
mProgItem->mProgDir = this->mProgItem->mProgsDir + "/" + progName;
|
mProgItem->mProgDir = mProgItem->mProgsDir + "/" + progName;
|
||||||
LoEmptyDialog *dlgTip = new LoEmptyDialog(this);
|
LoEmptyDialog *dlgTip = new LoEmptyDialog(this);
|
||||||
saveThread = QThread::create([this](){
|
saveThread = QThread::create([this](){
|
||||||
save();
|
save();
|
||||||
|
@ -239,10 +237,10 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
connect(toolBar, &QToolBar::actionTriggered, this, [this](QAction *act) {
|
connect(toolBar, &QToolBar::actionTriggered, this, [this](QAction *act) {
|
||||||
auto data = act->data();
|
auto data = act->data();
|
||||||
if(data.type()!=QVariant::Int) return;
|
if(data.type()!=QVariant::Int) return;
|
||||||
auto scene = progEditorMid->graphicsView->scene();
|
auto scene = mPageEditor->graphicsView->scene();
|
||||||
if(nullptr == scene) return;
|
if(scene==0) return;
|
||||||
int order = progEditorMid->sortedEles().count();
|
int order = mPageEditor->sortedEles().count();
|
||||||
EBase *element = nullptr;
|
EBase *element = 0;
|
||||||
int iNewWidth = mProgItem->mWidth;
|
int iNewWidth = mProgItem->mWidth;
|
||||||
int iNewHeight = mProgItem->mHeight;
|
int iNewHeight = mProgItem->mHeight;
|
||||||
if(iNewWidth>128) iNewWidth = iNewWidth * 2 / 3;
|
if(iNewWidth>128) iNewWidth = iNewWidth * 2 / 3;
|
||||||
|
@ -261,11 +259,8 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
ePhoto->setZValue(order++);
|
ePhoto->setZValue(order++);
|
||||||
scene->addItem(ePhoto);
|
scene->addItem(ePhoto);
|
||||||
if(i==files.count()-1) {
|
if(i==files.count()-1) {
|
||||||
auto scene = progEditorMid->graphicsView->scene();
|
auto sels = scene->selectedItems();
|
||||||
if(nullptr != scene) {
|
if(sels.count() == 1) sels.at(0)->setSelected(false);
|
||||||
auto list = scene->selectedItems();
|
|
||||||
if(list.count() == 1) static_cast<EBase*>(list.at(0))->setSelected(false);
|
|
||||||
}
|
|
||||||
ePhoto->setSelected(true);
|
ePhoto->setSelected(true);
|
||||||
gFileHome = ePhoto->mDir;
|
gFileHome = ePhoto->mDir;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +269,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EGif::filters());
|
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EGif::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto eGif = EGif::create(files[i], mPageItem);
|
auto eGif = EGif::create(files[i], mPageItem);
|
||||||
if(eGif==nullptr) continue;
|
if(eGif==0) continue;
|
||||||
auto img = eGif->mMovie->currentPixmap();
|
auto img = eGif->mMovie->currentPixmap();
|
||||||
auto rect = Tools::centerRect(img.width(), img.height(), mProgItem->mWidth, mProgItem->mHeight);
|
auto rect = Tools::centerRect(img.width(), img.height(), mProgItem->mWidth, mProgItem->mHeight);
|
||||||
eGif->setPos(rect.topLeft());
|
eGif->setPos(rect.topLeft());
|
||||||
|
@ -282,11 +277,8 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
eGif->setZValue(order++);
|
eGif->setZValue(order++);
|
||||||
scene->addItem(eGif);
|
scene->addItem(eGif);
|
||||||
if(i == files.count()-1) {
|
if(i == files.count()-1) {
|
||||||
auto scene = progEditorMid->graphicsView->scene();
|
auto sels = scene->selectedItems();
|
||||||
if(nullptr != scene) {
|
if(sels.count() == 1) sels.at(0)->setSelected(false);
|
||||||
auto list = scene->selectedItems();
|
|
||||||
if(list.count() == 1) static_cast<EBase*>(list.at(0))->setSelected(false);
|
|
||||||
}
|
|
||||||
eGif->setSelected(true);
|
eGif->setSelected(true);
|
||||||
gFileHome = eGif->mDir;
|
gFileHome = eGif->mDir;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +324,6 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
element->setSize(mProgItem->mWidth, mProgItem->mHeight);
|
element->setSize(mProgItem->mWidth, mProgItem->mHeight);
|
||||||
}
|
}
|
||||||
else if(type==EBase::Timer) element = new ETimer();
|
else if(type==EBase::Timer) element = new ETimer();
|
||||||
else if(type==EBase::Audio) ;
|
|
||||||
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
||||||
if(element) {
|
if(element) {
|
||||||
if(element->mWidth==0) {
|
if(element->mWidth==0) {
|
||||||
|
@ -343,11 +334,8 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
scene->addItem(element);
|
scene->addItem(element);
|
||||||
mNewEleX += 8;
|
mNewEleX += 8;
|
||||||
mNewEleY += 8;
|
mNewEleY += 8;
|
||||||
QGraphicsScene *scene = progEditorMid->graphicsView->scene();
|
auto sels = scene->selectedItems();
|
||||||
if(nullptr != scene){
|
if(sels.count() == 1) sels.at(0)->setSelected(false);
|
||||||
QList<QGraphicsItem *> list = scene->selectedItems();
|
|
||||||
if(list.count() == 1) static_cast<EBase*>(list.at(0))->setSelected(false);
|
|
||||||
}
|
|
||||||
element->setSelected(true);
|
element->setSelected(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -375,11 +363,11 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
toolBar->setIconSize(QSize(22,16));
|
toolBar->setIconSize(QSize(22,16));
|
||||||
toolBar->setStyleSheet("QToolBar{spacing: 8px;}");
|
toolBar->setStyleSheet("QToolBar{spacing: 8px;}");
|
||||||
|
|
||||||
QAction *actAdd = new QAction(QIcon(":/res/program/Add.png"), tr("Add page"));
|
auto actAdd = new QAction(QIcon(":/res/program/Add.png"), tr("Add page"));
|
||||||
connect(actAdd, &QAction::triggered, this, &ProgEditorWin::onAddPage);
|
connect(actAdd, &QAction::triggered, this, &ProgEditorWin::onAddPage);
|
||||||
toolBar->addAction(actAdd);
|
toolBar->addAction(actAdd);
|
||||||
|
|
||||||
QAction *actCopy = new QAction(QIcon(":/res/program/Copy.png"), tr("Copy page"));
|
auto actCopy = new QAction(QIcon(":/res/program/Copy.png"), tr("Copy page"));
|
||||||
connect(actCopy, &QAction::triggered, this, [this] {
|
connect(actCopy, &QAction::triggered, this, [this] {
|
||||||
if(listPage->count() > 0) {
|
if(listPage->count() > 0) {
|
||||||
auto cur = static_cast<PageListItem*>(listPage->currentItem());
|
auto cur = static_cast<PageListItem*>(listPage->currentItem());
|
||||||
|
@ -394,9 +382,9 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
});
|
});
|
||||||
toolBar->addAction(actCopy);
|
toolBar->addAction(actCopy);
|
||||||
|
|
||||||
QAction *actDel = new QAction(QIcon(":/res/program/Delete.png"), tr("Delete page"));
|
auto actDel = new QAction(QIcon(":/res/program/Delete.png"), tr("Delete page"));
|
||||||
connect(actDel, &QAction::triggered, this, [this] {
|
connect(actDel, &QAction::triggered, this, [this] {
|
||||||
if(listPage->count() == 1) progEditorMid->onClean();
|
if(listPage->count() == 1) mPageEditor->onClean();
|
||||||
else if(listPage->count() > 1) {
|
else if(listPage->count() > 1) {
|
||||||
auto item = static_cast<PageListItem*>(listPage->currentItem());
|
auto item = static_cast<PageListItem*>(listPage->currentItem());
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"), tr("Are you sure you want to delete this program page?"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::information(this, tr("Tip Info"), tr("Are you sure you want to delete this program page?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
|
@ -410,7 +398,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
});
|
});
|
||||||
toolBar->addAction(actDel);
|
toolBar->addAction(actDel);
|
||||||
|
|
||||||
QAction *actMoveUp = new QAction(QIcon(":/res/program/GoUp.png"), tr("Move up"));
|
auto actMoveUp = new QAction(QIcon(":/res/program/GoUp.png"), tr("Move up"));
|
||||||
connect(actMoveUp, &QAction::triggered, this, [this] {
|
connect(actMoveUp, &QAction::triggered, this, [this] {
|
||||||
if(listPage->count() > 1) {
|
if(listPage->count() > 1) {
|
||||||
int index = listPage->currentRow();
|
int index = listPage->currentRow();
|
||||||
|
@ -426,7 +414,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
});
|
});
|
||||||
toolBar->addAction(actMoveUp);
|
toolBar->addAction(actMoveUp);
|
||||||
|
|
||||||
QAction *actMoveDown = new QAction(QIcon(":/res/program/GoDown.png"), tr("Move down"));
|
auto actMoveDown = new QAction(QIcon(":/res/program/GoDown.png"), tr("Move down"));
|
||||||
connect(actMoveDown, &QAction::triggered, this, [this] {
|
connect(actMoveDown, &QAction::triggered, this, [this] {
|
||||||
if(listPage->count() > 1) {
|
if(listPage->count() > 1) {
|
||||||
int index = listPage->currentRow();
|
int index = listPage->currentRow();
|
||||||
|
@ -446,30 +434,28 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
|
|
||||||
listPage = new QListWidget();
|
listPage = new QListWidget();
|
||||||
listPage->setMaximumWidth(190);
|
listPage->setMaximumWidth(190);
|
||||||
connect(listPage, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous) {
|
connect(listPage, &QListWidget::currentItemChanged, this, [=](QListWidgetItem *current, QListWidgetItem *previous) {
|
||||||
auto curItem = static_cast<PageListItem*>(current);
|
auto curItem = static_cast<PageListItem*>(current);
|
||||||
auto preItem = static_cast<PageListItem*>(previous);
|
auto preItem = static_cast<PageListItem*>(previous);
|
||||||
if(nullptr != preItem) preItem->mScene->clearSelection();
|
if(preItem) preItem->mScene->clearSelection();
|
||||||
mPageItem = curItem;
|
mPageItem = curItem;
|
||||||
auto scene = progEditorMid->graphicsView->scene();
|
auto scene = mPageEditor->graphicsView->scene();
|
||||||
if(scene != nullptr) disconnect(scene, &QGraphicsScene::selectionChanged, this, 0);
|
if(scene) disconnect(scene, 0, 0, 0);
|
||||||
if(progEditorMid->curScale != 100) {
|
if(mPageEditor->curScale != 100) {
|
||||||
progEditorMid->curScale = 100;
|
mPageEditor->curScale = 100;
|
||||||
progEditorMid->fdScale->setText("100");
|
mPageEditor->fdScale->setText("100");
|
||||||
progEditorMid->graphicsView->resetTransform();
|
mPageEditor->graphicsView->resetTransform();
|
||||||
}
|
}
|
||||||
if(curItem == nullptr) progEditorMid->graphicsView->setScene(nullptr);
|
if(curItem == 0) mPageEditor->graphicsView->setScene(0);
|
||||||
else {
|
else {
|
||||||
progEditorMid->graphicsView->setScene(scene = curItem->mScene);
|
mPageEditor->graphicsView->setScene(scene = curItem->mScene);
|
||||||
connect(scene, &QGraphicsScene::selectionChanged, this, [this] {
|
connect(scene, &QGraphicsScene::selectionChanged, this, [=] {
|
||||||
auto scene = progEditorMid->graphicsView->scene();
|
|
||||||
if(scene==nullptr) return;
|
|
||||||
auto sels = scene->selectedItems();
|
auto sels = scene->selectedItems();
|
||||||
auto scroll = static_cast<QScrollArea*>(mTabsAttr->widget(0));
|
auto scroll = static_cast<QScrollArea*>(mTabsAttr->widget(0));
|
||||||
if(sels.size() != 1) {
|
if(sels.size() != 1) {
|
||||||
mTabsAttr->setCurrentIndex(1);
|
mTabsAttr->setCurrentIndex(1);
|
||||||
auto wgt = scroll->takeWidget();
|
auto wgt = scroll->takeWidget();
|
||||||
if(wgt!=nullptr) delete wgt;
|
if(wgt) delete wgt;
|
||||||
} else {
|
} else {
|
||||||
mTabsAttr->setCurrentIndex(0);
|
mTabsAttr->setCurrentIndex(0);
|
||||||
scroll->setWidget(static_cast<EBase*>(sels[0])->attrWgt());
|
scroll->setWidget(static_cast<EBase*>(sels[0])->attrWgt());
|
||||||
|
@ -479,7 +465,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
}
|
}
|
||||||
auto scroll = static_cast<QScrollArea*>(mTabsAttr->widget(1));
|
auto scroll = static_cast<QScrollArea*>(mTabsAttr->widget(1));
|
||||||
scroll->takeWidget();
|
scroll->takeWidget();
|
||||||
if(curItem != nullptr) {
|
if(curItem) {
|
||||||
scroll->setWidget(curItem->attrWgt());
|
scroll->setWidget(curItem->attrWgt());
|
||||||
scroll->updateGeometry();
|
scroll->updateGeometry();
|
||||||
}
|
}
|
||||||
|
@ -488,7 +474,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
vBoxPage->addWidget(listPage);
|
vBoxPage->addWidget(listPage);
|
||||||
hBox->addLayout(vBoxPage);
|
hBox->addLayout(vBoxPage);
|
||||||
|
|
||||||
hBox->addWidget(progEditorMid = new PageEditor(this), 1);
|
hBox->addWidget(mPageEditor = new PageEditor, 1);
|
||||||
|
|
||||||
mTabsAttr = new QTabWidget();
|
mTabsAttr = new QTabWidget();
|
||||||
mTabsAttr->setMinimumWidth(360);
|
mTabsAttr->setMinimumWidth(360);
|
||||||
|
@ -567,7 +553,9 @@ void ProgEditorWin::closeEvent(QCloseEvent *event) {
|
||||||
if(res == QMessageBox::Yes) onSave();
|
if(res == QMessageBox::Yes) onSave();
|
||||||
else if(res == QMessageBox::Cancel) event->ignore();
|
else if(res == QMessageBox::Cancel) event->ignore();
|
||||||
}
|
}
|
||||||
parentWidget()->setVisible(true);
|
#ifdef Q_OS_MAC
|
||||||
|
if(event->isAccepted()) parentWidget()->show();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
//停止每个页面元素的播放,将节目目录下的每个页面的文件夹另命名
|
//停止每个页面元素的播放,将节目目录下的每个页面的文件夹另命名
|
||||||
void ProgEditorWin::save() {
|
void ProgEditorWin::save() {
|
||||||
|
|
|
@ -10,7 +10,6 @@ class ProgEditorWin : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ProgEditorWin(ProgItem *progItem, QWidget *);
|
explicit ProgEditorWin(ProgItem *progItem, QWidget *);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onSave();
|
void onSave();
|
||||||
void onAddPage();
|
void onAddPage();
|
||||||
|
@ -23,7 +22,7 @@ private:
|
||||||
|
|
||||||
QListWidget *listPage;
|
QListWidget *listPage;
|
||||||
PageListItem *mPageItem = nullptr;
|
PageListItem *mPageItem = nullptr;
|
||||||
PageEditor *progEditorMid;
|
PageEditor *mPageEditor;
|
||||||
QTabWidget *mTabsAttr;
|
QTabWidget *mTabsAttr;
|
||||||
QList<QJsonObject> mPageJsons;
|
QList<QJsonObject> mPageJsons;
|
||||||
ProgItem *mProgItem;
|
ProgItem *mProgItem;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user