summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorSami Merilä <sami.merila@nokia.com>2009-05-25 07:16:53 (GMT)
committerSami Merilä <sami.merila@nokia.com>2009-05-25 07:16:53 (GMT)
commitfc8673c8a0e3ef11aa1eb8c932e0fcd843c11465 (patch)
tree5f1ce0be9985e9b323c028cd8e9e89f14ac14df3 /src/gui/styles
parentbdab465426195f70f7276a768cea49715d585828 (diff)
downloadQt-fc8673c8a0e3ef11aa1eb8c932e0fcd843c11465.zip
Qt-fc8673c8a0e3ef11aa1eb8c932e0fcd843c11465.tar.gz
Qt-fc8673c8a0e3ef11aa1eb8c932e0fcd843c11465.tar.bz2
S60Style: Reorganize methods in source files to match header file order.
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp601
-rw-r--r--src/gui/styles/qs60style_p.h20
-rw-r--r--src/gui/styles/qs60style_symbian.cpp73
3 files changed, 353 insertions, 341 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index cc4582b..2af80f0 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -118,109 +118,6 @@ static const int frameElementsCount =
const int KNotFound = -1;
-void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
- QPainter *painter, const QRect &rect, SkinElementFlags flags)
-{
- static const bool doCache =
-#if defined(Q_WS_S60)
- // Freezes on 3.1. Anyways, caching is only really needed on touch UI
- !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
-#else
- true;
-#endif
- const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
- if (!skinPartPixMap.isNull())
- painter->drawPixmap(rect.topLeft(), skinPartPixMap);
-}
-
-void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags)
-{
- static const bool doCache =
-#if defined(Q_WS_S60)
- // Freezes on 3.1. Anyways, caching is only really needed on touch UI
- !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
-#else
- true;
-#endif
- const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags));
- if (!frameElementPixMap.isNull())
- painter->drawPixmap(rect.topLeft(), frameElementPixMap);
-}
-
-void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
- QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end,
- Qt::Orientation orientation, QPainter *painter, const QRect &rect,
- SkinElementFlags flags)
-{
- QSize startEndSize(partSize(start, flags));
- startEndSize.scale(rect.size(), Qt::KeepAspectRatio);
-
- QRect startRect = QRect(rect.topLeft(), startEndSize);
- QRect middleRect = rect;
- QRect endRect;
-
- if (orientation == Qt::Horizontal) {
- startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width()));
- endRect = startRect.translated(rect.width() - startRect.width(), 0);
- middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
- } else {
- startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height()));
- endRect = startRect.translated(0, rect.height() - startRect.height());
- middleRect.adjust(0, startRect.height(), 0, -startRect.height());
- }
-
-#if 0
- painter->save();
- painter->setOpacity(.3);
- painter->fillRect(startRect, Qt::red);
- painter->fillRect(middleRect, Qt::green);
- painter->fillRect(endRect, Qt::blue);
- painter->restore();
-#else
- drawPart(start, painter, startRect, flags);
- if (middleRect.isValid())
- drawPart(middle, painter, middleRect, flags);
- drawPart(end, painter, endRect, flags);
-#endif
-}
-
-QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
- const QSize &size, SkinElementFlags flags)
-{
- QPixmap result;
- const QString cacheKey =
- QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4")
- .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
- if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::part(part, size, flags);
- QPixmapCache::insert(cacheKey, result);
- }
- return result;
-}
-
-QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags)
-{
- QPixmap result;
- const QString cacheKey =
- QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4")
- .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags);
- if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::frame(frame, size, flags);
- QPixmapCache::insert(cacheKey, result);
- }
- return result;
-}
-
-void QS60StylePrivate::refreshUI()
-{
- foreach (QWidget *topLevelWidget, QApplication::allWidgets()) {
- topLevelWidget->updateGeometry();
- //todo: study how we can get rid of this. Apparently scrollbars cache pixelmetrics values, and we need them to update themselves
- // maybe styleChanged event is enough?
- QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size()));
- }
-}
-
void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
const QRect &rect, SkinElementFlags flags)
{
@@ -348,73 +245,6 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
}
}
-QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
-{
- QSize result(20, 20);
- switch (part)
- {
- case QS60StyleEnums::SP_QgnGrafBarProgress:
- result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth));
- break;
- case QS60StyleEnums::SP_QgnGrafTabActiveM:
- case QS60StyleEnums::SP_QgnGrafTabPassiveM:
- case QS60StyleEnums::SP_QgnGrafTabActiveR:
- case QS60StyleEnums::SP_QgnGrafTabPassiveR:
- case QS60StyleEnums::SP_QgnGrafTabPassiveL:
- case QS60StyleEnums::SP_QgnGrafTabActiveL:
- break;
- case QS60StyleEnums::SP_QgnIndiSliderEdit:
- result.scale(pixelMetric(QStyle::PM_SliderLength),
- pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio);
- break;
-
- case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
- case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
- case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed:
- case QS60StyleEnums::SP_QsnCpScrollBgBottom:
- case QS60StyleEnums::SP_QsnCpScrollBgMiddle:
- case QS60StyleEnums::SP_QsnCpScrollBgTop:
- case QS60StyleEnums::SP_QsnCpScrollHandleBottom:
- case QS60StyleEnums::SP_QsnCpScrollHandleMiddle:
- case QS60StyleEnums::SP_QsnCpScrollHandleTop:
- result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent));
- result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent));
- break;
- default:
- // Generic frame part size gathering.
- for (int i = 0; i < frameElementsCount; ++i)
- {
- switch (m_frameElementsData[i].center - part) {
- case 8: /* CornerTl */
- case 7: /* CornerTr */
- case 6: /* CornerBl */
- case 5: /* CornerBr */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
- // Falltrough intended...
- case 4: /* SideT */
- case 3: /* SideB */
- result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
- break;
- case 2: /* SideL */
- case 1: /* SideR */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
- break;
- case 0: /* center */
- default:
- break;
- }
- }
- break;
- }
- if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) {
- const int temp = result.width();
- result.setWidth(result.height());
- result.setHeight(temp);
- }
- return result;
-}
-
-
void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part,
QPainter *painter, const QRect &rect, SkinElementFlags flags)
{
@@ -440,6 +270,96 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
}
}
+QVariant QS60StylePrivate::styleProperty(const char *name) const
+{
+ if (name == propertyKeyLayouts) {
+#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
+ static QStringList layouts;
+ if (layouts.isEmpty())
+ for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++)
+ layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName);
+ return layouts;
+#else
+ qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!");
+#endif
+ }
+ return QVariant();
+}
+
+QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *option)
+{
+ QColor retColor (color);
+ if (option && !(option->state & QStyle::State_Enabled)) {
+ QColor hsvColor = retColor.toHsv();
+ int colorSat = hsvColor.saturation();
+ int colorVal = hsvColor.value();
+ colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
+ colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
+ hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
+ retColor = hsvColor.toRgb();
+ }
+ return retColor;
+}
+
+QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
+{
+ QColor result(baseColor);
+ bool modifyColor = false;
+ if (result.saturation() == 0) {
+ result.setHsv(result.hue(), 128, result.value());
+ modifyColor = true;
+ }
+ if (result.value() == 0) {
+ result.setHsv(result.hue(), result.saturation(), 128);
+ modifyColor = true;
+ }
+ if (modifyColor)
+ result = result.lighter(175);
+ else
+ result = result.lighter(225);
+ return result;
+}
+
+bool QS60StylePrivate::isSkinnableDialog(const QWidget *widget)
+{
+ return (qobject_cast<const QMessageBox *> (widget) ||
+ qobject_cast<const QErrorMessage *> (widget));
+}
+
+QFont QS60StylePrivate::s60Font(
+ QS60StyleEnums::FontCategories fontCategory, int pointSize) const
+{
+ QFont result;
+ int actualPointSize = pointSize;
+ if (actualPointSize <= 0) {
+ const QFont appFont = QApplication::font();
+ actualPointSize = appFont.pointSize();
+ if (actualPointSize <= 0)
+ actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY();
+ }
+ Q_ASSERT(actualPointSize > 0);
+ const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
+ if (!m_mappedFontsCache.contains(key)) {
+ result = s60Font_specific(fontCategory, actualPointSize);
+ m_mappedFontsCache.insert(key, result);
+ } else {
+ result = m_mappedFontsCache.value(key);
+ if (result.pointSize() != actualPointSize)
+ result.setPointSize(actualPointSize);
+ }
+ return result;
+}
+
+//todo: you could pass a reason to clear cache here, so that we could
+// deduce whether or not the specific cache needs to be cleared
+void QS60StylePrivate::clearCaches()
+{
+ m_colorCache.clear();
+ m_mappedFontsCache.clear();
+ QPixmapCache::clear();
+ m_backgroundValid = false;
+}
+
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use
// for QPalette::Button and QPalette::ToolTipBase. Therefore we need to guesstimate
// this by calculating average rgb values for button pixels.
@@ -502,11 +422,6 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme
}
-int QS60StylePrivate::focusRectPenWidth()
-{
- return pixelMetric(QS60Style::PM_DefaultFrameWidth);
-}
-
void QS60StylePrivate::setThemePalette(QApplication *app) const
{
if (!app)
@@ -634,166 +549,187 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
app->setPalette(applicationPalette);
}
-void QS60Style::polish(QApplication *application)
+int QS60StylePrivate::focusRectPenWidth()
{
- Q_D(const QS60Style);
- originalPalette = application->palette();
- d->setThemePalette(application);
+ return pixelMetric(QS60Style::PM_DefaultFrameWidth);
}
-void QS60Style::polish(QWidget *widget)
+#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
+void QS60StylePrivate::setCurrentLayout(int index)
{
- Q_D(const QS60Style);
- QCommonStyle::polish(widget);
+ m_pmPointer = data[index];
+}
+#endif
- if (!widget)
- return;
- if (QS60StylePrivate::isSkinnableDialog(widget)) {
- widget->setAttribute(Qt::WA_StyledBackground);
- } else if (false
-#ifndef QT_NO_MENU
- || qobject_cast<const QMenu *> (widget)
-#endif // QT_NO_MENU
- ) {
- widget->setAttribute(Qt::WA_StyledBackground);
- } else if (false
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- ) {
- widget->setAttribute(Qt::WA_StyledBackground);
- }
- d->setThemePalette(widget);
+void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
+ QPainter *painter, const QRect &rect, SkinElementFlags flags)
+{
+ static const bool doCache =
+#if defined(Q_WS_S60)
+ // Freezes on 3.1. Anyways, caching is only really needed on touch UI
+ !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
+#else
+ true;
+#endif
+ const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
+ if (!skinPartPixMap.isNull())
+ painter->drawPixmap(rect.topLeft(), skinPartPixMap);
}
-void QS60Style::unpolish(QApplication *application)
+void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags)
{
- QPalette newPalette = qApp->style()->standardPalette();
- application->setPalette(newPalette);
- QApplicationPrivate::setSystemPalette(originalPalette);
+ static const bool doCache =
+#if defined(Q_WS_S60)
+ // Freezes on 3.1. Anyways, caching is only really needed on touch UI
+ !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
+#else
+ true;
+#endif
+ const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags));
+ if (!frameElementPixMap.isNull())
+ painter->drawPixmap(rect.topLeft(), frameElementPixMap);
}
-void QS60Style::unpolish(QWidget *widget)
+void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
+ QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end,
+ Qt::Orientation orientation, QPainter *painter, const QRect &rect,
+ SkinElementFlags flags)
{
- if (QS60StylePrivate::isSkinnableDialog(widget)) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- } else if (false
-#ifndef QT_NO_MENU
- || qobject_cast<const QMenu *> (widget)
-#endif // QT_NO_MENU
- ) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- } else if (false
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- ) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- }
+ QSize startEndSize(partSize(start, flags));
+ startEndSize.scale(rect.size(), Qt::KeepAspectRatio);
- if (widget) {
- widget->setPalette(QPalette());
- }
+ QRect startRect = QRect(rect.topLeft(), startEndSize);
+ QRect middleRect = rect;
+ QRect endRect;
- QCommonStyle::unpolish(widget);
-}
+ if (orientation == Qt::Horizontal) {
+ startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width()));
+ endRect = startRect.translated(rect.width() - startRect.width(), 0);
+ middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
+ } else {
+ startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height()));
+ endRect = startRect.translated(0, rect.height() - startRect.height());
+ middleRect.adjust(0, startRect.height(), 0, -startRect.height());
+ }
-QVariant QS60StylePrivate::styleProperty(const char *name) const
-{
- if (name == propertyKeyLayouts) {
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
- static QStringList layouts;
- if (layouts.isEmpty())
- for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++)
- layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName);
- return layouts;
+#if 0
+ painter->save();
+ painter->setOpacity(.3);
+ painter->fillRect(startRect, Qt::red);
+ painter->fillRect(middleRect, Qt::green);
+ painter->fillRect(endRect, Qt::blue);
+ painter->restore();
#else
- qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!");
+ drawPart(start, painter, startRect, flags);
+ if (middleRect.isValid())
+ drawPart(middle, painter, middleRect, flags);
+ drawPart(end, painter, endRect, flags);
#endif
- }
- return QVariant();
}
-QFont QS60StylePrivate::s60Font(
- QS60StyleEnums::FontCategories fontCategory, int pointSize) const
+QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
+ const QSize &size, SkinElementFlags flags)
{
- QFont result;
- int actualPointSize = pointSize;
- if (actualPointSize <= 0) {
- const QFont appFont = QApplication::font();
- actualPointSize = appFont.pointSize();
- if (actualPointSize <= 0)
- actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY();
- }
- Q_ASSERT(actualPointSize > 0);
- const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
- if (!m_mappedFontsCache.contains(key)) {
- result = s60Font_specific(fontCategory, actualPointSize);
- m_mappedFontsCache.insert(key, result);
- } else {
- result = m_mappedFontsCache.value(key);
- if (result.pointSize() != actualPointSize)
- result.setPointSize(actualPointSize);
+ QPixmap result;
+ const QString cacheKey =
+ QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4")
+ .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
+ if (!QPixmapCache::find(cacheKey, result)) {
+ result = QS60StylePrivate::part(part, size, flags);
+ QPixmapCache::insert(cacheKey, result);
}
return result;
}
-//todo: you could pass a reason to clear cache here, so that we could
-// deduce whether or not the specific cache needs to be cleared
-void QS60StylePrivate::clearCaches()
-{
- m_colorCache.clear();
- m_mappedFontsCache.clear();
- QPixmapCache::clear();
- m_backgroundValid = false;
-}
-
-QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
+QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags)
{
- QColor result(baseColor);
- bool modifyColor = false;
- if (result.saturation() == 0) {
- result.setHsv(result.hue(), 128, result.value());
- modifyColor = true;
- }
- if (result.value() == 0) {
- result.setHsv(result.hue(), result.saturation(), 128);
- modifyColor = true;
+ QPixmap result;
+ const QString cacheKey =
+ QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4")
+ .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags);
+ if (!QPixmapCache::find(cacheKey, result)) {
+ result = QS60StylePrivate::frame(frame, size, flags);
+ QPixmapCache::insert(cacheKey, result);
}
- if (modifyColor)
- result = result.lighter(175);
- else
- result = result.lighter(225);
return result;
}
-bool QS60StylePrivate::isSkinnableDialog(const QWidget *widget)
+void QS60StylePrivate::refreshUI()
{
- return (qobject_cast<const QMessageBox *> (widget) ||
- qobject_cast<const QErrorMessage *> (widget));
+ foreach (QWidget *topLevelWidget, QApplication::allWidgets()) {
+ topLevelWidget->updateGeometry();
+ //todo: study how we can get rid of this. Apparently scrollbars cache pixelmetrics values, and we need them to update themselves
+ // maybe styleChanged event is enough?
+ //QCoreApplication::postEvent(topLevelWidget, new QEvent(QEvent::StyleChange));
+ QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size()));
+ }
}
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-void QS60StylePrivate::setCurrentLayout(int index)
+QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
{
- m_pmPointer = data[index];
-}
-#endif
+ QSize result(20, 20);
+ switch (part)
+ {
+ case QS60StyleEnums::SP_QgnGrafBarProgress:
+ result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth));
+ break;
+ case QS60StyleEnums::SP_QgnGrafTabActiveM:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveM:
+ case QS60StyleEnums::SP_QgnGrafTabActiveR:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveR:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveL:
+ case QS60StyleEnums::SP_QgnGrafTabActiveL:
+ break;
+ case QS60StyleEnums::SP_QgnIndiSliderEdit:
+ result.scale(pixelMetric(QStyle::PM_SliderLength),
+ pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio);
+ break;
-QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *option)
-{
- QColor retColor (color);
- if (option && !(option->state & QStyle::State_Enabled)) {
- QColor hsvColor = retColor.toHsv();
- int colorSat = hsvColor.saturation();
- int colorVal = hsvColor.value();
- colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
- colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
- hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
- retColor = hsvColor.toRgb();
+ case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
+ case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
+ case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed:
+ case QS60StyleEnums::SP_QsnCpScrollBgBottom:
+ case QS60StyleEnums::SP_QsnCpScrollBgMiddle:
+ case QS60StyleEnums::SP_QsnCpScrollBgTop:
+ case QS60StyleEnums::SP_QsnCpScrollHandleBottom:
+ case QS60StyleEnums::SP_QsnCpScrollHandleMiddle:
+ case QS60StyleEnums::SP_QsnCpScrollHandleTop:
+ result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent));
+ result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent));
+ break;
+ default:
+ // Generic frame part size gathering.
+ for (int i = 0; i < frameElementsCount; ++i)
+ {
+ switch (m_frameElementsData[i].center - part) {
+ case 8: /* CornerTl */
+ case 7: /* CornerTr */
+ case 6: /* CornerBl */
+ case 5: /* CornerBr */
+ result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ // Falltrough intended...
+ case 4: /* SideT */
+ case 3: /* SideB */
+ result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
+ break;
+ case 2: /* SideL */
+ case 1: /* SideR */
+ result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ break;
+ case 0: /* center */
+ default:
+ break;
+ }
+ }
+ break;
}
- return retColor;
+ if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) {
+ const int temp = result.width();
+ result.setWidth(result.height());
+ result.setHeight(temp);
+ }
+ return result;
}
/*!
@@ -2674,6 +2610,71 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
return ret;
}
+void QS60Style::polish(QWidget *widget)
+{
+ Q_D(const QS60Style);
+ QCommonStyle::polish(widget);
+
+ if (!widget)
+ return;
+
+ if (QS60StylePrivate::isSkinnableDialog(widget)) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ } else if (false
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif // QT_NO_MENU
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ } else if (false
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ }
+ d->setThemePalette(widget);
+}
+
+void QS60Style::unpolish(QWidget *widget)
+{
+ if (QS60StylePrivate::isSkinnableDialog(widget)) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ } else if (false
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif // QT_NO_MENU
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ } else if (false
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ }
+
+ if (widget) {
+ widget->setPalette(QPalette());
+ }
+
+ QCommonStyle::unpolish(widget);
+}
+
+void QS60Style::polish(QApplication *application)
+{
+ Q_D(const QS60Style);
+ originalPalette = application->palette();
+ d->setThemePalette(application);
+}
+
+void QS60Style::unpolish(QApplication *application)
+{
+ QPalette newPalette = qApp->style()->standardPalette();
+ application->setPalette(newPalette);
+ QApplicationPrivate::setSystemPalette(originalPalette);
+}
+
void QS60Style::setStyleProperty(const char *name, const QVariant &value)
{
Q_D(QS60Style);
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index cf850c6..1df202d 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -355,14 +355,19 @@ public:
int index, const QStyleOption *option);
// gets state specific color
static QColor stateColor(const QColor &color, const QStyleOption *option);
+ // gets lighter color than base color
static QColor lighterColor(const QColor &baseColor);
+ //deduces if the given widget should have separately themeable background
+ //todo: change method name
static bool isSkinnableDialog(const QWidget *widget);
// gets layout
static const QHash<QStyle::PixelMetric, int> &s60StyleLayout();
QFont s60Font(QS60StyleEnums::FontCategories fontCategory,
int pointSize = -1) const;
+ // clears all style caches (fonts, colors, pixmaps)
void clearCaches();
+ // returns themed background texture
static QPixmap backgroundTexture();
static bool isTouchSupported();
@@ -371,7 +376,7 @@ public:
// calculates average color based on button skin graphics (minus borders).
QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const;
void setThemePalette(QApplication *application) const;
- void setThemePalette(QWidget *application) const;
+ void setThemePalette(QWidget *widget) const;
void setBackgroundTexture(QApplication *application) const;
static int focusRectPenWidth();
@@ -409,19 +414,20 @@ private:
static void drawFrame(SkinFrameElements frame, QPainter *painter,
const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
- static QSize partSize(QS60StyleEnums::SkinParts part,
- SkinElementFlags flags = KDefaultSkinElementFlags);
- static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
- SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedPart(QS60StyleEnums::SkinParts part, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
+
+ static void refreshUI();
+
+ static QSize partSize(QS60StyleEnums::SkinParts part,
+ SkinElementFlags flags = KDefaultSkinElementFlags);
+ static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
+ SkinElementFlags flags = KDefaultSkinElementFlags);
static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
- static void refreshUI();
-
static QSize screenSize();
static bool m_backgroundValid;
diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp
index 76c94ad..fd96a2b 100644
--- a/src/gui/styles/qs60style_symbian.cpp
+++ b/src/gui/styles/qs60style_symbian.cpp
@@ -667,6 +667,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
HBufC* iconFile = HBufC::NewLC( KMaxFileName );
TPtr fileNamePtr = iconFile->Des();
fallbackInfo(part, fileNamePtr, fallbackGraphicID);
+ // todo: could we instead use AknIconUtils::AvkonIconFileName(); to avoid allocating each time?
CFbsBitmap *icon = 0;
CFbsBitmap *iconMask = 0;
@@ -990,6 +991,23 @@ QS60StylePrivate::~QS60StylePrivate()
m_backgroundValid = false;
}
+void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
+{
+ if (name == QLatin1String("foo")) {
+ // BaR
+ } else {
+ setStyleProperty(name, value);
+ }
+}
+
+QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
+{
+ if (name == QLatin1String("foo"))
+ return QLatin1String("Bar");
+ else
+ return styleProperty(name);
+}
+
short QS60StylePrivate::pixelMetric(int metric)
{
#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
@@ -1004,6 +1022,24 @@ short QS60StylePrivate::pixelMetric(int metric)
#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
}
+QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
+ int index, const QStyleOption *option)
+{
+ static const TAknsItemID *idMap[] = {
+ &KAknsIIDQsnHighlightColors,
+ &KAknsIIDQsnIconColors,
+ &KAknsIIDQsnLineColors,
+ &KAknsIIDQsnOtherColors,
+ &KAknsIIDQsnParentColors,
+ &KAknsIIDQsnTextColors
+ };
+ Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
+ const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
+ return option ? QS60StylePrivate::stateColor(color, option) : color;
+}
+
+// In some cases, the AVKON UI themegraphic is already in 'disabled state'.
+// If so, return true for these parts.
bool QS60StyleModeSpecifics::disabledPartGraphic(QS60StyleEnums::SkinParts &part)
{
bool disabledGraphic = false;
@@ -1028,6 +1064,8 @@ bool QS60StyleModeSpecifics::disabledPartGraphic(QS60StyleEnums::SkinParts &part
return disabledGraphic;
}
+// In some cases, the AVKON UI themegraphic is already in 'disabled state'.
+// If so, return true for these frames.
bool QS60StyleModeSpecifics::disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame)
{
bool disabledGraphic = false;
@@ -1076,7 +1114,7 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin
QPixmap result = skinnedGraphics(updatedPart, size, flags);
// TODO: fix this
QStyleOption opt;
- // opt.palette = q->standardPalette();
+ //opt.palette = q->standardPalette();
// For now, always generate new icon based on "selected". In the future possibly, expand
// this to consist other possibilities as well.
@@ -1122,39 +1160,6 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin
return result;
}
-void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
-{
- if (name == QLatin1String("foo")) {
- // BaR
- } else {
- setStyleProperty(name, value);
- }
-}
-
-QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
-{
- if (name == QLatin1String("foo"))
- return QLatin1String("Bar");
- else
- return styleProperty(name);
-}
-
-QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
- int index, const QStyleOption *option)
-{
- static const TAknsItemID *idMap[] = {
- &KAknsIIDQsnHighlightColors,
- &KAknsIIDQsnIconColors,
- &KAknsIIDQsnLineColors,
- &KAknsIIDQsnOtherColors,
- &KAknsIIDQsnParentColors,
- &KAknsIIDQsnTextColors
- };
- Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
- const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
- return option ? QS60StylePrivate::stateColor(color, option) : color;
-}
-
// If the public SDK returns compressed images, please let us also uncompress those!
void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap)
{