summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qcombobox.cpp
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2010-03-17 12:21:22 (GMT)
committerSami Merila <sami.merila@nokia.com>2010-03-17 12:21:22 (GMT)
commitceff979ce3c9401151acdcd53af872cefbaaa962 (patch)
tree08025b3c65f04de0665dd01cd85326bd25dc0122 /src/gui/widgets/qcombobox.cpp
parent24096c5613731ae19e8fefe071570fa1d0e7ab36 (diff)
downloadQt-ceff979ce3c9401151acdcd53af872cefbaaa962.zip
Qt-ceff979ce3c9401151acdcd53af872cefbaaa962.tar.gz
Qt-ceff979ce3c9401151acdcd53af872cefbaaa962.tar.bz2
Change QS60Style to use combobox popup menu
Instead of using traditional dropdown menus, use popup menu, like native side does. Related to https://qtrequirements.europe.nokia.com/browse/QT-2274 Popup is positioned according to S60 popup position rules: - in portrait at the bottom, with square popup (dimension is screen width minus border) - in landscape, centered on Y-axis, on X-axis to the right border (with LeftToRight UI direction) Background behind popup is dimmed. Popup has automatic scrollbar if content does not fit into the popup. Popup background graphic is S60 dialog graphic. Task-number: QT-2274 Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/widgets/qcombobox.cpp')
-rw-r--r--src/gui/widgets/qcombobox.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 585db70..7d02e14 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -532,9 +532,11 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
QStyleOptionComboBox opt = comboStyleOption();
const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo);
#ifndef QT_NO_SCROLLBAR
+#ifndef Q_WS_S60
if (usePopup)
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
#endif
+#endif
if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
usePopup) {
view->setMouseTracking(true);
@@ -2416,24 +2418,44 @@ void QComboBox::showPopup()
// Position horizontally.
listRect.moveLeft(above.x());
+#ifndef Q_WS_S60
// Position vertically so the curently selected item lines up
// with the combo box.
const QRect currentItemRect = view()->visualRect(view()->currentIndex());
const int offset = listRect.top() - currentItemRect.top();
listRect.moveTop(above.y() + offset - listRect.top());
+#endif
// Clamp the listRect height and vertical position so we don't expand outside the
// available screen geometry.This may override the vertical position, but it is more
// important to show as much as possible of the popup.
const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height());
+#ifdef Q_WS_S60
+ //popup needs to be stretched with screen minimum dimension
+ listRect.setHeight(qMin(screen.height(), screen.width()));
+#else
listRect.setHeight(height);
+#endif
+
if (boundToScreen) {
if (listRect.top() < screen.top())
listRect.moveTop(screen.top());
if (listRect.bottom() > screen.bottom())
listRect.moveBottom(screen.bottom());
}
+#ifdef Q_WS_S60
+ if (screen.width() < screen.height()) {
+ // in portait, menu should be positioned above softkeys
+ listRect.moveBottom(screen.bottom());
+ } else {
+ // landscape, menu should be at the right and horizontally centered
+ listRect.setWidth(listRect.height());
+ listRect.moveCenter(screen.center());
+ (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
+ listRect.setLeft(screen.left());
+ }
+#endif
} else if (!boundToScreen || listRect.height() <= belowHeight) {
listRect.moveTopLeft(below);
} else if (listRect.height() <= aboveHeight) {
@@ -2642,6 +2664,34 @@ void QComboBox::changeEvent(QEvent *e)
if (d->lineEdit)
d->updateLineEditGeometry();
d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem);
+
+#ifdef Q_WS_S60
+ if (d->container) {
+ QStyleOptionComboBox opt;
+ initStyleOption(&opt);
+
+ if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
+ const QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
+
+ QRect listRect(style()->subControlRect(QStyle::CC_ComboBox, &opt,
+ QStyle::SC_ComboBoxListBoxPopup, this));
+ listRect.setHeight(qMin(screen.height(), screen.width()));
+
+ if (screen.width() < screen.height()) {
+ // in portait, menu should be positioned above softkeys
+ listRect.moveBottom(screen.bottom());
+ } else {
+ // landscape, menu should be at the right and horizontally centered
+ listRect.setWidth(listRect.height());
+ listRect.moveCenter(screen.center());
+ (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
+ listRect.setLeft(screen.left());
+ }
+ d->container->setGeometry(listRect);
+ }
+ }
+#endif
+
// ### need to update scrollers etc. as well here
break;
case QEvent::EnabledChange: