summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qs60style.cpp
diff options
context:
space:
mode:
authorJanne Koskinen <janne.p.koskinen@digia.com>2010-01-29 13:38:09 (GMT)
committerJanne Koskinen <janne.p.koskinen@digia.com>2010-01-29 13:38:09 (GMT)
commitf4784025082b84a02e51dcde89bf32ad77cb4ccd (patch)
treee9c63d745d4b96a9e276c23d92d940017811dbb3 /src/gui/styles/qs60style.cpp
parent2812fb6ee0357e4da4d9a776638914416274a2f1 (diff)
parent4f584d5d4c53d8510a34a698fac0f78c17f6cb93 (diff)
downloadQt-f4784025082b84a02e51dcde89bf32ad77cb4ccd.zip
Qt-f4784025082b84a02e51dcde89bf32ad77cb4ccd.tar.gz
Qt-f4784025082b84a02e51dcde89bf32ad77cb4ccd.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.6
Diffstat (limited to 'src/gui/styles/qs60style.cpp')
-rw-r--r--src/gui/styles/qs60style.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 3f4f190..a40a84c 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -985,7 +985,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
//Handle graphics
const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget);
QS60StylePrivate::SkinElements handleElement;
- if (optionSlider->state & QStyle::State_Sunken)
+ if (optionSlider->state & State_Sunken)
handleElement =
horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical;
else
@@ -1985,7 +1985,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
*/
void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
- Q_D(const QS60Style);
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
bool commonStyleDraws = false;
@@ -2021,8 +2020,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff;
painter->save();
- QColor themeColor = QS60StylePrivate::themePalette()->windowText().color();
- QColor windowTextColor = option->palette.windowText().color();
+ const QColor themeColor = QS60StylePrivate::themePalette()->windowText().color();
+ const QColor windowTextColor = option->palette.windowText().color();
if (themeColor != windowTextColor)
painter->setPen(windowTextColor);
@@ -2069,8 +2068,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
buttonRect.adjust(0, -newY, -1, -newY);
painter->save();
- QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option);
- QColor buttonTextColor = option->palette.buttonText().color();
+ const QColor themeColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option);
+ const QColor buttonTextColor = option->palette.buttonText().color();
if (themeColor != buttonTextColor)
painter->setPen(buttonTextColor);
else
@@ -2401,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);
@@ -2621,29 +2612,31 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
// lets use spinbox frame here as well, as no combobox specific value available.
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0;
const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize);
- const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
- const int ypos = cmb->rect.y();
QSize buttonSize;
buttonSize.setWidth(buttonWidth + 2 * buttonMargin);
buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares
buttonSize = buttonSize.expandedTo(QApplication::globalStrut());
switch (scontrol) {
- case SC_ComboBoxArrow:
+ case SC_ComboBoxArrow: {
+ const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth;
+ const int ypos = cmb->rect.y();
ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin);
+ }
break;
case SC_ComboBoxEditField: {
- const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width();
+ const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width();
ret = QRect(
frameThickness,
frameThickness,
withFrameX - frameThickness,
- cmb->rect.height() - 2 * frameThickness);
+ height - 2 * frameThickness);
}
break;
default:
break;
}
+ ret = visualRect(cmb->direction, cmb->rect, ret);
}
break;
case CC_GroupBox:
@@ -2964,11 +2957,13 @@ void QS60Style::unpolish(QWidget *widget)
if (widget)
widget->setPalette(QPalette());
-#ifndef QT_NO_PROGRESSBAR
+#if defined(Q_WS_S60) && !defined(QT_NO_PROGRESSBAR)
if (QProgressBar *bar = qobject_cast<QProgressBar *>(widget)) {
widget->removeEventFilter(this);
d->m_bars.removeAll(bar);
}
+#else
+ Q_UNUSED(d)
#endif
QCommonStyle::unpolish(widget);
}
@@ -3000,9 +2995,8 @@ void QS60Style::unpolish(QApplication *application)
*/
bool QS60Style::event(QEvent *e)
{
- Q_D(QS60Style);
-
#ifdef QT_KEYPAD_NAVIGATION
+ Q_D(QS60Style);
const QEvent::Type eventType = e->type();
if ((eventType == QEvent::FocusIn ||
eventType == QEvent::FocusOut ||
@@ -3166,6 +3160,10 @@ bool QS60Style::eventFilter(QObject *object, QEvent *event)
return QStyle::eventFilter(object, event);
}
+/*!
+ \internal
+ Handle the timer \a event.
+*/
void QS60Style::timerEvent(QTimerEvent *event)
{
#ifdef Q_WS_S60