tdf#130857 qt weld: Hide widget marked for deletion
Add a helper method QtBuilder::deleteObject that takes care of marking no longer needed objects for deletion and use it in the 3 places so far calling QObject::deleteLater themselves. If the object marked for deletion is a widget, hide it as well, as it could otherwise still be "in the way". This was seen wit the edit (QLineEdit) of the editable combobox in the "File" -> "Properties" dialog, "General" tab (in a WIP branch for adding support for that dialog), where the unnecessary edit was shown on top of the combobox, hiding the combobox content + dropdown button. Change-Id: Ie299b80824c94d40cfac9f7962c9bd4ba95b446d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177057 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
This commit is contained in:
parent
3e65d085ef
commit
df39550839
2 changed files with 11 additions and 4 deletions
|
@ -84,6 +84,7 @@ public:
|
|||
virtual void set_response(std::u16string_view sID, short nResponse) override;
|
||||
|
||||
private:
|
||||
static void deleteObject(QObject* pObject);
|
||||
void setProperties(QObject* obj, stringmap& rProps);
|
||||
static void setLabelProperties(QLabel& rLabel, stringmap& rProps);
|
||||
void setSpinButtonProperties(QDoubleSpinBox& rSpinBox, stringmap& rProps);
|
||||
|
|
|
@ -348,7 +348,7 @@ void QtBuilder::tweakInsertedChild(QObject* pParent, QObject* pCurrentChild, std
|
|||
// an editable GtkComboBox has an internal GtkEntry child,
|
||||
// but QComboBox doesn't need a separate widget for it, so
|
||||
// delete it
|
||||
pCurrentChild->deleteLater();
|
||||
deleteObject(pCurrentChild);
|
||||
}
|
||||
|
||||
if (sType == "label")
|
||||
|
@ -362,8 +362,7 @@ void QtBuilder::tweakInsertedChild(QObject* pParent, QObject* pCurrentChild, std
|
|||
// For QGroupBox, the title can be set directly. Therefore, take over the
|
||||
// title from the label and delete the separate label widget again
|
||||
pGroupBox->setTitle(pLabel->text());
|
||||
pLabel->setParent(nullptr);
|
||||
pLabel->deleteLater();
|
||||
deleteObject(pLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,6 +525,13 @@ void QtBuilder::set_response(std::u16string_view sID, short nResponse)
|
|||
pPushButton->setProperty(QtInstanceMessageDialog::PROPERTY_VCL_RESPONSE_CODE, int(nResponse));
|
||||
}
|
||||
|
||||
void QtBuilder::deleteObject(QObject* pObject)
|
||||
{
|
||||
if (pObject->isWidgetType())
|
||||
static_cast<QWidget*>(pObject)->hide();
|
||||
pObject->deleteLater();
|
||||
}
|
||||
|
||||
void QtBuilder::setProperties(QObject* pObject, stringmap& rProps)
|
||||
{
|
||||
if (QMessageBox* pMessageBox = qobject_cast<QMessageBox*>(pObject))
|
||||
|
@ -604,7 +610,7 @@ void QtBuilder::setProperties(QObject* pObject, stringmap& rProps)
|
|||
// parentless GtkImage in .ui file is only used for setting button
|
||||
// image, so the object is no longer needed after doing so
|
||||
if (!pImageLabel->parent())
|
||||
pImageLabel->deleteLater();
|
||||
deleteObject(pImageLabel);
|
||||
}
|
||||
else if (rKey == u"label")
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue