Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markers fixes and polish #336

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/core/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ void Canvas::setMarker(const QString &title,
void Canvas::setMarker(const int frame)
{
setMarker(QString::number(mMarkers.size()), frame);
emit markersChanged();
}

void Canvas::setMarkerEnabled(const int frame,
Expand Down Expand Up @@ -551,6 +552,7 @@ void Canvas::moveMarkerFrame(const int markerFrame,
if (index >= 0) {
mMarkers.at(index).frame = newFrame;
emit newFrameRange(mRange);
emit markersChanged();
}
}

Expand Down Expand Up @@ -578,6 +580,7 @@ const std::vector<FrameMarker> Canvas::getMarkers()
void Canvas::clearMarkers()
{
mMarkers.clear();
emit markersChanged();
emit requestUpdate();
}

Expand Down
1 change: 1 addition & 0 deletions src/core/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ class CORE_EXPORT Canvas : public CanvasBase
void openApplyExpressionDialog(QrealAnimator* const target);
void currentPickedColor(const QColor &color);
void currentHoverColor(const QColor &color);
void markersChanged();

public:
void makePointCtrlsSymmetric();
Expand Down
14 changes: 13 additions & 1 deletion src/ui/widgets/markereditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ MarkerEditor::MarkerEditor(Canvas *scene,
lay->addWidget(mTree);
setup();
populate();

if (mScene) {
connect(mScene, &Canvas::markersChanged, this, &MarkerEditor::populate);
}
}

void MarkerEditor::setup()
Expand Down Expand Up @@ -80,11 +84,19 @@ void MarkerEditor::setup()

connect(addButton, &QPushButton::clicked,
this, [this]() {
auto item = new QTreeWidgetItem(mTree);
const int frame = mScene ? mScene->getCurrentFrame() : 0;
for (int i = 0; i < mTree->topLevelItemCount(); ++i) {
auto existingItem = mTree->topLevelItem(i);
if (existingItem && existingItem->data(0, Qt::UserRole).toInt() == frame) {
return;
}
}
auto item = new QTreeWidgetItem(mTree);
mTree->blockSignals(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why block?

item->setText(1, QString::number(frame));
item->setText(0, QString::number(frame));
item->setData(0, Qt::UserRole, frame);
mTree->blockSignals(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does nothing? the block is removed before anything happens in mTree.

Copy link
Author

@pgilfernandez pgilfernandez Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that I commented that:

if you have a marker in frame 0 and add a new one at any other frame with the "+" button of the Marker Editor, it deletes any marker created at frame 0...".

My research found that when creating a new row in the Markers Editor window, it launches too the itemChanged function, taking the current oframeand frame values that at that point are both just initialized with value 0 and ending up with deleting the marker at frame 0.
Blocking the signals for line 96, 97 and 98 ensures there is not update in that range but later when oframe and frame really take the values of the current "time line" position and the rest works as expected.

item->setCheckState(0, Qt::Checked);
item->setFlags(item->flags() | Qt::ItemIsEditable);
mTree->addTopLevelItem(item);
Expand Down
Loading