summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qcombobox.cpp
diff options
context:
space:
mode:
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 f71d250..c16f18a 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);
@@ -2417,24 +2419,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) {
@@ -2643,6 +2665,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: