changeset 18 | 2f34d5167611 |
parent 3 | 41300fa6a67c |
child 19 | fcece45ef507 |
3:41300fa6a67c | 18:2f34d5167611 |
---|---|
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
66 #include "qtextedit.h" |
66 #include "qtextedit.h" |
67 #include "qtoolbar.h" |
67 #include "qtoolbar.h" |
68 #include "qtoolbutton.h" |
68 #include "qtoolbutton.h" |
69 #include "qfocusframe.h" |
69 #include "qfocusframe.h" |
70 #include "qformlayout.h" |
70 #include "qformlayout.h" |
71 #include "qradiobutton.h" |
|
72 #include "qcheckbox.h" |
|
73 #include "qdesktopwidget.h" |
|
74 #include "qprogressbar.h" |
|
71 |
75 |
72 #include "private/qtoolbarextension_p.h" |
76 #include "private/qtoolbarextension_p.h" |
73 #include "private/qcombobox_p.h" |
77 #include "private/qcombobox_p.h" |
74 #include "private/qwidget_p.h" |
78 #include "private/qwidget_p.h" |
75 #include "private/qapplication_p.h" |
79 #include "private/qapplication_p.h" |
86 |
90 |
87 static const qreal goldenRatio = 1.618; |
91 static const qreal goldenRatio = 1.618; |
88 |
92 |
89 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
93 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
90 // *** generated layout data *** |
94 // *** generated layout data *** |
91 {240,320,1,15,"QVGA Landscape"}, |
95 {240,320,1,16,"QVGA Landscape"}, |
92 {320,240,1,15,"QVGA Portrait"}, |
96 {320,240,1,16,"QVGA Portrait"}, |
93 {360,640,1,15,"NHD Landscape"}, |
97 {360,640,1,16,"NHD Landscape"}, |
94 {640,360,1,15,"NHD Portrait"}, |
98 {640,360,1,16,"NHD Portrait"}, |
95 {352,800,1,12,"E90 Landscape"} |
99 {352,800,1,12,"E90 Landscape"} |
96 // *** End of generated data *** |
100 // *** End of generated data *** |
97 }; |
101 }; |
98 const int QS60StylePrivate::m_numberOfLayouts = |
102 const int QS60StylePrivate::m_numberOfLayouts = |
99 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
103 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
100 |
104 |
101 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
105 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
102 // *** generated pixel metrics *** |
106 // *** generated pixel metrics *** |
103 {5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,3,3,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1}, |
107 {5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1}, |
104 {5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1}, |
108 {5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1}, |
105 {7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, |
109 {7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, |
106 {7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, |
110 {7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, |
107 {7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} |
111 {7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} |
108 // *** End of generated data *** |
112 // *** End of generated data *** |
109 }; |
113 }; |
110 |
114 |
111 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
115 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
113 // theme background texture |
117 // theme background texture |
114 QPixmap *QS60StylePrivate::m_background = 0; |
118 QPixmap *QS60StylePrivate::m_background = 0; |
115 |
119 |
116 // theme palette |
120 // theme palette |
117 QPalette *QS60StylePrivate::m_themePalette = 0; |
121 QPalette *QS60StylePrivate::m_themePalette = 0; |
122 |
|
123 qint64 QS60StylePrivate::m_webPaletteKey = 0; |
|
118 |
124 |
119 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
125 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
120 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
126 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
121 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
127 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
122 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
128 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
283 drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
289 drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
284 break; |
290 break; |
285 case SE_Editor: |
291 case SE_Editor: |
286 drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
292 drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
287 break; |
293 break; |
294 case SE_DropArea: |
|
295 drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); |
|
296 break; |
|
288 default: |
297 default: |
289 break; |
298 break; |
290 } |
299 } |
291 } |
300 } |
292 |
301 |
308 QColor retColor (color); |
317 QColor retColor (color); |
309 if (option && !(option->state & QStyle::State_Enabled)) { |
318 if (option && !(option->state & QStyle::State_Enabled)) { |
310 QColor hsvColor = retColor.toHsv(); |
319 QColor hsvColor = retColor.toHsv(); |
311 int colorSat = hsvColor.saturation(); |
320 int colorSat = hsvColor.saturation(); |
312 int colorVal = hsvColor.value(); |
321 int colorVal = hsvColor.value(); |
313 colorSat = (colorSat!=0) ? (colorSat>>1) : 128; |
322 colorSat = (colorSat != 0) ? (colorSat >> 1) : 128; |
314 colorVal = (colorVal!=0) ? (colorVal>>1) : 128; |
323 colorVal = (colorVal != 0) ? (colorVal >> 1) : 128; |
315 hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); |
324 hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); |
316 retColor = hsvColor.toRgb(); |
325 retColor = hsvColor.toRgb(); |
317 } |
326 } |
318 return retColor; |
327 return retColor; |
319 } |
328 } |
337 return result; |
346 return result; |
338 } |
347 } |
339 |
348 |
340 bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget) |
349 bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget) |
341 { |
350 { |
342 return qobject_cast<const QDialog *> (widget); |
351 return (widget ? (widget->windowType() == Qt::Dialog) : false); |
343 } |
352 } |
344 |
353 |
345 QFont QS60StylePrivate::s60Font( |
354 QFont QS60StylePrivate::s60Font( |
346 QS60StyleEnums::FontCategories fontCategory, int pointSize) const |
355 QS60StyleEnums::FontCategories fontCategory, |
356 int pointSize, bool resolveFontSize) const |
|
347 { |
357 { |
348 QFont result; |
358 QFont result; |
349 int actualPointSize = pointSize; |
359 int actualPointSize = pointSize; |
350 if (actualPointSize <= 0) { |
360 if (actualPointSize <= 0) { |
351 const QFont appFont = QApplication::font(); |
361 const QFont appFont = QApplication::font(); |
354 actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); |
364 actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); |
355 } |
365 } |
356 Q_ASSERT(actualPointSize > 0); |
366 Q_ASSERT(actualPointSize > 0); |
357 const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); |
367 const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); |
358 if (!m_mappedFontsCache.contains(key)) { |
368 if (!m_mappedFontsCache.contains(key)) { |
359 result = s60Font_specific(fontCategory, actualPointSize); |
369 result = s60Font_specific(fontCategory, actualPointSize, resolveFontSize); |
360 m_mappedFontsCache.insert(key, result); |
370 m_mappedFontsCache.insert(key, result); |
361 } else { |
371 } else { |
362 result = m_mappedFontsCache.value(key); |
372 result = m_mappedFontsCache.value(key); |
363 if (result.pointSize() != actualPointSize) |
373 if (result.pointSize() != actualPointSize) |
364 result.setPointSize(actualPointSize); |
374 result.setPointSize(actualPointSize); |
370 { |
380 { |
371 switch(reason){ |
381 switch(reason){ |
372 case CC_LayoutChange: |
382 case CC_LayoutChange: |
373 // when layout changes, the colors remain in cache, but graphics and fonts can change |
383 // when layout changes, the colors remain in cache, but graphics and fonts can change |
374 m_mappedFontsCache.clear(); |
384 m_mappedFontsCache.clear(); |
375 deleteBackground(); |
|
376 QPixmapCache::clear(); |
385 QPixmapCache::clear(); |
377 break; |
386 break; |
378 case CC_ThemeChange: |
387 case CC_ThemeChange: |
379 m_colorCache.clear(); |
388 m_colorCache.clear(); |
380 QPixmapCache::clear(); |
389 QPixmapCache::clear(); |
398 { |
407 { |
399 const bool cachedColorExists = m_colorCache.contains(frame); |
408 const bool cachedColorExists = m_colorCache.contains(frame); |
400 if (!cachedColorExists) { |
409 if (!cachedColorExists) { |
401 const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); |
410 const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); |
402 const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); |
411 const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); |
403 Q_ASSERT(2*frameCornerWidth<32); |
412 Q_ASSERT(2 * frameCornerWidth < 32); |
404 Q_ASSERT(2*frameCornerHeight<32); |
413 Q_ASSERT(2 * frameCornerHeight < 32); |
405 |
414 |
406 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32,32)).toImage(); |
415 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
407 Q_ASSERT(frameImage.bytesPerLine() > 0); |
416 Q_ASSERT(frameImage.bytesPerLine() > 0); |
408 if (frameImage.isNull()) |
417 if (frameImage.isNull()) |
409 return Qt::black; |
418 return Qt::black; |
410 |
419 |
411 const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
420 const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
416 int estimatedBlue = 0; |
425 int estimatedBlue = 0; |
417 |
426 |
418 int skips = 0; |
427 int skips = 0; |
419 int estimations = 0; |
428 int estimations = 0; |
420 |
429 |
421 const int topBorderLastPixel = frameCornerHeight*frameImage.width()-1; |
430 const int topBorderLastPixel = frameCornerHeight*frameImage.width() - 1; |
422 const int bottomBorderFirstPixel = frameImage.width()*frameImage.height()-frameCornerHeight*frameImage.width()-1; |
431 const int bottomBorderFirstPixel = frameImage.width() * frameImage.height() - frameCornerHeight*frameImage.width() - 1; |
423 const int rightBorderFirstPixel = frameImage.width()-frameCornerWidth; |
432 const int rightBorderFirstPixel = frameImage.width() - frameCornerWidth; |
424 const int leftBorderLastPixel = frameCornerWidth; |
433 const int leftBorderLastPixel = frameCornerWidth; |
425 |
434 |
426 while ((skips + estimations) < pixels) { |
435 while ((skips + estimations) < pixels) { |
427 if ((skips+estimations) > topBorderLastPixel && |
436 if ((skips + estimations) > topBorderLastPixel && |
428 (skips+estimations) < bottomBorderFirstPixel) { |
437 (skips + estimations) < bottomBorderFirstPixel) { |
429 for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) { |
438 for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) { |
430 if (rowIndex > leftBorderLastPixel && |
439 if (rowIndex > leftBorderLastPixel && |
431 rowIndex < rightBorderFirstPixel) { |
440 rowIndex < rightBorderFirstPixel) { |
432 estimatedRed += qRed(*pixelRgb); |
441 estimatedRed += qRed(*pixelRgb); |
433 estimatedGreen += qGreen(*pixelRgb); |
442 estimatedGreen += qGreen(*pixelRgb); |
528 if (orientation == Qt::Horizontal) { |
537 if (orientation == Qt::Horizontal) { |
529 startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
538 startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
530 endRect = startRect.translated(rect.width() - startRect.width(), 0); |
539 endRect = startRect.translated(rect.width() - startRect.width(), 0); |
531 middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
540 middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
532 if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
541 if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
533 const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x())>>1; |
542 const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1; |
534 startRect.setWidth(startRect.width()-overlap); |
543 startRect.setWidth(startRect.width() - overlap); |
535 endRect.adjust(overlap,0,0,0); |
544 endRect.adjust(overlap, 0, 0, 0); |
536 } |
545 } |
537 } else { |
546 } else { |
538 startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
547 startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
539 endRect = startRect.translated(0, rect.height() - startRect.height()); |
548 endRect = startRect.translated(0, rect.height() - startRect.height()); |
540 middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
549 middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
541 if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
550 if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
542 const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y())>>1; |
551 const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1; |
543 startRect.setHeight(startRect.height()-overlap); |
552 startRect.setHeight(startRect.height() - overlap); |
544 endRect.adjust(0,overlap,0,0); |
553 endRect.adjust(0, overlap, 0, 0); |
545 } |
554 } |
546 } |
555 } |
547 |
556 |
548 #if 0 |
557 #if 0 |
549 painter->save(); |
558 painter->save(); |
562 |
571 |
563 QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, |
572 QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, |
564 const QSize &size, QPainter *painter, SkinElementFlags flags) |
573 const QSize &size, QPainter *painter, SkinElementFlags flags) |
565 { |
574 { |
566 QPixmap result; |
575 QPixmap result; |
576 const int animationFrame = (flags & SF_Animation) ? currentAnimationFrame(part) : 0; |
|
577 |
|
567 const QString cacheKey = |
578 const QString cacheKey = |
568 QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") |
579 QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4 AnimationFrame=%5") |
569 .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); |
580 .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags).arg(animationFrame); |
570 if (!QPixmapCache::find(cacheKey, result)) { |
581 if (!QPixmapCache::find(cacheKey, result)) { |
571 result = QS60StylePrivate::part(part, size, painter, flags); |
582 result = QS60StylePrivate::part(part, size, painter, flags); |
572 QPixmapCache::insert(cacheKey, result); |
583 QPixmapCache::insert(cacheKey, result); |
573 } |
584 } |
574 return result; |
585 return result; |
619 fontCategory = QS60StyleEnums::FC_Secondary; |
630 fontCategory = QS60StyleEnums::FC_Secondary; |
620 } else if (qobject_cast<QGroupBox *>(widget)){ |
631 } else if (qobject_cast<QGroupBox *>(widget)){ |
621 fontCategory = QS60StyleEnums::FC_Title; |
632 fontCategory = QS60StyleEnums::FC_Title; |
622 } |
633 } |
623 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
634 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
635 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
|
636 && (widget->font().resolve() & QFont::SizeResolved); |
|
624 const QFont suggestedFont = |
637 const QFont suggestedFont = |
625 s60Font(fontCategory, widget->font().pointSizeF()); |
638 s60Font(fontCategory, widget->font().pointSizeF(), resolveFontSize); |
626 widget->setFont(suggestedFont); |
639 widget->setFont(suggestedFont); |
627 } |
640 } |
628 } |
641 } |
629 |
642 |
630 void QS60StylePrivate::setThemePalette(QWidget *widget) const |
643 void QS60StylePrivate::setThemePalette(QWidget *widget) const |
668 palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); |
681 palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); |
669 palette->setColor(QPalette::Highlight, |
682 palette->setColor(QPalette::Highlight, |
670 s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); |
683 s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); |
671 // set background image as a texture brush |
684 // set background image as a texture brush |
672 palette->setBrush(QPalette::Window, backgroundTexture()); |
685 palette->setBrush(QPalette::Window, backgroundTexture()); |
673 // set these as transparent so that styled full screen theme background is visible |
686 // set as transparent so that styled full screen theme background is visible |
674 palette->setColor(QPalette::AlternateBase, Qt::transparent); |
|
675 palette->setBrush(QPalette::Base, Qt::transparent); |
687 palette->setBrush(QPalette::Base, Qt::transparent); |
676 // set button and tooltipbase based on pixel colors |
688 // set button and tooltipbase based on pixel colors |
677 const QColor buttonColor = colorFromFrameGraphics(SF_ButtonNormal); |
689 const QColor buttonColor = colorFromFrameGraphics(SF_ButtonNormal); |
678 palette->setColor(QPalette::Button, buttonColor); |
690 palette->setColor(QPalette::Button, buttonColor); |
679 const QColor toolTipColor = colorFromFrameGraphics(SF_ToolTip); |
691 const QColor toolTipColor = colorFromFrameGraphics(SF_ToolTip); |
681 palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); |
693 palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); |
682 palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); |
694 palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); |
683 palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); |
695 palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); |
684 palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); |
696 palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); |
685 palette->setColor(QPalette::Shadow, Qt::black); |
697 palette->setColor(QPalette::Shadow, Qt::black); |
698 QColor alternateBase = palette->light().color(); |
|
699 alternateBase.setAlphaF(0.8); |
|
700 palette->setColor(QPalette::AlternateBase, alternateBase); |
|
686 |
701 |
687 QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash |
702 QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash |
688 setThemePaletteHash(palette); |
703 setThemePaletteHash(palette); |
689 storeThemePalette(palette); |
704 storeThemePalette(palette); |
690 } |
705 } |
771 widgetPalette.setColor(QPalette::HighlightedText, |
786 widgetPalette.setColor(QPalette::HighlightedText, |
772 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
787 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
773 QApplication::setPalette(widgetPalette, "QComboBox"); |
788 QApplication::setPalette(widgetPalette, "QComboBox"); |
774 widgetPalette = *palette; |
789 widgetPalette = *palette; |
775 |
790 |
791 widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
|
792 QApplication::setPalette(widgetPalette, "QRadioButton"); |
|
793 QApplication::setPalette(widgetPalette, "QCheckBox"); |
|
794 widgetPalette = *palette; |
|
795 |
|
776 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
796 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
777 widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); |
797 widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); |
778 widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); |
798 widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); |
779 widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter()); |
799 widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter()); |
780 QApplication::setPalette(widgetPalette, "QDial"); |
800 QApplication::setPalette(widgetPalette, "QDial"); |
787 //Webpages should not use S60 theme colors as they are designed to work |
807 //Webpages should not use S60 theme colors as they are designed to work |
788 //with themeBackground and do not generally mesh well with web page backgrounds. |
808 //with themeBackground and do not generally mesh well with web page backgrounds. |
789 QPalette webPalette = *palette; |
809 QPalette webPalette = *palette; |
790 webPalette.setColor(QPalette::WindowText, Qt::black); |
810 webPalette.setColor(QPalette::WindowText, Qt::black); |
791 webPalette.setColor(QPalette::Text, Qt::black); |
811 webPalette.setColor(QPalette::Text, Qt::black); |
812 webPalette.setBrush(QPalette::Base, Qt::white); |
|
813 |
|
792 QApplication::setPalette(webPalette, "QWebView"); |
814 QApplication::setPalette(webPalette, "QWebView"); |
793 QApplication::setPalette(webPalette, "QGraphicsWebView"); |
815 QApplication::setPalette(webPalette, "QGraphicsWebView"); |
816 |
|
817 m_webPaletteKey = webPalette.cacheKey(); |
|
794 } |
818 } |
795 |
819 |
796 QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
820 QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
797 { |
821 { |
798 QSize result(20, 20); |
822 QSize result(20, 20); |
807 case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
831 case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
808 case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
832 case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
809 case QS60StyleEnums::SP_QgnGrafTabActiveL: |
833 case QS60StyleEnums::SP_QgnGrafTabActiveL: |
810 //Returned QSize for tabs must not be square, but narrow rectangle with width:height |
834 //Returned QSize for tabs must not be square, but narrow rectangle with width:height |
811 //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
835 //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
812 result.setWidth(result.height()>>1); |
836 result.setWidth(result.height() >> 1); |
813 break; |
837 break; |
814 |
838 |
815 case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
839 case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
816 case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
840 case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
817 case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
841 case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
818 result.setWidth(result.height()>>1); |
842 result.setWidth(result.height() >> 1); |
819 break; |
843 break; |
820 |
844 |
821 case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
845 case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
822 case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
846 case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
823 result.scale(pixelMetric(QStyle::PM_SliderLength), |
847 result.scale(pixelMetric(QStyle::PM_SliderLength), |
824 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
848 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
825 break; |
849 break; |
827 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
851 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
828 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
852 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
829 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
853 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
830 break; |
854 break; |
831 |
855 |
832 case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
|
833 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
856 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
834 case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
|
835 case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
857 case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
836 case QS60StyleEnums::SP_QsnCpScrollBgMiddle: |
|
837 case QS60StyleEnums::SP_QsnCpScrollBgTop: |
858 case QS60StyleEnums::SP_QsnCpScrollBgTop: |
838 case QS60StyleEnums::SP_QsnCpScrollHandleBottom: |
859 case QS60StyleEnums::SP_QsnCpScrollHandleBottom: |
860 case QS60StyleEnums::SP_QsnCpScrollHandleTop: |
|
861 case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
|
862 result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
|
863 result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); |
|
864 break; |
|
865 case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
|
866 case QS60StyleEnums::SP_QsnCpScrollBgMiddle: |
|
839 case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: |
867 case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: |
840 case QS60StyleEnums::SP_QsnCpScrollHandleTop: |
|
841 result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
868 result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
842 result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); |
869 result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); |
843 break; |
870 break; |
844 default: |
871 default: |
845 // Generic frame part size gathering. |
872 // Generic frame part size gathering. |
873 result.setHeight(temp); |
900 result.setHeight(temp); |
874 } |
901 } |
875 return result; |
902 return result; |
876 } |
903 } |
877 |
904 |
878 bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) |
905 bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget) |
879 { |
906 { |
907 // Always return true for web pages. |
|
908 if (widget && m_webPaletteKey == QApplication::palette(widget).cacheKey()) |
|
909 return true; |
|
880 //If brush is not changed from style's default values, draw theme graphics. |
910 //If brush is not changed from style's default values, draw theme graphics. |
881 return (backgroundBrush.color() == Qt::transparent || |
911 return (backgroundBrush.color() == Qt::transparent || |
882 backgroundBrush.style() == Qt::NoBrush) ? true : false; |
912 backgroundBrush.style() == Qt::NoBrush) ? true : false; |
883 } |
913 } |
884 |
914 |
918 |
948 |
919 const QS60StylePrivate::SkinElements grooveElement = |
949 const QS60StylePrivate::SkinElements grooveElement = |
920 horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; |
950 horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; |
921 QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); |
951 QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); |
922 |
952 |
923 const QStyle::SubControls subControls = optionSlider->subControls; |
953 const SubControls subControls = optionSlider->subControls; |
924 |
954 |
925 // select correct slider (horizontal/vertical/pressed) |
955 // select correct slider (horizontal/vertical/pressed) |
926 const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider)); |
956 const bool sliderPressed = ((optionSlider->state & State_Sunken) && (subControls & SC_ScrollBarSlider)); |
927 const QS60StylePrivate::SkinElements handleElement = |
957 const QS60StylePrivate::SkinElements handleElement = |
928 horizontal ? |
958 horizontal ? |
929 ( sliderPressed ? |
959 ( sliderPressed ? |
930 QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : |
960 QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : |
931 QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : |
961 QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : |
942 |
972 |
943 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
973 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
944 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
974 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
945 |
975 |
946 //Highlight |
976 //Highlight |
947 /* if (optionSlider->state & QStyle::State_HasFocus) |
977 /* if (optionSlider->state & State_HasFocus) |
948 drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ |
978 drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ |
949 |
979 |
950 //Groove graphics |
980 //Groove graphics |
951 if (QS60StylePrivate::hasSliderGrooveGraphic()) { |
981 if (QS60StylePrivate::hasSliderGrooveGraphic()) { |
952 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
982 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
953 QS60StylePrivate::SE_SliderGrooveHorizontal : |
983 QS60StylePrivate::SE_SliderGrooveHorizontal : |
954 QS60StylePrivate::SE_SliderGrooveVertical; |
984 QS60StylePrivate::SE_SliderGrooveVertical; |
955 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
985 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
956 } else { |
986 } else { |
957 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
987 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
958 const QPoint sliderGrooveCenter = sliderGroove.center(); |
988 const QPoint sliderGrooveCenter = sliderGroove.center(); |
968 } |
998 } |
969 |
999 |
970 //Handle graphics |
1000 //Handle graphics |
971 const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
1001 const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
972 QS60StylePrivate::SkinElements handleElement; |
1002 QS60StylePrivate::SkinElements handleElement; |
973 if (optionSlider->state & QStyle::State_Sunken) |
1003 if (optionSlider->state & State_Sunken) |
974 handleElement = |
1004 handleElement = |
975 horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; |
1005 horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; |
976 else |
1006 else |
977 handleElement = |
1007 handleElement = |
978 horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; |
1008 horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; |
979 QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); |
1009 QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); |
980 } |
1010 } |
981 break; |
1011 break; |
990 // Button frame |
1020 // Button frame |
991 QStyleOptionFrame buttonOption; |
1021 QStyleOptionFrame buttonOption; |
992 buttonOption.QStyleOption::operator=(*cmb); |
1022 buttonOption.QStyleOption::operator=(*cmb); |
993 const int maxHeight = cmbxFrame.height(); |
1023 const int maxHeight = cmbxFrame.height(); |
994 const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); |
1024 const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); |
995 const int topLeftPoint = direction ? cmbxEditField.right()+1 : cmbxEditField.left()+1-maxWidth; |
1025 const int topLeftPoint = direction ? |
1026 (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); |
|
996 const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); |
1027 const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); |
997 buttonOption.rect = buttonRect; |
1028 buttonOption.rect = buttonRect; |
998 buttonOption.state = cmb->state & (State_Enabled | State_MouseOver); |
1029 buttonOption.state = cmb->state; |
999 drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
1030 drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
1000 |
1031 |
1001 // draw label background - label itself is drawn separately |
1032 // draw label background - label itself is drawn separately |
1002 const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; |
1033 const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; |
1003 QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); |
1034 QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); |
1015 break; |
1046 break; |
1016 #endif // QT_NO_COMBOBOX |
1047 #endif // QT_NO_COMBOBOX |
1017 #ifndef QT_NO_TOOLBUTTON |
1048 #ifndef QT_NO_TOOLBUTTON |
1018 case CC_ToolButton: |
1049 case CC_ToolButton: |
1019 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
1050 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
1020 const State bflags = toolBtn->state; |
1051 State bflags = toolBtn->state & ~State_Sunken; |
1052 |
|
1053 if (bflags & State_AutoRaise) { |
|
1054 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { |
|
1055 bflags &= ~State_Raised; |
|
1056 } |
|
1057 } |
|
1058 State mflags = bflags; |
|
1059 if (toolBtn->state & State_Sunken) { |
|
1060 if (toolBtn->activeSubControls & SC_ToolButton) |
|
1061 bflags |= State_Sunken; |
|
1062 mflags |= State_Sunken; |
|
1063 } |
|
1064 |
|
1021 const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
1065 const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
1022 QRect menuRect = QRect(); |
1066 QRect menuRect = QRect(); |
1023 if (toolBtn->subControls & SC_ToolButtonMenu) |
1067 if (toolBtn->subControls & SC_ToolButtonMenu) |
1024 menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); |
1068 menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); |
1025 |
1069 |
1026 QStyleOptionToolButton toolButton = *toolBtn; |
1070 if (toolBtn->subControls & SC_ToolButton) { |
1027 |
|
1028 if (sub&SC_ToolButton) { |
|
1029 QStyleOption tool(0); |
1071 QStyleOption tool(0); |
1030 tool.palette = toolBtn->palette; |
1072 tool.palette = toolBtn->palette; |
1031 |
1073 |
1032 // Check if toolbutton is in toolbar. |
1074 if (bflags & (State_Sunken | State_On | State_Raised | State_Enabled)) { |
1033 QToolBar *toolBar = 0; |
|
1034 if (widget) |
|
1035 toolBar = qobject_cast<QToolBar *>(widget->parentWidget()); |
|
1036 |
|
1037 if (bflags & (State_Sunken | State_On | State_Raised)) { |
|
1038 tool.rect = button.unite(menuRect); |
1075 tool.rect = button.unite(menuRect); |
1039 tool.state = bflags; |
1076 tool.state = bflags; |
1040 |
1077 const QToolButton *toolButtonWidget = qobject_cast<const QToolButton *>(widget); |
1041 // todo: I'd like to move extension button next to where last button is |
1078 QS60StylePrivate::SkinElements element; |
1042 // however, the painter seems to want to clip the button rect even if I turn of the clipping. |
1079 if (toolButtonWidget) |
1043 if (toolBar && (qobject_cast<const QToolBarExtension *>(widget))){ |
1080 element = (toolButtonWidget->isDown()) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; |
1044 /*QList<QAction *> actionList = toolBar->actions(); |
1081 else |
1045 const int actionCount = actionList.count(); |
1082 element = (option->state & State_Sunken) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; |
1046 const int toolbarWidth = toolBar->width(); |
1083 QS60StylePrivate::drawSkinElement(element, painter, tool.rect, flags); |
1047 const int extButtonWidth = pixelMetric(PM_ToolBarExtensionExtent, option, widget); |
1084 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
1048 const int toolBarButtonWidth = pixelMetric(PM_ToolBarIconSize, option, widget); |
|
1049 const int frame = pixelMetric(PM_ToolBarFrameWidth, option, widget); |
|
1050 const int margin = pixelMetric(PM_ToolBarItemMargin, option, widget); |
|
1051 const int border = frame + margin; |
|
1052 const int spacing = pixelMetric(PM_ToolBarItemSpacing, option, widget); |
|
1053 const int toolBarButtonArea = toolbarWidth - extButtonWidth - spacing - 2*border; |
|
1054 const int numberOfVisibleButtons = toolBarButtonArea / toolBarButtonWidth; |
|
1055 // new extension button place is after border and all the other visible buttons (with spacings) |
|
1056 const int newXForExtensionButton = numberOfVisibleButtons * toolBarButtonWidth + (numberOfVisibleButtons-1)*spacing + border; |
|
1057 painter->save(); |
|
1058 painter->setClipping(false); |
|
1059 tool.rect.translate(-newXForExtensionButton,0); |
|
1060 painter->restore();*/ |
|
1061 } |
|
1062 |
|
1063 if (toolBar){ |
|
1064 /*if (toolBar->orientation() == Qt::Vertical){ |
|
1065 // todo: I'd like to make all vertical buttons the same size, but again the painter |
|
1066 // prefers to use clipping for button rects, even though clipping has been set off. |
|
1067 painter->save(); |
|
1068 painter->setClipping(false); |
|
1069 |
|
1070 const int origWidth = tool.rect.width(); |
|
1071 const int newWidth = toolBar->width()-2*pixelMetric(PM_ToolBarFrameWidth, option, widget); |
|
1072 painter->translate(origWidth-newWidth,0); |
|
1073 tool.rect.translate(origWidth-tool.rect.width(),0); |
|
1074 tool.rect.setWidth(newWidth); |
|
1075 |
|
1076 if (option->state & QStyle::State_Sunken) |
|
1077 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButtonPressed, painter, tool.rect, flags); |
|
1078 else |
|
1079 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButton, painter, tool.rect, flags); |
|
1080 |
|
1081 }*/ |
|
1082 if (option->state & QStyle::State_Sunken) |
|
1083 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButtonPressed, painter, tool.rect, flags); |
|
1084 else |
|
1085 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButton, painter, tool.rect, flags); |
|
1086 /* |
|
1087 if (toolBar->orientation() == Qt::Vertical) |
|
1088 painter->restore(); |
|
1089 */ |
|
1090 } else { |
|
1091 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
|
1092 } |
|
1093 |
|
1094 if (toolButton.subControls & SC_ToolButtonMenu) { |
|
1095 tool.rect = menuRect; |
|
1096 tool.state = bflags; |
|
1097 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
|
1098 } |
|
1099 } |
1085 } |
1100 } |
1086 if (toolBtn->subControls & SC_ToolButtonMenu) { |
1101 |
1087 tool.rect = menuRect; |
1088 tool.state = mflags; |
|
1089 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
|
1090 } |
|
1091 } |
|
1092 QStyleOptionToolButton toolButton = *toolBtn; |
|
1102 if (toolBtn->features & QStyleOptionToolButton::Arrow) { |
1093 if (toolBtn->features & QStyleOptionToolButton::Arrow) { |
1103 QStyle::PrimitiveElement pe; |
1094 PrimitiveElement pe; |
1104 switch (toolBtn->arrowType) { |
1095 switch (toolBtn->arrowType) { |
1105 case Qt::LeftArrow: |
1096 case Qt::LeftArrow: |
1106 pe = QStyle::PE_IndicatorArrowLeft; |
1097 pe = PE_IndicatorArrowLeft; |
1107 break; |
1098 break; |
1108 case Qt::RightArrow: |
1099 case Qt::RightArrow: |
1109 pe = QStyle::PE_IndicatorArrowRight; |
1100 pe = PE_IndicatorArrowRight; |
1110 break; |
1101 break; |
1111 case Qt::UpArrow: |
1102 case Qt::UpArrow: |
1112 pe = QStyle::PE_IndicatorArrowUp; |
1103 pe = PE_IndicatorArrowUp; |
1113 break; |
1104 break; |
1114 case Qt::DownArrow: |
1105 case Qt::DownArrow: |
1115 pe = QStyle::PE_IndicatorArrowDown; |
1106 pe = PE_IndicatorArrowDown; |
1116 break; |
1107 break; |
1117 default: |
1108 default: |
1118 break; } |
1109 break; } |
1119 toolButton.rect = button; |
1110 toolButton.rect = button; |
1120 drawPrimitive(pe, &toolButton, painter, widget); |
1111 drawPrimitive(pe, &toolButton, painter, widget); |
1194 case CC_GroupBox: |
1185 case CC_GroupBox: |
1195 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
1186 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
1196 // Draw frame |
1187 // Draw frame |
1197 const QRect textRect = subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); |
1188 const QRect textRect = subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); |
1198 const QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); |
1189 const QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); |
1199 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { |
1190 if (groupBox->subControls & SC_GroupBoxFrame) { |
1200 QStyleOptionFrameV2 frame; |
1191 QStyleOptionFrameV2 frame; |
1201 frame.QStyleOption::operator=(*groupBox); |
1192 frame.QStyleOption::operator=(*groupBox); |
1202 frame.features = groupBox->features; |
1193 frame.features = groupBox->features; |
1203 frame.lineWidth = groupBox->lineWidth; |
1194 frame.lineWidth = groupBox->lineWidth; |
1204 frame.midLineWidth = groupBox->midLineWidth; |
1195 frame.midLineWidth = groupBox->midLineWidth; |
1205 frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); |
1196 frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); |
1206 drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); |
1197 drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); |
1207 } |
1198 } |
1208 |
1199 |
1209 // Draw title |
1200 // Draw title |
1210 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
1201 if ((groupBox->subControls & SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
1211 const QColor textColor = groupBox->textColor; |
1202 const QColor textColor = groupBox->textColor; |
1212 painter->save(); |
1203 painter->save(); |
1213 |
1204 |
1214 if (textColor.isValid()) |
1205 if (textColor.isValid()) |
1215 painter->setPen(textColor); |
1206 painter->setPen(textColor); |
1216 int alignment = int(groupBox->textAlignment); |
1207 int alignment = int(groupBox->textAlignment); |
1217 if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget)) |
1208 if (!styleHint(SH_UnderlineShortcut, option, widget)) |
1218 alignment |= Qt::TextHideMnemonic; |
1209 alignment |= Qt::TextHideMnemonic; |
1219 |
1210 |
1220 drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | Qt::AlignVCenter | alignment, |
1211 drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | Qt::AlignVCenter | alignment, |
1221 groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
1212 groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
1222 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
1213 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
1244 void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
1235 void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
1245 { |
1236 { |
1246 Q_D(const QS60Style); |
1237 Q_D(const QS60Style); |
1247 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
1238 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
1248 switch (element) { |
1239 switch (element) { |
1240 case CE_CheckBox: |
|
1241 case CE_RadioButton: |
|
1242 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1243 bool isRadio = (element == CE_RadioButton); |
|
1244 // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
|
1245 if (btn->state & State_HasFocus) { |
|
1246 QStyleOptionFocusRect fropt; |
|
1247 fropt.QStyleOption::operator=(*btn); |
|
1248 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
|
1249 : SE_CheckBoxFocusRect, btn, widget); |
|
1250 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
1251 } |
|
1252 QStyleOptionButton subopt = *btn; |
|
1253 |
|
1254 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
|
1255 : SE_CheckBoxIndicator, btn, widget); |
|
1256 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
|
1257 &subopt, painter, widget); |
|
1258 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents |
|
1259 : SE_CheckBoxContents, btn, widget); |
|
1260 |
|
1261 drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); |
|
1262 } |
|
1263 break; |
|
1264 |
|
1249 case CE_PushButton: |
1265 case CE_PushButton: |
1250 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1266 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1251 |
1267 |
1252 drawControl(CE_PushButtonBevel, btn, painter, widget); |
1268 drawControl(CE_PushButtonBevel, btn, painter, widget); |
1253 QStyleOptionButton subopt = *btn; |
1269 QStyleOptionButton subopt = *btn; |
1256 drawControl(CE_PushButtonLabel, &subopt, painter, widget); |
1272 drawControl(CE_PushButtonLabel, &subopt, painter, widget); |
1257 } |
1273 } |
1258 break; |
1274 break; |
1259 case CE_PushButtonBevel: |
1275 case CE_PushButtonBevel: |
1260 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1276 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1261 const bool isDisabled = !(option->state & QStyle::State_Enabled); |
1277 const bool isDisabled = !(option->state & State_Enabled); |
1262 const bool isFlat = button->features & QStyleOptionButton::Flat; |
1278 const bool isFlat = button->features & QStyleOptionButton::Flat; |
1263 QS60StyleEnums::SkinParts skinPart; |
1279 QS60StyleEnums::SkinParts skinPart; |
1264 QS60StylePrivate::SkinElements skinElement; |
1280 QS60StylePrivate::SkinElements skinElement; |
1265 if (!isDisabled) { |
1281 if (!isDisabled) { |
1266 const bool isPressed = (option->state & QStyle::State_Sunken) || |
1282 const bool isPressed = (option->state & State_Sunken) || |
1267 (option->state & QStyle::State_On); |
1283 (option->state & State_On); |
1268 if (isFlat) { |
1284 if (isFlat) { |
1269 skinPart = |
1285 skinPart = |
1270 isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; |
1286 isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; |
1271 } else { |
1287 } else { |
1272 skinElement = |
1288 skinElement = |
1287 #ifndef QT_NO_TOOLBUTTON |
1303 #ifndef QT_NO_TOOLBUTTON |
1288 case CE_ToolButtonLabel: |
1304 case CE_ToolButtonLabel: |
1289 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
1305 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
1290 QStyleOptionToolButton optionToolButton = *toolBtn; |
1306 QStyleOptionToolButton optionToolButton = *toolBtn; |
1291 |
1307 |
1292 if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken) |
1308 if (!optionToolButton.icon.isNull() && (optionToolButton.state & State_Sunken) |
1293 && (optionToolButton.state & State_Enabled)) { |
1309 && (optionToolButton.state & State_Enabled)) { |
1294 |
1310 |
1295 const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; |
1311 const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; |
1296 const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize), |
1312 const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize), |
1297 QIcon::Normal, state)); |
1313 QIcon::Normal, state)); |
1346 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
1362 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
1347 QStyleOptionViewItemV4 voptAdj = *vopt; |
1363 QStyleOptionViewItemV4 voptAdj = *vopt; |
1348 painter->save(); |
1364 painter->save(); |
1349 |
1365 |
1350 painter->setClipRect(voptAdj.rect); |
1366 painter->setClipRect(voptAdj.rect); |
1351 const bool isSelected = (vopt->state & QStyle::State_Selected); |
1367 const bool isSelected = (vopt->state & State_Selected); |
1352 const bool hasFocus = (vopt->state & QStyle::State_HasFocus); |
1368 const bool hasFocus = (vopt->state & State_HasFocus); |
1353 |
1369 |
1354 bool isScrollBarVisible = false; |
1370 bool isScrollBarVisible = false; |
1355 int scrollBarWidth = 0; |
1371 int scrollBarWidth = 0; |
1356 QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget); |
1372 QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget); |
1357 for (int i = 0; i < scrollBars.size(); ++i) { |
1373 for (int i = 0; i < scrollBars.size(); ++i) { |
1361 scrollBarWidth = scrollBar->size().width(); |
1377 scrollBarWidth = scrollBar->size().width(); |
1362 break; |
1378 break; |
1363 } |
1379 } |
1364 } |
1380 } |
1365 |
1381 |
1366 int rightValue = widget ? widget->contentsRect().right() : 0; |
1382 int rightValue = widget ? widget->contentsRect().right() : voptAdj.rect.right(); |
1367 |
1383 |
1368 if (isScrollBarVisible) |
1384 if (isScrollBarVisible) |
1369 rightValue -= scrollBarWidth; |
1385 rightValue -= scrollBarWidth; |
1370 |
1386 |
1371 if (voptAdj.rect.right() > rightValue) |
1387 if (voptAdj.rect.right() > rightValue) |
1379 if (vopt->backgroundBrush == Qt::NoBrush) { |
1395 if (vopt->backgroundBrush == Qt::NoBrush) { |
1380 if (itemView) { |
1396 if (itemView) { |
1381 const QModelIndex index = vopt->index; |
1397 const QModelIndex index = vopt->index; |
1382 //todo: Draw cell background only once - for the first cell. |
1398 //todo: Draw cell background only once - for the first cell. |
1383 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
1399 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
1384 const QModelIndex indexFirst = itemView->model()->index(0,0); |
1400 const QModelIndex indexFirst = itemView->model()->index(0, 0); |
1385 const QModelIndex indexLast = itemView->model()->index( |
1401 const QModelIndex indexLast = itemView->model()->index( |
1386 itemView->model()->rowCount()-1,itemView->model()->columnCount()-1); |
1402 itemView->model()->rowCount() - 1, itemView->model()->columnCount() -1); |
1387 if (itemView->viewport()) |
1403 if (itemView->viewport()) |
1388 voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), |
1404 voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), |
1389 itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); |
1405 itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); |
1390 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1406 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1391 } |
1407 } |
1421 else |
1437 else |
1422 painter->fillRect(highlightRect, vopt->palette.highlight()); |
1438 painter->fillRect(highlightRect, vopt->palette.highlight()); |
1423 } |
1439 } |
1424 |
1440 |
1425 // draw the icon |
1441 // draw the icon |
1426 const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
1442 const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
1427 const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off; |
1443 const QIcon::State state = voptAdj.state & State_Open ? QIcon::On : QIcon::Off; |
1428 voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1444 voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1429 |
1445 |
1430 // Draw selection check mark. Show check mark only in multi selection modes. |
1446 // Draw selection check mark. Show check mark only in multi selection modes. |
1431 if (itemView) { |
1447 if (itemView) { |
1432 const bool singleSelection = |
1448 const bool singleSelection = |
1434 itemView->selectionMode() == QAbstractItemView::NoSelection); |
1450 itemView->selectionMode() == QAbstractItemView::NoSelection); |
1435 const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
1451 const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
1436 |
1452 |
1437 QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
1453 QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
1438 // Draw selection mark. |
1454 // Draw selection mark. |
1439 if (voptAdj.state & QStyle::State_Selected && !singleSelection) { |
1455 if (voptAdj.state & State_Selected && !singleSelection) { |
1440 checkMarkOption.rect = selectionRect; |
1456 checkMarkOption.rect = selectionRect; |
1441 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1457 drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1442 if ( textRect.right() > selectionRect.left() ) |
1458 if ( textRect.right() > selectionRect.left() ) |
1443 textRect.setRight(selectionRect.left()); |
1459 textRect.setRight(selectionRect.left()); |
1444 } else if (singleSelection && |
1460 } else if (singleSelection && |
1445 voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && |
1461 voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && |
1446 selectionRect.isValid()) { |
1462 selectionRect.isValid()) { |
1447 checkMarkOption.rect = selectionRect; |
1463 checkMarkOption.rect = selectionRect; |
1448 checkMarkOption.state = checkMarkOption.state & ~QStyle::State_HasFocus; |
1464 checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; |
1449 |
1465 |
1450 switch (vopt->checkState) { |
1466 switch (vopt->checkState) { |
1451 case Qt::Unchecked: |
1467 case Qt::Unchecked: |
1452 checkMarkOption.state |= QStyle::State_Off; |
1468 checkMarkOption.state |= State_Off; |
1453 break; |
1469 break; |
1454 case Qt::PartiallyChecked: |
1470 case Qt::PartiallyChecked: |
1455 checkMarkOption.state |= QStyle::State_NoChange; |
1471 checkMarkOption.state |= State_NoChange; |
1456 break; |
1472 break; |
1457 case Qt::Checked: |
1473 case Qt::Checked: |
1458 checkMarkOption.state |= QStyle::State_On; |
1474 checkMarkOption.state |= State_On; |
1459 break; |
1475 break; |
1460 } |
1476 } |
1461 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1477 drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1462 } |
1478 } |
1463 } |
1479 } |
1464 |
1480 |
1465 // draw the text |
1481 // draw the text |
1466 if (!voptAdj.text.isEmpty()) { |
1482 if (!voptAdj.text.isEmpty()) { |
1481 #endif // QT_NO_ITEMVIEWS |
1497 #endif // QT_NO_ITEMVIEWS |
1482 #ifndef QT_NO_TABBAR |
1498 #ifndef QT_NO_TABBAR |
1483 case CE_TabBarTabShape: |
1499 case CE_TabBarTabShape: |
1484 if (const QStyleOptionTabV3 *optionTab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
1500 if (const QStyleOptionTabV3 *optionTab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
1485 QStyleOptionTabV3 optionTabAdj = *optionTab; |
1501 QStyleOptionTabV3 optionTabAdj = *optionTab; |
1486 const bool isSelected = optionTab->state & QStyle::State_Selected; |
1502 const bool isSelected = optionTab->state & State_Selected; |
1487 const bool directionMirrored = (optionTab->direction == Qt::RightToLeft); |
1503 const bool directionMirrored = (optionTab->direction == Qt::RightToLeft); |
1488 QS60StylePrivate::SkinElements skinElement; |
1504 QS60StylePrivate::SkinElements skinElement; |
1489 switch (optionTab->shape) { |
1505 switch (optionTab->shape) { |
1490 case QTabBar::TriangularEast: |
1506 case QTabBar::TriangularEast: |
1491 case QTabBar::RoundedEast: |
1507 case QTabBar::RoundedEast: |
1516 skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| |
1532 skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| |
1517 skinElement==QS60StylePrivate::SE_TabBarTabNorthActive|| |
1533 skinElement==QS60StylePrivate::SE_TabBarTabNorthActive|| |
1518 skinElement==QS60StylePrivate::SE_TabBarTabSouthActive|| |
1534 skinElement==QS60StylePrivate::SE_TabBarTabSouthActive|| |
1519 skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { |
1535 skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { |
1520 const int borderThickness = |
1536 const int borderThickness = |
1521 QS60StylePrivate::pixelMetric(QStyle::PM_DefaultFrameWidth); |
1537 QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1522 const int tabOverlap = |
1538 const int tabOverlap = |
1523 QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness; |
1539 QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; |
1524 //todo: draw navi wipe behind tabbar - must be drawn with first draw |
1540 //todo: draw navi wipe behind tabbar - must be drawn with first draw |
1525 |
1541 |
1526 if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| |
1542 if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| |
1527 skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| |
1543 skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| |
1528 skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| |
1544 skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| |
1541 case CE_TabBarTabLabel: |
1557 case CE_TabBarTabLabel: |
1542 if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
1558 if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
1543 QStyleOptionTabV3 optionTab = *tab; |
1559 QStyleOptionTabV3 optionTab = *tab; |
1544 QRect tr = optionTab.rect; |
1560 QRect tr = optionTab.rect; |
1545 const bool directionMirrored = (optionTab.direction == Qt::RightToLeft); |
1561 const bool directionMirrored = (optionTab.direction == Qt::RightToLeft); |
1546 const int borderThickness = QS60StylePrivate::pixelMetric(QStyle::PM_DefaultFrameWidth); |
1562 const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1547 const int tabOverlap = |
1563 const int tabOverlap = |
1548 QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness; |
1564 QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; |
1549 const QRect windowRect = painter->window(); |
1565 const QRect windowRect = painter->window(); |
1550 |
1566 |
1551 switch (tab->shape) { |
1567 switch (tab->shape) { |
1552 case QTabBar::TriangularWest: |
1568 case QTabBar::TriangularWest: |
1553 case QTabBar::RoundedWest: |
1569 case QTabBar::RoundedWest: |
1569 painter->save(); |
1585 painter->save(); |
1570 QFont f = painter->font(); |
1586 QFont f = painter->font(); |
1571 f.setPointSizeF(f.pointSizeF() * KTabFontMul); |
1587 f.setPointSizeF(f.pointSizeF() * KTabFontMul); |
1572 painter->setFont(f); |
1588 painter->setFont(f); |
1573 |
1589 |
1574 if (option->state & QStyle::State_Selected){ |
1590 const bool selected = optionTab.state & State_Selected; |
1591 if (selected) |
|
1575 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1592 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1576 QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); |
1593 QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); |
1577 } |
|
1578 |
1594 |
1579 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1595 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1580 || optionTab.shape == QTabBar::RoundedWest |
1596 || optionTab.shape == QTabBar::RoundedWest |
1581 || optionTab.shape == QTabBar::TriangularEast |
1597 || optionTab.shape == QTabBar::TriangularEast |
1582 || optionTab.shape == QTabBar::TriangularWest; |
1598 || optionTab.shape == QTabBar::TriangularWest; |
1583 const bool selected = optionTab.state & State_Selected; |
1599 |
1584 if (verticalTabs) { |
1600 if (verticalTabs) { |
1585 painter->save(); |
1601 painter->save(); |
1586 int newX, newY, newRotation; |
1602 int newX, newY, newRotation; |
1587 if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { |
1603 if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { |
1588 newX = tr.width(); |
1604 newX = tr.width(); |
1597 QTransform m; |
1613 QTransform m; |
1598 m.translate(newX, newY); |
1614 m.translate(newX, newY); |
1599 m.rotate(newRotation); |
1615 m.rotate(newRotation); |
1600 painter->setTransform(m, true); |
1616 painter->setTransform(m, true); |
1601 } |
1617 } |
1602 tr.adjust(0, 0, pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget), |
1618 tr.adjust(0, 0, pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget), |
1603 pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget)); |
1619 pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); |
1604 |
1620 |
1605 if (selected) { |
1621 if (selected) { |
1606 tr.setBottom(tr.bottom() - pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget)); |
1622 tr.setBottom(tr.bottom() - pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); |
1607 tr.setRight(tr.right() - pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget)); |
1623 tr.setRight(tr.right() - pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget)); |
1608 } |
1624 } |
1609 |
1625 |
1610 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; |
1626 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; |
1611 if (!styleHint(SH_UnderlineShortcut, &optionTab, widget)) |
1627 if (!styleHint(SH_UnderlineShortcut, &optionTab, widget)) |
1612 alignment |= Qt::TextHideMnemonic; |
1628 alignment |= Qt::TextHideMnemonic; |
1616 if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) |
1632 if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) |
1617 iconSize = QSize(iconExtent, iconExtent); |
1633 iconSize = QSize(iconExtent, iconExtent); |
1618 QPixmap tabIcon = optionTab.icon.pixmap(iconSize, |
1634 QPixmap tabIcon = optionTab.icon.pixmap(iconSize, |
1619 (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
1635 (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
1620 if (tab->text.isEmpty()) |
1636 if (tab->text.isEmpty()) |
1621 painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1), |
1637 painter->drawPixmap(tr.center().x() - (tabIcon.height() >> 1), |
1622 tr.center().y() - (tabIcon.height() >>1), |
1638 tr.center().y() - (tabIcon.height() >> 1), |
1623 tabIcon); |
1639 tabIcon); |
1624 else |
1640 else |
1625 painter->drawPixmap(tr.left() + tabOverlap, |
1641 painter->drawPixmap(tr.left() + tabOverlap, |
1626 tr.center().y() - (tabIcon.height() >>1), |
1642 tr.center().y() - (tabIcon.height() >> 1), |
1627 tabIcon); |
1643 tabIcon); |
1628 tr.setLeft(tr.left() + iconSize.width() + 4); |
1644 tr.setLeft(tr.left() + iconSize.width() + 4); |
1629 } |
1645 } |
1630 |
1646 |
1631 QCommonStyle::drawItemText(painter, tr, alignment, optionTab.palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
1647 QCommonStyle::drawItemText(painter, tr, alignment, optionTab.palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
1643 |
1659 |
1644 if (optionProgressBar->minimum == optionProgressBar->maximum && optionProgressBar->minimum == 0) { |
1660 if (optionProgressBar->minimum == optionProgressBar->maximum && optionProgressBar->minimum == 0) { |
1645 // busy indicator |
1661 // busy indicator |
1646 const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ? |
1662 const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ? |
1647 QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest; |
1663 QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest; |
1648 QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWait, painter, progressRect, flags | orientationFlag); |
1664 |
1665 QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWaitAnim, |
|
1666 painter, progressRect, flags | orientationFlag | QS60StylePrivate::SF_Animation ); |
|
1649 } else { |
1667 } else { |
1650 const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 |
1668 const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 |
1651 : (qreal)optionProgressBar->progress / optionProgressBar->maximum; |
1669 : (qreal)optionProgressBar->progress / optionProgressBar->maximum; |
1670 const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
|
1652 if (optionProgressBar->orientation == Qt::Horizontal) { |
1671 if (optionProgressBar->orientation == Qt::Horizontal) { |
1653 progressRect.setWidth(int(progressRect.width() * progressFactor)); |
1672 progressRect.setWidth(int(progressRect.width() * progressFactor)); |
1654 if(optionProgressBar->direction == Qt::RightToLeft) |
1673 if(optionProgressBar->direction == Qt::RightToLeft) |
1655 progressRect.translate(optionProgressBar->rect.width()-progressRect.width(),0); |
1674 progressRect.translate(optionProgressBar->rect.width() - progressRect.width(), 0); |
1656 progressRect.adjust(1, 0, -1, 0); |
1675 progressRect.adjust(frameWidth, 0, -frameWidth, 0); |
1657 } else { |
1676 } else { |
1658 progressRect.adjust(0, 1, 0, -1); |
1677 progressRect.adjust(0, frameWidth, 0, -frameWidth); |
1659 progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); |
1678 progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); |
1660 } |
1679 } |
1661 |
1680 |
1662 const QS60StylePrivate::SkinElements skinElement = optionProgressBar->orientation == Qt::Horizontal ? |
1681 const QS60StylePrivate::SkinElements skinElement = optionProgressBar->orientation == Qt::Horizontal ? |
1663 QS60StylePrivate::SE_ProgressBarIndicatorHorizontal : QS60StylePrivate::SE_ProgressBarIndicatorVertical; |
1682 QS60StylePrivate::SE_ProgressBarIndicatorHorizontal : QS60StylePrivate::SE_ProgressBarIndicatorVertical; |
1709 |
1728 |
1710 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
1729 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
1711 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
1730 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
1712 |
1731 |
1713 //todo: move the vertical spacing stuff into subElementRect |
1732 //todo: move the vertical spacing stuff into subElementRect |
1714 const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
1733 const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
1715 if (checkable){ |
1734 if (checkable){ |
1716 const int hSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
1735 const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
1717 QStyleOptionMenuItem optionCheckBox; |
1736 QStyleOptionMenuItem optionCheckBox; |
1718 optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
1737 optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
1719 optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1738 optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1720 optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
1739 optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
1721 const int moveByX = optionCheckBox.rect.width()+vSpacing; |
1740 const int moveByX = optionCheckBox.rect.width() + vSpacing; |
1722 if (optionMenuItem.direction == Qt::LeftToRight) { |
1741 if (optionMenuItem.direction == Qt::LeftToRight) { |
1723 textRect.translate(moveByX,0); |
1742 textRect.translate(moveByX, 0); |
1724 iconRect.translate(moveByX, 0); |
1743 iconRect.translate(moveByX, 0); |
1725 iconRect.setWidth(iconRect.width()+vSpacing); |
1744 iconRect.setWidth(iconRect.width() + vSpacing); |
1726 textRect.setWidth(textRect.width()-moveByX-vSpacing); |
1745 textRect.setWidth(textRect.width() - moveByX - vSpacing); |
1727 optionCheckBox.rect.translate(vSpacing/2, hSpacing/2); |
1746 optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1); |
1728 } else { |
1747 } else { |
1729 textRect.setWidth(textRect.width()-moveByX); |
1748 textRect.setWidth(textRect.width() - moveByX); |
1730 iconRect.setWidth(iconRect.width()+vSpacing); |
1749 iconRect.setWidth(iconRect.width() + vSpacing); |
1731 iconRect.translate(-optionCheckBox.rect.width()-vSpacing, 0); |
1750 iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); |
1732 optionCheckBox.rect.translate(textRect.width()+iconRect.width(),0); |
1751 optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); |
1733 } |
1752 } |
1734 drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); |
1753 drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); |
1735 } |
1754 } |
1736 //draw icon and/or checkState |
1755 //draw icon and/or checkState |
1737 QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
1756 QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
1738 enabled ? QIcon::Normal : QIcon::Disabled); |
1757 enabled ? QIcon::Normal : QIcon::Disabled); |
1739 const bool itemWithIcon = !pix.isNull(); |
1758 const bool itemWithIcon = !pix.isNull(); |
1740 if (itemWithIcon) { |
1759 if (itemWithIcon) { |
1741 drawItemPixmap(painter, iconRect, text_flags, pix); |
1760 drawItemPixmap(painter, iconRect, text_flags, pix); |
1742 if (optionMenuItem.direction == Qt::LeftToRight) |
1761 if (optionMenuItem.direction == Qt::LeftToRight) |
1743 textRect.translate(vSpacing,0); |
1762 textRect.translate(vSpacing, 0); |
1744 else |
1763 else |
1745 textRect.translate(-vSpacing,0); |
1764 textRect.translate(-vSpacing, 0); |
1746 textRect.setWidth(textRect.width()-vSpacing); |
1765 textRect.setWidth(textRect.width()-vSpacing); |
1747 } |
1766 } |
1748 |
1767 |
1749 //draw indicators |
1768 //draw indicators |
1750 if (drawSubMenuIndicator) { |
1769 if (drawSubMenuIndicator) { |
1751 QStyleOptionMenuItem arrowOptions; |
1770 QStyleOptionMenuItem arrowOptions; |
1752 arrowOptions.QStyleOption::operator=(*menuItem); |
1771 arrowOptions.QStyleOption::operator=(*menuItem); |
1753 const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget)>>1) + |
1772 const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget) >> 1) + |
1754 pixelMetric(QStyle::PM_LayoutVerticalSpacing, option, widget); |
1773 pixelMetric(PM_LayoutVerticalSpacing, option, widget); |
1755 if (optionMenuItem.direction == Qt::LeftToRight) |
1774 if (optionMenuItem.direction == Qt::LeftToRight) |
1756 arrowOptions.rect.setLeft(textRect.right()); |
1775 arrowOptions.rect.setLeft(textRect.right()); |
1757 arrowOptions.rect.setWidth(indicatorWidth); |
1776 arrowOptions.rect.setWidth(indicatorWidth); |
1758 //by default sub menu indicator in S60 points to east,so here icon |
1777 //by default sub menu indicator in S60 points to east,so here icon |
1759 // direction is set to north (and south when in RightToLeft) |
1778 // direction is set to north (and south when in RightToLeft) |
1793 case CE_HeaderSection: |
1812 case CE_HeaderSection: |
1794 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1813 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1795 painter->save(); |
1814 painter->save(); |
1796 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1815 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1797 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1816 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1798 linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1817 linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1799 : linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1818 : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1800 linePen.setWidth(penWidth); |
1819 linePen.setWidth(penWidth); |
1801 painter->setPen(linePen); |
1820 painter->setPen(linePen); |
1802 if (header->orientation == Qt::Horizontal){ |
1821 if (header->orientation == Qt::Horizontal){ |
1803 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1822 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1804 } else { |
1823 } else { |
1813 //Draw corner button as normal pushButton. |
1832 //Draw corner button as normal pushButton. |
1814 if (qobject_cast<const QAbstractButton *>(widget)) { |
1833 if (qobject_cast<const QAbstractButton *>(widget)) { |
1815 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1834 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1816 QStyleOptionHeader subopt = *header; |
1835 QStyleOptionHeader subopt = *header; |
1817 const int borderTweak = |
1836 const int borderTweak = |
1818 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1; |
1837 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
1819 if (subopt.direction == Qt::LeftToRight) |
1838 if (subopt.direction == Qt::LeftToRight) |
1820 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1839 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1821 else |
1840 else |
1822 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1841 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1823 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1842 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1889 break; |
1908 break; |
1890 #endif //QT_NO_TOOLBAR |
1909 #endif //QT_NO_TOOLBAR |
1891 case CE_ShapedFrame: |
1910 case CE_ShapedFrame: |
1892 if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
1911 if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
1893 const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
1912 const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
1894 if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base())) |
1913 if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base(), widget)) |
1895 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
1914 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
1896 else |
1915 else |
1897 QCommonStyle::drawControl(element, option, painter, widget); |
1916 QCommonStyle::drawControl(element, option, painter, widget); |
1898 } else if (qobject_cast<const QTableView *>(widget)) { |
1917 } else if (qobject_cast<const QTableView *>(widget)) { |
1899 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
1918 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
1906 //todo: update to horizontal table graphic |
1925 //todo: update to horizontal table graphic |
1907 adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
1926 adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
1908 } else { |
1927 } else { |
1909 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1928 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1910 if (option->direction == Qt::LeftToRight) |
1929 if (option->direction == Qt::LeftToRight) |
1911 headerRect.adjust(-2*frameWidth, 0, 0, 0); |
1930 headerRect.adjust(-2 * frameWidth, 0, 0, 0); |
1912 else |
1931 else |
1913 headerRect.adjust(0, 0, 2*frameWidth, 0); |
1932 headerRect.adjust(0, 0, 2 * frameWidth, 0); |
1914 } |
1933 } |
1915 if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
1934 if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
1916 QS60StylePrivate::drawSkinElement( |
1935 QS60StylePrivate::drawSkinElement( |
1917 QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
1936 QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
1918 |
1937 |
1920 QCommonStyle::drawControl(element, option, painter, widget); |
1939 QCommonStyle::drawControl(element, option, painter, widget); |
1921 } |
1940 } |
1922 break; |
1941 break; |
1923 case CE_MenuScroller: |
1942 case CE_MenuScroller: |
1924 break; |
1943 break; |
1925 case CE_FocusFrame: |
1944 case CE_FocusFrame: { |
1926 { |
|
1927 // The pen width should nearly fill the layoutspacings around the widget |
1945 // The pen width should nearly fill the layoutspacings around the widget |
1928 const int penWidth = |
1946 const int penWidth = |
1929 qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) |
1947 qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) |
1930 - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets |
1948 - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets |
1931 |
1949 |
1980 /*! |
1998 /*! |
1981 \reimp |
1999 \reimp |
1982 */ |
2000 */ |
1983 void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
2001 void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
1984 { |
2002 { |
1985 Q_D(const QS60Style); |
|
1986 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
2003 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
1987 bool commonStyleDraws = false; |
2004 bool commonStyleDraws = false; |
1988 |
2005 |
1989 switch (element) { |
2006 switch (element) { |
2007 case PE_FrameFocusRect: { |
|
2008 //Draw themed highlight to radiobuttons and checkboxes. |
|
2009 //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. |
|
2010 if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) |
|
2011 if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && |
|
2012 (qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) |
|
2013 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
|
2014 else |
|
2015 commonStyleDraws = true; |
|
2016 } |
|
2017 break; |
|
1990 #ifndef QT_NO_LINEEDIT |
2018 #ifndef QT_NO_LINEEDIT |
1991 case PE_PanelLineEdit: |
2019 case PE_PanelLineEdit: |
1992 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2020 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
1993 #ifndef QT_NO_COMBOBOX |
2021 #ifndef QT_NO_COMBOBOX |
1994 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
2022 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
1995 break; |
2023 break; |
1996 #endif |
2024 #endif |
1997 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) |
2025 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) |
1998 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
2026 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
1999 else |
2027 else |
2000 commonStyleDraws = true; |
2028 commonStyleDraws = true; |
2001 } |
2029 } |
2002 break; |
2030 break; |
2003 #endif // QT_NO_LINEEDIT |
2031 #endif // QT_NO_LINEEDIT |
2004 case PE_IndicatorCheckBox: |
2032 case PE_IndicatorCheckBox: { |
2005 { |
|
2006 // Draw checkbox indicator as color skinned graphics. |
2033 // Draw checkbox indicator as color skinned graphics. |
2007 const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? |
2034 const QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? |
2008 QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; |
2035 QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; |
2009 painter->save(); |
2036 painter->save(); |
2010 |
2037 |
2011 QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); |
2038 const QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); |
2012 QColor windowTextColor = option->palette.windowText().color(); |
2039 const QColor windowTextColor = option->palette.windowText().color(); |
2013 |
2040 |
2014 if (themeColor != windowTextColor) |
2041 if (themeColor != windowTextColor) |
2015 painter->setPen(windowTextColor); |
2042 painter->setPen(windowTextColor); |
2016 |
2043 |
2017 QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned ); |
2044 QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned ); |
2027 QAbstractItemView::SingleSelection || listItem->selectionMode() == QAbstractItemView::NoSelection; |
2054 QAbstractItemView::SingleSelection || listItem->selectionMode() == QAbstractItemView::NoSelection; |
2028 // draw either checkbox at the beginning |
2055 // draw either checkbox at the beginning |
2029 if (checkBoxVisible && singleSelection) { |
2056 if (checkBoxVisible && singleSelection) { |
2030 drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
2057 drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
2031 // ... or normal "tick" selection at the end. |
2058 // ... or normal "tick" selection at the end. |
2032 } else if (option->state & QStyle::State_Selected) { |
2059 } else if (option->state & State_Selected) { |
2033 QRect tickRect = option->rect; |
2060 QRect tickRect = option->rect; |
2034 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); |
2061 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); |
2035 // adjust tickmark rect to exclude frame border |
2062 // adjust tickmark rect to exclude frame border |
2036 tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth); |
2063 tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
2037 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2064 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2038 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2065 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2039 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2066 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2040 } |
2067 } |
2041 } |
2068 } |
2043 #endif //QT_NO_ITEMVIEWS |
2070 #endif //QT_NO_ITEMVIEWS |
2044 break; |
2071 break; |
2045 case PE_IndicatorRadioButton: { |
2072 case PE_IndicatorRadioButton: { |
2046 QRect buttonRect = option->rect; |
2073 QRect buttonRect = option->rect; |
2047 //there is empty (a. 33%) space in svg graphics for radiobutton |
2074 //there is empty (a. 33%) space in svg graphics for radiobutton |
2048 const qreal reduceWidth = (qreal)buttonRect.width()/3.0; |
2075 const qreal reduceWidth = (qreal)buttonRect.width() / 3.0; |
2049 const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0; |
2076 const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0; |
2050 // Try to occupy the full area |
2077 // Try to occupy the full area |
2051 const qreal scaler = 1 + (reduceWidth/rectWidth); |
2078 const qreal scaler = 1 + (reduceWidth/rectWidth); |
2052 buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
2079 buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
2053 buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
2080 buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
2054 // move the rect up for half of the new height-gain |
2081 // move the rect up for half of the new height-gain |
2055 const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; |
2082 const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; |
2056 buttonRect.adjust(0, -newY, -1, -newY); |
2083 buttonRect.adjust(0, -newY, -1, -newY); |
2057 |
2084 |
2058 painter->save(); |
2085 painter->save(); |
2059 QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); |
2086 const QColor themeColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); |
2060 QColor buttonTextColor = option->palette.buttonText().color(); |
2087 const QColor buttonTextColor = option->palette.buttonText().color(); |
2061 if (themeColor != buttonTextColor) |
2088 if (themeColor != buttonTextColor) |
2062 painter->setPen(buttonTextColor); |
2089 painter->setPen(buttonTextColor); |
2063 else |
2090 else |
2064 painter->setPen(themeColor); |
2091 painter->setPen(themeColor); |
2065 |
2092 |
2066 // Draw radiobutton indicator as color skinned graphics. |
2093 // Draw radiobutton indicator as color skinned graphics. |
2067 QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? |
2094 QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? |
2068 QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; |
2095 QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; |
2069 QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, |
2096 QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, |
2070 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2097 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2071 painter->restore(); |
2098 painter->restore(); |
2072 } |
2099 } |
2073 break; |
2100 break; |
2074 case PE_PanelButtonCommand: |
2101 case PE_PanelButtonCommand: |
2075 case PE_PanelButtonTool: |
2102 case PE_PanelButtonTool: |
2076 case PE_PanelButtonBevel: |
2103 case PE_PanelButtonBevel: |
2077 case PE_FrameButtonBevel: { |
2104 case PE_FrameButtonBevel: |
2078 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) { |
2105 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) { |
2079 const bool isPressed = option->state & QStyle::State_Sunken; |
2106 const bool isPressed = option->state & State_Sunken; |
2080 const QS60StylePrivate::SkinElements skinElement = |
2107 const QS60StylePrivate::SkinElements skinElement = |
2081 isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
2108 isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
2082 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
2109 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
2083 } else { |
2110 } else { |
2084 commonStyleDraws = true; |
2111 commonStyleDraws = true; |
2085 } |
|
2086 } |
2112 } |
2087 break; |
2113 break; |
2088 #ifndef QT_NO_TOOLBUTTON |
2114 #ifndef QT_NO_TOOLBUTTON |
2089 case PE_IndicatorArrowDown: |
2115 case PE_IndicatorArrowDown: |
2090 case PE_IndicatorArrowLeft: |
2116 case PE_IndicatorArrowLeft: |
2106 #endif //QT_NO_TOOLBUTTON |
2132 #endif //QT_NO_TOOLBUTTON |
2107 #ifndef QT_NO_SPINBOX |
2133 #ifndef QT_NO_SPINBOX |
2108 case PE_IndicatorSpinDown: |
2134 case PE_IndicatorSpinDown: |
2109 case PE_IndicatorSpinUp: |
2135 case PE_IndicatorSpinUp: |
2110 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2136 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2111 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2137 if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) { |
2112 if (QS60StylePrivate::canDrawThemeBackground(optionSpinBox.palette.base())) { |
2138 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2113 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2139 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2114 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2140 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2115 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2141 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2116 const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; |
2142 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2117 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2143 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2118 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); |
2144 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
2119 } else { |
2145 } else { |
2120 commonStyleDraws = true; |
2146 commonStyleDraws = true; |
2121 } |
2147 } |
2122 } |
2148 } |
2149 #endif //QT_NO_SPINBOX |
|
2123 #ifndef QT_NO_COMBOBOX |
2150 #ifndef QT_NO_COMBOBOX |
2124 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2151 if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2125 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) { |
2152 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) { |
2126 // We want to draw down arrow here for comboboxes as well. |
2153 // We want to draw down arrow here for comboboxes as well. |
2154 QStyleOptionFrame optionsComboBox = *cmb; |
|
2127 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2155 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2128 QStyleOptionFrame comboBox = *cmb; |
2156 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2129 const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; |
2157 optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2130 comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2158 QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
2131 QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); |
|
2132 } else { |
2159 } else { |
2133 commonStyleDraws = true; |
2160 commonStyleDraws = true; |
2134 } |
2161 } |
2135 } |
2162 } |
2136 #endif //QT_NO_COMBOBOX |
2163 #endif //QT_NO_COMBOBOX |
2144 #ifndef QT_NO_COMBOBOX |
2171 #ifndef QT_NO_COMBOBOX |
2145 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2172 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2146 // We want to draw down arrow here for comboboxes as well. |
2173 // We want to draw down arrow here for comboboxes as well. |
2147 QStyleOptionFrame comboBox = *cmb; |
2174 QStyleOptionFrame comboBox = *cmb; |
2148 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
2175 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
2149 comboBox.rect.adjust(0,frameWidth,0,-frameWidth); |
2176 comboBox.rect.adjust(0, frameWidth, 0, -frameWidth); |
2150 QCommonStyle::drawPrimitive(element, &comboBox, painter, widget); |
2177 QCommonStyle::drawPrimitive(element, &comboBox, painter, widget); |
2151 } |
2178 } |
2152 #endif //QT_NO_COMBOBOX |
2179 #endif //QT_NO_COMBOBOX |
2153 break; |
2180 break; |
2154 #endif //QT_NO_SPINBOX |
|
2155 case PE_Widget: |
2181 case PE_Widget: |
2156 if (QS60StylePrivate::drawsOwnThemeBackground(widget) |
2182 if (QS60StylePrivate::drawsOwnThemeBackground(widget) |
2157 #ifndef QT_NO_COMBOBOX |
2183 #ifndef QT_NO_COMBOBOX |
2158 || qobject_cast<const QComboBoxListView *>(widget) |
2184 || qobject_cast<const QComboBoxListView *>(widget) |
2159 #endif //QT_NO_COMBOBOX |
2185 #endif //QT_NO_COMBOBOX |
2160 #ifndef QT_NO_MENU |
2186 #ifndef QT_NO_MENU |
2161 || qobject_cast<const QMenu *> (widget) |
2187 || qobject_cast<const QMenu *> (widget) |
2162 #endif //QT_NO_MENU |
2188 #endif //QT_NO_MENU |
2163 ) { |
2189 ) { |
2164 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) |
2190 //Need extra check since dialogs have their own theme background |
2191 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && |
|
2192 option->palette.window().texture().cacheKey() == |
|
2193 QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
|
2165 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2194 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2166 else |
2195 else |
2167 commonStyleDraws = true; |
2196 commonStyleDraws = true; |
2168 } |
2197 } |
2169 break; |
2198 break; |
2199 break; |
2228 break; |
2200 case PE_Frame: |
2229 case PE_Frame: |
2201 break; |
2230 break; |
2202 #ifndef QT_NO_ITEMVIEWS |
2231 #ifndef QT_NO_ITEMVIEWS |
2203 case PE_PanelItemViewItem: |
2232 case PE_PanelItemViewItem: |
2204 case PE_PanelItemViewRow: // ### Qt 5: remove |
|
2205 break; |
2233 break; |
2206 #endif //QT_NO_ITEMVIEWS |
2234 #endif //QT_NO_ITEMVIEWS |
2207 |
2235 |
2208 case PE_IndicatorMenuCheckMark: |
2236 case PE_IndicatorMenuCheckMark: |
2209 if (const QStyleOptionMenuItem *checkBox = qstyleoption_cast<const QStyleOptionMenuItem *>(option)){ |
2237 if (const QStyleOptionMenuItem *checkBox = qstyleoption_cast<const QStyleOptionMenuItem *>(option)){ |
2256 |
2284 |
2257 if (option->state & State_Children) { |
2285 if (option->state & State_Children) { |
2258 QS60StyleEnums::SkinParts skinPart = |
2286 QS60StyleEnums::SkinParts skinPart = |
2259 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2287 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2260 int minDimension = qMin(option->rect.width(), option->rect.height()); |
2288 int minDimension = qMin(option->rect.width(), option->rect.height()); |
2261 const int resizeValue = minDimension >> 1; |
|
2262 minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
|
2263 QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
2289 QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
2264 int verticalMagic(0); |
2290 const int magicTweak = 3; |
2265 // magic values for positioning svg icon. |
2291 int resizeValue = minDimension >> 1; |
2266 if (option->rect.width() <= option->rect.height()) |
2292 if (!QS60StylePrivate::isTouchSupported()) { |
2267 verticalMagic = 3; |
2293 minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
2268 iconRect.translate(3, verticalMagic - resizeValue); |
2294 iconRect.setSize(QSize(minDimension, minDimension)); |
2295 const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; |
|
2296 resizeValue = verticalMagic - resizeValue; |
|
2297 } |
|
2298 iconRect.translate(magicTweak, resizeValue); |
|
2269 QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2299 QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2270 } |
2300 } |
2271 } |
2301 } |
2272 break; |
2302 break; |
2273 |
2303 case PE_PanelItemViewRow: // ### Qt 5: remove |
2304 #ifndef QT_NO_ITEMVIEWS |
|
2305 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
2306 if (vopt->palette.base().texture().cacheKey() != QS60StylePrivate::m_themePalette->base().texture().cacheKey()) { |
|
2307 //QPalette::Base has been changed, let commonstyle draw the item |
|
2308 commonStyleDraws = true; |
|
2309 } else { |
|
2310 QPalette::ColorGroup cg = vopt->state & State_Enabled ? QPalette::Normal : QPalette::Disabled; |
|
2311 if (cg == QPalette::Normal && !(vopt->state & State_Active)) |
|
2312 cg = QPalette::Inactive; |
|
2313 if (vopt->features & QStyleOptionViewItemV2::Alternate) |
|
2314 painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); |
|
2315 //apart from alternate base, no background for list item is drawn for S60Style |
|
2316 } |
|
2317 } |
|
2318 #endif |
|
2319 break; |
|
2274 case PE_PanelScrollAreaCorner: |
2320 case PE_PanelScrollAreaCorner: |
2275 break; |
2321 break; |
2276 |
2322 case PE_IndicatorItemViewItemDrop: |
2323 if (QS60StylePrivate::isTouchSupported()) |
|
2324 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DropArea, painter, option->rect, flags); |
|
2325 else |
|
2326 commonStyleDraws = true; |
|
2327 break; |
|
2277 // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2328 // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2278 case PE_FrameLineEdit: |
2329 case PE_FrameLineEdit: |
2279 case PE_IndicatorDockWidgetResizeHandle: |
2330 case PE_IndicatorDockWidgetResizeHandle: |
2280 case PE_PanelTipLabel: |
2331 case PE_PanelTipLabel: |
2281 |
2332 |
2292 #ifndef QT_NO_TOOLBAR |
2343 #ifndef QT_NO_TOOLBAR |
2293 case PE_PanelToolBar: |
2344 case PE_PanelToolBar: |
2294 #endif //QT_NO_TOOLBAR |
2345 #endif //QT_NO_TOOLBAR |
2295 #ifndef QT_NO_COLUMNVIEW |
2346 #ifndef QT_NO_COLUMNVIEW |
2296 case PE_IndicatorColumnViewArrow: |
2347 case PE_IndicatorColumnViewArrow: |
2297 case PE_IndicatorItemViewItemDrop: |
|
2298 #endif //QT_NO_COLUMNVIEW |
2348 #endif //QT_NO_COLUMNVIEW |
2299 case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
2349 case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
2300 default: |
2350 default: |
2301 commonStyleDraws = true; |
2351 commonStyleDraws = true; |
2302 } |
2352 } |
2336 QSize sz(csz); |
2386 QSize sz(csz); |
2337 switch (ct) { |
2387 switch (ct) { |
2338 case CT_ToolButton: |
2388 case CT_ToolButton: |
2339 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2389 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2340 //FIXME properly - style should calculate the location of border frame-part |
2390 //FIXME properly - style should calculate the location of border frame-part |
2341 sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); |
2391 sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin)); |
2342 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
2392 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
2343 if (toolBtn->subControls & SC_ToolButtonMenu) |
2393 if (toolBtn->subControls & SC_ToolButtonMenu) |
2344 sz += QSize(pixelMetric(PM_MenuButtonIndicator),0); |
2394 sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); |
2345 break; |
2395 break; |
2346 case CT_PushButton: |
2396 case CT_PushButton: |
2347 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2397 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2348 //FIXME properly - style should calculate the location of border frame-part |
2398 //FIXME properly - style should calculate the location of border frame-part |
2349 sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); |
2399 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) { |
2350 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) |
|
2351 if (buttonWidget->isCheckable()) |
2400 if (buttonWidget->isCheckable()) |
2352 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2401 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2402 const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0; |
|
2403 const int textHeight = (buttonWidget->text().length() > 0) ? |
|
2404 buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0; |
|
2405 const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0; |
|
2406 |
|
2407 const int contentHeight = |
|
2408 qMax(qMax(iconHeight, decoratorHeight) + pixelMetric(PM_ButtonMargin), |
|
2409 textHeight + 2*pixelMetric(PM_ButtonMargin)); |
|
2410 sz.setHeight(contentHeight); |
|
2411 sz += QSize(2 * pixelMetric(PM_ButtonMargin), 0); |
|
2412 } |
|
2353 break; |
2413 break; |
2354 case CT_LineEdit: |
2414 case CT_LineEdit: |
2355 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2415 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2356 sz += QSize(2*f->lineWidth, 4*f->lineWidth); |
2416 sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); |
2357 break; |
2417 break; |
2358 case CT_TabBarTab: |
2418 case CT_TabBarTab: { |
2359 { |
|
2360 const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
2419 const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
2361 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
2420 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
2362 if (naviPaneSize.height() > sz.height()) |
2421 if (naviPaneSize.height() > sz.height()) |
2363 sz.setHeight(naviPaneSize.height()); |
2422 sz.setHeight(naviPaneSize.height()); |
2364 } |
2423 } |
2366 case CT_ItemViewItem: |
2425 case CT_ItemViewItem: |
2367 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2426 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2368 if (QS60StylePrivate::isTouchSupported()) |
2427 if (QS60StylePrivate::isTouchSupported()) |
2369 //Make itemview easier to use in touch devices |
2428 //Make itemview easier to use in touch devices |
2370 //QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
2429 //QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
2371 sz.setHeight(sz.height() + 2*pixelMetric(QStyle::PM_FocusFrameVMargin)); |
2430 sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); |
2372 break; |
2431 break; |
2432 #ifndef QT_NO_COMBOBOX |
|
2433 case CT_ComboBox: { |
|
2434 // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
|
2435 // Make sure, that the combobox says within the screen. |
|
2436 const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
|
2437 -QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
|
2438 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
|
2439 boundedTo(desktopContentSize); |
|
2440 } |
|
2441 break; |
|
2442 #endif |
|
2373 default: |
2443 default: |
2374 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2444 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2375 break; |
2445 break; |
2376 } |
2446 } |
2377 return sz; |
2447 return sz; |
2382 QStyleHintReturn *hret) const |
2452 QStyleHintReturn *hret) const |
2383 { |
2453 { |
2384 int retValue = -1; |
2454 int retValue = -1; |
2385 switch (sh) { |
2455 switch (sh) { |
2386 case SH_Table_GridLineColor: |
2456 case SH_Table_GridLineColor: |
2387 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgba()); |
2457 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
2388 break; |
2458 break; |
2389 case SH_GroupBox_TextLabelColor: |
2459 case SH_GroupBox_TextLabelColor: |
2390 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgba()); |
2460 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
2391 break; |
2461 break; |
2392 case SH_ScrollBar_ScrollWhenPointerLeavesControl: |
2462 case SH_ScrollBar_ScrollWhenPointerLeavesControl: |
2393 retValue = true; |
2463 retValue = true; |
2394 break; |
2464 break; |
2395 case SH_Slider_SnapToValue: |
2465 case SH_Slider_SnapToValue: |
2406 break; |
2476 break; |
2407 case SH_Dial_BackgroundRole: |
2477 case SH_Dial_BackgroundRole: |
2408 retValue = QPalette::Base; |
2478 retValue = QPalette::Base; |
2409 break; |
2479 break; |
2410 case SH_ItemView_ActivateItemOnSingleClick: |
2480 case SH_ItemView_ActivateItemOnSingleClick: |
2411 retValue = true; |
2481 retValue = QS60StylePrivate::isSingleClickUi(); |
2412 break; |
2482 break; |
2413 case SH_ProgressDialog_TextLabelAlignment: |
2483 case SH_ProgressDialog_TextLabelAlignment: |
2414 retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? |
2484 retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? |
2415 Qt::AlignLeft : |
2485 Qt::AlignLeft : |
2416 Qt::AlignRight; |
2486 Qt::AlignRight; |
2439 case SH_RequestSoftwareInputPanel: |
2509 case SH_RequestSoftwareInputPanel: |
2440 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
2510 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
2441 break; |
2511 break; |
2442 case SH_FormLayoutWrapPolicy: |
2512 case SH_FormLayoutWrapPolicy: |
2443 retValue = QFormLayout::WrapLongRows; |
2513 retValue = QFormLayout::WrapLongRows; |
2514 break; |
|
2515 case SH_ScrollBar_ContextMenu: |
|
2516 retValue = false; |
|
2444 break; |
2517 break; |
2445 default: |
2518 default: |
2446 retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
2519 retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
2447 break; |
2520 break; |
2448 } |
2521 } |
2467 if (scrollbarOption->maximum != scrollbarOption->minimum) { |
2540 if (scrollbarOption->maximum != scrollbarOption->minimum) { |
2468 const uint range = scrollbarOption->maximum - scrollbarOption->minimum; |
2541 const uint range = scrollbarOption->maximum - scrollbarOption->minimum; |
2469 sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep); |
2542 sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep); |
2470 |
2543 |
2471 const int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget); |
2544 const int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget); |
2472 if (sliderlen < slidermin || range > (INT_MAX>>1)) |
2545 if (sliderlen < slidermin || range > (INT_MAX >> 1)) |
2473 sliderlen = slidermin; |
2546 sliderlen = slidermin; |
2474 if (sliderlen > maxlen) |
2547 if (sliderlen > maxlen) |
2475 sliderlen = maxlen; |
2548 sliderlen = maxlen; |
2476 } else { |
2549 } else { |
2477 sliderlen = maxlen; |
2550 sliderlen = maxlen; |
2518 #endif // QT_NO_SCROLLBAR |
2591 #endif // QT_NO_SCROLLBAR |
2519 case CC_SpinBox: |
2592 case CC_SpinBox: |
2520 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2593 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2521 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2594 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2522 const int buttonMargin = spinbox->frame ? 2 : 0; |
2595 const int buttonMargin = spinbox->frame ? 2 : 0; |
2523 const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin; |
2596 const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
2524 QSize buttonSize; |
2597 QSize buttonSize; |
2525 buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); |
2598 buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); |
2526 buttonSize.setWidth(buttonWidth); |
2599 //width should at least be equal to height |
2600 buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); |
|
2527 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2601 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2528 |
2602 |
2529 const int y = frameThickness + spinbox->rect.y(); |
2603 const int y = frameThickness + spinbox->rect.y(); |
2530 const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2*buttonSize.width(); |
2604 const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2 * buttonSize.width(); |
2531 |
2605 |
2532 switch (scontrol) { |
2606 switch (scontrol) { |
2533 case SC_SpinBoxUp: |
2607 case SC_SpinBoxUp: |
2534 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2608 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2535 return QRect(); |
2609 return QRect(); |
2536 ret = QRect(x, y, buttonWidth, buttonSize.height()); |
2610 ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
2537 break; |
2611 break; |
2538 case SC_SpinBoxDown: |
2612 case SC_SpinBoxDown: |
2539 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2613 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2540 return QRect(); |
2614 return QRect(); |
2541 ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height()); |
2615 ret = QRect(x + buttonSize.width(), y, buttonSize.width(), buttonSize.height()); |
2542 break; |
2616 break; |
2543 case SC_SpinBoxEditField: |
2617 case SC_SpinBoxEditField: |
2544 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2618 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2545 ret = QRect( |
2619 ret = QRect( |
2546 frameThickness, |
2620 frameThickness, |
2547 frameThickness, |
2621 frameThickness, |
2548 spinbox->rect.width() - 2*frameThickness, |
2622 spinbox->rect.width() - 2 * frameThickness, |
2549 spinbox->rect.height() - 2*frameThickness); |
2623 spinbox->rect.height() - 2 * frameThickness); |
2550 else |
2624 else |
2551 ret = QRect( |
2625 ret = QRect( |
2552 frameThickness, |
2626 frameThickness, |
2553 frameThickness, |
2627 frameThickness, |
2554 x - frameThickness, |
2628 x - frameThickness, |
2555 spinbox->rect.height() - 2*frameThickness); |
2629 spinbox->rect.height() - 2 * frameThickness); |
2556 break; |
2630 break; |
2557 case SC_SpinBoxFrame: |
2631 case SC_SpinBoxFrame: |
2558 ret = spinbox->rect; |
2632 ret = spinbox->rect; |
2559 break; |
2633 break; |
2560 default: |
2634 default: |
2566 case CC_ComboBox: |
2640 case CC_ComboBox: |
2567 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
2641 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
2568 ret = cmb->rect; |
2642 ret = cmb->rect; |
2569 const int width = cmb->rect.width(); |
2643 const int width = cmb->rect.width(); |
2570 const int height = cmb->rect.height(); |
2644 const int height = cmb->rect.height(); |
2645 const int buttonIconSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize); |
|
2571 const int buttonMargin = cmb->frame ? 2 : 0; |
2646 const int buttonMargin = cmb->frame ? 2 : 0; |
2572 // lets use spinbox frame here as well, as no combobox specific value available. |
2647 // lets use spinbox frame here as well, as no combobox specific value available. |
2573 const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; |
2648 const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; |
2574 const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); |
2649 const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); |
2575 |
2650 |
2576 QSize buttonSize; |
2651 QSize buttonSize; |
2577 buttonSize.setHeight(qMax(8, (cmb->rect.height()>>1) - frameThickness)); //minimum of 8 pixels |
2652 buttonSize.setWidth(buttonWidth + 2 * buttonMargin); |
2578 buttonSize.setWidth(buttonWidth+2*buttonMargin); |
2653 buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares |
2579 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2654 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2580 switch (scontrol) { |
2655 switch (scontrol) { |
2581 case SC_ComboBoxArrow: |
2656 case SC_ComboBoxArrow: { |
2582 ret.setRect( |
2657 const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; |
2583 ret.x() + ret.width() - buttonMargin - buttonWidth, |
2658 const int ypos = cmb->rect.y(); |
2584 ret.y() + buttonMargin, |
2659 ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); |
2585 buttonWidth, |
2660 } |
2586 height - 2*buttonMargin); |
|
2587 break; |
2661 break; |
2588 case SC_ComboBoxEditField: { |
2662 case SC_ComboBoxEditField: { |
2589 ret.setRect( |
2663 const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); |
2590 ret.x() + frameThickness, |
2664 ret = QRect( |
2591 ret.y() + frameThickness, |
2665 frameThickness, |
2592 ret.width() - 2*frameThickness - buttonSize.width(), |
2666 frameThickness, |
2593 ret.height() - 2*frameThickness); |
2667 withFrameX - frameThickness, |
2668 height - 2 * frameThickness); |
|
2594 } |
2669 } |
2595 break; |
2670 break; |
2596 default: |
2671 default: |
2597 break; |
2672 break; |
2598 } |
2673 } |
2674 ret = visualRect(cmb->direction, cmb->rect, ret); |
|
2599 } |
2675 } |
2600 break; |
2676 break; |
2601 case CC_GroupBox: |
2677 case CC_GroupBox: |
2602 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
2678 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
2603 ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
2679 ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
2604 switch (scontrol) { |
2680 switch (scontrol) { |
2605 case SC_GroupBoxCheckBox: //fallthrough |
2681 case SC_GroupBoxCheckBox: //fallthrough |
2606 case SC_GroupBoxLabel: { |
2682 case SC_GroupBoxLabel: { |
2607 //slightly indent text and boxes, so that dialog border does not mess with them. |
2683 //slightly indent text and boxes, so that dialog border does not mess with them. |
2608 const int horizontalSpacing = |
2684 const int horizontalSpacing = |
2609 QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
2685 QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
2610 ret.adjust(2,horizontalSpacing-3,0,0); |
2686 ret.adjust(2, horizontalSpacing - 3, 0, 0); |
2611 } |
2687 } |
2612 break; |
2688 break; |
2613 case SC_GroupBoxFrame: { |
2689 case SC_GroupBoxFrame: { |
2614 const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); |
2690 const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); |
2615 const int tbHeight = textBox.height(); |
2691 const int tbHeight = textBox.height(); |
2616 ret.translate(0, -ret.y()); |
2692 ret.translate(0, -ret.y()); |
2617 // include title to within the groupBox frame |
2693 // include title to within the groupBox frame |
2618 ret.setHeight(ret.height()+tbHeight); |
2694 ret.setHeight(ret.height() + tbHeight); |
2619 if (widget && ret.bottom() > widget->rect().bottom()) |
2695 if (widget && ret.bottom() > widget->rect().bottom()) |
2620 ret.setBottom(widget->rect().bottom()); |
2696 ret.setBottom(widget->rect().bottom()); |
2621 } |
2697 } |
2622 break; |
2698 break; |
2623 default: |
2699 default: |
2625 } |
2701 } |
2626 } |
2702 } |
2627 break; |
2703 break; |
2628 case CC_ToolButton: |
2704 case CC_ToolButton: |
2629 if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
2705 if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
2630 const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2*pixelMetric(PM_ButtonMargin); |
2706 const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2 * pixelMetric(PM_ButtonMargin); |
2631 const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); |
2707 const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); |
2632 ret = toolButton->rect; |
2708 ret = toolButton->rect; |
2633 const bool popup = (toolButton->features & |
2709 const bool popup = (toolButton->features & |
2634 (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
2710 (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
2635 == QStyleOptionToolButton::MenuButtonPopup; |
2711 == QStyleOptionToolButton::MenuButtonPopup; |
2659 */ |
2735 */ |
2660 QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const |
2736 QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const |
2661 { |
2737 { |
2662 QRect ret; |
2738 QRect ret; |
2663 switch (element) { |
2739 switch (element) { |
2740 case SE_RadioButtonFocusRect: |
|
2741 ret = opt->rect; |
|
2742 break; |
|
2664 case SE_LineEditContents: { |
2743 case SE_LineEditContents: { |
2665 // in S60 the input text box doesn't start from line Edit's TL, but |
2744 // in S60 the input text box doesn't start from line Edit's TL, but |
2666 // a bit indented. |
2745 // a bit indented. |
2667 QRect lineEditRect = opt->rect; |
2746 QRect lineEditRect = opt->rect; |
2668 const int adjustment = opt->rect.height()>>2; |
2747 const int adjustment = opt->rect.height() >> 2; |
2669 lineEditRect.adjust(adjustment,0,0,0); |
2748 lineEditRect.adjust(adjustment, 0, 0, 0); |
2670 ret = lineEditRect; |
2749 ret = lineEditRect; |
2671 } |
2750 } |
2672 break; |
2751 break; |
2673 case SE_TabBarTearIndicator: |
2752 case SE_TabBarTearIndicator: |
2674 ret = QRect(0,0,0,0); |
2753 ret = QRect(0, 0, 0, 0); |
2675 break; |
2754 break; |
2676 case SE_TabWidgetTabBar: |
2755 case SE_TabWidgetTabBar: |
2677 if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
2756 if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
2678 ret = QCommonStyle::subElementRect(element, opt, widget); |
2757 ret = QCommonStyle::subElementRect(element, opt, widget); |
2679 |
2758 |
2680 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
2759 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
2681 const int tabOverlapNoBorder = |
2760 const int tabOverlapNoBorder = |
2682 QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap); |
2761 QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap); |
2683 const int tabOverlap = |
2762 const int tabOverlap = |
2684 tabOverlapNoBorder-QS60StylePrivate::pixelMetric(QStyle::PM_DefaultFrameWidth); |
2763 tabOverlapNoBorder-QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
2685 const QTabWidget *tab = qobject_cast<const QTabWidget *>(widget); |
2764 const QTabWidget *tab = qobject_cast<const QTabWidget *>(widget); |
2686 int gain = (tab) ? tabOverlap * tab->count() : 0; |
2765 int gain = (tab) ? tabOverlap * tab->count() : 0; |
2687 switch (twf->shape) { |
2766 switch (twf->shape) { |
2688 case QTabBar::RoundedNorth: |
2767 case QTabBar::RoundedNorth: |
2689 case QTabBar::TriangularNorth: |
2768 case QTabBar::TriangularNorth: |
2691 case QTabBar::TriangularSouth: { |
2770 case QTabBar::TriangularSouth: { |
2692 if (widget) { |
2771 if (widget) { |
2693 // make sure that gain does not set the rect outside of widget boundaries |
2772 // make sure that gain does not set the rect outside of widget boundaries |
2694 if (twf->direction == Qt::RightToLeft) { |
2773 if (twf->direction == Qt::RightToLeft) { |
2695 if ((ret.left() - gain) < widget->rect().left()) |
2774 if ((ret.left() - gain) < widget->rect().left()) |
2696 gain = widget->rect().left()-ret.left(); |
2775 gain = widget->rect().left() - ret.left(); |
2697 ret.adjust(-gain,0,0,0); |
2776 ret.adjust(-gain, 0, 0, 0); |
2698 } else { |
2777 } else { |
2699 if ((ret.right() + gain) > widget->rect().right()) |
2778 if ((ret.right() + gain) > widget->rect().right()) |
2700 gain = widget->rect().right()-ret.right(); |
2779 gain = widget->rect().right() - ret.right(); |
2701 ret.adjust(0,0,gain,0); |
2780 ret.adjust(0, 0, gain, 0); |
2702 } |
2781 } |
2703 } |
2782 } |
2704 break; |
2783 break; |
2705 } |
2784 } |
2706 default: { |
2785 default: { |
2707 if (widget) { |
2786 if (widget) { |
2708 if ((ret.bottom() + gain) > widget->rect().bottom()) |
2787 if ((ret.bottom() + gain) > widget->rect().bottom()) |
2709 gain = widget->rect().bottom()-ret.bottom(); |
2788 gain = widget->rect().bottom() - ret.bottom(); |
2710 ret.adjust(0,0,0,gain); |
2789 ret.adjust(0, 0, 0, gain); |
2711 } |
2790 } |
2712 break; |
2791 break; |
2713 } |
2792 } |
2714 } |
2793 } |
2715 } |
2794 } |
2728 // text and decoration towards the beginning |
2807 // text and decoration towards the beginning |
2729 if (listItem && |
2808 if (listItem && |
2730 multiSelection && |
2809 multiSelection && |
2731 (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { |
2810 (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { |
2732 const int verticalSpacing = |
2811 const int verticalSpacing = |
2733 QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
2812 QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
2734 //const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
2813 //const int horizontalSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
2735 const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); |
2814 const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); |
2736 ret.adjust(-checkBoxRectWidth-verticalSpacing,0,-checkBoxRectWidth-verticalSpacing,0); |
2815 ret.adjust(-checkBoxRectWidth - verticalSpacing, 0, -checkBoxRectWidth - verticalSpacing, 0); |
2737 } |
2816 } |
2738 } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
2817 } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
2739 const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
2818 const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
2740 const int indicatorWidth = checkable ? |
2819 const int indicatorWidth = checkable ? |
2741 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2820 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2756 |
2835 |
2757 // Make room for submenu indicator |
2836 // Make room for submenu indicator |
2758 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ |
2837 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ |
2759 // submenu indicator is very small, so lets halve the rect |
2838 // submenu indicator is very small, so lets halve the rect |
2760 if (menuItem->direction == Qt::LeftToRight) |
2839 if (menuItem->direction == Qt::LeftToRight) |
2761 ret.adjust(0,0,-(indicatorWidth >> 1),0); |
2840 ret.adjust(0, 0, -(indicatorWidth >> 1), 0); |
2762 else |
2841 else |
2763 ret.adjust((indicatorWidth >> 1),0,0,0); |
2842 ret.adjust((indicatorWidth >> 1), 0, 0, 0); |
2764 } |
2843 } |
2765 } |
2844 } |
2766 } |
2845 } |
2767 break; |
2846 break; |
2768 case SE_ItemViewItemCheckIndicator: |
2847 case SE_ItemViewItemCheckIndicator: |
2775 const bool checkBoxOnly = (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) && |
2854 const bool checkBoxOnly = (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) && |
2776 listItem && |
2855 listItem && |
2777 singleSelection; |
2856 singleSelection; |
2778 |
2857 |
2779 // Selection check mark rect. |
2858 // Selection check mark rect. |
2780 const int indicatorWidth = QS60StylePrivate::pixelMetric(QStyle::PM_IndicatorWidth); |
2859 const int indicatorWidth = QS60StylePrivate::pixelMetric(PM_IndicatorWidth); |
2781 const int indicatorHeight = QS60StylePrivate::pixelMetric(QStyle::PM_IndicatorHeight); |
2860 const int indicatorHeight = QS60StylePrivate::pixelMetric(PM_IndicatorHeight); |
2782 const int spacing = QS60StylePrivate::pixelMetric(QStyle::PM_CheckBoxLabelSpacing); |
2861 const int spacing = QS60StylePrivate::pixelMetric(PM_CheckBoxLabelSpacing); |
2783 |
2862 |
2784 const int itemHeight = opt->rect.height(); |
2863 const int itemHeight = opt->rect.height(); |
2785 int heightOffset = 0; |
2864 int heightOffset = 0; |
2786 if (indicatorHeight < itemHeight) |
2865 if (indicatorHeight < itemHeight) |
2787 heightOffset = ((itemHeight - indicatorHeight)>>1); |
2866 heightOffset = ((itemHeight - indicatorHeight) >> 1); |
2788 if (checkBoxOnly) { |
2867 if (checkBoxOnly) { |
2789 // Move rect and make it slightly smaller, so that |
2868 // Move rect and make it slightly smaller, so that |
2790 // a) highlight border does not cross the rect |
2869 // a) highlight border does not cross the rect |
2791 // b) in s60 list checkbox is smaller than normal checkbox |
2870 // b) in s60 list checkbox is smaller than normal checkbox |
2792 //todo; magic three |
2871 //todo; magic three |
2793 ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset, |
2872 ret.setRect(opt->rect.left() + 3, opt->rect.top() + heightOffset, |
2794 indicatorWidth-3, indicatorHeight-3); |
2873 indicatorWidth - 3, indicatorHeight - 3); |
2795 } else { |
2874 } else { |
2796 ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, |
2875 ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, |
2797 indicatorWidth, indicatorHeight); |
2876 indicatorWidth, indicatorHeight); |
2798 } |
2877 } |
2799 } else { |
2878 } else { |
2809 else |
2888 else |
2810 ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth)); |
2889 ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth)); |
2811 } |
2890 } |
2812 ret = visualRect(opt->direction, opt->rect, ret); |
2891 ret = visualRect(opt->direction, opt->rect, ret); |
2813 break; |
2892 break; |
2893 case SE_RadioButtonIndicator: { |
|
2894 const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
|
2895 ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), |
|
2896 pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), height); |
|
2897 ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it |
|
2898 ret = visualRect(opt->direction, opt->rect, ret); |
|
2899 } |
|
2900 break; |
|
2901 case SE_CheckBoxIndicator: { |
|
2902 const int height = pixelMetric(PM_IndicatorHeight, opt, widget); |
|
2903 ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), |
|
2904 pixelMetric(PM_IndicatorWidth, opt, widget), height); |
|
2905 ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it |
|
2906 ret = visualRect(opt->direction, opt->rect, ret); |
|
2907 } |
|
2908 break; |
|
2909 case SE_CheckBoxFocusRect: |
|
2910 ret = opt->rect; |
|
2911 break; |
|
2814 default: |
2912 default: |
2815 ret = QCommonStyle::subElementRect(element, opt, widget); |
2913 ret = QCommonStyle::subElementRect(element, opt, widget); |
2816 } |
2914 } |
2817 return ret; |
2915 return ret; |
2818 } |
2916 } |
2825 Q_D(const QS60Style); |
2923 Q_D(const QS60Style); |
2826 QCommonStyle::polish(widget); |
2924 QCommonStyle::polish(widget); |
2827 |
2925 |
2828 if (!widget) |
2926 if (!widget) |
2829 return; |
2927 return; |
2928 |
|
2929 //Currently we only support animations in QProgressBar. |
|
2930 #ifndef QT_NO_PROGRESSBAR |
|
2931 if (qobject_cast<QProgressBar *>(widget)) |
|
2932 widget->installEventFilter(this); |
|
2933 #endif |
|
2830 |
2934 |
2831 if (false |
2935 if (false |
2832 #ifndef QT_NO_SCROLLBAR |
2936 #ifndef QT_NO_SCROLLBAR |
2833 || qobject_cast<QScrollBar *>(widget) |
2937 || qobject_cast<QScrollBar *>(widget) |
2834 #endif |
2938 #endif |
2858 /*! |
2962 /*! |
2859 \reimp |
2963 \reimp |
2860 */ |
2964 */ |
2861 void QS60Style::unpolish(QWidget *widget) |
2965 void QS60Style::unpolish(QWidget *widget) |
2862 { |
2966 { |
2967 Q_D(QS60Style); |
|
2968 |
|
2863 if (false |
2969 if (false |
2864 #ifndef QT_NO_SCROLLBAR |
2970 #ifndef QT_NO_SCROLLBAR |
2865 || qobject_cast<QScrollBar *>(widget) |
2971 || qobject_cast<QScrollBar *>(widget) |
2866 #endif |
2972 #endif |
2867 ) |
2973 ) |
2884 } |
2990 } |
2885 |
2991 |
2886 if (widget) |
2992 if (widget) |
2887 widget->setPalette(QPalette()); |
2993 widget->setPalette(QPalette()); |
2888 |
2994 |
2995 #if defined(Q_WS_S60) && !defined(QT_NO_PROGRESSBAR) |
|
2996 if (QProgressBar *bar = qobject_cast<QProgressBar *>(widget)) { |
|
2997 widget->removeEventFilter(this); |
|
2998 d->m_bars.removeAll(bar); |
|
2999 } |
|
3000 #else |
|
3001 Q_UNUSED(d) |
|
3002 #endif |
|
2889 QCommonStyle::unpolish(widget); |
3003 QCommonStyle::unpolish(widget); |
2890 } |
3004 } |
2891 |
3005 |
2892 /*! |
3006 /*! |
2893 \reimp |
3007 \reimp |
2915 \reimp |
3029 \reimp |
2916 */ |
3030 */ |
2917 bool QS60Style::event(QEvent *e) |
3031 bool QS60Style::event(QEvent *e) |
2918 { |
3032 { |
2919 #ifdef QT_KEYPAD_NAVIGATION |
3033 #ifdef QT_KEYPAD_NAVIGATION |
2920 if (QS60StylePrivate::isTouchSupported()) |
|
2921 return false; |
|
2922 Q_D(QS60Style); |
3034 Q_D(QS60Style); |
3035 const QEvent::Type eventType = e->type(); |
|
3036 if ((eventType == QEvent::FocusIn || |
|
3037 eventType == QEvent::FocusOut || |
|
3038 eventType == QEvent::EnterEditFocus || |
|
3039 eventType == QEvent::LeaveEditFocus) && |
|
3040 QS60StylePrivate::isTouchSupported()) |
|
3041 return false; |
|
3042 #endif |
|
3043 |
|
2923 switch (e->type()) { |
3044 switch (e->type()) { |
3045 case QEvent::Timer: { |
|
3046 QTimerEvent *te = static_cast<QTimerEvent*>(e); |
|
3047 timerEvent(te); |
|
3048 } |
|
3049 break; |
|
3050 #ifdef QT_KEYPAD_NAVIGATION |
|
2924 case QEvent::FocusIn: |
3051 case QEvent::FocusIn: |
2925 if (QWidget *focusWidget = QApplication::focusWidget()) { |
3052 if (QWidget *focusWidget = QApplication::focusWidget()) { |
2926 if (!d->m_focusFrame) |
3053 if (!d->m_focusFrame) |
2927 d->m_focusFrame = new QFocusFrame(focusWidget); |
3054 d->m_focusFrame = new QFocusFrame(focusWidget); |
2928 d->m_focusFrame->setWidget(focusWidget); |
3055 d->m_focusFrame->setWidget(focusWidget); |
2937 case QEvent::EnterEditFocus: |
3064 case QEvent::EnterEditFocus: |
2938 case QEvent::LeaveEditFocus: |
3065 case QEvent::LeaveEditFocus: |
2939 if (d->m_focusFrame) |
3066 if (d->m_focusFrame) |
2940 d->m_focusFrame->update(); |
3067 d->m_focusFrame->update(); |
2941 break; |
3068 break; |
3069 #endif |
|
2942 default: |
3070 default: |
2943 break; |
3071 break; |
2944 } |
3072 } |
2945 #else |
|
2946 Q_UNUSED(e) |
|
2947 #endif |
|
2948 return false; |
3073 return false; |
2949 } |
3074 } |
2950 |
3075 |
2951 /*! |
3076 /*! |
2952 \internal |
3077 \internal |
2953 */ |
3078 */ |
2954 QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, |
3079 QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, |
2955 const QStyleOption *option, const QWidget *widget) const |
3080 const QStyleOption *option, const QWidget *widget) const |
2956 { |
3081 { |
2957 const int iconDimension = QS60StylePrivate::pixelMetric(QStyle::PM_ToolBarIconSize); |
3082 const int iconDimension = QS60StylePrivate::pixelMetric(PM_ToolBarIconSize); |
2958 const QRect iconSize = (!option) ? QRect(0,0,iconDimension,iconDimension) : option->rect; |
3083 const QRect iconSize = (!option) ? QRect(0, 0, iconDimension, iconDimension) : option->rect; |
2959 QS60StyleEnums::SkinParts part; |
3084 QS60StyleEnums::SkinParts part; |
2960 QS60StylePrivate::SkinElementFlags adjustedFlags; |
3085 QS60StylePrivate::SkinElementFlags adjustedFlags; |
2961 if (option) |
3086 if (option) |
2962 adjustedFlags = (option->state & State_Enabled || option->state == 0) ? |
3087 adjustedFlags = (option->state & State_Enabled || option->state == 0) ? |
2963 QS60StylePrivate::SF_StateEnabled : |
3088 QS60StylePrivate::SF_StateEnabled : |
2964 QS60StylePrivate::SF_StateDisabled; |
3089 QS60StylePrivate::SF_StateDisabled; |
2965 |
3090 |
2966 switch(standardIcon) { |
3091 switch(standardIcon) { |
2967 case QStyle::SP_MessageBoxWarning: |
3092 case SP_MessageBoxWarning: |
2968 part = QS60StyleEnums::SP_QgnNoteWarning; |
3093 part = QS60StyleEnums::SP_QgnNoteWarning; |
2969 break; |
3094 break; |
2970 case QStyle::SP_MessageBoxInformation: |
3095 case SP_MessageBoxInformation: |
2971 part = QS60StyleEnums::SP_QgnNoteInfo; |
3096 part = QS60StyleEnums::SP_QgnNoteInfo; |
2972 break; |
3097 break; |
2973 case QStyle::SP_MessageBoxCritical: |
3098 case SP_MessageBoxCritical: |
2974 part = QS60StyleEnums::SP_QgnNoteError; |
3099 part = QS60StyleEnums::SP_QgnNoteError; |
2975 break; |
3100 break; |
2976 case QStyle::SP_MessageBoxQuestion: |
3101 case SP_MessageBoxQuestion: |
2977 part = QS60StyleEnums::SP_QgnNoteQuery; |
3102 part = QS60StyleEnums::SP_QgnNoteQuery; |
2978 break; |
3103 break; |
2979 case QStyle::SP_ArrowRight: |
3104 case SP_ArrowRight: |
2980 part = QS60StyleEnums::SP_QgnIndiNaviArrowRight; |
3105 part = QS60StyleEnums::SP_QgnIndiNaviArrowRight; |
2981 break; |
3106 break; |
2982 case QStyle::SP_ArrowLeft: |
3107 case SP_ArrowLeft: |
2983 part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3108 part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
2984 break; |
3109 break; |
2985 case QStyle::SP_ArrowUp: |
3110 case SP_ArrowUp: |
2986 part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3111 part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
2987 adjustedFlags |= QS60StylePrivate::SF_PointEast; |
3112 adjustedFlags |= QS60StylePrivate::SF_PointEast; |
2988 break; |
3113 break; |
2989 case QStyle::SP_ArrowDown: |
3114 case SP_ArrowDown: |
2990 part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3115 part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
2991 adjustedFlags |= QS60StylePrivate::SF_PointWest; |
3116 adjustedFlags |= QS60StylePrivate::SF_PointWest; |
2992 break; |
3117 break; |
2993 case QStyle::SP_ArrowBack: |
3118 case SP_ArrowBack: |
2994 if (QApplication::layoutDirection() == Qt::RightToLeft) |
3119 if (QApplication::layoutDirection() == Qt::RightToLeft) |
2995 return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
3120 return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
2996 return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
3121 return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
2997 case QStyle::SP_ArrowForward: |
3122 case SP_ArrowForward: |
2998 if (QApplication::layoutDirection() == Qt::RightToLeft) |
3123 if (QApplication::layoutDirection() == Qt::RightToLeft) |
2999 return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
3124 return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
3000 return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
3125 return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
3001 case QStyle::SP_ComputerIcon: |
3126 case SP_ComputerIcon: |
3002 part = QS60StyleEnums::SP_QgnPropPhoneMemcLarge; |
3127 part = QS60StyleEnums::SP_QgnPropPhoneMemcLarge; |
3003 break; |
3128 break; |
3004 case QStyle::SP_DirClosedIcon: |
3129 case SP_DirClosedIcon: |
3005 part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3130 part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3006 break; |
3131 break; |
3007 case QStyle::SP_DirOpenIcon: |
3132 case SP_DirOpenIcon: |
3008 part = QS60StyleEnums::SP_QgnPropFolderCurrent; |
3133 part = QS60StyleEnums::SP_QgnPropFolderCurrent; |
3009 break; |
3134 break; |
3010 case QStyle::SP_DirIcon: |
3135 case SP_DirIcon: |
3011 part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3136 part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3012 break; |
3137 break; |
3013 case QStyle::SP_FileDialogNewFolder: |
3138 case SP_FileDialogNewFolder: |
3014 part = QS60StyleEnums::SP_QgnPropFolderSmallNew; |
3139 part = QS60StyleEnums::SP_QgnPropFolderSmallNew; |
3015 break; |
3140 break; |
3016 case QStyle::SP_FileIcon: |
3141 case SP_FileIcon: |
3017 part = QS60StyleEnums::SP_QgnPropFileSmall; |
3142 part = QS60StyleEnums::SP_QgnPropFileSmall; |
3018 break; |
3143 break; |
3019 case QStyle::SP_TrashIcon: |
3144 case SP_TrashIcon: |
3020 part = QS60StyleEnums::SP_QgnNoteErased; |
3145 part = QS60StyleEnums::SP_QgnNoteErased; |
3021 break; |
3146 break; |
3022 case QStyle::SP_ToolBarHorizontalExtensionButton: |
3147 case SP_ToolBarHorizontalExtensionButton: |
3023 part = QS60StyleEnums::SP_QgnIndiSubMenu; |
3148 part = QS60StyleEnums::SP_QgnIndiSubMenu; |
3024 if (QApplication::layoutDirection() == Qt::RightToLeft) |
3149 if (QApplication::layoutDirection() == Qt::RightToLeft) |
3025 adjustedFlags |= QS60StylePrivate::SF_PointSouth; |
3150 adjustedFlags |= QS60StylePrivate::SF_PointSouth; |
3026 break; |
3151 break; |
3027 case QStyle::SP_ToolBarVerticalExtensionButton: |
3152 case SP_ToolBarVerticalExtensionButton: |
3028 adjustedFlags |= QS60StylePrivate::SF_PointEast; |
3153 adjustedFlags |= QS60StylePrivate::SF_PointEast; |
3029 part = QS60StyleEnums::SP_QgnIndiSubMenu; |
3154 part = QS60StyleEnums::SP_QgnIndiSubMenu; |
3030 break; |
3155 break; |
3031 |
3156 |
3032 default: |
3157 default: |
3036 const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); |
3161 const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); |
3037 return cachedPixMap.isNull() ? |
3162 return cachedPixMap.isNull() ? |
3038 QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); |
3163 QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); |
3039 } |
3164 } |
3040 |
3165 |
3166 /*! |
|
3167 \internal |
|
3168 Animate indeterminate progress bars only when visible |
|
3169 */ |
|
3170 bool QS60Style::eventFilter(QObject *object, QEvent *event) |
|
3171 { |
|
3172 #ifdef Q_WS_S60 |
|
3173 #ifndef QT_NO_PROGRESSBAR |
|
3174 Q_D(QS60Style); |
|
3175 switch(event->type()) { |
|
3176 case QEvent::StyleChange: |
|
3177 case QEvent::Show: |
|
3178 if (QProgressBar *bar = qobject_cast<QProgressBar *>(object)) { |
|
3179 if (!d->m_bars.contains(bar)) |
|
3180 d->m_bars << bar; |
|
3181 if (d->m_bars.size() == 1) //only start with first animated progressbar |
|
3182 d->startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
|
3183 } |
|
3184 break; |
|
3185 case QEvent::Destroy: |
|
3186 case QEvent::Hide: |
|
3187 d->stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
|
3188 d->m_bars.removeAll(reinterpret_cast<QProgressBar *>(object)); |
|
3189 break; |
|
3190 default: |
|
3191 break; |
|
3192 } |
|
3193 #endif // QT_NO_PROGRESSBAR |
|
3194 #endif // Q_WS_S60 |
|
3195 return QStyle::eventFilter(object, event); |
|
3196 } |
|
3197 |
|
3198 /*! |
|
3199 \internal |
|
3200 Handle the timer \a event. |
|
3201 */ |
|
3202 void QS60Style::timerEvent(QTimerEvent *event) |
|
3203 { |
|
3204 #ifdef Q_WS_S60 |
|
3205 #ifndef QT_NO_PROGRESSBAR |
|
3206 Q_D(QS60Style); |
|
3207 |
|
3208 QS60StyleAnimation *progressBarAnimation = |
|
3209 QS60StylePrivate::animationDefinition(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
|
3210 |
|
3211 if (event->timerId() == progressBarAnimation->timerId()) { |
|
3212 |
|
3213 Q_ASSERT(progressBarAnimation->interval() > 0); |
|
3214 |
|
3215 if (progressBarAnimation->currentFrame() == progressBarAnimation->frameCount() ) |
|
3216 if (progressBarAnimation->playMode() == QS60StyleEnums::AM_Looping) |
|
3217 progressBarAnimation->setCurrentFrame(0); |
|
3218 else |
|
3219 d->stopAnimation(progressBarAnimation->animationId()); |
|
3220 |
|
3221 foreach (QProgressBar *bar, d->m_bars) { |
|
3222 if ((bar->minimum() == 0 && bar->maximum() == 0)) |
|
3223 bar->update(); |
|
3224 } |
|
3225 progressBarAnimation->setCurrentFrame(progressBarAnimation->currentFrame() + 1); |
|
3226 } |
|
3227 #endif // QT_NO_PROGRESSBAR |
|
3228 #endif // Q_WS_S60 |
|
3229 event->ignore(); |
|
3230 } |
|
3231 |
|
3041 extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); |
3232 extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); |
3042 |
3233 |
3043 bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) |
3234 bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) |
3044 { |
3235 { |
3045 const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); |
3236 const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); |
3047 return false; |
3238 return false; |
3048 |
3239 |
3049 const QPaintDevice *target = painter->device(); |
3240 const QPaintDevice *target = painter->device(); |
3050 if (target->devType() == QInternal::Widget) { |
3241 if (target->devType() == QInternal::Widget) { |
3051 const QWidget *widget = static_cast<const QWidget *>(target); |
3242 const QWidget *widget = static_cast<const QWidget *>(target); |
3052 const QVector<QRect> &rects = rgn.rects(); |
3243 if (!widget->testAttribute(Qt::WA_TranslucentBackground)) { |
3053 for (int i = 0; i < rects.size(); ++i) { |
3244 const QVector<QRect> &rects = rgn.rects(); |
3054 const QRect rect(rects.at(i)); |
3245 for (int i = 0; i < rects.size(); ++i) { |
3055 painter->drawPixmap(rect.topLeft(), backgroundTexture, |
3246 const QRect rect(rects.at(i)); |
3056 rect.translated(qt_s60_fill_background_offset(widget))); |
3247 painter->drawPixmap(rect.topLeft(), backgroundTexture, |
3248 rect.translated(qt_s60_fill_background_offset(widget))); |
|
3249 } |
|
3057 } |
3250 } |
3058 } |
3251 } |
3059 return true; |
3252 return true; |
3060 } |
3253 } |
3061 |
3254 |