Skip to content

Commit

Permalink
Backport bottom right resizer fix to bottom / right resizers.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <[email protected]>
  • Loading branch information
cneben committed Dec 8, 2023
1 parent 0dc98e8 commit 7b15ebf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/qanBottomResizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,12 @@ void BottomResizer::mouseMoveEvent(QMouseEvent* event)
if (_target != nullptr) {
const qreal targetHeight = _targetInitialSize.height() + delta.y();

const auto targetContentMinHeight = _targetContent ? _targetContent->childrenRect().y() + _targetContent->childrenRect().height() : 0;
auto childrenRect = _targetContent->childrenRect();
if (childrenRect.size().isEmpty()) // Note 20231208: Fix a nasty bug (Qt 5.15.13 ?) where size() is empty when there
childrenRect = QRectF{}; // is no longer any childs but rect position is left with invalid value.
const auto targetContentMinHeight = _targetContent ? childrenRect.y() + childrenRect.height() : 0;
const auto minimumTargetHeight = qMax(_minimumTargetSize.height(), targetContentMinHeight);
const auto targetContentMinWidth = _targetContent ? _targetContent->childrenRect().x() + _targetContent->childrenRect().width() : 0;
const auto targetContentMinWidth = _targetContent ? childrenRect.x() + childrenRect.width() : 0;
const auto minimumTargetWidth = qMax(_minimumTargetSize.width(), targetContentMinWidth);

if (targetHeight > minimumTargetHeight) { // Do not resize below minimumTargetSize
Expand Down
1 change: 0 additions & 1 deletion src/qanBottomRightResizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ void BottomRightResizer::mouseMoveEvent(QMouseEvent* event)
_target->setHeight(targetHeight);
} else {
const qreal targetHeight = _targetInitialSize.height() + delta.y();
qWarning() << "targetHeight=" << targetHeight;
if (targetHeight > minimumTargetHeight)
_target->setHeight(targetHeight);
}
Expand Down
5 changes: 4 additions & 1 deletion src/qanRightResizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ void RightResizer::mouseMoveEvent(QMouseEvent* event)
// Do not resize below minimumSize
const qreal targetWidth = _targetInitialSize.width() + delta.x();

const auto targetContentMinWidth = _targetContent ? _targetContent->childrenRect().x() + _targetContent->childrenRect().width() : 0;
auto childrenRect = _targetContent->childrenRect();
if (childrenRect.size().isEmpty()) // Note 20231208: Fix a nasty bug (Qt 5.15.13 ?) where size() is empty when there
childrenRect = QRectF{}; // is no longer any childs but rect position is left with invalid value.
const auto targetContentMinWidth = _targetContent ? childrenRect.x() + childrenRect.width() : 0;
const auto minimumTargetWidth = qMax(_minimumTargetSize.width(), targetContentMinWidth);

if (targetWidth > minimumTargetWidth) {
Expand Down

0 comments on commit 7b15ebf

Please sign in to comment.