From: Shawn Rutledge Date: Thu, 4 Oct 2012 13:43:11 +0000 (+0200) Subject: QScreen manual test improvements: fields resize, better formatting X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78f946f6dc23185e86d7a59e703cd8b3b6ee0e39;p=profile%2Fivi%2Fqtbase.git QScreen manual test improvements: fields resize, better formatting 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 --- diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp index 4f7ff8c..460fdc3 100644 --- a/tests/manual/qscreen/main.cpp +++ b/tests/manual/qscreen/main.cpp @@ -62,8 +62,8 @@ void updateSiblings(PropertyWatcher* w) void screenAdded(QScreen* screen) { screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F); - qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), - screen->virtualSiblings().count(), qPrintable(screen->virtualSiblings().first()->name())); + qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), screen->virtualSiblings().count(), + (screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name()))); PropertyWatcher *w = new PropertyWatcher(screen, QString::number(i++)); QLineEdit *siblingsField = new QLineEdit(); siblingsField->setObjectName("siblings"); diff --git a/tests/manual/qscreen/propertyfield.cpp b/tests/manual/qscreen/propertyfield.cpp index 6ac63b3..c5e9442 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; } diff --git a/tests/manual/qscreen/propertywatcher.cpp b/tests/manual/qscreen/propertywatcher.cpp index d342a94..ee037a0 100644 --- a/tests/manual/qscreen/propertywatcher.cpp +++ b/tests/manual/qscreen/propertywatcher.cpp @@ -63,6 +63,7 @@ PropertyWatcher::PropertyWatcher(QObject *subject, QString annotation, QWidget * QPushButton *updateButton = new QPushButton("update"); connect(updateButton, &QPushButton::clicked, this, &PropertyWatcher::updateAllFields); m_layout->addRow("", updateButton); + m_layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(m_layout); connect(subject, &QObject::destroyed, this, &PropertyWatcher::subjectDestroyed); } diff --git a/tests/manual/qscreen/propertywatcher.h b/tests/manual/qscreen/propertywatcher.h index c55776e..63c828f 100644 --- a/tests/manual/qscreen/propertywatcher.h +++ b/tests/manual/qscreen/propertywatcher.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef WIDGET_H -#define WIDGET_H +#ifndef PROPERTY_WATCHER_H +#define PROPERTY_WATCHER_H #include @@ -69,4 +69,4 @@ protected: QFormLayout * m_layout; }; -#endif // WIDGET_H +#endif // PROPERTY_WATCHER_H