summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qs60style.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles/qs60style.cpp')
-rw-r--r--src/gui/styles/qs60style.cpp82
1 files changed, 57 insertions, 25 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 071b60a..b066967 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -57,7 +57,6 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl
static const QByteArray propertyKeyLayouts = "layouts";
static const QByteArray propertyKeyCurrentlayout = "currentlayout";
-#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = {
// *** generated layout data ***
{240,320,1,14,true,QLatin1String("QVGA Landscape Mirrored")},
@@ -93,9 +92,9 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = {
};
const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0];
-#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-bool QS60StylePrivate::m_backgroundValid = false;
+// theme background texture
+QPixmap *QS60StylePrivate::m_background = 0;
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = {
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter},
@@ -118,6 +117,11 @@ static const int frameElementsCount =
const int KNotFound = -1;
+QS60StylePrivate::~QS60StylePrivate()
+{
+ deleteBackground();
+}
+
void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
const QRect &rect, SkinElementFlags flags)
{
@@ -251,10 +255,18 @@ void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part,
drawPart(part, painter, rect, flags);
}
+short QS60StylePrivate::pixelMetric(int metric)
+{
+ Q_ASSERT(metric < MAX_PIXELMETRICS);
+ const short returnValue = m_pmPointer[metric];
+ if (returnValue==-909)
+ return -1;
+ return returnValue;
+}
+
void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
{
if (name == propertyKeyCurrentlayout) {
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList();
const QString layout = value.toString();
Q_ASSERT(layouts.contains(layout));
@@ -264,24 +276,17 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
clearCaches();
refreshUI();
return;
-#else
- qFatal("Cannot set static layout. Dynamic layouts are used!");
-#endif
}
}
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();
}
@@ -352,25 +357,25 @@ QFont QS60StylePrivate::s60Font(
void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason)
{
- switch(reason){
+ switch(reason){
case CC_LayoutChange:
// when layout changes, the colors remain in cache, but graphics and fonts can change
m_mappedFontsCache.clear();
- m_backgroundValid = false;
+ deleteBackground();
QPixmapCache::clear();
break;
case CC_ThemeChange:
m_colorCache.clear();
QPixmapCache::clear();
- m_backgroundValid = false;
+ deleteBackground();
case CC_UndefinedChange:
default:
m_colorCache.clear();
m_mappedFontsCache.clear();
QPixmapCache::clear();
- m_backgroundValid = false;
+ deleteBackground();
break;
- }
+ }
}
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use
@@ -561,18 +566,23 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
app->setPalette(applicationPalette);
}
+void QS60StylePrivate::deleteBackground()
+{
+ if (QS60StylePrivate::m_background) {
+ delete QS60StylePrivate::m_background;
+ QS60StylePrivate::m_background = 0;
+ }
+}
+
int QS60StylePrivate::focusRectPenWidth()
{
return pixelMetric(QS60Style::PM_DefaultFrameWidth);
}
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
void QS60StylePrivate::setCurrentLayout(int index)
{
m_pmPointer = data[index];
}
-#endif
-
void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
QPainter *painter, const QRect &rect, SkinElementFlags flags)
@@ -1314,16 +1324,14 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
(listView->selectionMode() == QAbstractItemView::SingleSelection ||
listView->selectionMode() == QAbstractItemView::NoSelection);
QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
- if (voptAdj.state & QStyle::State_Selected &&
- !singleSelection) {
+ if (voptAdj.state & QStyle::State_Selected && !singleSelection) {
QStyleOptionViewItemV4 option(voptAdj);
option.rect = selectionRect;
// Draw selection mark.
drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget);
if ( textRect.right() > selectionRect.left() )
textRect.setRight(selectionRect.left());
- }
- else if (singleSelection &&
+ } else if (singleSelection &&
voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) {
// draw the check mark
if (selectionRect.isValid()) {
@@ -2178,7 +2186,6 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const
metricValue = QCommonStyle::pixelMetric(metric, option, widget);
if (metric == PM_SubMenuOverlap && widget){
- const int widgetWidth = widget->width();
const QMenu *menu = qobject_cast<const QMenu *>(widget);
if (menu && menu->activeAction() && menu->activeAction()->menu()) {
const int menuWidth = menu->activeAction()->menu()->sizeHint().width();
@@ -2408,11 +2415,12 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
ret = QCommonStyle::subControlRect(control, option, scontrol, widget);
switch (scontrol) {
case SC_GroupBoxCheckBox: //fallthrough
- case SC_GroupBoxLabel:
+ case SC_GroupBoxLabel: {
//slightly indent text and boxes, so that dialog border does not mess with them.
const int horizontalSpacing =
QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
ret.adjust(2,horizontalSpacing-3,0,0);
+ }
break;
case SC_GroupBoxFrame: {
const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget);
@@ -2678,6 +2686,7 @@ void QS60Style::polish(QApplication *application)
void QS60Style::unpolish(QApplication *application)
{
+ Q_UNUSED(application)
QPalette newPalette = qApp->style()->standardPalette();
application->setPalette(newPalette);
QApplicationPrivate::setSystemPalette(originalPalette);
@@ -2780,6 +2789,29 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap);
}
+extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget);
+
+bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset,
+ const QBrush &brush)
+{
+ const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
+ if (backgroundTexture.cacheKey() != brush.texture().cacheKey())
+ return false;
+
+ const QPaintDevice *target = painter->device();
+ if (target->devType() == QInternal::Widget) {
+ const QWidget *widget = static_cast<const QWidget *>(target);
+ const QRegion translated = rgn.translated(offset);
+ const QVector<QRect> &rects = translated.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect rect(rects.at(i));
+ painter->drawPixmap(rect.topLeft(), backgroundTexture,
+ rect.translated(qt_s60_fill_background_offset(widget)));
+ }
+ }
+ return true;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_STYLE_S60 || QT_PLUGIN