widgets/wrapper: fix margin wrapper reactvity and margins

Fixed reactivity of the paren't actual size not working before child
had been assigned.

Fixed incorrect margins when actual size is less than implicit size.
This commit is contained in:
outfoxxed committed 2024-11-19 02:57:04 -08:00
1 parent 033e810871
commit ee93306312
1 file changed
+11 -4
+11 -4
View File
@@ -20,6 +20,8 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare
}
void MarginWrapperManager::componentComplete() {
this->WrapperManager::componentComplete();
if (this->mWrapper) {
QObject::connect(
this->mWrapper,
@@ -36,8 +38,6 @@ void MarginWrapperManager::componentComplete() {
);
}
this->WrapperManager::componentComplete();
if (!this->mChild) this->updateGeometry();
}
@@ -97,12 +97,19 @@ qreal MarginWrapperManager::targetChildHeight() const {
qreal MarginWrapperManager::targetChildX() const {
if (this->mResizeChild) return this->mMargin;
else return this->mWrapper->width() / 2 - this->mChild->implicitWidth() / 2;
else {
return std::max(this->mMargin, this->mWrapper->width() / 2 - this->mChild->implicitWidth() / 2);
}
}
qreal MarginWrapperManager::targetChildY() const {
if (this->mResizeChild) return this->mMargin;
else return this->mWrapper->height() / 2 - this->mChild->implicitHeight() / 2;
else {
return std::max(
this->mMargin,
this->mWrapper->height() / 2 - this->mChild->implicitHeight() / 2
);
}
}
void MarginWrapperManager::onWrapperWidthChanged() {