summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qs60style.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <aportale@trolltech.com>2010-01-28 12:24:01 (GMT)
committerAlessandro Portale <aportale@trolltech.com>2010-01-28 12:31:54 (GMT)
commit7060118fe35b358ce6739734d03a285708127b60 (patch)
tree98004c06ea4044ef8a287912e1172fd6d2dfe167 /src/gui/styles/qs60style.cpp
parent297e84fcfed524687455d3d94161bf2a32f62d37 (diff)
downloadQt-7060118fe35b358ce6739734d03a285708127b60.zip
Qt-7060118fe35b358ce6739734d03a285708127b60.tar.gz
Qt-7060118fe35b358ce6739734d03a285708127b60.tar.bz2
Shortening and fixing previous fix for QTBUG-6371
Shortening: Use much mor code from CommonStyle Fixing: Subtract PM_Layout[Left|Right]Margin from desktop width. This fix is anyways not relly useful. It heals some Ui designs with sizeconstrains which do not fit into mobile screens. But it will fail In following situations: Widget, and a too-long combobox in a horizontal Layout. The combobox would be cropped to Desktop width but the widget(s) left and/or right of the Combobox are not considered. So, that the Ui still is too wide. The correct fix will be for set the size policy of the combobox to something less greedy. Task-number: QTBUG-6371 Reviewed-by: Sami Merila modified: gui/styles/qs60style.cpp
Diffstat (limited to 'src/gui/styles/qs60style.cpp')
-rw-r--r--src/gui/styles/qs60style.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 78279d1..8dfe867 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2400,21 +2400,13 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
break;
#ifndef QT_NO_COMBOBOX
case CT_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- const int frameWidth = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0;
- const int textMargins = 2*(pixelMetric(PM_FocusFrameHMargin) + 1);
- const int smallestExtraWidth = 23;
- // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
- const int extra =
- qMax(smallestExtraWidth, 2*textMargins + pixelMetric(PM_ScrollBarExtent, opt, widget));
- sz = QSize(sz.width() + frameWidth + extra, sz.height() + frameWidth);
- int maxScreenWidth = QApplication::desktop()->availableGeometry().size().width();
- if (sz.width() > maxScreenWidth) {
- maxScreenWidth = maxScreenWidth - (extra + frameWidth);
- sz.setWidth(maxScreenWidth);
- }
- }
- break;
+ // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints
+ // Make sure, that the combobox says within the screen.
+ const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size()
+ -QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0);
+ sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget).
+ boundedTo(desktopContentSize);
+ break;
#endif
default:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);