From 78f946f6dc23185e86d7a59e703cd8b3b6ee0e39 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 4 Oct 2012 15:43:11 +0200 Subject: QScreen manual test improvements: fields resize, better formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's necessary to set the fieldGrowthPolicy on the QFormLayout in order to have expanding fields on the Mac. Geometry formatting with negative x and y values looks better. Display fewer decimal digits for double fields. Change-Id: Icb252c0c3fb7b605253e04c3361beba124570840 Reviewed-by: Samuel Rødal --- tests/manual/qscreen/propertyfield.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'tests/manual/qscreen/propertyfield.cpp') diff --git a/tests/manual/qscreen/propertyfield.cpp b/tests/manual/qscreen/propertyfield.cpp index 6ac63b3c65..c5e9442a26 100644 --- a/tests/manual/qscreen/propertyfield.cpp +++ b/tests/manual/qscreen/propertyfield.cpp @@ -56,14 +56,26 @@ PropertyField::PropertyField(QObject* subject, const QMetaProperty& prop, QWidge QString PropertyField::valueToString(QVariant val) { - QString text = val.toString(); - if (val.type() == QVariant::Size) + QString text; + switch (val.type()) { + case QVariant::Double: + text = QString("%1").arg(val.toReal(), 0, 'f', 4); + break; + case QVariant::Size: text = QString("%1 x %2").arg(val.toSize().width()).arg(val.toSize().height()); - else if (val.type() == QVariant::SizeF) + break; + case QVariant::SizeF: text = QString("%1 x %2").arg(val.toSizeF().width()).arg(val.toSizeF().height()); - else if (val.type() == QVariant::Rect) - text = QString("%1 x %2 +%3 +%4").arg(val.toRect().width()) - .arg(val.toRect().height()).arg(val.toRect().x()).arg(val.toRect().y()); + break; + case QVariant::Rect: { + QRect rect = val.toRect(); + text = QString("%1 x %2 %3%4 %5%6").arg(rect.width()) + .arg(rect.height()).arg(rect.x() < 0 ? "" : "+").arg(rect.x()) + .arg(rect.y() < 0 ? "" : "+").arg(rect.y()); + } break; + default: + text = val.toString(); + } return text; } -- cgit v1.2.3