forked from qt-creator/qt-creator
QmlDesigner: Disable Timeview and CurveEditorView when widget is invisble
Task-number: QDS-5159 Change-Id: Ibae0b9742d4aaac6a1def1c84342a031baf75256 Reviewed-by: Knud Dollereder <knud.dollereder@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -81,6 +81,18 @@ void CurveEditor::clearCanvas()
|
||||
m_view->reset({});
|
||||
}
|
||||
|
||||
void CurveEditor::showEvent(QShowEvent *event)
|
||||
{
|
||||
emit viewEnabledChanged(true);
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void CurveEditor::hideEvent(QHideEvent *event)
|
||||
{
|
||||
emit viewEnabledChanged(false);
|
||||
QWidget::hideEvent(event);
|
||||
}
|
||||
|
||||
QToolBar *CurveEditor::createToolBar(CurveEditorModel *model)
|
||||
{
|
||||
auto *bar = new QToolBar;
|
||||
|
@@ -49,6 +49,13 @@ public:
|
||||
|
||||
void clearCanvas();
|
||||
|
||||
signals:
|
||||
void viewEnabledChanged(const bool);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
|
||||
private:
|
||||
QToolBar *createToolBar(CurveEditorModel *model);
|
||||
|
||||
|
@@ -51,6 +51,13 @@ CurveEditorView::CurveEditorView(QObject *parent)
|
||||
connect(m_model, &CurveEditorModel::commitStartFrame, this, &CurveEditorView::commitStartFrame);
|
||||
connect(m_model, &CurveEditorModel::commitEndFrame, this, &CurveEditorView::commitEndFrame);
|
||||
connect(m_model, &CurveEditorModel::curveChanged, this, &CurveEditorView::commitKeyframes);
|
||||
|
||||
connect(m_editor, &CurveEditor::viewEnabledChanged, this, [this](bool enabled){
|
||||
setEnabled(enabled);
|
||||
if (enabled)
|
||||
init();
|
||||
});
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
CurveEditorView::~CurveEditorView() {}
|
||||
@@ -70,10 +77,8 @@ void CurveEditorView::modelAttached(Model *model)
|
||||
{
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
QmlTimeline timeline = activeTimeline();
|
||||
if (timeline.isValid()) {
|
||||
m_model->setTimeline(timeline);
|
||||
}
|
||||
if (isEnabled())
|
||||
init();
|
||||
}
|
||||
|
||||
void CurveEditorView::modelAboutToBeDetached(Model *model)
|
||||
@@ -389,4 +394,13 @@ void CurveEditorView::commitEndFrame(int frame)
|
||||
timeline.modelNode().variantProperty("endFrame").setValue(frame);
|
||||
}
|
||||
|
||||
void CurveEditorView::init()
|
||||
{
|
||||
QmlTimeline timeline = activeTimeline();
|
||||
if (timeline.isValid()) {
|
||||
m_model->setTimeline(timeline);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -85,6 +85,7 @@ private:
|
||||
void commitCurrentFrame(int frame);
|
||||
void commitStartFrame(int frame);
|
||||
void commitEndFrame(int frame);
|
||||
void init();
|
||||
|
||||
private:
|
||||
bool m_block;
|
||||
|
@@ -71,6 +71,7 @@ TimelineView::TimelineView(QObject *parent)
|
||||
, m_timelineWidget(nullptr)
|
||||
{
|
||||
EasingCurve::registerStreamOperators();
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
TimelineView::~TimelineView() = default;
|
||||
|
@@ -606,13 +606,7 @@ void TimelineWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
/*
|
||||
m_timelineView->setEnabled(true);
|
||||
TODO See QDS-4191
|
||||
*/
|
||||
|
||||
if (m_timelineView->model())
|
||||
init();
|
||||
|
||||
graphicsScene()->setWidth(m_graphicsView->viewport()->width());
|
||||
graphicsScene()->invalidateLayout();
|
||||
@@ -620,6 +614,10 @@ void TimelineWidget::showEvent(QShowEvent *event)
|
||||
graphicsScene()->onShow();
|
||||
|
||||
QWidget::showEvent(event);
|
||||
|
||||
//All the events have to be fully processed before we call init()
|
||||
if (m_timelineView->model())
|
||||
QTimer::singleShot(0, [this]() { init(); });
|
||||
}
|
||||
|
||||
void TimelineWidget::resizeEvent(QResizeEvent *event)
|
||||
@@ -630,7 +628,7 @@ void TimelineWidget::resizeEvent(QResizeEvent *event)
|
||||
|
||||
void TimelineWidget::hideEvent(QHideEvent *event)
|
||||
{
|
||||
/* m_timelineView->setEnabled(false); TODO See QDS-4191 */
|
||||
m_timelineView->setEnabled(false);
|
||||
QWidget::hideEvent(event);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user