branch | RCL_3 |
changeset 8 | 3f74d0d4af4c |
parent 5 | d3bac044e0f0 |
child 14 | c0432d11811c |
6:dee5afe5301f | 8:3f74d0d4af4c |
---|---|
48 #include "qpixmapcache.h" |
48 #include "qpixmapcache.h" |
49 |
49 |
50 #include "qcalendarwidget.h" |
50 #include "qcalendarwidget.h" |
51 #include "qdial.h" |
51 #include "qdial.h" |
52 #include "qdialog.h" |
52 #include "qdialog.h" |
53 #include "qmessagebox.h" |
|
53 #include "qgroupbox.h" |
54 #include "qgroupbox.h" |
54 #include "qheaderview.h" |
55 #include "qheaderview.h" |
55 #include "qlist.h" |
56 #include "qlist.h" |
56 #include "qlistwidget.h" |
57 #include "qlistwidget.h" |
57 #include "qlistview.h" |
58 #include "qlistview.h" |
59 #include "qmenubar.h" |
60 #include "qmenubar.h" |
60 #include "qpushbutton.h" |
61 #include "qpushbutton.h" |
61 #include "qscrollarea.h" |
62 #include "qscrollarea.h" |
62 #include "qscrollbar.h" |
63 #include "qscrollbar.h" |
63 #include "qtabbar.h" |
64 #include "qtabbar.h" |
64 #include "qtablewidget.h" |
|
65 #include "qtableview.h" |
65 #include "qtableview.h" |
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" |
90 |
90 |
91 static const qreal goldenRatio = 1.618; |
91 static const qreal goldenRatio = 1.618; |
92 |
92 |
93 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
93 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
94 // *** generated layout data *** |
94 // *** generated layout data *** |
95 {240,320,1,16,"QVGA Landscape"}, |
95 {240,320,1,17,"QVGA Landscape"}, |
96 {320,240,1,16,"QVGA Portrait"}, |
96 {320,240,1,17,"QVGA Portrait"}, |
97 {360,640,1,16,"NHD Landscape"}, |
97 {360,640,1,17,"NHD Landscape"}, |
98 {640,360,1,16,"NHD Portrait"}, |
98 {640,360,1,17,"NHD Portrait"}, |
99 {352,800,1,12,"E90 Landscape"} |
99 {352,800,1,12,"E90 Landscape"} |
100 // *** End of generated data *** |
100 // *** End of generated data *** |
101 }; |
101 }; |
102 const int QS60StylePrivate::m_numberOfLayouts = |
102 const int QS60StylePrivate::m_numberOfLayouts = |
103 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
103 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
104 |
104 |
105 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
105 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
106 // *** generated pixel metrics *** |
106 // *** generated pixel metrics *** |
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}, |
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,0,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, 106}, |
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}, |
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,0,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, 106}, |
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}, |
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,0,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, 135}, |
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}, |
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,0,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, 135}, |
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} |
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,0,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, 106} |
112 // *** End of generated data *** |
112 // *** End of generated data *** |
113 }; |
113 }; |
114 |
114 |
115 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
115 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
116 |
116 |
117 // theme background texture |
117 // theme background texture |
118 QPixmap *QS60StylePrivate::m_background = 0; |
118 QPixmap *QS60StylePrivate::m_background = 0; |
119 |
119 |
120 // theme palette |
120 // theme palette |
121 QPalette *QS60StylePrivate::m_themePalette = 0; |
121 QPalette *QS60StylePrivate::m_themePalette = 0; |
122 |
|
123 qint64 QS60StylePrivate::m_webPaletteKey = 0; |
|
122 |
124 |
123 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
125 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
124 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
126 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
125 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
127 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
126 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
128 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
127 {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
129 {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
128 {SE_OptionsMenu, QS60StyleEnums::SP_QsnFrPopupCenter}, |
130 {SE_PopupBackground, QS60StyleEnums::SP_QsnFrPopupCenter}, |
129 {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
131 {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
130 {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, |
132 {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, |
131 {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, |
133 {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, |
132 {SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, |
134 {SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, |
133 {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
135 {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
246 QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
248 QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
247 break; |
249 break; |
248 case SE_ListHighlight: |
250 case SE_ListHighlight: |
249 drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); |
251 drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); |
250 break; |
252 break; |
251 case SE_OptionsMenu: |
253 case SE_PopupBackground: |
252 drawFrame(SF_OptionsMenu, painter, rect, flags | SF_PointNorth); |
254 drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth); |
253 break; |
255 break; |
254 case SE_SettingsList: |
256 case SE_SettingsList: |
255 drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); |
257 drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); |
256 break; |
258 break; |
257 case SE_TableItem: |
259 case SE_TableItem: |
287 drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
289 drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
288 break; |
290 break; |
289 case SE_Editor: |
291 case SE_Editor: |
290 drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
292 drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
291 break; |
293 break; |
294 case SE_DropArea: |
|
295 drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); |
|
296 break; |
|
292 default: |
297 default: |
293 break; |
298 break; |
294 } |
299 } |
295 } |
300 } |
296 |
301 |
300 drawPart(part, painter, rect, flags); |
305 drawPart(part, painter, rect, flags); |
301 } |
306 } |
302 |
307 |
303 short QS60StylePrivate::pixelMetric(int metric) |
308 short QS60StylePrivate::pixelMetric(int metric) |
304 { |
309 { |
310 //If it is a custom value, need to strip away the base to map to internal |
|
311 //pixel metric value table |
|
312 if (metric & QStyle::PM_CustomBase) { |
|
313 metric -= QStyle::PM_CustomBase; |
|
314 metric += MAX_NON_CUSTOM_PIXELMETRICS - 1; |
|
315 } |
|
316 |
|
305 Q_ASSERT(metric < MAX_PIXELMETRICS); |
317 Q_ASSERT(metric < MAX_PIXELMETRICS); |
306 const short returnValue = m_pmPointer[metric]; |
318 const short returnValue = m_pmPointer[metric]; |
307 return returnValue; |
319 return returnValue; |
308 } |
320 } |
309 |
321 |
400 // Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). |
412 // Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). |
401 QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const |
413 QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const |
402 { |
414 { |
403 const bool cachedColorExists = m_colorCache.contains(frame); |
415 const bool cachedColorExists = m_colorCache.contains(frame); |
404 if (!cachedColorExists) { |
416 if (!cachedColorExists) { |
405 const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); |
417 const int frameCornerWidth = pixelMetric(PM_FrameCornerWidth); |
406 const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); |
418 const int frameCornerHeight = pixelMetric(PM_FrameCornerHeight); |
407 Q_ASSERT(2 * frameCornerWidth < 32); |
419 Q_ASSERT(2 * frameCornerWidth < 32); |
408 Q_ASSERT(2 * frameCornerHeight < 32); |
420 Q_ASSERT(2 * frameCornerHeight < 32); |
409 |
421 |
410 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
422 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
411 Q_ASSERT(frameImage.bytesPerLine() > 0); |
423 Q_ASSERT(frameImage.bytesPerLine() > 0); |
623 fontCategory = QS60StyleEnums::FC_Primary; |
635 fontCategory = QS60StyleEnums::FC_Primary; |
624 } else if (qobject_cast<QHeaderView *>(widget)){ |
636 } else if (qobject_cast<QHeaderView *>(widget)){ |
625 fontCategory = QS60StyleEnums::FC_Secondary; |
637 fontCategory = QS60StyleEnums::FC_Secondary; |
626 } else if (qobject_cast<QGroupBox *>(widget)){ |
638 } else if (qobject_cast<QGroupBox *>(widget)){ |
627 fontCategory = QS60StyleEnums::FC_Title; |
639 fontCategory = QS60StyleEnums::FC_Title; |
640 } else if (qobject_cast<QMessageBox *>(widget)){ |
|
641 fontCategory = QS60StyleEnums::FC_Primary; |
|
628 } |
642 } |
629 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
643 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
630 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
644 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
631 && (widget->font().resolve() & QFont::SizeResolved); |
645 && (widget->font().resolve() & QFont::SizeResolved); |
632 const QFont suggestedFont = |
646 const QFont suggestedFont = |
752 widgetPalette.setColor(QPalette::ButtonText, |
766 widgetPalette.setColor(QPalette::ButtonText, |
753 s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
767 s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
754 QApplication::setPalette(widgetPalette, "QMenuBar"); |
768 QApplication::setPalette(widgetPalette, "QMenuBar"); |
755 widgetPalette = *palette; |
769 widgetPalette = *palette; |
756 |
770 |
771 widgetPalette.setColor(QPalette::Text, |
|
772 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
|
773 widgetPalette.setColor(QPalette::HighlightedText, |
|
774 s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
|
775 QApplication::setPalette(widgetPalette, "QMenu"); |
|
776 widgetPalette = *palette; |
|
777 |
|
757 widgetPalette.setColor(QPalette::WindowText, |
778 widgetPalette.setColor(QPalette::WindowText, |
758 s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
779 s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
780 widgetPalette.setColor(QPalette::HighlightedText, |
|
781 s60Color(QS60StyleEnums::CL_QsnTextColors, 3, 0)); |
|
759 QApplication::setPalette(widgetPalette, "QTabBar"); |
782 QApplication::setPalette(widgetPalette, "QTabBar"); |
760 widgetPalette = *palette; |
783 widgetPalette = *palette; |
761 |
784 |
785 widgetPalette.setColor(QPalette::HighlightedText, |
|
786 s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
|
787 QApplication::setPalette(widgetPalette, "QListView"); |
|
788 widgetPalette = *palette; |
|
789 |
|
762 widgetPalette.setColor(QPalette::Text, |
790 widgetPalette.setColor(QPalette::Text, |
763 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
791 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
792 widgetPalette.setColor(QPalette::HighlightedText, |
|
793 s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
|
764 QApplication::setPalette(widgetPalette, "QTableView"); |
794 QApplication::setPalette(widgetPalette, "QTableView"); |
765 widgetPalette = *palette; |
795 widgetPalette = *palette; |
766 |
796 |
767 widgetPalette.setColor(QPalette::Text, |
797 widgetPalette.setColor(QPalette::Text, |
768 s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
798 s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
782 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
812 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
783 QApplication::setPalette(widgetPalette, "QComboBox"); |
813 QApplication::setPalette(widgetPalette, "QComboBox"); |
784 widgetPalette = *palette; |
814 widgetPalette = *palette; |
785 |
815 |
786 widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
816 widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
817 widgetPalette.setColor(QPalette::HighlightedText, |
|
818 s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
|
787 QApplication::setPalette(widgetPalette, "QRadioButton"); |
819 QApplication::setPalette(widgetPalette, "QRadioButton"); |
788 QApplication::setPalette(widgetPalette, "QCheckBox"); |
820 QApplication::setPalette(widgetPalette, "QCheckBox"); |
789 widgetPalette = *palette; |
821 widgetPalette = *palette; |
790 |
822 |
791 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
823 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
802 //Webpages should not use S60 theme colors as they are designed to work |
834 //Webpages should not use S60 theme colors as they are designed to work |
803 //with themeBackground and do not generally mesh well with web page backgrounds. |
835 //with themeBackground and do not generally mesh well with web page backgrounds. |
804 QPalette webPalette = *palette; |
836 QPalette webPalette = *palette; |
805 webPalette.setColor(QPalette::WindowText, Qt::black); |
837 webPalette.setColor(QPalette::WindowText, Qt::black); |
806 webPalette.setColor(QPalette::Text, Qt::black); |
838 webPalette.setColor(QPalette::Text, Qt::black); |
839 webPalette.setBrush(QPalette::Base, Qt::white); |
|
840 |
|
807 QApplication::setPalette(webPalette, "QWebView"); |
841 QApplication::setPalette(webPalette, "QWebView"); |
808 QApplication::setPalette(webPalette, "QGraphicsWebView"); |
842 QApplication::setPalette(webPalette, "QGraphicsWebView"); |
843 |
|
844 m_webPaletteKey = webPalette.cacheKey(); |
|
809 } |
845 } |
810 |
846 |
811 QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
847 QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
812 { |
848 { |
813 QSize result(20, 20); |
849 QSize result(20, 20); |
839 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
875 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
840 break; |
876 break; |
841 |
877 |
842 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
878 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
843 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
879 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
844 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
880 result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
845 break; |
881 break; |
846 |
882 |
847 case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
|
848 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
883 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
849 case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
|
850 case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
884 case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
851 case QS60StyleEnums::SP_QsnCpScrollBgMiddle: |
|
852 case QS60StyleEnums::SP_QsnCpScrollBgTop: |
885 case QS60StyleEnums::SP_QsnCpScrollBgTop: |
853 case QS60StyleEnums::SP_QsnCpScrollHandleBottom: |
886 case QS60StyleEnums::SP_QsnCpScrollHandleBottom: |
887 case QS60StyleEnums::SP_QsnCpScrollHandleTop: |
|
888 case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
|
889 result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
|
890 result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); |
|
891 break; |
|
892 case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
|
893 case QS60StyleEnums::SP_QsnCpScrollBgMiddle: |
|
854 case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: |
894 case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: |
855 case QS60StyleEnums::SP_QsnCpScrollHandleTop: |
|
856 result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
895 result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
857 result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); |
896 result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); |
858 break; |
897 break; |
859 default: |
898 default: |
860 // Generic frame part size gathering. |
899 // Generic frame part size gathering. |
863 switch (m_frameElementsData[i].center - part) { |
902 switch (m_frameElementsData[i].center - part) { |
864 case 8: /* CornerTl */ |
903 case 8: /* CornerTl */ |
865 case 7: /* CornerTr */ |
904 case 7: /* CornerTr */ |
866 case 6: /* CornerBl */ |
905 case 6: /* CornerBl */ |
867 case 5: /* CornerBr */ |
906 case 5: /* CornerBr */ |
868 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
907 result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
869 // Falltrough intended... |
908 // Falltrough intended... |
870 case 4: /* SideT */ |
909 case 4: /* SideT */ |
871 case 3: /* SideB */ |
910 case 3: /* SideB */ |
872 result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight)); |
911 result.setHeight(pixelMetric(PM_FrameCornerHeight)); |
873 break; |
912 break; |
874 case 2: /* SideL */ |
913 case 2: /* SideL */ |
875 case 1: /* SideR */ |
914 case 1: /* SideR */ |
876 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
915 result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
877 break; |
916 break; |
878 case 0: /* center */ |
917 case 0: /* center */ |
879 default: |
918 default: |
880 break; |
919 break; |
881 } |
920 } |
888 result.setHeight(temp); |
927 result.setHeight(temp); |
889 } |
928 } |
890 return result; |
929 return result; |
891 } |
930 } |
892 |
931 |
893 bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) |
932 bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget) |
894 { |
933 { |
934 // Always return true for web pages. |
|
935 if (widget && m_webPaletteKey == QApplication::palette(widget).cacheKey()) |
|
936 return true; |
|
895 //If brush is not changed from style's default values, draw theme graphics. |
937 //If brush is not changed from style's default values, draw theme graphics. |
896 return (backgroundBrush.color() == Qt::transparent || |
938 return (backgroundBrush.color() == Qt::transparent || |
897 backgroundBrush.style() == Qt::NoBrush) ? true : false; |
939 backgroundBrush.style() == Qt::NoBrush) ? true : false; |
898 } |
940 } |
899 |
941 |
967 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
1009 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
968 QS60StylePrivate::SE_SliderGrooveHorizontal : |
1010 QS60StylePrivate::SE_SliderGrooveHorizontal : |
969 QS60StylePrivate::SE_SliderGrooveVertical; |
1011 QS60StylePrivate::SE_SliderGrooveVertical; |
970 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
1012 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
971 } else { |
1013 } else { |
972 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
|
973 const QPoint sliderGrooveCenter = sliderGroove.center(); |
1014 const QPoint sliderGrooveCenter = sliderGroove.center(); |
974 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
1015 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
975 painter->save(); |
1016 painter->save(); |
976 if (widget) |
1017 if (widget) |
977 painter->setPen(widget->palette().windowText().color()); |
1018 painter->setPen(widget->palette().windowText().color()); |
1094 break; } |
1135 break; } |
1095 toolButton.rect = button; |
1136 toolButton.rect = button; |
1096 drawPrimitive(pe, &toolButton, painter, widget); |
1137 drawPrimitive(pe, &toolButton, painter, widget); |
1097 } |
1138 } |
1098 |
1139 |
1099 if (toolBtn->text.length()>0 || |
1140 if (toolBtn->text.length() > 0 || |
1100 !toolBtn->icon.isNull()) { |
1141 !toolBtn->icon.isNull()) { |
1101 const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
1142 const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
1102 toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
1143 toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
1103 drawControl(CE_ToolButtonLabel, &toolButton, painter, widget); |
1144 drawControl(CE_ToolButtonLabel, &toolButton, painter, widget); |
1104 } |
1145 } |
1224 switch (element) { |
1265 switch (element) { |
1225 case CE_CheckBox: |
1266 case CE_CheckBox: |
1226 case CE_RadioButton: |
1267 case CE_RadioButton: |
1227 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1268 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1228 bool isRadio = (element == CE_RadioButton); |
1269 bool isRadio = (element == CE_RadioButton); |
1270 QStyleOptionButton subopt = *btn; |
|
1271 |
|
1229 // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
1272 // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
1230 if (btn->state & State_HasFocus) { |
1273 if (btn->state & State_HasFocus) { |
1231 QStyleOptionFocusRect fropt; |
1274 QStyleOptionFocusRect fropt; |
1232 fropt.QStyleOption::operator=(*btn); |
1275 fropt.QStyleOption::operator=(*btn); |
1233 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
1276 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
1234 : SE_CheckBoxFocusRect, btn, widget); |
1277 : SE_CheckBoxFocusRect, btn, widget); |
1235 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
1278 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
1279 |
|
1280 subopt.palette.setColor(QPalette::Active, QPalette::WindowText, |
|
1281 subopt.palette.highlightedText().color()); |
|
1236 } |
1282 } |
1237 QStyleOptionButton subopt = *btn; |
|
1238 |
1283 |
1239 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
1284 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
1240 : SE_CheckBoxIndicator, btn, widget); |
1285 : SE_CheckBoxIndicator, btn, widget); |
1241 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
1286 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
1242 &subopt, painter, widget); |
1287 &subopt, painter, widget); |
1332 else |
1377 else |
1333 editRect.translate(comboBox->iconSize.width() + 4, 0); |
1378 editRect.translate(comboBox->iconSize.width() + 4, 0); |
1334 } |
1379 } |
1335 if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
1380 if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
1336 QCommonStyle::drawItemText(painter, |
1381 QCommonStyle::drawItemText(painter, |
1337 editRect.adjusted(QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth), 0, -1, 0), |
1382 editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), |
1338 visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
1383 visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
1339 comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText); |
1384 comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText); |
1340 } |
1385 } |
1341 painter->restore(); |
1386 painter->restore(); |
1342 } |
1387 } |
1391 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1436 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1392 } |
1437 } |
1393 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1438 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1394 |
1439 |
1395 // draw the focus rect |
1440 // draw the focus rect |
1396 if (isSelected | hasFocus) { |
1441 if (isSelected || hasFocus ) { |
1397 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
1442 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
1398 QAbstractItemView::SelectionBehavior selectionBehavior = |
1443 QAbstractItemView::SelectionBehavior selectionBehavior = |
1399 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
1444 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
1400 if (selectionBehavior != QAbstractItemView::SelectItems) { |
1445 if (selectionBehavior != QAbstractItemView::SelectItems) { |
1401 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
1446 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
1463 } |
1508 } |
1464 } |
1509 } |
1465 |
1510 |
1466 // draw the text |
1511 // draw the text |
1467 if (!voptAdj.text.isEmpty()) { |
1512 if (!voptAdj.text.isEmpty()) { |
1468 if (isSelected) { |
1513 if (isSelected || hasFocus ) |
1469 if (qobject_cast<const QTableView *>(widget)) |
1514 painter->setPen(voptAdj.palette.highlightedText().color()); |
1470 voptAdj.palette.setColor( |
1515 else |
1471 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
1516 painter->setPen(voptAdj.palette.text().color()); |
1472 else |
|
1473 voptAdj.palette.setColor( |
|
1474 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
|
1475 } |
|
1476 painter->setPen(voptAdj.palette.text().color()); |
|
1477 d->viewItemDrawText(painter, &voptAdj, textRect); |
1517 d->viewItemDrawText(painter, &voptAdj, textRect); |
1478 } |
1518 } |
1479 painter->restore(); |
1519 painter->restore(); |
1480 } |
1520 } |
1481 break; |
1521 break; |
1573 painter->setFont(f); |
1613 painter->setFont(f); |
1574 |
1614 |
1575 const bool selected = optionTab.state & State_Selected; |
1615 const bool selected = optionTab.state & State_Selected; |
1576 if (selected) |
1616 if (selected) |
1577 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1617 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1578 QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); |
1618 optionTab.palette.highlightedText().color()); |
1579 |
1619 |
1580 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1620 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1581 || optionTab.shape == QTabBar::RoundedWest |
1621 || optionTab.shape == QTabBar::RoundedWest |
1582 || optionTab.shape == QTabBar::TriangularEast |
1622 || optionTab.shape == QTabBar::TriangularEast |
1583 || optionTab.shape == QTabBar::TriangularWest; |
1623 || optionTab.shape == QTabBar::TriangularWest; |
1706 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
1746 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
1707 | Qt::TextSingleLine | Qt::AlignVCenter; |
1747 | Qt::TextSingleLine | Qt::AlignVCenter; |
1708 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
1748 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
1709 text_flags |= Qt::TextHideMnemonic; |
1749 text_flags |= Qt::TextHideMnemonic; |
1710 |
1750 |
1711 if ((option->state & State_Selected) && (option->state & State_Enabled)) |
1751 const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); |
1752 if (selected) |
|
1712 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1753 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1713 |
1754 |
1714 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
1755 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
1715 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
1756 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
1716 |
1757 |
1776 optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor( |
1817 optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor( |
1777 optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); |
1818 optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); |
1778 painter->save(); |
1819 painter->save(); |
1779 painter->setOpacity(0.5); |
1820 painter->setOpacity(0.5); |
1780 } |
1821 } |
1822 if (selected) |
|
1823 optionMenuItem.palette.setColor( |
|
1824 QPalette::Active, QPalette::Text, optionMenuItem.palette.highlightedText().color()); |
|
1825 |
|
1781 QCommonStyle::drawItemText(painter, textRect, text_flags, |
1826 QCommonStyle::drawItemText(painter, textRect, text_flags, |
1782 optionMenuItem.palette, enabled, |
1827 optionMenuItem.palette, enabled, |
1783 optionMenuItem.text, QPalette::Text); |
1828 optionMenuItem.text, QPalette::Text); |
1784 if (!enabled) |
1829 if (!enabled) |
1785 painter->restore(); |
1830 painter->restore(); |
1797 case CE_HeaderSection: |
1842 case CE_HeaderSection: |
1798 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1843 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1799 painter->save(); |
1844 painter->save(); |
1800 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1845 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1801 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1846 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1802 linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1847 linePen.width() + QS60StylePrivate::pixelMetric(PM_BoldLineWidth) |
1803 : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1848 : linePen.width() + QS60StylePrivate::pixelMetric(PM_ThinLineWidth); |
1804 linePen.setWidth(penWidth); |
1849 linePen.setWidth(penWidth); |
1805 painter->setPen(linePen); |
1850 painter->setPen(linePen); |
1806 if (header->orientation == Qt::Horizontal){ |
1851 if (header->orientation == Qt::Horizontal){ |
1807 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1852 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1808 } else { |
1853 } else { |
1817 //Draw corner button as normal pushButton. |
1862 //Draw corner button as normal pushButton. |
1818 if (qobject_cast<const QAbstractButton *>(widget)) { |
1863 if (qobject_cast<const QAbstractButton *>(widget)) { |
1819 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1864 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1820 QStyleOptionHeader subopt = *header; |
1865 QStyleOptionHeader subopt = *header; |
1821 const int borderTweak = |
1866 const int borderTweak = |
1822 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
1867 QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
1823 if (subopt.direction == Qt::LeftToRight) |
1868 if (subopt.direction == Qt::LeftToRight) |
1824 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1869 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1825 else |
1870 else |
1826 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1871 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1827 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1872 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1893 break; |
1938 break; |
1894 #endif //QT_NO_TOOLBAR |
1939 #endif //QT_NO_TOOLBAR |
1895 case CE_ShapedFrame: |
1940 case CE_ShapedFrame: |
1896 if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
1941 if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
1897 const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
1942 const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
1898 if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base())) |
1943 if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base(), widget)) |
1899 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
1944 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
1900 else |
1945 else |
1901 QCommonStyle::drawControl(element, option, painter, widget); |
1946 QCommonStyle::drawControl(element, option, painter, widget); |
1902 } else if (qobject_cast<const QTableView *>(widget)) { |
1947 } else if (qobject_cast<const QTableView *>(widget)) { |
1903 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
1948 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
1925 } |
1970 } |
1926 break; |
1971 break; |
1927 case CE_MenuScroller: |
1972 case CE_MenuScroller: |
1928 break; |
1973 break; |
1929 case CE_FocusFrame: { |
1974 case CE_FocusFrame: { |
1930 // The pen width should nearly fill the layoutspacings around the widget |
|
1931 const int penWidth = |
|
1932 qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) |
|
1933 - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets |
|
1934 |
|
1935 #ifdef QT_KEYPAD_NAVIGATION |
1975 #ifdef QT_KEYPAD_NAVIGATION |
1936 bool editFocus = false; |
1976 bool editFocus = false; |
1937 if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { |
1977 if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { |
1938 if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) |
1978 if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) |
1939 editFocus = true; |
1979 editFocus = true; |
1940 } |
1980 } |
1941 const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve. |
1981 const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve. |
1942 #else |
1982 #else |
1943 const qreal opacity = 0.5; |
1983 const qreal opacity = 0.85; |
1944 #endif |
1984 #endif |
1945 // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. |
1985 // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin |
1946 const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0; |
1986 // Otherwise, we would overlay adjacent widgets. |
1947 |
1987 const int frameHeightReduction = |
1948 // Make sure that the pen stroke is inside the rect |
1988 qMin(0, pixelMetric(QStyle::PM_LayoutVerticalSpacing) |
1949 const QRectF adjustedRect = |
1989 - pixelMetric(QStyle::PM_FocusFrameVMargin)); |
1950 QRectF(option->rect).adjusted( |
1990 const int frameWidthReduction = |
1951 rectAdjustment + penWidth, |
1991 qMin(0, pixelMetric(QStyle::PM_LayoutHorizontalSpacing) |
1952 rectAdjustment + penWidth, |
1992 - pixelMetric(QStyle::PM_FocusFrameHMargin)); |
1953 -rectAdjustment - penWidth, |
1993 const int rounding = |
1954 -rectAdjustment - penWidth |
1994 qMin(pixelMetric(QStyle::PM_FocusFrameVMargin), |
1955 ); |
1995 pixelMetric(QStyle::PM_LayoutVerticalSpacing)); |
1956 |
1996 const QRect frameRect = |
1957 const qreal roundRectRadius = penWidth * goldenRatio; |
1997 option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, |
1998 frameWidthReduction, frameHeightReduction); |
|
1999 QPainterPath framePath; |
|
2000 framePath.addRoundedRect(frameRect, rounding, rounding); |
|
1958 |
2001 |
1959 painter->save(); |
2002 painter->save(); |
1960 painter->setRenderHint(QPainter::Antialiasing); |
2003 painter->setRenderHint(QPainter::Antialiasing); |
1961 painter->setOpacity(opacity); |
2004 painter->setOpacity(opacity); |
1962 painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth)); |
2005 painter->fillPath(framePath, option->palette.color(QPalette::Text)); |
1963 painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); |
|
1964 painter->restore(); |
2006 painter->restore(); |
1965 } |
2007 } |
1966 break; |
2008 break; |
1967 case CE_Splitter: |
2009 case CE_Splitter: |
1968 if (option->state & State_Sunken && option->state & State_Enabled) { |
2010 if (option->state & State_Sunken && option->state & State_Enabled) { |
2005 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2047 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2006 #ifndef QT_NO_COMBOBOX |
2048 #ifndef QT_NO_COMBOBOX |
2007 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
2049 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
2008 break; |
2050 break; |
2009 #endif |
2051 #endif |
2010 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) |
2052 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) |
2011 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
2053 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
2012 else |
2054 else |
2013 commonStyleDraws = true; |
2055 commonStyleDraws = true; |
2014 } |
2056 } |
2015 break; |
2057 break; |
2030 painter->restore(); |
2072 painter->restore(); |
2031 } |
2073 } |
2032 break; |
2074 break; |
2033 case PE_IndicatorViewItemCheck: |
2075 case PE_IndicatorViewItemCheck: |
2034 #ifndef QT_NO_ITEMVIEWS |
2076 #ifndef QT_NO_ITEMVIEWS |
2035 if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) { |
2077 if (const QAbstractItemView *itemView = (qobject_cast<const QAbstractItemView *>(widget))) { |
2036 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2078 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2037 const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; |
2079 const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; |
2038 const bool singleSelection = listItem->selectionMode() == |
2080 const bool singleSelection = itemView->selectionMode() == |
2039 QAbstractItemView::SingleSelection || listItem->selectionMode() == QAbstractItemView::NoSelection; |
2081 QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection; |
2040 // draw either checkbox at the beginning |
2082 // draw either checkbox at the beginning |
2041 if (checkBoxVisible && singleSelection) { |
2083 if (checkBoxVisible && singleSelection) { |
2042 drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
2084 drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
2043 // ... or normal "tick" selection at the end. |
2085 // ... or normal "tick" selection at the end. |
2044 } else if (option->state & State_Selected) { |
2086 } else if (option->state & State_Selected) { |
2045 QRect tickRect = option->rect; |
2087 QRect tickRect = option->rect; |
2046 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); |
2088 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); |
2047 // adjust tickmark rect to exclude frame border |
2089 // adjust tickmark rect to exclude frame border |
2048 tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
2090 tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
2049 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2091 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2050 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2092 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2051 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2093 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2085 break; |
2127 break; |
2086 case PE_PanelButtonCommand: |
2128 case PE_PanelButtonCommand: |
2087 case PE_PanelButtonTool: |
2129 case PE_PanelButtonTool: |
2088 case PE_PanelButtonBevel: |
2130 case PE_PanelButtonBevel: |
2089 case PE_FrameButtonBevel: |
2131 case PE_FrameButtonBevel: |
2090 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) { |
2132 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) { |
2091 const bool isPressed = option->state & State_Sunken; |
2133 const bool isPressed = option->state & State_Sunken; |
2092 const QS60StylePrivate::SkinElements skinElement = |
2134 const QS60StylePrivate::SkinElements skinElement = |
2093 isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
2135 isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
2094 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
2136 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
2095 } else { |
2137 } else { |
2117 #endif //QT_NO_TOOLBUTTON |
2159 #endif //QT_NO_TOOLBUTTON |
2118 #ifndef QT_NO_SPINBOX |
2160 #ifndef QT_NO_SPINBOX |
2119 case PE_IndicatorSpinDown: |
2161 case PE_IndicatorSpinDown: |
2120 case PE_IndicatorSpinUp: |
2162 case PE_IndicatorSpinUp: |
2121 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2163 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2122 if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base())) { |
2164 if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) { |
2123 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2165 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2124 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2166 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2125 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2167 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2126 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2168 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2127 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2169 const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
2128 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2170 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2129 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
2171 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
2130 } else { |
2172 } else { |
2131 commonStyleDraws = true; |
2173 commonStyleDraws = true; |
2132 } |
2174 } |
2133 } |
2175 } |
2134 #endif //QT_NO_SPINBOX |
2176 #endif //QT_NO_SPINBOX |
2135 #ifndef QT_NO_COMBOBOX |
2177 #ifndef QT_NO_COMBOBOX |
2136 if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2178 if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2137 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) { |
2179 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) { |
2138 // We want to draw down arrow here for comboboxes as well. |
2180 // We want to draw down arrow here for comboboxes as well. |
2139 QStyleOptionFrame optionsComboBox = *cmb; |
2181 QStyleOptionFrame optionsComboBox = *cmb; |
2140 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2182 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2141 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2183 const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
2142 optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2184 optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2143 QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
2185 QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
2144 } else { |
2186 } else { |
2145 commonStyleDraws = true; |
2187 commonStyleDraws = true; |
2146 } |
2188 } |
2171 #ifndef QT_NO_MENU |
2213 #ifndef QT_NO_MENU |
2172 || qobject_cast<const QMenu *> (widget) |
2214 || qobject_cast<const QMenu *> (widget) |
2173 #endif //QT_NO_MENU |
2215 #endif //QT_NO_MENU |
2174 ) { |
2216 ) { |
2175 //Need extra check since dialogs have their own theme background |
2217 //Need extra check since dialogs have their own theme background |
2176 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()) && |
2218 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && |
2177 option->palette.window().texture().cacheKey() == |
2219 option->palette.window().texture().cacheKey() == |
2178 QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
2220 QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
2179 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2221 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); |
2180 else |
2222 else |
2181 commonStyleDraws = true; |
2223 commonStyleDraws = true; |
2182 } |
2224 } |
2183 break; |
2225 break; |
2184 case PE_FrameWindow: |
2226 case PE_FrameWindow: |
2269 |
2311 |
2270 if (option->state & State_Children) { |
2312 if (option->state & State_Children) { |
2271 QS60StyleEnums::SkinParts skinPart = |
2313 QS60StyleEnums::SkinParts skinPart = |
2272 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2314 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2273 int minDimension = qMin(option->rect.width(), option->rect.height()); |
2315 int minDimension = qMin(option->rect.width(), option->rect.height()); |
2274 const int resizeValue = minDimension >> 1; |
|
2275 minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
|
2276 QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
2316 QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
2277 int verticalMagic(0); |
2317 const int magicTweak = 3; |
2278 // magic values for positioning svg icon. |
2318 int resizeValue = minDimension >> 1; |
2279 if (option->rect.width() <= option->rect.height()) |
2319 if (!QS60StylePrivate::isTouchSupported()) { |
2280 verticalMagic = 3; |
2320 minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
2281 iconRect.translate(3, verticalMagic - resizeValue); |
2321 iconRect.setSize(QSize(minDimension, minDimension)); |
2322 const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; |
|
2323 resizeValue = verticalMagic - resizeValue; |
|
2324 } |
|
2325 iconRect.translate(magicTweak, resizeValue); |
|
2282 QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2326 QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2283 } |
2327 } |
2284 } |
2328 } |
2285 break; |
2329 break; |
2286 case PE_PanelItemViewRow: // ### Qt 5: remove |
2330 case PE_PanelItemViewRow: // ### Qt 5: remove |
2300 } |
2344 } |
2301 #endif |
2345 #endif |
2302 break; |
2346 break; |
2303 case PE_PanelScrollAreaCorner: |
2347 case PE_PanelScrollAreaCorner: |
2304 break; |
2348 break; |
2305 |
2349 case PE_IndicatorItemViewItemDrop: |
2350 if (QS60StylePrivate::isTouchSupported()) |
|
2351 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DropArea, painter, option->rect, flags); |
|
2352 else |
|
2353 commonStyleDraws = true; |
|
2354 break; |
|
2306 // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2355 // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2307 case PE_FrameLineEdit: |
2356 case PE_FrameLineEdit: |
2308 case PE_IndicatorDockWidgetResizeHandle: |
2357 case PE_IndicatorDockWidgetResizeHandle: |
2309 case PE_PanelTipLabel: |
2358 case PE_PanelTipLabel: |
2310 |
2359 |
2321 #ifndef QT_NO_TOOLBAR |
2370 #ifndef QT_NO_TOOLBAR |
2322 case PE_PanelToolBar: |
2371 case PE_PanelToolBar: |
2323 #endif //QT_NO_TOOLBAR |
2372 #endif //QT_NO_TOOLBAR |
2324 #ifndef QT_NO_COLUMNVIEW |
2373 #ifndef QT_NO_COLUMNVIEW |
2325 case PE_IndicatorColumnViewArrow: |
2374 case PE_IndicatorColumnViewArrow: |
2326 case PE_IndicatorItemViewItemDrop: |
|
2327 #endif //QT_NO_COLUMNVIEW |
2375 #endif //QT_NO_COLUMNVIEW |
2328 case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
2376 case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
2329 default: |
2377 default: |
2330 commonStyleDraws = true; |
2378 commonStyleDraws = true; |
2331 } |
2379 } |
2339 { |
2387 { |
2340 int metricValue = QS60StylePrivate::pixelMetric(metric); |
2388 int metricValue = QS60StylePrivate::pixelMetric(metric); |
2341 if (metricValue == KNotFound) |
2389 if (metricValue == KNotFound) |
2342 metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
2390 metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
2343 |
2391 |
2344 if (metric == PM_SubMenuOverlap && widget) { |
|
2345 const QMenu *menu = qobject_cast<const QMenu *>(widget); |
|
2346 if (menu && menu->activeAction() && menu->activeAction()->menu()) { |
|
2347 const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); |
|
2348 metricValue = -menuWidth; |
|
2349 } |
|
2350 } |
|
2351 //if layout direction is mirrored, switch left and right border margins |
2392 //if layout direction is mirrored, switch left and right border margins |
2352 if (option && option->direction == Qt::RightToLeft) { |
2393 if (option && option->direction == Qt::RightToLeft) { |
2353 if (metric == PM_LayoutLeftMargin) |
2394 if (metric == PM_LayoutLeftMargin) |
2354 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
2395 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
2355 else if (metric == PM_LayoutRightMargin) |
2396 else if (metric == PM_LayoutRightMargin) |
2356 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
2397 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
2357 } |
2398 } |
2399 |
|
2400 if (widget && (metric == PM_LayoutTopMargin)) |
|
2401 if (widget->windowType() == Qt::Dialog) |
|
2402 //double the top layout margin for dialogs, it is very close to real value |
|
2403 //without having to define custom pixel metric |
|
2404 metricValue *= 2; |
|
2358 return metricValue; |
2405 return metricValue; |
2359 } |
2406 } |
2360 |
2407 |
2361 /*! \reimp */ |
2408 /*! \reimp */ |
2362 QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
2409 QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
2373 sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); |
2420 sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); |
2374 break; |
2421 break; |
2375 case CT_PushButton: |
2422 case CT_PushButton: |
2376 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2423 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2377 //FIXME properly - style should calculate the location of border frame-part |
2424 //FIXME properly - style should calculate the location of border frame-part |
2378 sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin)); |
2425 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) { |
2379 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) |
|
2380 if (buttonWidget->isCheckable()) |
2426 if (buttonWidget->isCheckable()) |
2381 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2427 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2428 const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0; |
|
2429 const int textHeight = (buttonWidget->text().length() > 0) ? |
|
2430 buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0; |
|
2431 const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0; |
|
2432 |
|
2433 const int contentHeight = |
|
2434 qMax(qMax(iconHeight, decoratorHeight) + pixelMetric(PM_ButtonMargin), |
|
2435 textHeight + 2*pixelMetric(PM_ButtonMargin)); |
|
2436 sz.setHeight(contentHeight); |
|
2437 sz += QSize(2 * pixelMetric(PM_ButtonMargin), 0); |
|
2438 } |
|
2382 break; |
2439 break; |
2383 case CT_LineEdit: |
2440 case CT_LineEdit: |
2384 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2441 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2385 sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); |
2442 sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); |
2386 break; |
2443 break; |
2399 sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); |
2456 sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); |
2400 break; |
2457 break; |
2401 #ifndef QT_NO_COMBOBOX |
2458 #ifndef QT_NO_COMBOBOX |
2402 case CT_ComboBox: { |
2459 case CT_ComboBox: { |
2403 // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
2460 // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
2404 // Make sure, that the combobox says within the screen. |
2461 // Make sure, that the combobox stays within the screen. |
2405 const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
2462 const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
2406 -QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
2463 - QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
2407 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
2464 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
2408 boundedTo(desktopContentSize); |
2465 boundedTo(desktopContentSize); |
2409 } |
2466 } |
2410 break; |
2467 break; |
2411 #endif |
2468 #endif |
2420 int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
2477 int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
2421 QStyleHintReturn *hret) const |
2478 QStyleHintReturn *hret) const |
2422 { |
2479 { |
2423 int retValue = -1; |
2480 int retValue = -1; |
2424 switch (sh) { |
2481 switch (sh) { |
2482 case SH_RequestSoftwareInputPanel: |
|
2483 if (QS60StylePrivate::isSingleClickUi()) |
|
2484 retValue = RSIP_OnMouseClick; |
|
2485 else |
|
2486 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
|
2487 break; |
|
2488 case SH_ComboBox_Popup: |
|
2489 retValue = true; |
|
2490 break; |
|
2425 case SH_Table_GridLineColor: |
2491 case SH_Table_GridLineColor: |
2426 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
2492 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
2427 break; |
2493 break; |
2428 case SH_GroupBox_TextLabelColor: |
2494 case SH_GroupBox_TextLabelColor: |
2429 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
2495 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
2473 retValue = true; |
2539 retValue = true; |
2474 break; |
2540 break; |
2475 case SH_UnderlineShortcut: |
2541 case SH_UnderlineShortcut: |
2476 retValue = 0; |
2542 retValue = 0; |
2477 break; |
2543 break; |
2478 case SH_RequestSoftwareInputPanel: |
|
2479 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
|
2480 break; |
|
2481 case SH_FormLayoutWrapPolicy: |
2544 case SH_FormLayoutWrapPolicy: |
2482 retValue = QFormLayout::WrapLongRows; |
2545 retValue = QFormLayout::WrapLongRows; |
2546 break; |
|
2547 case SH_ScrollBar_ContextMenu: |
|
2548 retValue = false; |
|
2483 break; |
2549 break; |
2484 default: |
2550 default: |
2485 retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
2551 retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
2486 break; |
2552 break; |
2487 } |
2553 } |
2557 #endif // QT_NO_SCROLLBAR |
2623 #endif // QT_NO_SCROLLBAR |
2558 case CC_SpinBox: |
2624 case CC_SpinBox: |
2559 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2625 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2560 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2626 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2561 const int buttonMargin = spinbox->frame ? 2 : 0; |
2627 const int buttonMargin = spinbox->frame ? 2 : 0; |
2562 const int buttonWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
2628 const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
2629 // Spinbox buttons should be no larger than one fourth of total width. |
|
2630 // Thus, side-by-side buttons would take half of the total width. |
|
2631 const int maxSize = qMax(spinbox->rect.width() / 4, buttonContentWidth); |
|
2563 QSize buttonSize; |
2632 QSize buttonSize; |
2564 buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); |
2633 buttonSize.setHeight(qMin(maxSize, qMax(8, spinbox->rect.height() - frameThickness))); |
2565 //width should at least be equal to height |
2634 //width should at least be equal to height |
2566 buttonSize.setWidth(qMax(buttonSize.height(), buttonWidth)); |
2635 buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); |
2567 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2636 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2568 |
2637 |
2569 const int y = frameThickness + spinbox->rect.y(); |
2638 // Normally spinbuttons should be side-by-side, but if spinbox grows very big |
2570 const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2 * buttonSize.width(); |
2639 // and spinbuttons reach their maximum size, they can be deployed one top of the other. |
2640 const bool sideBySide = (buttonSize.height() * 2 < spinbox->rect.height()) ? false : true; |
|
2641 const int y = frameThickness + spinbox->rect.y() + |
|
2642 (spinbox->rect.height() - (sideBySide ? 1 : 2) * buttonSize.height()) / 2; |
|
2643 const int x = spinbox->rect.x() + |
|
2644 spinbox->rect.width() - frameThickness - (sideBySide ? 2 : 1) * buttonSize.width(); |
|
2571 |
2645 |
2572 switch (scontrol) { |
2646 switch (scontrol) { |
2573 case SC_SpinBoxUp: |
2647 case SC_SpinBoxUp: |
2574 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2648 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2575 return QRect(); |
2649 return QRect(); |
2576 ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
2650 ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
2577 break; |
2651 break; |
2578 case SC_SpinBoxDown: |
2652 case SC_SpinBoxDown: |
2579 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2653 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2580 return QRect(); |
2654 return QRect(); |
2581 ret = QRect(x + buttonSize.width(), y, buttonSize.width(), buttonSize.height()); |
2655 ret = QRect(x + (sideBySide ? buttonSize.width() : 0), |
2656 y + (sideBySide ? 0 : buttonSize.height()), |
|
2657 buttonSize.width(), buttonSize.height()); |
|
2582 break; |
2658 break; |
2583 case SC_SpinBoxEditField: |
2659 case SC_SpinBoxEditField: |
2584 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2660 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2585 ret = QRect( |
2661 ret = QRect( |
2586 frameThickness, |
2662 frameThickness, |
2630 ret = QRect( |
2706 ret = QRect( |
2631 frameThickness, |
2707 frameThickness, |
2632 frameThickness, |
2708 frameThickness, |
2633 withFrameX - frameThickness, |
2709 withFrameX - frameThickness, |
2634 height - 2 * frameThickness); |
2710 height - 2 * frameThickness); |
2711 } |
|
2712 break; |
|
2713 case SC_ComboBoxListBoxPopup: { |
|
2714 const QRect desktopContent = QApplication::desktop()->availableGeometry(); |
|
2715 |
|
2716 // take the size of this and position bottom above available area |
|
2717 QRect popupRect; |
|
2718 const int width = desktopContent.width() - pixelMetric(PM_LayoutRightMargin) - pixelMetric(PM_LayoutLeftMargin); |
|
2719 popupRect.setWidth(width); |
|
2720 popupRect.setHeight(desktopContent.height()); //combobox resets height anyway based on content |
|
2721 popupRect.setBottom(desktopContent.bottom()); |
|
2722 popupRect.translate(pixelMetric(PM_LayoutLeftMargin), 0); |
|
2723 ret = popupRect; |
|
2635 } |
2724 } |
2636 break; |
2725 break; |
2637 default: |
2726 default: |
2638 break; |
2727 break; |
2639 } |
2728 } |
2706 case SE_RadioButtonFocusRect: |
2795 case SE_RadioButtonFocusRect: |
2707 ret = opt->rect; |
2796 ret = opt->rect; |
2708 break; |
2797 break; |
2709 case SE_LineEditContents: { |
2798 case SE_LineEditContents: { |
2710 // in S60 the input text box doesn't start from line Edit's TL, but |
2799 // in S60 the input text box doesn't start from line Edit's TL, but |
2711 // a bit indented. |
2800 // a bit indented (8 pixels). |
2712 QRect lineEditRect = opt->rect; |
2801 const int KLineEditDefaultIndention = 8; |
2713 const int adjustment = opt->rect.height() >> 2; |
2802 ret = visualRect( |
2714 lineEditRect.adjust(adjustment, 0, 0, 0); |
2803 opt->direction, opt->rect, opt->rect.adjusted(KLineEditDefaultIndention, 0, 0, 0)); |
2715 ret = lineEditRect; |
|
2716 } |
2804 } |
2717 break; |
2805 break; |
2718 case SE_TabBarTearIndicator: |
2806 case SE_TabBarTearIndicator: |
2719 ret = QRect(0, 0, 0, 0); |
2807 ret = QRect(0, 0, 0, 0); |
2720 break; |
2808 break; |
2786 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2874 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2787 pixelMetric(PM_SmallIconSize, opt, widget); |
2875 pixelMetric(PM_SmallIconSize, opt, widget); |
2788 ret = menuItem->rect; |
2876 ret = menuItem->rect; |
2789 |
2877 |
2790 if (element == SE_ItemViewItemDecoration) { |
2878 if (element == SE_ItemViewItemDecoration) { |
2791 if (menuItem->direction == Qt::RightToLeft) |
2879 if (menuItem->icon.isNull()) { |
2792 ret.translate(ret.width()-indicatorWidth, 0); |
2880 ret = QRect(); |
2793 ret.setWidth(indicatorWidth); |
2881 } else { |
2882 if (menuItem->direction == Qt::RightToLeft) |
|
2883 ret.translate(ret.width()-indicatorWidth, 0); |
|
2884 ret.setWidth(indicatorWidth); |
|
2885 } |
|
2794 } else { |
2886 } else { |
2795 ret = menuItem->rect; |
2887 ret = menuItem->rect; |
2796 if (!menuItem->icon.isNull()) |
2888 if (!menuItem->icon.isNull()) |
2797 if (menuItem->direction == Qt::LeftToRight) |
2889 if (menuItem->direction == Qt::LeftToRight) |
2798 ret.adjust(indicatorWidth, 0, 0, 0); |
2890 ret.adjust(indicatorWidth, 0, 0, 0); |
2848 case SE_HeaderLabel: |
2940 case SE_HeaderLabel: |
2849 ret = QCommonStyle::subElementRect(element, opt, widget); |
2941 ret = QCommonStyle::subElementRect(element, opt, widget); |
2850 if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
2942 if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
2851 // Subtract area needed for line |
2943 // Subtract area needed for line |
2852 if (opt->state & State_Horizontal) |
2944 if (opt->state & State_Horizontal) |
2853 ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth)); |
2945 ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_BoldLineWidth)); |
2854 else |
2946 else |
2855 ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth)); |
2947 ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_ThinLineWidth)); |
2856 } |
2948 } |
2857 ret = visualRect(opt->direction, opt->rect, ret); |
2949 ret = visualRect(opt->direction, opt->rect, ret); |
2858 break; |
2950 break; |
2859 case SE_RadioButtonIndicator: { |
2951 case SE_RadioButtonIndicator: { |
2860 const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
2952 const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
3161 return QStyle::eventFilter(object, event); |
3253 return QStyle::eventFilter(object, event); |
3162 } |
3254 } |
3163 |
3255 |
3164 /*! |
3256 /*! |
3165 \internal |
3257 \internal |
3166 Handle the timer \a event. |
3258 Handle the timer \a event. |
3167 */ |
3259 */ |
3168 void QS60Style::timerEvent(QTimerEvent *event) |
3260 void QS60Style::timerEvent(QTimerEvent *event) |
3169 { |
3261 { |
3170 #ifdef Q_WS_S60 |
3262 #ifdef Q_WS_S60 |
3171 #ifndef QT_NO_PROGRESSBAR |
3263 #ifndef QT_NO_PROGRESSBAR |