Skip to content

Commit

Permalink
Add a small delay before updating the qml preview
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and lbartoletti committed Jan 10, 2025
1 parent c0b65b0 commit 0352f51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gui/vector/qgsattributesformproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,14 +1390,15 @@ void QgsAttributesDnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int colum

//qmlCode
QgsCodeEditor *qmlCode = new QgsCodeEditor( this );
qmlCode->setEditingTimeoutInterval( 250 );
qmlCode->setText( itemData.qmlElementEditorConfiguration().qmlCode );

QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
QgsFeature previewFeature;
mLayer->getFeatures().nextFeature( previewFeature );

//update preview on text change
connect( qmlCode, &QsciScintilla::textChanged, this, [=] {
connect( qmlCode, &QgsCodeEditor::editingTimeout, this, [=] {
qmlWrapper->setQmlCode( qmlCode->text() );
qmlWrapper->reinitWidget();
qmlWrapper->setFeature( previewFeature );
Expand Down Expand Up @@ -1532,7 +1533,7 @@ void QgsAttributesDnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int colum
qmlPreviewBox->setMinimumWidth( 200 );
qmlPreviewBox->setWidget( qmlWrapper->widget() );
//emit to load preview for the first time
emit qmlCode->textChanged();
emit qmlCode->editingTimeout();
qmlSplitter->addWidget( qmlPreviewBox );
qmlSplitter->setChildrenCollapsible( false );
qmlSplitter->setHandleWidth( 6 );
Expand Down

0 comments on commit 0352f51

Please sign in to comment.