summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-05-22 10:31:07 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-27 02:44:07 +0200
commit87f560d217da6172c9386eacb0c90cf6473e670b (patch)
treef2444ec790a1aa8f3d897f90ddf808f3570e5880 /src
parent824a1bac502fec2a7a1e20555336da9c00b5bd67 (diff)
downloadqtquickcontrols-87f560d217da6172c9386eacb0c90cf6473e670b.tar.gz
Improve size hints for SpinBox and TextField
These were both too small on most platforms. Since we have rather broken logic in widgets for this, I will simply assume they share the same height. Change-Id: I98da5a925087fec300de3c1c91b58110103e1a38 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/SpinBox.qml2
-rw-r--r--src/private/qquickstyleitem.cpp25
-rw-r--r--src/styles/Desktop/SpinBoxStyle.qml2
-rw-r--r--src/styles/Desktop/TextFieldStyle.qml2
4 files changed, 16 insertions, 15 deletions
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index 2f90ff95..ec563afc 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -159,7 +159,7 @@ Control {
readonly property alias containsMouse: mouseArea.containsMouse
- readonly property int contentHeight: Math.max(input.implicitHeight, 20)
+ readonly property int contentHeight: Math.max(input.implicitHeight, 16)
readonly property int contentWidth: Math.max(maxSizeHint.implicitWidth, minSizeHint.implicitWidth)
}
diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp
index 62c716fb..7da0ebdf 100644
--- a/src/private/qquickstyleitem.cpp
+++ b/src/private/qquickstyleitem.cpp
@@ -780,12 +780,6 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
int newHeight = qMax(height, btn->fontMetrics.height());
size = qApp->style()->sizeFromContents(QStyle::CT_ComboBox, m_styleoption, QSize(newWidth, newHeight)); }
break;
- case SpinBox: {
- QStyleOptionSpinBox *box = qstyleoption_cast<QStyleOptionSpinBox*>(m_styleoption);
- int newWidth = qMax(width, box->fontMetrics.width(QLatin1String("0.0")));
- int newHeight = qMax(height, box->fontMetrics.height());
- size = qApp->style()->sizeFromContents(QStyle::CT_SpinBox, m_styleoption, QSize(newWidth, newHeight)); }
- break;
case Tab:
size = qApp->style()->sizeFromContents(QStyle::CT_TabBarTab, m_styleoption, QSize(width,height));
break;
@@ -795,6 +789,13 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
case ProgressBar:
size = qApp->style()->sizeFromContents(QStyle::CT_ProgressBar, m_styleoption, QSize(width,height));
break;
+ case SpinBox:
+#ifdef Q_OS_MAC
+ if (style() == "mac") {
+ size = qApp->style()->sizeFromContents(QStyle::CT_SpinBox, m_styleoption, QSize(width, height + 4));
+ break;
+ }
+#endif // fall trough if not mac
case Edit:
#ifdef Q_OS_MAC
if (style() =="mac") {
@@ -805,13 +806,13 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
} else
#endif
{
- size = QSize(width, height);
- if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(m_styleoption))
- size += QSize(2*f->lineWidth, 2*f->lineWidth);
+ // We have to create a new style option since we might be calling with a QStyleOptionSpinBox
+ QStyleOptionFrame frame;
+ frame.state = m_styleoption->state;
+ frame.lineWidth = qApp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, m_styleoption, 0);
+ frame.rect = m_styleoption->rect;
+ size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, &frame, QSize(width, height));
}
-
- if (hints().indexOf("rounded") != -1)
- size += QSize(0, 3);
break;
case GroupBox: {
QStyleOptionGroupBox *box = qstyleoption_cast<QStyleOptionGroupBox*>(m_styleoption);
diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml
index 644b4972..227a6e7c 100644
--- a/src/styles/Desktop/SpinBoxStyle.qml
+++ b/src/styles/Desktop/SpinBoxStyle.qml
@@ -100,7 +100,7 @@ PaddedStyle {
style.upRect = styleitem.subControlRect("up");
style.downRect = styleitem.subControlRect("down");
var inputRect = styleitem.subControlRect("edit");
- edit.anchors.topMargin = inputRect.y
+ edit.anchors.topMargin = inputRect.y + (styleitem.style === "mac" ? 1 : 0)
edit.anchors.leftMargin = inputRect.x
edit.anchors.rightMargin = style.width - inputRect.width - edit.anchors.leftMargin
edit.anchors.bottomMargin = style.height - inputRect.height - edit.anchors.topMargin
diff --git a/src/styles/Desktop/TextFieldStyle.qml b/src/styles/Desktop/TextFieldStyle.qml
index ae8bcc06..9a093d2a 100644
--- a/src/styles/Desktop/TextFieldStyle.qml
+++ b/src/styles/Desktop/TextFieldStyle.qml
@@ -72,7 +72,7 @@ Style {
contentWidth: 100
// Form QLineEdit::sizeHint
- contentHeight: Math.max(control.__contentHeight, 14) + topMargin + bottomMargin
+ contentHeight: Math.max(control.__contentHeight, 16)
FocusFrame {
anchors.fill: parent