Port users of get{Contents,Text}Margins() missed first time around
Done-with: Sona Kurazyan <sona.kurazyan@qt.io> Change-Id: I5b584cbe468429c53c2d661a0d7957d74e7ad691 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
f23f9ba041
commit
4726f47b41
|
|
@ -463,14 +463,13 @@ void tst_QGraphicsProxyWidget::setWidget()
|
|||
QCOMPARE(proxy->focusPolicy(), Qt::WheelFocus);
|
||||
QVERIFY(proxy->acceptDrops());
|
||||
QCOMPARE(proxy->acceptHoverEvents(), true); // to get widget enter events
|
||||
int left, top, right, bottom;
|
||||
widget->getContentsMargins(&left, &top, &right, &bottom);
|
||||
const QMarginsF margins = QMarginsF{widget->contentsMargins()};
|
||||
qreal rleft, rtop, rright, rbottom;
|
||||
proxy->getContentsMargins(&rleft, &rtop, &rright, &rbottom);
|
||||
QCOMPARE((qreal)left, rleft);
|
||||
QCOMPARE((qreal)top, rtop);
|
||||
QCOMPARE((qreal)right, rright);
|
||||
QCOMPARE((qreal)bottom, rbottom);
|
||||
QCOMPARE(margins.left(), rleft);
|
||||
QCOMPARE(margins.top(), rtop);
|
||||
QCOMPARE(margins.right(), rright);
|
||||
QCOMPARE(margins.bottom(), rbottom);
|
||||
} else {
|
||||
// proxy shouldn't mess with the widget if it can't insert it.
|
||||
QCOMPARE(proxy->widget(), nullptr);
|
||||
|
|
|
|||
|
|
@ -2526,9 +2526,8 @@ void tst_QGraphicsView::viewportUpdateMode2()
|
|||
view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||
view.setScene(&dummyScene);
|
||||
view.ensurePolished(); // make sure we get the right content margins
|
||||
int left, top, right, bottom;
|
||||
view.getContentsMargins(&left, &top, &right, &bottom);
|
||||
view.resize(200 + left + right, 200 + top + bottom);
|
||||
const QMargins margins = view.contentsMargins();
|
||||
view.resize(200 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom());
|
||||
toplevel.show();
|
||||
qApp->setActiveWindow(&toplevel);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
|
||||
|
|
@ -4043,9 +4042,8 @@ void tst_QGraphicsView::update()
|
|||
CustomView view(0, &toplevel);
|
||||
view.setScene(&dummyScene);
|
||||
view.ensurePolished(); // must ensure polished to get content margins right
|
||||
int left, top, right, bottom;
|
||||
view.getContentsMargins(&left, &top, &right, &bottom);
|
||||
view.resize(200 + left + right, 200 + top + bottom);
|
||||
const QMargins margins = view.contentsMargins();
|
||||
view.resize(200 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom());
|
||||
toplevel.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
|
||||
|
||||
|
|
|
|||
|
|
@ -3530,6 +3530,13 @@ void tst_QLineEdit::textMargin()
|
|||
centerOnScreen(&tlw);
|
||||
tlw.show();
|
||||
|
||||
const QMargins margins = testWidget.textMargins();
|
||||
QCOMPARE(left, margins.left());
|
||||
QCOMPARE(top, margins.top());
|
||||
QCOMPARE(right, margins.right());
|
||||
QCOMPARE(bottom, margins.bottom());
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 14)
|
||||
int l;
|
||||
int t;
|
||||
int r;
|
||||
|
|
@ -3539,6 +3546,7 @@ void tst_QLineEdit::textMargin()
|
|||
QCOMPARE(top, t);
|
||||
QCOMPARE(right, r);
|
||||
QCOMPARE(bottom, b);
|
||||
#endif
|
||||
|
||||
QTest::mouseClick(&testWidget, Qt::LeftButton, 0, mousePressPos);
|
||||
QTRY_COMPARE(testWidget.cursorPosition(), cursorPosition);
|
||||
|
|
|
|||
|
|
@ -951,8 +951,7 @@ void tst_QMenu::menuSizeHint()
|
|||
for (auto str : {"trer", "ezrfgtgvqd", "sdgzgzerzerzer", "eerzertz", "er"})
|
||||
menu.addAction(str);
|
||||
|
||||
int left, top, right, bottom;
|
||||
menu.getContentsMargins(&left, &top, &right, &bottom);
|
||||
const QMargins cm = menu.contentsMargins();
|
||||
const int panelWidth = menu.style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, &menu);
|
||||
const int hmargin = menu.style()->pixelMetric(QStyle::PM_MenuHMargin, 0, &menu),
|
||||
vmargin = menu.style()->pixelMetric(QStyle::PM_MenuVMargin, 0, &menu);
|
||||
|
|
@ -962,15 +961,15 @@ void tst_QMenu::menuSizeHint()
|
|||
for (QAction *action : menu.actions()) {
|
||||
maxWidth = qMax(maxWidth, menu.actionGeometry(action).width());
|
||||
result |= menu.actionGeometry(action);
|
||||
QCOMPARE(result.x(), left + hmargin + panelWidth);
|
||||
QCOMPARE(result.y(), top + vmargin + panelWidth);
|
||||
QCOMPARE(result.x(), cm.left() + hmargin + panelWidth);
|
||||
QCOMPARE(result.y(), cm.top() + vmargin + panelWidth);
|
||||
}
|
||||
|
||||
QStyleOption opt(0);
|
||||
opt.rect = menu.rect();
|
||||
opt.state = QStyle::State_None;
|
||||
|
||||
QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(hmargin + right + panelWidth, vmargin + top + panelWidth);
|
||||
QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(hmargin + cm.right() + panelWidth, vmargin + cm.top() + panelWidth);
|
||||
|
||||
resSize = menu.style()->sizeFromContents(QStyle::CT_Menu, &opt,
|
||||
resSize.expandedTo(QApplication::globalStrut()), &menu);
|
||||
|
|
@ -1571,8 +1570,7 @@ void tst_QMenu::menuSize_Scrolling()
|
|||
|
||||
int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, this);
|
||||
int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this);
|
||||
int leftMargin, topMargin, rightMargin, bottomMargin;
|
||||
getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
|
||||
const QMargins cm = contentsMargins();
|
||||
QRect lastItem = actionGeometry(actions().at(actions().length() - 1));
|
||||
QSize s = size();
|
||||
#ifdef Q_OS_WINRT
|
||||
|
|
@ -1585,7 +1583,7 @@ void tst_QMenu::menuSize_Scrolling()
|
|||
return;
|
||||
}
|
||||
|
||||
QCOMPARE( s.width(), lastItem.right() + fw + hmargin + rightMargin + 1);
|
||||
QCOMPARE( s.width(), lastItem.right() + fw + hmargin + cm.right() + 1);
|
||||
QMenu::showEvent(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue