forked from qt-creator/qt-creator
Add context-menu to insert a keyframe for all visible curves
Change-Id: If86550bb9b8e73ff22fdbe3c2ffc579c35c505da Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -299,6 +299,13 @@ void GraphicsView::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
QAction *openEditorAction = menu.addAction(tr("Open Style Editor"));
|
QAction *openEditorAction = menu.addAction(tr("Open Style Editor"));
|
||||||
connect(openEditorAction, &QAction::triggered, openStyleEditor);
|
connect(openEditorAction, &QAction::triggered, openStyleEditor);
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
auto insertKeyframes = [this, event]() {
|
||||||
|
insertKeyframe(globalToRaster(event->globalPos()).x(), true);
|
||||||
|
};
|
||||||
|
QAction *insertKeyframeAction = menu.addAction(tr("Insert Keyframe"));
|
||||||
|
connect(insertKeyframeAction, &QAction::triggered, insertKeyframes);
|
||||||
|
|
||||||
menu.exec(event->globalPos());
|
menu.exec(event->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,12 +407,14 @@ void GraphicsView::applyZoom(double x, double y, const QPoint &pivot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::insertKeyframe(double time)
|
void GraphicsView::insertKeyframe(double time, bool allVisibleCurves)
|
||||||
{
|
{
|
||||||
const auto itemList = items();
|
const auto itemList = items();
|
||||||
for (auto *item : itemList) {
|
for (auto *item : itemList) {
|
||||||
if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) {
|
if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) {
|
||||||
if (curveItem->isUnderMouse())
|
if (allVisibleCurves)
|
||||||
|
curveItem->insertKeyframeByTime(std::round(time));
|
||||||
|
else if (curveItem->isUnderMouse())
|
||||||
curveItem->insertKeyframeByTime(std::round(time));
|
curveItem->insertKeyframeByTime(std::round(time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -124,7 +124,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void applyZoom(double x, double y, const QPoint &pivot = QPoint());
|
void applyZoom(double x, double y, const QPoint &pivot = QPoint());
|
||||||
|
|
||||||
void insertKeyframe(double time);
|
void insertKeyframe(double time, bool allVisibleCurves = false);
|
||||||
|
|
||||||
void deleteSelectedKeyframes();
|
void deleteSelectedKeyframes();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user