summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2010-01-26 10:57:21 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-01-27 10:32:55 (GMT)
commit790ed32b99ae9cf61c86ed099dd1e9b2df251635 (patch)
treed7a282a73c96d8cd846e4d6463364f88deec5a08
parent9c772c7c7b0ef98f875bf178254044b416015923 (diff)
downloadQt-790ed32b99ae9cf61c86ed099dd1e9b2df251635.zip
Qt-790ed32b99ae9cf61c86ed099dd1e9b2df251635.tar.gz
Qt-790ed32b99ae9cf61c86ed099dd1e9b2df251635.tar.bz2
QFileDialog layout issue on Symbian
If long path (or any other long string) is added to a combobox, it grows outside of screen area. QS60Style needs to check that widget will not grow wider than screen area. Task-number: QTBUG-6371 Reviewed-by: Alessandro Portale (cherry picked from commit e571e0f012e3e27ffff56493755999da1960318c)
-rw-r--r--src/gui/styles/qs60style.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index bba9ed7..92cac52 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2398,6 +2398,24 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
//QCommonStyle does not adjust height with horizontal margin, it only adjusts width
sz.setHeight(sz.height() + 2 * pixelMetric(QStyle::PM_FocusFrameVMargin));
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;
+#endif
default:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
break;