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