Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d43eff2
Comment dockable added. Basic connects added
davidlamhauge Nov 2, 2019
cccf4f9
Comments saved on keyframe. Minor ui changes
davidlamhauge Nov 2, 2019
635dfdd
save and load xml works
davidlamhauge Nov 5, 2019
3fc602f
Fixed update error, and start char values
davidlamhauge Nov 5, 2019
8b490c0
Limit raised to 250 chars. whole keyframe exp can be used
davidlamhauge Nov 6, 2019
778ce5b
Deleted two irrelevant files
davidlamhauge Nov 8, 2019
c30f8ea
Simplify UI
MrStevns Nov 9, 2019
4293464
Fix memory issues caused by accessing values that no longer exists.
MrStevns Nov 9, 2019
e57d784
No need to hide dock, can simply remove the widget by default
MrStevns Nov 9, 2019
cbd0c25
Refactor load/save comments in filemanager
MrStevns Nov 9, 2019
561fb98
Add forgotten nullptr check
MrStevns Nov 9, 2019
ec81770
Merge pull request #10 from CandyFace/PR_1292_changes
davidlamhauge Nov 9, 2019
4bda3b9
Make sure frame is updated when changing layer
MrStevns Nov 9, 2019
c04e5f4
Clear focus on FocusOutEvent
MrStevns Nov 9, 2019
3b53ea1
Merge branch 'master' into issue1288_comments_to_frames
davidlamhauge Nov 9, 2019
5ae84ed
Remove no longer valid function
MrStevns Nov 10, 2019
1590477
Apply comments when leaving widget, out of focus is too late
MrStevns Nov 10, 2019
331edbc
Refactor getKeyFrame
MrStevns Nov 10, 2019
c8a27ba
Apply comments per keystroke
MrStevns Nov 10, 2019
ebe6a95
Merge branch 'issue1288_comments_to_frames' into PR_1292_changes
candyface Nov 10, 2019
1bc46ce
Merge pull request #11 from CandyFace/PR_1292_changes
davidlamhauge Nov 10, 2019
87323e9
Disable comment fields during playback
davidlamhauge Nov 10, 2019
b529f44
merge conflicts with Master solved
davidlamhauge Jan 17, 2020
1033c24
Solved most merge conflicts with master. Not saving comments!
davidlamhauge Apr 6, 2022
1da6252
Fixed saving comments
davidlamhauge Apr 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ HEADERS += \
src/doubleprogressdialog.h \
src/colorslider.h \
src/checkupdatesdialog.h \
src/framecommentwidget.h \
src/presetdialog.h \
src/commandlineparser.h \
src/commandlineexporter.h \
Expand Down Expand Up @@ -150,6 +151,7 @@ SOURCES += \
src/doubleprogressdialog.cpp \
src/colorslider.cpp \
src/checkupdatesdialog.cpp \
src/framecommentwidget.cpp \
src/presetdialog.cpp \
src/app_util.cpp \
src/commandlineparser.cpp \
Expand Down Expand Up @@ -185,6 +187,7 @@ FORMS += \
ui/filespage.ui \
ui/toolspage.ui \
ui/toolboxwidget.ui \
ui/framecommentwidget.ui \
ui/presetdialog.ui

GIT {
Expand Down
196 changes: 196 additions & 0 deletions app/src/framecommentwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
#include "framecommentwidget.h"
#include "ui_framecommentwidget.h"

#include "editor.h"
#include "keyframe.h"

#include "layermanager.h"
#include "playbackmanager.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(this, &FrameCommentWidget::visibilityChanged, this, &FrameCommentWidget::updateConnections);
updateConnections();
}

void FrameCommentWidget::updateUI()
{
}

void FrameCommentWidget::setCore(Editor *editor)
{
mEditor = editor;
}

void FrameCommentWidget::dialogueTextChanged()
{
int len = ui->textEditDialogue->toPlainText().length();
ui->labelDialogueCounter->setText(tr("%1 chars").arg(QString::number(len)));
}

void FrameCommentWidget::actionTextChanged()
{
int len = ui->textEditAction->toPlainText().length();
ui->labelActionCounter->setText(tr("%1 chars").arg(QString::number(len)));
}

void FrameCommentWidget::slugTextChanged()
{
int len = ui->textEditSlug->toPlainText().length();
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)
{
if (frame >= mEditor->layers()->currentLayer()->firstKeyFramePosition())
{
fillComments();
}
else
{
clearFrameCommentsFields();
}
}
}

void FrameCommentWidget::currentLayerChanged(int index)
{
Q_UNUSED(index)
currentFrameChanged(mEditor->currentFrame());
}

void FrameCommentWidget::clearFrameCommentsFields()
{
ui->textEditDialogue->clear();
ui->textEditAction->clear();
ui->textEditSlug->clear();
}

void FrameCommentWidget::playStateChanged(bool isPlaying)
{
mIsPlaying = isPlaying;
if (!mIsPlaying)
{
enableCommentFields();
currentFrameChanged(mEditor->currentFrame());
}
else
{
disableCommentFields();
}
}

void FrameCommentWidget::updateConnections()
{
if (!isVisible())
{
disconnectNotifiers();
}
else
{
makeConnections();
}
}

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());
}

void FrameCommentWidget::applyComments()
{
KeyFrame* keyframe = getKeyFrame();
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);
}

KeyFrame* FrameCommentWidget::getKeyFrame()
{
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));
if (keyframe == nullptr) { return nullptr; }

return keyframe;
}

void FrameCommentWidget::makeConnections()
{
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, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments);
connect(ui->textEditAction, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments);
connect(ui->textEditDialogue, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments);

connect(mEditor, &Editor::scrubbed, 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);
}

void FrameCommentWidget::disconnectNotifiers()
{
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, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments);
disconnect(ui->textEditAction, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments);
disconnect(ui->textEditDialogue, &QPlainTextEdit::textChanged, this, &FrameCommentWidget::applyComments);

disconnect(mEditor, &Editor::scrubbed, this, &FrameCommentWidget::currentFrameChanged);
disconnect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &FrameCommentWidget::currentLayerChanged);
disconnect(mEditor, &Editor::objectLoaded, this, &FrameCommentWidget::fillComments);
disconnect(mEditor->playback(), &PlaybackManager::playStateChanged, this, &FrameCommentWidget::playStateChanged);
}
59 changes: 59 additions & 0 deletions app/src/framecommentwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef FRAMECOMMENTWIDGET_H
#define FRAMECOMMENTWIDGET_H

#include <QWidget>
#include "basedockwidget.h"

class Editor;
class KeyFrame;
class Layer;

namespace Ui {
class FrameComment;
}

class FrameCommentWidget : public BaseDockWidget
{
Q_OBJECT

public:
explicit FrameCommentWidget(QWidget *parent = nullptr);
~FrameCommentWidget() override;

void initUI() override;
void updateUI() override;
void setCore(Editor* editor);

void applyComments();
void fillComments();

private:
Ui::FrameComment *ui;

void dialogueTextChanged();
void actionTextChanged();
void slugTextChanged();

void enableCommentFields();
void disableCommentFields();

void currentFrameChanged(int frame);
void currentLayerChanged(int index);

void clearFrameCommentsFields();

void updateConnections();

void playStateChanged(bool isPlaying);

KeyFrame* getKeyFrame();

void makeConnections();
void disconnectNotifiers();

bool mIsPlaying = false;

Editor* mEditor = nullptr;
};

#endif // FRAMECOMMENTWIDGET_H
8 changes: 8 additions & 0 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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"
Expand Down Expand Up @@ -160,6 +161,10 @@ void MainWindow2::createDockWidgets()
mDisplayOptionWidget = new DisplayOptionWidget(this);
mDisplayOptionWidget->setObjectName("DisplayOption");

mFrameComments = new FrameCommentWidget(this);
mFrameComments->setObjectName("FrameComments");
mFrameComments->setCore(mEditor);

mOnionSkinWidget = new OnionSkinWidget(this);
mOnionSkinWidget->setObjectName("Onion Skin");

Expand All @@ -181,6 +186,7 @@ void MainWindow2::createDockWidgets()
<< mColorInspector
<< mColorPalette
<< mDisplayOptionWidget
<< mFrameComments
<< mOnionSkinWidget
<< mToolOptions
<< mToolBox;
Expand Down Expand Up @@ -208,6 +214,7 @@ void MainWindow2::createDockWidgets()
addDockWidget(Qt::LeftDockWidgetArea, mDisplayOptionWidget);
addDockWidget(Qt::LeftDockWidgetArea, mOnionSkinWidget);
addDockWidget(Qt::BottomDockWidgetArea, mTimeLine);

setDockNestingEnabled(true);

/*
Expand Down Expand Up @@ -389,6 +396,7 @@ void MainWindow2::createMenus()
mTimeLine->toggleViewAction(),
mDisplayOptionWidget->toggleViewAction(),
mColorInspector->toggleViewAction(),
mFrameComments->toggleViewAction(),
mOnionSkinWidget->toggleViewAction()
};

Expand Down
2 changes: 2 additions & 0 deletions app/src/mainwindow2.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ScribbleArea;
class BaseDockWidget;
class ColorPaletteWidget;
class DisplayOptionWidget;
class FrameCommentWidget;
class OnionSkinWidget;
class ToolOptionWidget;
class TimeLine;
Expand Down Expand Up @@ -155,6 +156,7 @@ private slots:
ColorBox* mColorBox = nullptr;
ColorPaletteWidget* mColorPalette = nullptr;
DisplayOptionWidget* mDisplayOptionWidget = nullptr;
FrameCommentWidget* mFrameComments = nullptr;
ToolOptionWidget* mToolOptions = nullptr;
ToolBoxWidget* mToolBox = nullptr;
//Timeline2* mTimeline2 = nullptr;
Expand Down
Loading