aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-09-04 20:31:33 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-09-07 14:55:15 +0200
commit12d3882879401372e6fd5296144dca0c7368dc49 (patch)
tree71df74479afa0e13e6a08838859d01b4eddf2515
parent613ec309c1456783ef3a5e29532bdbce06e91a49 (diff)
Native style: set a sensible default width for TextField
Set the default width of an empty TextField to 90px (which is a number found by creating an NSTextField in XCode and measuring it with pixeltool). This should also make tst_QQuickPopup::macOS::cursorShape() pass. Change-Id: Ia2a059668c2e1eaea3eef20015a8ea99468dd8ad Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/imports/nativestyle/controls/DefaultTextField.qml5
-rw-r--r--tests/auto/qquickpopup/tst_qquickpopup.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/imports/nativestyle/controls/DefaultTextField.qml b/src/imports/nativestyle/controls/DefaultTextField.qml
index c2081d61..63489627 100644
--- a/src/imports/nativestyle/controls/DefaultTextField.qml
+++ b/src/imports/nativestyle/controls/DefaultTextField.qml
@@ -45,8 +45,9 @@ T.TextField {
readonly property bool nativeBackground: background instanceof NativeStyle.StyleItem
- implicitWidth: implicitBackgroundWidth + leftInset + rightInset
- || Math.max(contentWidth, placeholder.implicitWidth) + leftPadding + rightPadding
+ implicitWidth: Math.max(Math.max(contentWidth, placeholder.implicitWidth) + leftPadding + rightPadding,
+ implicitBackgroundWidth + leftInset + rightInset,
+ 90 /* minimum */ )
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
contentHeight + topPadding + bottomPadding,
placeholder.implicitHeight + topPadding + bottomPadding)
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
index fb91915c..ff04c99d 100644
--- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
@@ -983,6 +983,7 @@ void tst_QQuickPopup::cursorShape()
// Move the mouse over the text field.
const QPoint textFieldPos(popup->x() - 10, textField->height() / 2);
+ QVERIFY(textField->contains(textField->mapFromScene(textFieldPos)));
QTest::mouseMove(window, textFieldPos);
QCOMPARE(window->cursor().shape(), textField->cursor().shape());