forked from qt-creator/qt-creator
QmlDesigner: Shorten life time of AnimationCurveDialog
The AnimationCurveDialog is now always deleted when closed. This ensures that Qt Creator is shut down properly. Task-number: QDS-1525 Change-Id: I8630648e1d558bb9ed9823756c99fbbf38f8e353 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
c7d8b9b01c
commit
c0637b8283
@@ -104,10 +104,8 @@ QAction *createAction(const Core::Id &id,
|
||||
TimelineToolBar::TimelineToolBar(QWidget *parent)
|
||||
: QToolBar(parent)
|
||||
, m_grp()
|
||||
, m_dialog(Core::ICore::dialogParent())
|
||||
, m_curveModel(new AnimationCurveEditorModel(0., 500.))
|
||||
{
|
||||
m_dialog.setModel(m_curveModel);
|
||||
connect(m_curveModel,
|
||||
&AnimationCurveEditorModel::currentFrameChanged,
|
||||
this,
|
||||
@@ -128,6 +126,7 @@ void TimelineToolBar::reset()
|
||||
if (recording())
|
||||
m_recording->setChecked(false);
|
||||
|
||||
if (m_animatioCurveDialog)
|
||||
m_curveModel->reset({});
|
||||
}
|
||||
|
||||
@@ -173,6 +172,7 @@ void TimelineToolBar::setCurrentTimeline(const QmlTimeline &timeline)
|
||||
setStartFrame(timeline.startKeyframe());
|
||||
setEndFrame(timeline.endKeyframe());
|
||||
m_timelineLabel->setText(timeline.modelNode().id());
|
||||
if (m_animatioCurveDialog)
|
||||
m_curveModel->setTimeline(timeline);
|
||||
} else {
|
||||
m_timelineLabel->setText("");
|
||||
@@ -181,6 +181,7 @@ void TimelineToolBar::setCurrentTimeline(const QmlTimeline &timeline)
|
||||
|
||||
void TimelineToolBar::setStartFrame(qreal frame)
|
||||
{
|
||||
if (m_animatioCurveDialog)
|
||||
m_curveModel->setMinimumTime(frame);
|
||||
|
||||
auto text = QString::number(frame, 'f', 0);
|
||||
@@ -190,6 +191,7 @@ void TimelineToolBar::setStartFrame(qreal frame)
|
||||
|
||||
void TimelineToolBar::setCurrentFrame(qreal frame)
|
||||
{
|
||||
if (m_animatioCurveDialog)
|
||||
m_curveModel->setCurrentFrame(std::round(frame));
|
||||
|
||||
auto text = QString::number(frame, 'f', 0);
|
||||
@@ -198,6 +200,7 @@ void TimelineToolBar::setCurrentFrame(qreal frame)
|
||||
|
||||
void TimelineToolBar::setEndFrame(qreal frame)
|
||||
{
|
||||
if (m_animatioCurveDialog)
|
||||
m_curveModel->setMaximumTime(frame);
|
||||
|
||||
auto text = QString::number(frame, 'f', 0);
|
||||
@@ -232,9 +235,10 @@ void TimelineToolBar::openAnimationCurveEditor()
|
||||
timeline = tlv->timelineForState(tlv->currentState());
|
||||
}
|
||||
|
||||
m_dialog.refresh();
|
||||
ensureAnimationCurveDialog();
|
||||
m_animatioCurveDialog->refresh();
|
||||
m_curveModel->setTimeline(timeline);
|
||||
m_dialog.show();
|
||||
m_animatioCurveDialog->show();
|
||||
}
|
||||
|
||||
void TimelineToolBar::updateCurve(DesignTools::PropertyTreeItem *item)
|
||||
@@ -501,6 +505,15 @@ void TimelineToolBar::setupCurrentFrameValidator()
|
||||
m_lastFrame->text().toInt());
|
||||
}
|
||||
|
||||
void TimelineToolBar::ensureAnimationCurveDialog()
|
||||
{
|
||||
if (!m_animatioCurveDialog) {
|
||||
m_animatioCurveDialog = new AnimationCurveDialog(Core::ICore::dialogParent());
|
||||
m_animatioCurveDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_animatioCurveDialog->setModel(m_curveModel);
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineToolBar::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
||||
QT_FORWARD_DECLARE_CLASS(QObject)
|
||||
@@ -102,10 +104,11 @@ private:
|
||||
void createRightControls();
|
||||
void addSpacing(int width);
|
||||
void setupCurrentFrameValidator();
|
||||
void ensureAnimationCurveDialog();
|
||||
|
||||
QList<QObject *> m_grp;
|
||||
|
||||
AnimationCurveDialog m_dialog;
|
||||
QPointer<AnimationCurveDialog> m_animatioCurveDialog;
|
||||
|
||||
AnimationCurveEditorModel *m_curveModel = nullptr;
|
||||
|
||||
|
Reference in New Issue
Block a user