From d43eff23387b56366ed11564dcf4ab76a2464e02 Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Sat, 2 Nov 2019 10:45:03 +0100 Subject: [PATCH 01/19] Comment dockable added. Basic connects added --- app/app.pro | 9 +- app/src/framecommentwidget.cpp | 51 +++++ app/src/framecommentwidget.h | 31 +++ app/src/mainwindow2.cpp | 10 +- app/src/mainwindow2.h | 2 + app/ui/framecommentwidget.ui | 215 ++++++++++++++++++ core_lib/src/structure/keyframe.h | 12 + .../src/structure/layermultiplanecamera.cpp | 6 + .../src/structure/layermultiplanecamera.h | 39 ++++ 9 files changed, 371 insertions(+), 4 deletions(-) create mode 100644 app/src/framecommentwidget.cpp create mode 100644 app/src/framecommentwidget.h create mode 100644 app/ui/framecommentwidget.ui create mode 100644 core_lib/src/structure/layermultiplanecamera.cpp create mode 100644 core_lib/src/structure/layermultiplanecamera.h diff --git a/app/app.pro b/app/app.pro index e9c18401d9..d1a9e2c172 100644 --- a/app/app.pro +++ b/app/app.pro @@ -67,7 +67,8 @@ HEADERS += \ src/spinslider.h \ src/doubleprogressdialog.h \ src/colorslider.h \ - src/checkupdatesdialog.h + src/checkupdatesdialog.h \ + src/framecommentwidget.h SOURCES += \ src/importlayersdialog.cpp \ @@ -99,7 +100,8 @@ SOURCES += \ src/spinslider.cpp \ src/doubleprogressdialog.cpp \ src/colorslider.cpp \ - src/checkupdatesdialog.cpp + src/checkupdatesdialog.cpp \ + src/framecommentwidget.cpp FORMS += \ ui/importimageseqpreview.ui \ @@ -124,7 +126,8 @@ FORMS += \ ui/timelinepage.ui \ ui/filespage.ui \ ui/toolspage.ui \ - ui/toolboxwidget.ui + ui/toolboxwidget.ui \ + ui/framecommentwidget.ui diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp new file mode 100644 index 0000000000..a3e4b6e72b --- /dev/null +++ b/app/src/framecommentwidget.cpp @@ -0,0 +1,51 @@ +#include "framecommentwidget.h" +#include "ui_framecommentwidget.h" + +FrameCommentWidget::FrameCommentWidget(QWidget *parent) : + BaseDockWidget(parent) +{ + QWidget* innerWidget = new QWidget; + setWindowTitle(tr("Frame Comments")); + + ui = new Ui::FrameComment; + ui->setupUi(innerWidget); + setWidget(innerWidget); +} + +FrameCommentWidget::~FrameCommentWidget() +{ + delete ui; +} + +void FrameCommentWidget::initUI() +{ + connect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + connect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + connect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + dialogueTextChanged(""); + actionTextChanged(""); + notesTextChanged(""); +} + +void FrameCommentWidget::updateUI() +{ + +} + +void FrameCommentWidget::dialogueTextChanged(QString text) +{ + int len = text.length(); + ui->labDialogueCount->setText(tr("%1 chars").arg(QString::number(len))); +} + +void FrameCommentWidget::actionTextChanged(QString text) +{ + int len = text.length(); + ui->labActionCount->setText(tr("%1 chars").arg(QString::number(len))); +} + +void FrameCommentWidget::notesTextChanged(QString text) +{ + int len = text.length(); + ui->labNotesCount->setText(tr("%1 chars").arg(QString::number(len))); +} diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h new file mode 100644 index 0000000000..ef9f7cfadc --- /dev/null +++ b/app/src/framecommentwidget.h @@ -0,0 +1,31 @@ +#ifndef FRAMECOMMENTWIDGET_H +#define FRAMECOMMENTWIDGET_H + +#include +#include "basedockwidget.h" + +namespace Ui { + class FrameComment; +} + +class FrameCommentWidget : public BaseDockWidget +{ + Q_OBJECT + +public: + explicit FrameCommentWidget(QWidget *parent = nullptr); + ~FrameCommentWidget() override; + + void initUI() override; + void updateUI() override; + +public slots: + void dialogueTextChanged(QString text); + void actionTextChanged(QString text); + void notesTextChanged(QString text); + +private: + Ui::FrameComment *ui; +}; + +#endif // FRAMECOMMENTWIDGET_H diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index 72bfb73c43..864924a2e6 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -55,6 +55,7 @@ GNU General Public License for more details. #include "colorinspector.h" #include "colorpalettewidget.h" #include "displayoptionwidget.h" +#include "framecommentwidget.h" #include "tooloptionwidget.h" #include "preferencesdialog.h" #include "timeline.h" @@ -154,6 +155,9 @@ void MainWindow2::createDockWidgets() mDisplayOptionWidget = new DisplayOptionWidget(this); mDisplayOptionWidget->setObjectName("DisplayOption"); + mFrameComments = new FrameCommentWidget(this); + mFrameComments->setObjectName("FrameComments"); + mToolOptions = new ToolOptionWidget(this); mToolOptions->setObjectName("ToolOption"); @@ -172,6 +176,7 @@ void MainWindow2::createDockWidgets() << mColorInspector << mColorPalette << mDisplayOptionWidget + << mFrameComments << mToolOptions << mToolBox; @@ -193,6 +198,8 @@ void MainWindow2::createDockWidgets() addDockWidget(Qt::RightDockWidgetArea, mColorBox); addDockWidget(Qt::RightDockWidgetArea, mColorInspector); addDockWidget(Qt::RightDockWidgetArea, mColorPalette); + addDockWidget(Qt::RightDockWidgetArea, mFrameComments); + mFrameComments->hide(); addDockWidget(Qt::LeftDockWidgetArea, mToolBox); addDockWidget(Qt::LeftDockWidgetArea, mToolOptions); addDockWidget(Qt::LeftDockWidgetArea, mDisplayOptionWidget); @@ -348,7 +355,8 @@ void MainWindow2::createMenus() mColorPalette->toggleViewAction(), mTimeLine->toggleViewAction(), mDisplayOptionWidget->toggleViewAction(), - mColorInspector->toggleViewAction() + mColorInspector->toggleViewAction(), + mFrameComments->toggleViewAction() }; for (QAction* action : actions) diff --git a/app/src/mainwindow2.h b/app/src/mainwindow2.h index 9dc0499d7b..fab5b5a4ce 100644 --- a/app/src/mainwindow2.h +++ b/app/src/mainwindow2.h @@ -31,6 +31,7 @@ class ScribbleArea; class BaseDockWidget; class ColorPaletteWidget; class DisplayOptionWidget; +class FrameCommentWidget; class ToolOptionWidget; class TimeLine; class ToolBoxWidget; @@ -142,6 +143,7 @@ private slots: ColorBox* mColorBox = nullptr; ColorPaletteWidget* mColorPalette = nullptr; DisplayOptionWidget* mDisplayOptionWidget = nullptr; + FrameCommentWidget* mFrameComments = nullptr; ToolOptionWidget* mToolOptions = nullptr; ToolBoxWidget* mToolBox = nullptr; Timeline2* mTimeline2 = nullptr; diff --git a/app/ui/framecommentwidget.ui b/app/ui/framecommentwidget.ui new file mode 100644 index 0000000000..e7cd2fbd9d --- /dev/null +++ b/app/ui/framecommentwidget.ui @@ -0,0 +1,215 @@ + + + FrameComment + + + + 0 + 0 + 400 + 379 + + + + Frame Comments + + + + 2 + + + 4 + + + 4 + + + 4 + + + 4 + + + + + Max 100 chars each! + + + + + + + Qt::Horizontal + + + + + + + + + Dialogue: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + + + + + 100 + + + + + + + + + Action: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + + + + + 100 + + + + + + + + + Notes: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + + + + + 100 + + + + + + + Qt::Horizontal + + + + + + + + + Clear all + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Apply comments! + + + + + + + + + Qt::Vertical + + + + 20 + 117 + + + + + + + + + diff --git a/core_lib/src/structure/keyframe.h b/core_lib/src/structure/keyframe.h index 0124a88e19..d09f6564f7 100644 --- a/core_lib/src/structure/keyframe.h +++ b/core_lib/src/structure/keyframe.h @@ -46,6 +46,13 @@ class KeyFrame void setSelected(bool b) { mIsSelected = b; } bool isSelected() const { return mIsSelected; } + void setDialogueComment(QString comment) { mDialogueComment = comment; } + QString getDialogueComment() { return mDialogueComment; } + void setActionComment(QString comment) { mActionComment = comment; } + QString getActionComment() { return mActionComment; } + void setNotesComment(QString comment) { mNotesComment = comment; } + QString getNotesComment() { return mNotesComment; } + QString fileName() const { return mAttachedFileName; } void setFileName(QString strFileName) { mAttachedFileName = strFileName; } @@ -64,6 +71,11 @@ class KeyFrame bool mIsSelected = false; QString mAttachedFileName; + // comments + QString mDialogueComment = ""; + QString mActionComment = ""; + QString mNotesComment = ""; + std::vector mEventListeners; }; diff --git a/core_lib/src/structure/layermultiplanecamera.cpp b/core_lib/src/structure/layermultiplanecamera.cpp new file mode 100644 index 0000000000..9ee033705c --- /dev/null +++ b/core_lib/src/structure/layermultiplanecamera.cpp @@ -0,0 +1,6 @@ +#include "layermultiplanecamera.h" + +LayerMultiPlaneCamera::LayerMultiPlaneCamera(Object *object) :Layer(object, LAYER_TYPE::MULTIPLANCAMERA) +{ + setName(tr("Multiplane Camera")); +} diff --git a/core_lib/src/structure/layermultiplanecamera.h b/core_lib/src/structure/layermultiplanecamera.h new file mode 100644 index 0000000000..cc054d2dee --- /dev/null +++ b/core_lib/src/structure/layermultiplanecamera.h @@ -0,0 +1,39 @@ +#ifndef LAYERMULTIPLANECAMERA_H +#define LAYERMULTIPLANECAMERA_H + +#include "layer.h" + +struct Campoint { + int frame; + QTransform transform; + QPainterPath path; +}; + +class LayerMultiPlaneCamera : public Layer +{ + Q_OBJECT + +public: + LayerMultiPlaneCamera(Object* object); + + void setViewRect(QRect viewrect) { mViewRect = viewrect; } + QRect getViewRect() { return mViewRect; } + +private: + QList mCampointList; + QRect mViewRect; +}; + +#endif // LAYERMULTIPLANECAMERA_H +/* +Hver frame har sin egen Campoint. +DVS: +Frame 1 har altid et Campoint. Er der ikke nogen kamerabevægelser, bruges +Campoint fra frame 1 i hele scenen. +Laver man en pan fra frame 50 til 80 i en 300 frames lang scene vil følgende ske: +Frame 1 har et Campoint. +Idet frame 50 tildeles en transform, udregnes transforms for frame 1 til 50. Hvis +der ikke er forskel på fielden i frame 1 og 50, har alle 50 samme transform. +Idet frame 80 får en transform sker det samme. 50 til 80 udregnes. Når frame +80 ændres, vil 50 til 80 igen blive beregnet. +*/ From cccf4f9e09583829b6261e69e61084d402cb696e Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Sat, 2 Nov 2019 14:46:13 +0100 Subject: [PATCH 02/19] Comments saved on keyframe. Minor ui changes --- app/src/framecommentwidget.cpp | 47 ++++++++++++++++++++++++++++++++++ app/src/framecommentwidget.h | 6 +++++ app/ui/framecommentwidget.ui | 17 ++++-------- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index a3e4b6e72b..047156e583 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -1,6 +1,10 @@ #include "framecommentwidget.h" #include "ui_framecommentwidget.h" +#include "editor.h" +#include "layermanager.h" +#include "keyframe.h" + FrameCommentWidget::FrameCommentWidget(QWidget *parent) : BaseDockWidget(parent) { @@ -22,6 +26,9 @@ void FrameCommentWidget::initUI() connect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); connect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); connect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + connect(editor(), &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); + connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); + connect(ui->btnApplyComments, &QPushButton::clicked, this, &FrameCommentWidget::updateFrameComments); dialogueTextChanged(""); actionTextChanged(""); notesTextChanged(""); @@ -49,3 +56,43 @@ void FrameCommentWidget::notesTextChanged(QString text) int len = text.length(); ui->labNotesCount->setText(tr("%1 chars").arg(QString::number(len))); } + +void FrameCommentWidget::currentFrameChanged(int frame) +{ + if (editor()->layers()->currentLayer()->keyExists(frame)) + { + fillFrameComments(); + ui->btnApplyComments->setEnabled(true); + } + else + { + clearFrameCommentsFields(); + ui->btnApplyComments->setEnabled(false); + } +} + +void FrameCommentWidget::clearFrameCommentsFields() +{ + ui->leDialogue->clear(); + ui->leAction->clear(); + ui->leNotes->clear(); +} + +void FrameCommentWidget::updateFrameComments() +{ + KeyFrame* key = editor()->layers()->currentLayer()->getKeyFrameAt(editor()->currentFrame()); + if (key == nullptr) { return; } + key->setDialogueComment(ui->leDialogue->text()); + key->setActionComment(ui->leAction->text()); + key->setNotesComment(ui->leNotes->text()); +} + +void FrameCommentWidget::fillFrameComments() +{ + KeyFrame* key = editor()->layers()->currentLayer()->getKeyFrameAt(editor()->currentFrame()); + if (key == nullptr) { return; } + ui->leDialogue->setText(key->getDialogueComment()); + ui->leAction->setText(key->getActionComment()); + ui->leNotes->setText(key->getNotesComment()); +} + diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index ef9f7cfadc..02d23c622f 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -3,6 +3,7 @@ #include #include "basedockwidget.h" +#include "editor.h" namespace Ui { class FrameComment; @@ -23,9 +24,14 @@ public slots: void dialogueTextChanged(QString text); void actionTextChanged(QString text); void notesTextChanged(QString text); + void currentFrameChanged(int frame); + void clearFrameCommentsFields(); + void updateFrameComments(); private: Ui::FrameComment *ui; + + void fillFrameComments(); }; #endif // FRAMECOMMENTWIDGET_H diff --git a/app/ui/framecommentwidget.ui b/app/ui/framecommentwidget.ui index e7cd2fbd9d..b1b3669e53 100644 --- a/app/ui/framecommentwidget.ui +++ b/app/ui/framecommentwidget.ui @@ -30,7 +30,7 @@ 4 - + Max 100 chars each! @@ -157,19 +157,12 @@ - - - - Qt::Horizontal - - - - + - Clear all + Clear fields @@ -187,9 +180,9 @@ - + - Apply comments! + Apply comments From 635dfdd17adf8874701545fcf52c118a008abb6f Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Tue, 5 Nov 2019 16:19:12 +0100 Subject: [PATCH 03/19] save and load xml works --- app/src/framecommentwidget.cpp | 97 ++++++++++++++++++++------ app/src/framecommentwidget.h | 12 +++- app/src/mainwindow2.cpp | 1 + app/ui/framecommentwidget.ui | 48 +++++++++++++ core_lib/src/structure/filemanager.cpp | 77 ++++++++++++++++++++ core_lib/src/structure/filemanager.h | 5 +- core_lib/src/structure/keyframe.cpp | 7 ++ core_lib/src/structure/keyframe.h | 1 + 8 files changed, 226 insertions(+), 22 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 047156e583..1d092a28fc 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -3,7 +3,9 @@ #include "editor.h" #include "layermanager.h" +#include "playbackmanager.h" #include "keyframe.h" +#include FrameCommentWidget::FrameCommentWidget(QWidget *parent) : BaseDockWidget(parent) @@ -23,15 +25,8 @@ FrameCommentWidget::~FrameCommentWidget() void FrameCommentWidget::initUI() { - connect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); - connect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - connect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); - connect(editor(), &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); - connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - connect(ui->btnApplyComments, &QPushButton::clicked, this, &FrameCommentWidget::updateFrameComments); - dialogueTextChanged(""); - actionTextChanged(""); - notesTextChanged(""); + connect(this, &FrameCommentWidget::visibilityChanged, this, &FrameCommentWidget::updateConnections); + updateConnections(); } void FrameCommentWidget::updateUI() @@ -39,6 +34,12 @@ void FrameCommentWidget::updateUI() } +void FrameCommentWidget::setCore(Editor *editor) +{ + mEditor = editor; + currentFrameChanged(mEditor->currentFrame()); +} + void FrameCommentWidget::dialogueTextChanged(QString text) { int len = text.length(); @@ -59,40 +60,96 @@ void FrameCommentWidget::notesTextChanged(QString text) void FrameCommentWidget::currentFrameChanged(int frame) { - if (editor()->layers()->currentLayer()->keyExists(frame)) + if (!mIsPlaying) { - fillFrameComments(); - ui->btnApplyComments->setEnabled(true); - } - else - { - clearFrameCommentsFields(); - ui->btnApplyComments->setEnabled(false); + if (mEditor->layers()->currentLayer()->keyExists(frame)) + { + fillFrameComments(); + ui->btnApplyComments->setEnabled(true); + } + else + { + clearFrameCommentsFields(); + ui->btnApplyComments->setEnabled(false); + } } } +void FrameCommentWidget::currentLayerChanged(int index) +{ + Q_UNUSED(index) + currentFrameChanged(mEditor->currentFrame()); +} + void FrameCommentWidget::clearFrameCommentsFields() { ui->leDialogue->clear(); ui->leAction->clear(); ui->leNotes->clear(); + if (!mEditor->layers()->currentLayer()->keyExists(mEditor->currentFrame())) + ui->labLayerFrame->setText(""); } -void FrameCommentWidget::updateFrameComments() +void FrameCommentWidget::applyFrameComments() { - KeyFrame* key = editor()->layers()->currentLayer()->getKeyFrameAt(editor()->currentFrame()); + KeyFrame* key = mEditor->layers()->currentLayer()->getKeyFrameAt(mEditor->currentFrame()); if (key == nullptr) { return; } key->setDialogueComment(ui->leDialogue->text()); key->setActionComment(ui->leAction->text()); key->setNotesComment(ui->leNotes->text()); + mEditor->layers()->currentLayer()->setModified(key->pos(), true); +} + +void FrameCommentWidget::playStateChanged(bool isPlaying) +{ + mIsPlaying = isPlaying; +} + +void FrameCommentWidget::updateConnections() +{ + if (isVisible()) + { + connectAll(); + } + else + { + disconnectAll(); + } } void FrameCommentWidget::fillFrameComments() { - KeyFrame* key = editor()->layers()->currentLayer()->getKeyFrameAt(editor()->currentFrame()); + KeyFrame* key = mEditor->layers()->currentLayer()->getKeyFrameAt(mEditor->currentFrame()); if (key == nullptr) { return; } ui->leDialogue->setText(key->getDialogueComment()); ui->leAction->setText(key->getActionComment()); ui->leNotes->setText(key->getNotesComment()); + ui->labLayerFrame->setText(tr("%1 #%2 :").arg(mEditor->layers()->currentLayer()->name()).arg(QString::number(mEditor->currentFrame()))); +} + +void FrameCommentWidget::connectAll() +{ + connect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + connect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + connect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + connect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); + connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); + connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); + connect(ui->btnApplyComments, &QPushButton::clicked, this, &FrameCommentWidget::applyFrameComments); + connect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillFrameComments); + connect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); +} + +void FrameCommentWidget::disconnectAll() +{ + disconnect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + disconnect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + disconnect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + disconnect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); + disconnect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); + disconnect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); + disconnect(ui->btnApplyComments, &QPushButton::clicked, this, &FrameCommentWidget::applyFrameComments); + disconnect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillFrameComments); + disconnect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); } diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 02d23c622f..40a70e47b1 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -19,19 +19,29 @@ class FrameCommentWidget : public BaseDockWidget void initUI() override; void updateUI() override; + void setCore(Editor* editor); public slots: void dialogueTextChanged(QString text); void actionTextChanged(QString text); void notesTextChanged(QString text); void currentFrameChanged(int frame); + void currentLayerChanged(int index); void clearFrameCommentsFields(); - void updateFrameComments(); + void applyFrameComments(); + void playStateChanged(bool isPlaying); + void updateConnections(); private: Ui::FrameComment *ui; void fillFrameComments(); + void connectAll(); + void disconnectAll(); + + bool mIsPlaying = false; + + Editor* mEditor = nullptr; }; #endif // FRAMECOMMENTWIDGET_H diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index 864924a2e6..f2e1d10e3c 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -157,6 +157,7 @@ void MainWindow2::createDockWidgets() mFrameComments = new FrameCommentWidget(this); mFrameComments->setObjectName("FrameComments"); + mFrameComments->setCore(mEditor); mToolOptions = new ToolOptionWidget(this); mToolOptions->setObjectName("ToolOption"); diff --git a/app/ui/framecommentwidget.ui b/app/ui/framecommentwidget.ui index b1b3669e53..7fb51b907e 100644 --- a/app/ui/framecommentwidget.ui +++ b/app/ui/framecommentwidget.ui @@ -179,6 +179,54 @@ + + + + + + Qt::Horizontal + + + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + diff --git a/core_lib/src/structure/filemanager.cpp b/core_lib/src/structure/filemanager.cpp index e9bba799a9..2eea6972bb 100644 --- a/core_lib/src/structure/filemanager.cpp +++ b/core_lib/src/structure/filemanager.cpp @@ -23,6 +23,8 @@ GNU General Public License for more details. #include "qminiz.h" #include "fileformat.h" #include "object.h" +#include "layer.h" +#include "keyframe.h" #include "layercamera.h" namespace @@ -187,6 +189,10 @@ bool FileManager::loadObject(Object* object, const QDomElement& root) ObjectData* projectData = loadProjectData(element); object->setData(projectData); } + else if (element.tagName() == "framecomments") + { + loadFrameComments(object, element); + } else { Q_ASSERT(false); @@ -354,6 +360,10 @@ Status FileManager::save(Object* object, QString sFileName) QDomElement objectElement = object->saveXML(xmlDoc); root.appendChild(objectElement); + // save comment information + QDomElement frameComments = saveFrameComments(object, xmlDoc); + root.appendChild(frameComments); + dd << "Writing main xml file..."; const int indentSize = 2; @@ -488,6 +498,73 @@ QDomElement FileManager::saveProjectData(ObjectData* data, QDomDocument& xmlDoc) return rootTag; } +void FileManager::loadFrameComments(Object *obj, QDomElement &element) +{ + Layer* layer = nullptr; + KeyFrame* key = nullptr; + int index, newindex = -1; + + for(QDomNode tag = element.firstChild(); !tag.isNull(); tag = tag.nextSibling()) + { + QDomElement comments = tag.toElement(); + if (comments.isNull()) + { + continue; + } + // get layer index + index = comments.tagName().remove(0, 5).toInt(); + + // get layer + if (index != newindex) + { + layer = obj->getLayer(index); + } + + // get keyFrame + int frame = comments.attribute("frame").toInt(); + key = layer->getKeyFrameAt(frame); + + // set keyFrame comments + key->setDialogueComment(comments.attribute("dialogue")); + key->setActionComment(comments.attribute("action")); + key->setNotesComment(comments.attribute("notes")); + newindex = index; + } +} + +QDomElement FileManager::saveFrameComments(Object* obj, QDomDocument &xmlDoc) +{ + int layers = obj->getLayerCount(); + QDomElement rootTag = xmlDoc.createElement("framecomments"); + + KeyFrame* key = nullptr; + for (int i = 0; i < layers; i++) + { + Layer* layer = obj->getLayer(i); + QString tag = "index" + QString::number(i); + int frame = layer->firstKeyFramePosition(); + do + { + key = layer->getKeyFrameAt(frame); + if (key->frameHasComments()) + { + QDomElement tagComments = xmlDoc.createElement(tag); + tagComments.setAttribute("frame", frame); + tagComments.setAttribute("dialogue", key->getDialogueComment()); + tagComments.setAttribute("action", key->getActionComment()); + tagComments.setAttribute("notes", key->getNotesComment()); + rootTag.appendChild(tagComments); + } + if (frame == layer->getMaxKeyFramePosition()) + frame++; + else + frame = layer->getNextKeyFramePosition(frame); + } while (frame <= layer->getMaxKeyFramePosition()); + } + + return rootTag; +} + void FileManager::extractProjectData(const QDomElement& element, ObjectData* data) { Q_ASSERT(data); diff --git a/core_lib/src/structure/filemanager.h b/core_lib/src/structure/filemanager.h index 9ace6e8634..bcf0596868 100644 --- a/core_lib/src/structure/filemanager.h +++ b/core_lib/src/structure/filemanager.h @@ -36,7 +36,7 @@ class FileManager : public QObject Q_OBJECT public: - FileManager(QObject* parent = 0); + FileManager(QObject* parent = nullptr); Object* load(QString sFilenNme); Status save(Object*, QString sFileName); @@ -60,6 +60,9 @@ class FileManager : public QObject ObjectData* loadProjectData(const QDomElement& element); QDomElement saveProjectData(ObjectData*, QDomDocument& xmlDoc); + void loadFrameComments(Object* obj, QDomElement &element); + QDomElement saveFrameComments(Object* obj, QDomDocument& xmlDoc); + void extractProjectData(const QDomElement& element, ObjectData* data); Object* cleanUpWithErrorCode(Status); diff --git a/core_lib/src/structure/keyframe.cpp b/core_lib/src/structure/keyframe.cpp index d4e3a0cd9d..22a8c284f9 100644 --- a/core_lib/src/structure/keyframe.cpp +++ b/core_lib/src/structure/keyframe.cpp @@ -39,6 +39,13 @@ KeyFrame::~KeyFrame() } } +bool KeyFrame::frameHasComments() +{ + if (mDialogueComment.isEmpty() && mActionComment.isEmpty() && mNotesComment.isEmpty()) + return false; + return true; +} + void KeyFrame::addEventListener(KeyFrameEventListener* listener) { auto it = std::find(mEventListeners.begin(), mEventListeners.end(), listener); diff --git a/core_lib/src/structure/keyframe.h b/core_lib/src/structure/keyframe.h index d09f6564f7..ecdd18da66 100644 --- a/core_lib/src/structure/keyframe.h +++ b/core_lib/src/structure/keyframe.h @@ -52,6 +52,7 @@ class KeyFrame QString getActionComment() { return mActionComment; } void setNotesComment(QString comment) { mNotesComment = comment; } QString getNotesComment() { return mNotesComment; } + bool frameHasComments(); QString fileName() const { return mAttachedFileName; } void setFileName(QString strFileName) { mAttachedFileName = strFileName; } From 3fc602f19fd5bdee2753730cbc918f5fdff1782e Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Tue, 5 Nov 2019 17:26:34 +0100 Subject: [PATCH 04/19] Fixed update error, and start char values --- app/src/framecommentwidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 1d092a28fc..5ca75a50dd 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -26,6 +26,9 @@ FrameCommentWidget::~FrameCommentWidget() void FrameCommentWidget::initUI() { connect(this, &FrameCommentWidget::visibilityChanged, this, &FrameCommentWidget::updateConnections); + dialogueTextChanged(""); + actionTextChanged(""); + notesTextChanged(""); updateConnections(); } @@ -103,6 +106,10 @@ void FrameCommentWidget::applyFrameComments() void FrameCommentWidget::playStateChanged(bool isPlaying) { mIsPlaying = isPlaying; + if (!mIsPlaying) + { + currentFrameChanged(mEditor->currentFrame()); + } } void FrameCommentWidget::updateConnections() From 8b490c035e97403e5240fcb97100da1187703edc Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Wed, 6 Nov 2019 16:32:33 +0100 Subject: [PATCH 05/19] Limit raised to 250 chars. whole keyframe exp can be used --- app/src/framecommentwidget.cpp | 38 ++++++++++++++++---------- app/src/framecommentwidget.h | 5 ++++ app/ui/framecommentwidget.ui | 10 +++---- core_lib/src/structure/filemanager.cpp | 4 +-- core_lib/src/structure/keyframe.cpp | 2 +- core_lib/src/structure/keyframe.h | 6 ++-- 6 files changed, 39 insertions(+), 26 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 5ca75a50dd..aa14fa52b7 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -4,7 +4,6 @@ #include "editor.h" #include "layermanager.h" #include "playbackmanager.h" -#include "keyframe.h" #include FrameCommentWidget::FrameCommentWidget(QWidget *parent) : @@ -40,6 +39,8 @@ void FrameCommentWidget::updateUI() void FrameCommentWidget::setCore(Editor *editor) { mEditor = editor; + mLayer = editor->layers()->currentLayer(); + mKeyframe = mLayer->getKeyFrameAt(mEditor->currentFrame()); currentFrameChanged(mEditor->currentFrame()); } @@ -65,7 +66,7 @@ void FrameCommentWidget::currentFrameChanged(int frame) { if (!mIsPlaying) { - if (mEditor->layers()->currentLayer()->keyExists(frame)) + if (mLayer->firstKeyFramePosition() <= frame) { fillFrameComments(); ui->btnApplyComments->setEnabled(true); @@ -81,6 +82,7 @@ void FrameCommentWidget::currentFrameChanged(int frame) void FrameCommentWidget::currentLayerChanged(int index) { Q_UNUSED(index) + mLayer = mEditor->layers()->currentLayer(); currentFrameChanged(mEditor->currentFrame()); } @@ -89,18 +91,21 @@ void FrameCommentWidget::clearFrameCommentsFields() ui->leDialogue->clear(); ui->leAction->clear(); ui->leNotes->clear(); - if (!mEditor->layers()->currentLayer()->keyExists(mEditor->currentFrame())) + if (!mLayer->keyExists(mEditor->currentFrame())) ui->labLayerFrame->setText(""); } void FrameCommentWidget::applyFrameComments() { - KeyFrame* key = mEditor->layers()->currentLayer()->getKeyFrameAt(mEditor->currentFrame()); - if (key == nullptr) { return; } - key->setDialogueComment(ui->leDialogue->text()); - key->setActionComment(ui->leAction->text()); - key->setNotesComment(ui->leNotes->text()); - mEditor->layers()->currentLayer()->setModified(key->pos(), true); + mKeyframe = mLayer->getKeyFrameAt(mEditor->currentFrame()); + if (mKeyframe == nullptr) + mKeyframe = mLayer->getKeyFrameAt(mLayer->getPreviousFrameNumber(mEditor->currentFrame(), true)); + if (mKeyframe == nullptr) { return; } + mKeyframe->setDialogueComment(ui->leDialogue->text()); + mKeyframe->setActionComment(ui->leAction->text()); + mKeyframe->setSlugComment(ui->leNotes->text()); + ui->labLayerFrame->setText(tr("%1 #%2 :").arg(mLayer->name()).arg(QString::number(mKeyframe->pos()))); + mLayer->setModified(mKeyframe->pos(), true); } void FrameCommentWidget::playStateChanged(bool isPlaying) @@ -108,6 +113,7 @@ void FrameCommentWidget::playStateChanged(bool isPlaying) mIsPlaying = isPlaying; if (!mIsPlaying) { + mLayer = mEditor->layers()->currentLayer(); currentFrameChanged(mEditor->currentFrame()); } } @@ -126,12 +132,14 @@ void FrameCommentWidget::updateConnections() void FrameCommentWidget::fillFrameComments() { - KeyFrame* key = mEditor->layers()->currentLayer()->getKeyFrameAt(mEditor->currentFrame()); - if (key == nullptr) { return; } - ui->leDialogue->setText(key->getDialogueComment()); - ui->leAction->setText(key->getActionComment()); - ui->leNotes->setText(key->getNotesComment()); - ui->labLayerFrame->setText(tr("%1 #%2 :").arg(mEditor->layers()->currentLayer()->name()).arg(QString::number(mEditor->currentFrame()))); + mKeyframe = mLayer->getKeyFrameAt(mEditor->currentFrame()); + if (mKeyframe == nullptr) + mKeyframe = mLayer->getKeyFrameAt(mLayer->getPreviousFrameNumber(mEditor->currentFrame(), true)); + if (mKeyframe == nullptr) { return; } + ui->leDialogue->setText(mKeyframe->getDialogueComment()); + ui->leAction->setText(mKeyframe->getActionComment()); + ui->leNotes->setText(mKeyframe->getSlugComment()); + ui->labLayerFrame->setText(tr("%1 #%2 :").arg(mEditor->layers()->currentLayer()->name()).arg(QString::number(mKeyframe->pos()))); } void FrameCommentWidget::connectAll() diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 40a70e47b1..0a9fbcdfb6 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -4,6 +4,8 @@ #include #include "basedockwidget.h" #include "editor.h" +#include "keyframe.h" +#include "layer.h" namespace Ui { class FrameComment; @@ -42,6 +44,9 @@ public slots: bool mIsPlaying = false; Editor* mEditor = nullptr; + Layer* mLayer = nullptr; + KeyFrame* mKeyframe = nullptr; + }; #endif // FRAMECOMMENTWIDGET_H diff --git a/app/ui/framecommentwidget.ui b/app/ui/framecommentwidget.ui index 7fb51b907e..eef818dc22 100644 --- a/app/ui/framecommentwidget.ui +++ b/app/ui/framecommentwidget.ui @@ -32,7 +32,7 @@ - Max 100 chars each! + Max 250 chars each! @@ -77,7 +77,7 @@ - 100 + 250 @@ -115,7 +115,7 @@ - 100 + 250 @@ -124,7 +124,7 @@ - Notes: + Slug (Timing, Camera, ...) @@ -153,7 +153,7 @@ - 100 + 250 diff --git a/core_lib/src/structure/filemanager.cpp b/core_lib/src/structure/filemanager.cpp index 2eea6972bb..2c1ffe76a4 100644 --- a/core_lib/src/structure/filemanager.cpp +++ b/core_lib/src/structure/filemanager.cpp @@ -527,7 +527,7 @@ void FileManager::loadFrameComments(Object *obj, QDomElement &element) // set keyFrame comments key->setDialogueComment(comments.attribute("dialogue")); key->setActionComment(comments.attribute("action")); - key->setNotesComment(comments.attribute("notes")); + key->setSlugComment(comments.attribute("slug")); newindex = index; } } @@ -552,7 +552,7 @@ QDomElement FileManager::saveFrameComments(Object* obj, QDomDocument &xmlDoc) tagComments.setAttribute("frame", frame); tagComments.setAttribute("dialogue", key->getDialogueComment()); tagComments.setAttribute("action", key->getActionComment()); - tagComments.setAttribute("notes", key->getNotesComment()); + tagComments.setAttribute("slug", key->getSlugComment()); rootTag.appendChild(tagComments); } if (frame == layer->getMaxKeyFramePosition()) diff --git a/core_lib/src/structure/keyframe.cpp b/core_lib/src/structure/keyframe.cpp index 22a8c284f9..d5c03745d2 100644 --- a/core_lib/src/structure/keyframe.cpp +++ b/core_lib/src/structure/keyframe.cpp @@ -41,7 +41,7 @@ KeyFrame::~KeyFrame() bool KeyFrame::frameHasComments() { - if (mDialogueComment.isEmpty() && mActionComment.isEmpty() && mNotesComment.isEmpty()) + if (mDialogueComment.isEmpty() && mActionComment.isEmpty() && mSlugComment.isEmpty()) return false; return true; } diff --git a/core_lib/src/structure/keyframe.h b/core_lib/src/structure/keyframe.h index ecdd18da66..0de15f4877 100644 --- a/core_lib/src/structure/keyframe.h +++ b/core_lib/src/structure/keyframe.h @@ -50,8 +50,8 @@ class KeyFrame QString getDialogueComment() { return mDialogueComment; } void setActionComment(QString comment) { mActionComment = comment; } QString getActionComment() { return mActionComment; } - void setNotesComment(QString comment) { mNotesComment = comment; } - QString getNotesComment() { return mNotesComment; } + void setSlugComment(QString comment) { mSlugComment = comment; } + QString getSlugComment() { return mSlugComment; } bool frameHasComments(); QString fileName() const { return mAttachedFileName; } @@ -75,7 +75,7 @@ class KeyFrame // comments QString mDialogueComment = ""; QString mActionComment = ""; - QString mNotesComment = ""; + QString mSlugComment = ""; std::vector mEventListeners; }; From 778ce5b97ab7691257d8c51b6a0a4e473c32c92a Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Fri, 8 Nov 2019 06:15:54 +0100 Subject: [PATCH 06/19] Deleted two irrelevant files --- .../src/structure/layermultiplanecamera.cpp | 6 --- .../src/structure/layermultiplanecamera.h | 39 ------------------- 2 files changed, 45 deletions(-) delete mode 100644 core_lib/src/structure/layermultiplanecamera.cpp delete mode 100644 core_lib/src/structure/layermultiplanecamera.h diff --git a/core_lib/src/structure/layermultiplanecamera.cpp b/core_lib/src/structure/layermultiplanecamera.cpp deleted file mode 100644 index 9ee033705c..0000000000 --- a/core_lib/src/structure/layermultiplanecamera.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "layermultiplanecamera.h" - -LayerMultiPlaneCamera::LayerMultiPlaneCamera(Object *object) :Layer(object, LAYER_TYPE::MULTIPLANCAMERA) -{ - setName(tr("Multiplane Camera")); -} diff --git a/core_lib/src/structure/layermultiplanecamera.h b/core_lib/src/structure/layermultiplanecamera.h deleted file mode 100644 index cc054d2dee..0000000000 --- a/core_lib/src/structure/layermultiplanecamera.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef LAYERMULTIPLANECAMERA_H -#define LAYERMULTIPLANECAMERA_H - -#include "layer.h" - -struct Campoint { - int frame; - QTransform transform; - QPainterPath path; -}; - -class LayerMultiPlaneCamera : public Layer -{ - Q_OBJECT - -public: - LayerMultiPlaneCamera(Object* object); - - void setViewRect(QRect viewrect) { mViewRect = viewrect; } - QRect getViewRect() { return mViewRect; } - -private: - QList mCampointList; - QRect mViewRect; -}; - -#endif // LAYERMULTIPLANECAMERA_H -/* -Hver frame har sin egen Campoint. -DVS: -Frame 1 har altid et Campoint. Er der ikke nogen kamerabevægelser, bruges -Campoint fra frame 1 i hele scenen. -Laver man en pan fra frame 50 til 80 i en 300 frames lang scene vil følgende ske: -Frame 1 har et Campoint. -Idet frame 50 tildeles en transform, udregnes transforms for frame 1 til 50. Hvis -der ikke er forskel på fielden i frame 1 og 50, har alle 50 samme transform. -Idet frame 80 får en transform sker det samme. 50 til 80 udregnes. Når frame -80 ændres, vil 50 til 80 igen blive beregnet. -*/ From c30f8eadc7821f9cf7610afa697438b7d338e2b8 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 13:38:42 +0100 Subject: [PATCH 07/19] Simplify UI + Added new KeyFrameTextEdit class to make it possible to save on focus changes + Makes apply button redundant + Allows for multiple lines + No text limit. + Some refactoring --- app/app.pro | 2 + app/src/framecommentwidget.cpp | 88 ++++++++++++------------ app/src/framecommentwidget.h | 17 ++--- app/src/keyframetextedit.cpp | 13 ++++ app/src/keyframetextedit.h | 20 ++++++ app/ui/framecommentwidget.ui | 119 +++++---------------------------- 6 files changed, 104 insertions(+), 155 deletions(-) create mode 100644 app/src/keyframetextedit.cpp create mode 100644 app/src/keyframetextedit.h diff --git a/app/app.pro b/app/app.pro index d1a9e2c172..04ac3dbab6 100644 --- a/app/app.pro +++ b/app/app.pro @@ -39,6 +39,7 @@ INCLUDEPATH += \ HEADERS += \ src/importlayersdialog.h \ + src/keyframetextedit.h \ src/mainwindow2.h \ src/predefinedsetmodel.h \ src/pegbaralignmentdialog.h \ @@ -72,6 +73,7 @@ HEADERS += \ SOURCES += \ src/importlayersdialog.cpp \ + src/keyframetextedit.cpp \ src/main.cpp \ src/mainwindow2.cpp \ src/predefinedsetmodel.cpp \ diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index aa14fa52b7..04f5644df0 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -2,9 +2,11 @@ #include "ui_framecommentwidget.h" #include "editor.h" +#include "keyframe.h" + #include "layermanager.h" #include "playbackmanager.h" -#include +#include "keyframetextedit.h" FrameCommentWidget::FrameCommentWidget(QWidget *parent) : BaseDockWidget(parent) @@ -25,9 +27,6 @@ FrameCommentWidget::~FrameCommentWidget() void FrameCommentWidget::initUI() { connect(this, &FrameCommentWidget::visibilityChanged, this, &FrameCommentWidget::updateConnections); - dialogueTextChanged(""); - actionTextChanged(""); - notesTextChanged(""); updateConnections(); } @@ -44,22 +43,22 @@ void FrameCommentWidget::setCore(Editor *editor) currentFrameChanged(mEditor->currentFrame()); } -void FrameCommentWidget::dialogueTextChanged(QString text) +void FrameCommentWidget::dialogueTextChanged() { - int len = text.length(); - ui->labDialogueCount->setText(tr("%1 chars").arg(QString::number(len))); + int len = ui->textEditDialogue->toPlainText().length(); + ui->labelDialogueCounter->setText(tr("%1 chars").arg(QString::number(len))); } -void FrameCommentWidget::actionTextChanged(QString text) +void FrameCommentWidget::actionTextChanged() { - int len = text.length(); - ui->labActionCount->setText(tr("%1 chars").arg(QString::number(len))); + int len = ui->textEditAction->toPlainText().length(); + ui->labelActionCounter->setText(tr("%1 chars").arg(QString::number(len))); } -void FrameCommentWidget::notesTextChanged(QString text) +void FrameCommentWidget::notesTextChanged() { - int len = text.length(); - ui->labNotesCount->setText(tr("%1 chars").arg(QString::number(len))); + int len = ui->textEditSlug->toPlainText().length(); + ui->labelSlugCounter->setText(tr("%1 chars").arg(QString::number(len))); } void FrameCommentWidget::currentFrameChanged(int frame) @@ -69,12 +68,10 @@ void FrameCommentWidget::currentFrameChanged(int frame) if (mLayer->firstKeyFramePosition() <= frame) { fillFrameComments(); - ui->btnApplyComments->setEnabled(true); } else { clearFrameCommentsFields(); - ui->btnApplyComments->setEnabled(false); } } } @@ -88,11 +85,9 @@ void FrameCommentWidget::currentLayerChanged(int index) void FrameCommentWidget::clearFrameCommentsFields() { - ui->leDialogue->clear(); - ui->leAction->clear(); - ui->leNotes->clear(); - if (!mLayer->keyExists(mEditor->currentFrame())) - ui->labLayerFrame->setText(""); + ui->textEditDialogue->clear(); + ui->textEditAction->clear(); + ui->textEditSlug->clear(); } void FrameCommentWidget::applyFrameComments() @@ -101,10 +96,9 @@ void FrameCommentWidget::applyFrameComments() if (mKeyframe == nullptr) mKeyframe = mLayer->getKeyFrameAt(mLayer->getPreviousFrameNumber(mEditor->currentFrame(), true)); if (mKeyframe == nullptr) { return; } - mKeyframe->setDialogueComment(ui->leDialogue->text()); - mKeyframe->setActionComment(ui->leAction->text()); - mKeyframe->setSlugComment(ui->leNotes->text()); - ui->labLayerFrame->setText(tr("%1 #%2 :").arg(mLayer->name()).arg(QString::number(mKeyframe->pos()))); + mKeyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); + mKeyframe->setActionComment(ui->textEditAction->toPlainText()); + mKeyframe->setSlugComment(ui->textEditSlug->toPlainText()); mLayer->setModified(mKeyframe->pos(), true); } @@ -120,13 +114,13 @@ void FrameCommentWidget::playStateChanged(bool isPlaying) void FrameCommentWidget::updateConnections() { - if (isVisible()) + if (!isVisible()) { - connectAll(); + disconnectNotifiers(); } else { - disconnectAll(); + makeConnections(); } } @@ -136,35 +130,41 @@ void FrameCommentWidget::fillFrameComments() if (mKeyframe == nullptr) mKeyframe = mLayer->getKeyFrameAt(mLayer->getPreviousFrameNumber(mEditor->currentFrame(), true)); if (mKeyframe == nullptr) { return; } - ui->leDialogue->setText(mKeyframe->getDialogueComment()); - ui->leAction->setText(mKeyframe->getActionComment()); - ui->leNotes->setText(mKeyframe->getSlugComment()); - ui->labLayerFrame->setText(tr("%1 #%2 :").arg(mEditor->layers()->currentLayer()->name()).arg(QString::number(mKeyframe->pos()))); + ui->textEditDialogue->setPlainText(mKeyframe->getDialogueComment()); + ui->textEditAction->setPlainText(mKeyframe->getActionComment()); + ui->textEditSlug->setPlainText(mKeyframe->getSlugComment()); } -void FrameCommentWidget::connectAll() +void FrameCommentWidget::makeConnections() { - connect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); - connect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - connect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + connect(ui->textEditDialogue, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + connect(ui->textEditAction, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + connect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); + + connect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + connect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + connect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + connect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); - connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - connect(ui->btnApplyComments, &QPushButton::clicked, this, &FrameCommentWidget::applyFrameComments); connect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillFrameComments); connect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); } -void FrameCommentWidget::disconnectAll() +void FrameCommentWidget::disconnectNotifiers() { - disconnect(ui->leDialogue, &QLineEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); - disconnect(ui->leAction, &QLineEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - disconnect(ui->leNotes, &QLineEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + disconnect(ui->textEditDialogue, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + disconnect(ui->textEditAction, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + disconnect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + disconnect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); + + disconnect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + disconnect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + disconnect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + disconnect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); disconnect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); - disconnect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - disconnect(ui->btnApplyComments, &QPushButton::clicked, this, &FrameCommentWidget::applyFrameComments); disconnect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillFrameComments); disconnect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); } - diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 0a9fbcdfb6..2520cb1a1f 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -3,9 +3,10 @@ #include #include "basedockwidget.h" -#include "editor.h" -#include "keyframe.h" -#include "layer.h" + +class Editor; +class KeyFrame; +class Layer; namespace Ui { class FrameComment; @@ -24,9 +25,9 @@ class FrameCommentWidget : public BaseDockWidget void setCore(Editor* editor); public slots: - void dialogueTextChanged(QString text); - void actionTextChanged(QString text); - void notesTextChanged(QString text); + void dialogueTextChanged(); + void actionTextChanged(); + void notesTextChanged(); void currentFrameChanged(int frame); void currentLayerChanged(int index); void clearFrameCommentsFields(); @@ -38,8 +39,8 @@ public slots: Ui::FrameComment *ui; void fillFrameComments(); - void connectAll(); - void disconnectAll(); + void makeConnections(); + void disconnectNotifiers(); bool mIsPlaying = false; diff --git a/app/src/keyframetextedit.cpp b/app/src/keyframetextedit.cpp new file mode 100644 index 0000000000..fb6d260e2d --- /dev/null +++ b/app/src/keyframetextedit.cpp @@ -0,0 +1,13 @@ +#include "keyframetextedit.h" + +KeyFrameTextEdit::KeyFrameTextEdit(QWidget* parent) : QPlainTextEdit(parent) { + +} + +void KeyFrameTextEdit::focusOutEvent(QFocusEvent *event) { + + if (event->lostFocus()) { + emit(lostFocus()); + } + QPlainTextEdit::focusOutEvent(event); +} diff --git a/app/src/keyframetextedit.h b/app/src/keyframetextedit.h new file mode 100644 index 0000000000..aa4fdaef14 --- /dev/null +++ b/app/src/keyframetextedit.h @@ -0,0 +1,20 @@ +#ifndef KEYFRAMETEXTEDIT_H +#define KEYFRAMETEXTEDIT_H + +#include + +class KeyFrameTextEdit : public QPlainTextEdit { + + Q_OBJECT +public: + KeyFrameTextEdit(QWidget* parent = nullptr); + +Q_SIGNALS: + void lostFocus(); + +protected: + void focusOutEvent(QFocusEvent *e) override; + +}; + +#endif // KEYFRAMETEXTEDIT_H diff --git a/app/ui/framecommentwidget.ui b/app/ui/framecommentwidget.ui index eef818dc22..89656583f8 100644 --- a/app/ui/framecommentwidget.ui +++ b/app/ui/framecommentwidget.ui @@ -29,24 +29,10 @@ 4 - - - - Max 250 chars each! - - - - - - - Qt::Horizontal - - - - + Dialogue: @@ -66,7 +52,7 @@ - + 0 @@ -75,16 +61,12 @@ - - - 250 - - + - + Action: @@ -104,7 +86,7 @@ - + 0 @@ -113,16 +95,12 @@ - - - 250 - - + - + Slug (Timing, Camera, ...) @@ -142,7 +120,7 @@ - + 0 @@ -151,11 +129,7 @@ - - - 250 - - + @@ -181,76 +155,15 @@ - - - - Qt::Horizontal - - - - - - - - - TextLabel - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Apply comments - - - - - - - - - Qt::Vertical - - - - 20 - 117 - - - - + + + KeyFrameTextEdit + QPlainTextEdit +
keyframetextedit.h
+
+
From 42934643dca6c87928054ab789edad5154ec8ee8 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 14:54:57 +0100 Subject: [PATCH 08/19] Fix memory issues caused by accessing values that no longer exists. --- app/src/framecommentwidget.cpp | 79 ++++++++++++++++++---------------- app/src/framecommentwidget.h | 22 ++++++---- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 04f5644df0..933eb5080f 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -38,9 +38,6 @@ void FrameCommentWidget::updateUI() void FrameCommentWidget::setCore(Editor *editor) { mEditor = editor; - mLayer = editor->layers()->currentLayer(); - mKeyframe = mLayer->getKeyFrameAt(mEditor->currentFrame()); - currentFrameChanged(mEditor->currentFrame()); } void FrameCommentWidget::dialogueTextChanged() @@ -55,7 +52,7 @@ void FrameCommentWidget::actionTextChanged() ui->labelActionCounter->setText(tr("%1 chars").arg(QString::number(len))); } -void FrameCommentWidget::notesTextChanged() +void FrameCommentWidget::slugTextChanged() { int len = ui->textEditSlug->toPlainText().length(); ui->labelSlugCounter->setText(tr("%1 chars").arg(QString::number(len))); @@ -65,9 +62,9 @@ void FrameCommentWidget::currentFrameChanged(int frame) { if (!mIsPlaying) { - if (mLayer->firstKeyFramePosition() <= frame) + if (mEditor->layers()->currentLayer()->firstKeyFramePosition() <= frame) { - fillFrameComments(); + fillComments(); } else { @@ -79,7 +76,6 @@ void FrameCommentWidget::currentFrameChanged(int frame) void FrameCommentWidget::currentLayerChanged(int index) { Q_UNUSED(index) - mLayer = mEditor->layers()->currentLayer(); currentFrameChanged(mEditor->currentFrame()); } @@ -90,24 +86,11 @@ void FrameCommentWidget::clearFrameCommentsFields() ui->textEditSlug->clear(); } -void FrameCommentWidget::applyFrameComments() -{ - mKeyframe = mLayer->getKeyFrameAt(mEditor->currentFrame()); - if (mKeyframe == nullptr) - mKeyframe = mLayer->getKeyFrameAt(mLayer->getPreviousFrameNumber(mEditor->currentFrame(), true)); - if (mKeyframe == nullptr) { return; } - mKeyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); - mKeyframe->setActionComment(ui->textEditAction->toPlainText()); - mKeyframe->setSlugComment(ui->textEditSlug->toPlainText()); - mLayer->setModified(mKeyframe->pos(), true); -} - void FrameCommentWidget::playStateChanged(bool isPlaying) { mIsPlaying = isPlaying; if (!mIsPlaying) { - mLayer = mEditor->layers()->currentLayer(); currentFrameChanged(mEditor->currentFrame()); } } @@ -124,31 +107,51 @@ void FrameCommentWidget::updateConnections() } } -void FrameCommentWidget::fillFrameComments() +void FrameCommentWidget::fillComments() { - mKeyframe = mLayer->getKeyFrameAt(mEditor->currentFrame()); - if (mKeyframe == nullptr) - mKeyframe = mLayer->getKeyFrameAt(mLayer->getPreviousFrameNumber(mEditor->currentFrame(), true)); - if (mKeyframe == nullptr) { return; } - ui->textEditDialogue->setPlainText(mKeyframe->getDialogueComment()); - ui->textEditAction->setPlainText(mKeyframe->getActionComment()); - ui->textEditSlug->setPlainText(mKeyframe->getSlugComment()); + KeyFrame* keyframe = getKeyFrame(); + + ui->textEditDialogue->setPlainText(keyframe->getDialogueComment()); + ui->textEditAction->setPlainText(keyframe->getActionComment()); + ui->textEditSlug->setPlainText(keyframe->getSlugComment()); +} + +void FrameCommentWidget::applyComments() +{ + KeyFrame* keyframe = getKeyFrame(); + + keyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); + keyframe->setActionComment(ui->textEditAction->toPlainText()); + keyframe->setSlugComment(ui->textEditSlug->toPlainText()); + mEditor->layers()->currentLayer()->setModified(keyframe->pos(), true); +} + +KeyFrame* FrameCommentWidget::getKeyFrame() +{ + int currentFrame = mEditor->currentFrame(); + Layer* layer = mEditor->layers()->currentLayer(); + KeyFrame* keyframe = layer->getKeyFrameAt(currentFrame); + if (keyframe == nullptr) + keyframe = layer->getKeyFrameAt(layer->getPreviousFrameNumber(currentFrame, true)); + if (keyframe == nullptr) { return nullptr; } + + return keyframe; } void FrameCommentWidget::makeConnections() { connect(ui->textEditDialogue, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); connect(ui->textEditAction, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - connect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + connect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - connect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); - connect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); - connect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + connect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); + connect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); + connect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); connect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); - connect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillFrameComments); + connect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillComments); connect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); } @@ -156,15 +159,15 @@ void FrameCommentWidget::disconnectNotifiers() { disconnect(ui->textEditDialogue, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); disconnect(ui->textEditAction, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - disconnect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::notesTextChanged); + disconnect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); disconnect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - disconnect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); - disconnect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); - disconnect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyFrameComments); + disconnect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); disconnect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); disconnect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); - disconnect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillFrameComments); + disconnect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillComments); disconnect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); } diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 2520cb1a1f..57fa392fa4 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -24,29 +24,33 @@ class FrameCommentWidget : public BaseDockWidget void updateUI() override; void setCore(Editor* editor); -public slots: + void applyComments(); + void fillComments(); + +private: + Ui::FrameComment *ui; + void dialogueTextChanged(); void actionTextChanged(); - void notesTextChanged(); + void slugTextChanged(); + void currentFrameChanged(int frame); void currentLayerChanged(int index); + void clearFrameCommentsFields(); - void applyFrameComments(); - void playStateChanged(bool isPlaying); + void updateConnections(); -private: - Ui::FrameComment *ui; + void playStateChanged(bool isPlaying); + + KeyFrame* getKeyFrame(); - void fillFrameComments(); void makeConnections(); void disconnectNotifiers(); bool mIsPlaying = false; Editor* mEditor = nullptr; - Layer* mLayer = nullptr; - KeyFrame* mKeyframe = nullptr; }; From e57d784f709fc37bad8f0214538eb865f67b81f1 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 14:55:46 +0100 Subject: [PATCH 09/19] No need to hide dock, can simply remove the widget by default --- app/src/mainwindow2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index f2e1d10e3c..7ce3e283c1 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -199,12 +199,11 @@ void MainWindow2::createDockWidgets() addDockWidget(Qt::RightDockWidgetArea, mColorBox); addDockWidget(Qt::RightDockWidgetArea, mColorInspector); addDockWidget(Qt::RightDockWidgetArea, mColorPalette); - addDockWidget(Qt::RightDockWidgetArea, mFrameComments); - mFrameComments->hide(); addDockWidget(Qt::LeftDockWidgetArea, mToolBox); addDockWidget(Qt::LeftDockWidgetArea, mToolOptions); addDockWidget(Qt::LeftDockWidgetArea, mDisplayOptionWidget); addDockWidget(Qt::BottomDockWidgetArea, mTimeLine); + setDockNestingEnabled(true); /* From cbd0c253a8217b5a2cd084d200444e68f0511588 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 15:07:47 +0100 Subject: [PATCH 10/19] Refactor load/save comments in filemanager --- core_lib/src/structure/filemanager.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core_lib/src/structure/filemanager.cpp b/core_lib/src/structure/filemanager.cpp index 2c1ffe76a4..c7a23a75a9 100644 --- a/core_lib/src/structure/filemanager.cpp +++ b/core_lib/src/structure/filemanager.cpp @@ -502,7 +502,9 @@ void FileManager::loadFrameComments(Object *obj, QDomElement &element) { Layer* layer = nullptr; KeyFrame* key = nullptr; - int index, newindex = -1; + + int newLayerIndex = -1; + int oldLayerIndex = -1; for(QDomNode tag = element.firstChild(); !tag.isNull(); tag = tag.nextSibling()) { @@ -511,13 +513,14 @@ void FileManager::loadFrameComments(Object *obj, QDomElement &element) { continue; } - // get layer index - index = comments.tagName().remove(0, 5).toInt(); - // get layer - if (index != newindex) - { - layer = obj->getLayer(index); + oldLayerIndex = comments.attribute("layer").toInt(); + if (newLayerIndex != oldLayerIndex) { + layer = obj->getLayer(oldLayerIndex); + } + + if (layer == nullptr) { + continue; } // get keyFrame @@ -528,7 +531,8 @@ void FileManager::loadFrameComments(Object *obj, QDomElement &element) key->setDialogueComment(comments.attribute("dialogue")); key->setActionComment(comments.attribute("action")); key->setSlugComment(comments.attribute("slug")); - newindex = index; + + newLayerIndex = oldLayerIndex; } } @@ -541,7 +545,7 @@ QDomElement FileManager::saveFrameComments(Object* obj, QDomDocument &xmlDoc) for (int i = 0; i < layers; i++) { Layer* layer = obj->getLayer(i); - QString tag = "index" + QString::number(i); + QString tag = "content"; int frame = layer->firstKeyFramePosition(); do { @@ -549,6 +553,7 @@ QDomElement FileManager::saveFrameComments(Object* obj, QDomDocument &xmlDoc) if (key->frameHasComments()) { QDomElement tagComments = xmlDoc.createElement(tag); + tagComments.setAttribute("layer", i); tagComments.setAttribute("frame", frame); tagComments.setAttribute("dialogue", key->getDialogueComment()); tagComments.setAttribute("action", key->getActionComment()); From 561fb986354a6de445b0abe28d1ba6a9fb692672 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 15:08:18 +0100 Subject: [PATCH 11/19] Add forgotten nullptr check --- app/src/framecommentwidget.cpp | 2 ++ app/src/framecommentwidget.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 933eb5080f..218c422332 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -110,6 +110,7 @@ void FrameCommentWidget::updateConnections() void FrameCommentWidget::fillComments() { KeyFrame* keyframe = getKeyFrame(); + if (keyframe == nullptr) { return; } ui->textEditDialogue->setPlainText(keyframe->getDialogueComment()); ui->textEditAction->setPlainText(keyframe->getActionComment()); @@ -119,6 +120,7 @@ void FrameCommentWidget::fillComments() void FrameCommentWidget::applyComments() { KeyFrame* keyframe = getKeyFrame(); + if (keyframe == nullptr) { return; } keyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); keyframe->setActionComment(ui->textEditAction->toPlainText()); diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 57fa392fa4..e5a8e070a2 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -51,7 +51,6 @@ class FrameCommentWidget : public BaseDockWidget bool mIsPlaying = false; Editor* mEditor = nullptr; - }; #endif // FRAMECOMMENTWIDGET_H From 4bda3b9ae1b993606b6717469ca6ed80a5e64081 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 18:43:15 +0100 Subject: [PATCH 12/19] Make sure frame is updated when changing layer --- app/src/framecommentwidget.cpp | 23 +++++++++++++++++------ app/src/framecommentwidget.h | 5 ++++- app/src/mainwindow2.cpp | 1 + core_lib/src/interface/editor.cpp | 3 +++ core_lib/src/interface/editor.h | 1 + 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 218c422332..47e0ae7bc5 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -107,9 +107,20 @@ void FrameCommentWidget::updateConnections() } } +void FrameCommentWidget::applyCommentsToKeyframe(const int frame) +{ + KeyFrame* keyframe = getKeyFrame(frame); + if (keyframe == nullptr) { return; } + + keyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); + keyframe->setActionComment(ui->textEditAction->toPlainText()); + keyframe->setSlugComment(ui->textEditSlug->toPlainText()); + mEditor->layers()->currentLayer()->setModified(keyframe->pos(), true); +} + void FrameCommentWidget::fillComments() { - KeyFrame* keyframe = getKeyFrame(); + KeyFrame* keyframe = getKeyFrame(mEditor->currentFrame()); if (keyframe == nullptr) { return; } ui->textEditDialogue->setPlainText(keyframe->getDialogueComment()); @@ -119,7 +130,7 @@ void FrameCommentWidget::fillComments() void FrameCommentWidget::applyComments() { - KeyFrame* keyframe = getKeyFrame(); + KeyFrame* keyframe = getKeyFrame(mEditor->currentFrame()); if (keyframe == nullptr) { return; } keyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); @@ -128,13 +139,12 @@ void FrameCommentWidget::applyComments() mEditor->layers()->currentLayer()->setModified(keyframe->pos(), true); } -KeyFrame* FrameCommentWidget::getKeyFrame() +KeyFrame* FrameCommentWidget::getKeyFrame(int frame) { - int currentFrame = mEditor->currentFrame(); Layer* layer = mEditor->layers()->currentLayer(); - KeyFrame* keyframe = layer->getKeyFrameAt(currentFrame); + KeyFrame* keyframe = layer->getKeyFrameAt(frame); if (keyframe == nullptr) - keyframe = layer->getKeyFrameAt(layer->getPreviousFrameNumber(currentFrame, true)); + keyframe = layer->getKeyFrameAt(layer->getPreviousFrameNumber(frame, true)); if (keyframe == nullptr) { return nullptr; } return keyframe; @@ -155,6 +165,7 @@ void FrameCommentWidget::makeConnections() connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); connect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillComments); connect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); + connect(mEditor, &Editor::aboutToChangeFrame, this, &FrameCommentWidget::applyCommentsToKeyframe); } void FrameCommentWidget::disconnectNotifiers() diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index e5a8e070a2..5e7daaac05 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -27,6 +27,9 @@ class FrameCommentWidget : public BaseDockWidget void applyComments(); void fillComments(); +public slots: + void applyCommentsToKeyframe(const int frame); + private: Ui::FrameComment *ui; @@ -43,7 +46,7 @@ class FrameCommentWidget : public BaseDockWidget void playStateChanged(bool isPlaying); - KeyFrame* getKeyFrame(); + KeyFrame* getKeyFrame(int frame); void makeConnections(); void disconnectNotifiers(); diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index 7ce3e283c1..66b95115d0 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -220,6 +220,7 @@ void MainWindow2::createDockWidgets() makeConnections(mEditor, mColorInspector); makeConnections(mEditor, mColorPalette); makeConnections(mEditor, mToolOptions); + makeConnections(mEditor, mFrameComments); for (BaseDockWidget* w : mDockWidgets) { diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index 1bdb4cf1dc..c2fb9f7997 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -959,6 +959,7 @@ void Editor::updateCurrentFrame() void Editor::setCurrentLayerIndex(int i) { + emit aboutToChangeFrame(mFrame); mCurrentLayerIndex = i; Layer* layer = mObject->getLayer(i); @@ -970,6 +971,8 @@ void Editor::setCurrentLayerIndex(int i) void Editor::scrubTo(int frame) { + + emit aboutToChangeFrame(mFrame); if (frame < 1) { frame = 1; } int oldFrame = mFrame; mFrame = frame; diff --git a/core_lib/src/interface/editor.h b/core_lib/src/interface/editor.h index bfb22d978c..d70c078a7f 100644 --- a/core_lib/src/interface/editor.h +++ b/core_lib/src/interface/editor.h @@ -120,6 +120,7 @@ class Editor : public QObject void changeThinLinesButton(bool); void currentFrameChanged(int n); + void aboutToChangeFrame(int oldFrame); void needSave(); void needDisplayInfo(const QString& title, const QString& body); From c04e5f4666aceecc31f6adec6de6af48d2d9e08e Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sat, 9 Nov 2019 18:43:33 +0100 Subject: [PATCH 13/19] Clear focus on FocusOutEvent --- app/src/keyframetextedit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/keyframetextedit.cpp b/app/src/keyframetextedit.cpp index fb6d260e2d..be1e648e8e 100644 --- a/app/src/keyframetextedit.cpp +++ b/app/src/keyframetextedit.cpp @@ -8,6 +8,7 @@ void KeyFrameTextEdit::focusOutEvent(QFocusEvent *event) { if (event->lostFocus()) { emit(lostFocus()); + clearFocus(); } QPlainTextEdit::focusOutEvent(event); } From 5ae84ed53b95c8034b78aff19d38bfec4b183f9f Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sun, 10 Nov 2019 09:17:06 +0100 Subject: [PATCH 14/19] Remove no longer valid function --- app/src/mainwindow2.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index 66b95115d0..7ce3e283c1 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -220,7 +220,6 @@ void MainWindow2::createDockWidgets() makeConnections(mEditor, mColorInspector); makeConnections(mEditor, mColorPalette); makeConnections(mEditor, mToolOptions); - makeConnections(mEditor, mFrameComments); for (BaseDockWidget* w : mDockWidgets) { From 1590477caed24eef56ed76b43cdad2804b9cdaca Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sun, 10 Nov 2019 09:45:35 +0100 Subject: [PATCH 15/19] Apply comments when leaving widget, out of focus is too late --- app/src/framecommentwidget.cpp | 24 ++++++------------------ app/src/framecommentwidget.h | 3 --- app/src/keyframetextedit.cpp | 10 +++++++++- app/src/keyframetextedit.h | 3 ++- core_lib/src/interface/editor.cpp | 3 --- core_lib/src/interface/editor.h | 1 - 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 47e0ae7bc5..f92e6c1f1a 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -107,17 +107,6 @@ void FrameCommentWidget::updateConnections() } } -void FrameCommentWidget::applyCommentsToKeyframe(const int frame) -{ - KeyFrame* keyframe = getKeyFrame(frame); - if (keyframe == nullptr) { return; } - - keyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); - keyframe->setActionComment(ui->textEditAction->toPlainText()); - keyframe->setSlugComment(ui->textEditSlug->toPlainText()); - mEditor->layers()->currentLayer()->setModified(keyframe->pos(), true); -} - void FrameCommentWidget::fillComments() { KeyFrame* keyframe = getKeyFrame(mEditor->currentFrame()); @@ -157,15 +146,14 @@ void FrameCommentWidget::makeConnections() connect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - connect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); - connect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); - connect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); + connect(ui->textEditSlug, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); + connect(ui->textEditAction, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); + connect(ui->textEditDialogue, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); connect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); connect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillComments); connect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged); - connect(mEditor, &Editor::aboutToChangeFrame, this, &FrameCommentWidget::applyCommentsToKeyframe); } void FrameCommentWidget::disconnectNotifiers() @@ -175,9 +163,9 @@ void FrameCommentWidget::disconnectNotifiers() disconnect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); disconnect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - disconnect(ui->textEditSlug, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); - disconnect(ui->textEditAction, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); - disconnect(ui->textEditDialogue, &KeyFrameTextEdit::lostFocus, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditSlug, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditAction, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditDialogue, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); disconnect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); disconnect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 5e7daaac05..7d0a94b97e 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -27,9 +27,6 @@ class FrameCommentWidget : public BaseDockWidget void applyComments(); void fillComments(); -public slots: - void applyCommentsToKeyframe(const int frame); - private: Ui::FrameComment *ui; diff --git a/app/src/keyframetextedit.cpp b/app/src/keyframetextedit.cpp index be1e648e8e..c6db47cdaa 100644 --- a/app/src/keyframetextedit.cpp +++ b/app/src/keyframetextedit.cpp @@ -7,8 +7,16 @@ KeyFrameTextEdit::KeyFrameTextEdit(QWidget* parent) : QPlainTextEdit(parent) { void KeyFrameTextEdit::focusOutEvent(QFocusEvent *event) { if (event->lostFocus()) { - emit(lostFocus()); clearFocus(); } QPlainTextEdit::focusOutEvent(event); } + +bool KeyFrameTextEdit::event(QEvent* event) +{ + if (event->type() == QEvent::Leave) { + emit outsideWidget(); + } + + return QPlainTextEdit::event(event); +} diff --git a/app/src/keyframetextedit.h b/app/src/keyframetextedit.h index aa4fdaef14..f942d9b447 100644 --- a/app/src/keyframetextedit.h +++ b/app/src/keyframetextedit.h @@ -10,10 +10,11 @@ class KeyFrameTextEdit : public QPlainTextEdit { KeyFrameTextEdit(QWidget* parent = nullptr); Q_SIGNALS: - void lostFocus(); + void outsideWidget(); protected: void focusOutEvent(QFocusEvent *e) override; + bool event(QEvent* event) override; }; diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index c2fb9f7997..1bdb4cf1dc 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -959,7 +959,6 @@ void Editor::updateCurrentFrame() void Editor::setCurrentLayerIndex(int i) { - emit aboutToChangeFrame(mFrame); mCurrentLayerIndex = i; Layer* layer = mObject->getLayer(i); @@ -971,8 +970,6 @@ void Editor::setCurrentLayerIndex(int i) void Editor::scrubTo(int frame) { - - emit aboutToChangeFrame(mFrame); if (frame < 1) { frame = 1; } int oldFrame = mFrame; mFrame = frame; diff --git a/core_lib/src/interface/editor.h b/core_lib/src/interface/editor.h index d70c078a7f..bfb22d978c 100644 --- a/core_lib/src/interface/editor.h +++ b/core_lib/src/interface/editor.h @@ -120,7 +120,6 @@ class Editor : public QObject void changeThinLinesButton(bool); void currentFrameChanged(int n); - void aboutToChangeFrame(int oldFrame); void needSave(); void needDisplayInfo(const QString& title, const QString& body); From 331edbc761f24b31485ec2e34bf7f93c5c243860 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sun, 10 Nov 2019 09:48:21 +0100 Subject: [PATCH 16/19] Refactor getKeyFrame --- app/src/framecommentwidget.cpp | 9 +++++---- app/src/framecommentwidget.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index f92e6c1f1a..7a1a4d2fa4 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -109,7 +109,7 @@ void FrameCommentWidget::updateConnections() void FrameCommentWidget::fillComments() { - KeyFrame* keyframe = getKeyFrame(mEditor->currentFrame()); + KeyFrame* keyframe = getKeyFrame(); if (keyframe == nullptr) { return; } ui->textEditDialogue->setPlainText(keyframe->getDialogueComment()); @@ -119,7 +119,7 @@ void FrameCommentWidget::fillComments() void FrameCommentWidget::applyComments() { - KeyFrame* keyframe = getKeyFrame(mEditor->currentFrame()); + KeyFrame* keyframe = getKeyFrame(); if (keyframe == nullptr) { return; } keyframe->setDialogueComment(ui->textEditDialogue->toPlainText()); @@ -128,9 +128,10 @@ void FrameCommentWidget::applyComments() mEditor->layers()->currentLayer()->setModified(keyframe->pos(), true); } -KeyFrame* FrameCommentWidget::getKeyFrame(int frame) +KeyFrame* FrameCommentWidget::getKeyFrame() { - Layer* layer = mEditor->layers()->currentLayer(); + const int frame = mEditor->currentFrame(); + const Layer* layer = mEditor->layers()->currentLayer(); KeyFrame* keyframe = layer->getKeyFrameAt(frame); if (keyframe == nullptr) keyframe = layer->getKeyFrameAt(layer->getPreviousFrameNumber(frame, true)); diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index 7d0a94b97e..e5a8e070a2 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -43,7 +43,7 @@ class FrameCommentWidget : public BaseDockWidget void playStateChanged(bool isPlaying); - KeyFrame* getKeyFrame(int frame); + KeyFrame* getKeyFrame(); void makeConnections(); void disconnectNotifiers(); From c8a27baa19441d3c74557836827507e874bf8f75 Mon Sep 17 00:00:00 2001 From: CandyFace Date: Sun, 10 Nov 2019 11:41:53 +0100 Subject: [PATCH 17/19] Apply comments per keystroke Too many problems were discovered with the previous methods, let's keep it simple and try saving per keystroke... then we can optimize later if needed. --- app/app.pro | 2 -- app/src/framecommentwidget.cpp | 32 +++++++++++++++++--------------- app/src/keyframetextedit.cpp | 22 ---------------------- app/src/keyframetextedit.h | 21 --------------------- app/ui/framecommentwidget.ui | 13 +++---------- 5 files changed, 20 insertions(+), 70 deletions(-) delete mode 100644 app/src/keyframetextedit.cpp delete mode 100644 app/src/keyframetextedit.h diff --git a/app/app.pro b/app/app.pro index 04ac3dbab6..d1a9e2c172 100644 --- a/app/app.pro +++ b/app/app.pro @@ -39,7 +39,6 @@ INCLUDEPATH += \ HEADERS += \ src/importlayersdialog.h \ - src/keyframetextedit.h \ src/mainwindow2.h \ src/predefinedsetmodel.h \ src/pegbaralignmentdialog.h \ @@ -73,7 +72,6 @@ HEADERS += \ SOURCES += \ src/importlayersdialog.cpp \ - src/keyframetextedit.cpp \ src/main.cpp \ src/mainwindow2.cpp \ src/predefinedsetmodel.cpp \ diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index 7a1a4d2fa4..be9573ae7e 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -6,7 +6,6 @@ #include "layermanager.h" #include "playbackmanager.h" -#include "keyframetextedit.h" FrameCommentWidget::FrameCommentWidget(QWidget *parent) : BaseDockWidget(parent) @@ -32,7 +31,6 @@ void FrameCommentWidget::initUI() void FrameCommentWidget::updateUI() { - } void FrameCommentWidget::setCore(Editor *editor) @@ -62,7 +60,7 @@ void FrameCommentWidget::currentFrameChanged(int frame) { if (!mIsPlaying) { - if (mEditor->layers()->currentLayer()->firstKeyFramePosition() <= frame) + if (frame >= mEditor->layers()->currentLayer()->firstKeyFramePosition()) { fillComments(); } @@ -112,6 +110,10 @@ void FrameCommentWidget::fillComments() KeyFrame* keyframe = getKeyFrame(); if (keyframe == nullptr) { return; } + QSignalBlocker b(ui->textEditDialogue); + QSignalBlocker b2(ui->textEditAction); + QSignalBlocker b3(ui->textEditSlug); + ui->textEditDialogue->setPlainText(keyframe->getDialogueComment()); ui->textEditAction->setPlainText(keyframe->getActionComment()); ui->textEditSlug->setPlainText(keyframe->getSlugComment()); @@ -142,14 +144,14 @@ KeyFrame* FrameCommentWidget::getKeyFrame() void FrameCommentWidget::makeConnections() { - connect(ui->textEditDialogue, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); - connect(ui->textEditAction, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - connect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); + connect(ui->textEditDialogue, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + connect(ui->textEditAction, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + connect(ui->textEditSlug, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); connect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - connect(ui->textEditSlug, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); - connect(ui->textEditAction, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); - connect(ui->textEditDialogue, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); + connect(ui->textEditSlug, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments); + connect(ui->textEditAction, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments); + connect(ui->textEditDialogue, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments); connect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); @@ -159,14 +161,14 @@ void FrameCommentWidget::makeConnections() void FrameCommentWidget::disconnectNotifiers() { - disconnect(ui->textEditDialogue, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); - disconnect(ui->textEditAction, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); - disconnect(ui->textEditSlug, &KeyFrameTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); + disconnect(ui->textEditDialogue, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::dialogueTextChanged); + disconnect(ui->textEditAction, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::actionTextChanged); + disconnect(ui->textEditSlug, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::slugTextChanged); disconnect(ui->btnClearFields, &QPushButton::clicked, this, &FrameCommentWidget::clearFrameCommentsFields); - disconnect(ui->textEditSlug, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); - disconnect(ui->textEditAction, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); - disconnect(ui->textEditDialogue, &KeyFrameTextEdit::outsideWidget, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditSlug, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditAction, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments); + disconnect(ui->textEditDialogue, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments); disconnect(mEditor, &Editor::currentFrameChanged, this, &FrameCommentWidget::currentFrameChanged); disconnect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged); diff --git a/app/src/keyframetextedit.cpp b/app/src/keyframetextedit.cpp deleted file mode 100644 index c6db47cdaa..0000000000 --- a/app/src/keyframetextedit.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "keyframetextedit.h" - -KeyFrameTextEdit::KeyFrameTextEdit(QWidget* parent) : QPlainTextEdit(parent) { - -} - -void KeyFrameTextEdit::focusOutEvent(QFocusEvent *event) { - - if (event->lostFocus()) { - clearFocus(); - } - QPlainTextEdit::focusOutEvent(event); -} - -bool KeyFrameTextEdit::event(QEvent* event) -{ - if (event->type() == QEvent::Leave) { - emit outsideWidget(); - } - - return QPlainTextEdit::event(event); -} diff --git a/app/src/keyframetextedit.h b/app/src/keyframetextedit.h deleted file mode 100644 index f942d9b447..0000000000 --- a/app/src/keyframetextedit.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef KEYFRAMETEXTEDIT_H -#define KEYFRAMETEXTEDIT_H - -#include - -class KeyFrameTextEdit : public QPlainTextEdit { - - Q_OBJECT -public: - KeyFrameTextEdit(QWidget* parent = nullptr); - -Q_SIGNALS: - void outsideWidget(); - -protected: - void focusOutEvent(QFocusEvent *e) override; - bool event(QEvent* event) override; - -}; - -#endif // KEYFRAMETEXTEDIT_H diff --git a/app/ui/framecommentwidget.ui b/app/ui/framecommentwidget.ui index 89656583f8..a39acb4288 100644 --- a/app/ui/framecommentwidget.ui +++ b/app/ui/framecommentwidget.ui @@ -61,7 +61,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -157,13 +157,6 @@ - - - KeyFrameTextEdit - QPlainTextEdit -
keyframetextedit.h
-
-
From 87323e915eb11cdb774d9b907fb25aa3a3c63dbe Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Sun, 10 Nov 2019 12:37:07 +0100 Subject: [PATCH 18/19] Disable comment fields during playback --- app/src/framecommentwidget.cpp | 19 +++++++++++++++++++ app/src/framecommentwidget.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/app/src/framecommentwidget.cpp b/app/src/framecommentwidget.cpp index be9573ae7e..daa6811dcc 100644 --- a/app/src/framecommentwidget.cpp +++ b/app/src/framecommentwidget.cpp @@ -56,6 +56,20 @@ void FrameCommentWidget::slugTextChanged() ui->labelSlugCounter->setText(tr("%1 chars").arg(QString::number(len))); } +void FrameCommentWidget::enableCommentFields() +{ + ui->textEditDialogue->setEnabled(true); + ui->textEditAction->setEnabled(true); + ui->textEditSlug->setEnabled(true); +} + +void FrameCommentWidget::disableCommentFields() +{ + ui->textEditDialogue->setEnabled(false); + ui->textEditAction->setEnabled(false); + ui->textEditSlug->setEnabled(false); +} + void FrameCommentWidget::currentFrameChanged(int frame) { if (!mIsPlaying) @@ -89,8 +103,13 @@ void FrameCommentWidget::playStateChanged(bool isPlaying) mIsPlaying = isPlaying; if (!mIsPlaying) { + enableCommentFields(); currentFrameChanged(mEditor->currentFrame()); } + else + { + disableCommentFields(); + } } void FrameCommentWidget::updateConnections() diff --git a/app/src/framecommentwidget.h b/app/src/framecommentwidget.h index e5a8e070a2..0f89d9e5f2 100644 --- a/app/src/framecommentwidget.h +++ b/app/src/framecommentwidget.h @@ -34,6 +34,9 @@ class FrameCommentWidget : public BaseDockWidget void actionTextChanged(); void slugTextChanged(); + void enableCommentFields(); + void disableCommentFields(); + void currentFrameChanged(int frame); void currentLayerChanged(int index); From 1da62529a8b6dfdc586fe62828243cbe78c0447e Mon Sep 17 00:00:00 2001 From: David Lamhauge Date: Wed, 6 Apr 2022 19:53:55 +0200 Subject: [PATCH 19/19] Fixed saving comments --- core_lib/src/structure/filemanager.cpp | 73 ++------------------------ 1 file changed, 5 insertions(+), 68 deletions(-) diff --git a/core_lib/src/structure/filemanager.cpp b/core_lib/src/structure/filemanager.cpp index 340eec04e6..6c426f13b3 100644 --- a/core_lib/src/structure/filemanager.cpp +++ b/core_lib/src/structure/filemanager.cpp @@ -312,76 +312,9 @@ Status FileManager::save(const Object* object, const QString& sFileName) Status stPalette = writePalette(object, sDataFolder, filesToZip); dd.collect(stPalette.details()); -/* -<<<<<<< HEAD - bool saveLayersOK = true; - for (int i = 0; i < numLayers; ++i) - { - Layer* layer = object->getLayer(i); - dd << QString("Layer[%1] = [id=%2, name=%3, type=%4]").arg(i).arg(layer->id()).arg(layer->name()).arg(layer->type()); - - Status st = layer->save(sDataFolder, zippedFiles, [this] { progressForward(); }); - if (!st.ok()) - { - saveLayersOK = false; - dd.collect(st.details()); - dd << QString(" !! Failed to save Layer[%1] %2").arg(i).arg(layer->name()); - } - } - dd << "All Layers saved"; - - // save palette - QString sPaletteFile = object->savePalette(sDataFolder); - if (!sPaletteFile.isEmpty()) - zippedFiles.append(sPaletteFile); - else - dd << "Failed to save the palette xml"; - - progressForward(); - - // -------- save main XML file ----------- - QFile file(sMainXMLFile); - if (!file.open(QFile::WriteOnly | QFile::Text)) - { - return Status(Status::ERROR_FILE_CANNOT_OPEN, dd); - } - - QDomDocument xmlDoc("PencilDocument"); - QDomElement root = xmlDoc.createElement("document"); - QDomProcessingInstruction encoding = xmlDoc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); - xmlDoc.appendChild(encoding); - xmlDoc.appendChild(root); - - progressForward(); - - // save editor information - QDomElement projDataXml = saveProjectData(object->data(), xmlDoc); - root.appendChild(projDataXml); - - // save object - QDomElement objectElement = object->saveXML(xmlDoc); - root.appendChild(objectElement); - - // save comment information - QDomElement frameComments = saveFrameComments(object, xmlDoc); - root.appendChild(frameComments); - - dd << "Writing main xml file..."; - - const int indentSize = 2; - - QTextStream out(&file); - xmlDoc.save(out, indentSize); - out.flush(); - file.close(); - - dd << "Done writing main xml file at" << sMainXMLFile; - - zippedFiles.append(sMainXMLFile); -======= */ const bool saveOk = stKeyFrames.ok() && stMainXml.ok() && stPalette.ok(); -//>>>>>>> master + // save comment information progressForward(); @@ -795,6 +728,10 @@ Status FileManager::writeMainXml(const Object* object, const QString& mainXmlPat QDomElement objectElement = object->saveXML(xmlDoc); root.appendChild(objectElement); + // save comment information + QDomElement frameComments = saveFrameComments(object, xmlDoc); + root.appendChild(frameComments); + // save Pencil2D version QDomElement versionElem = xmlDoc.createElement("version"); versionElem.appendChild(xmlDoc.createTextNode(QString(APP_VERSION)));