author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 8 |
** |
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qs60style_p.h" |
|
43 |
||
44 |
#include "qapplication.h" |
|
45 |
#include "qpainter.h" |
|
46 |
#include "qstyleoption.h" |
|
47 |
#include "qevent.h" |
|
48 |
#include "qpixmapcache.h" |
|
49 |
||
50 |
#include "qcalendarwidget.h" |
|
51 |
#include "qdial.h" |
|
52 |
#include "qdialog.h" |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
53 |
#include "qmessagebox.h" |
0 | 54 |
#include "qgroupbox.h" |
55 |
#include "qheaderview.h" |
|
56 |
#include "qlist.h" |
|
57 |
#include "qlistwidget.h" |
|
58 |
#include "qlistview.h" |
|
59 |
#include "qmenu.h" |
|
60 |
#include "qmenubar.h" |
|
61 |
#include "qpushbutton.h" |
|
62 |
#include "qscrollarea.h" |
|
63 |
#include "qscrollbar.h" |
|
64 |
#include "qtabbar.h" |
|
65 |
#include "qtableview.h" |
|
66 |
#include "qtextedit.h" |
|
67 |
#include "qtoolbar.h" |
|
68 |
#include "qtoolbutton.h" |
|
69 |
#include "qfocusframe.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
#include "qformlayout.h" |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
71 |
#include "qradiobutton.h" |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
72 |
#include "qcheckbox.h" |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
73 |
#include "qdesktopwidget.h" |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
74 |
#include "qprogressbar.h" |
0 | 75 |
|
76 |
#include "private/qtoolbarextension_p.h" |
|
77 |
#include "private/qcombobox_p.h" |
|
78 |
#include "private/qwidget_p.h" |
|
79 |
#include "private/qapplication_p.h" |
|
80 |
||
81 |
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) |
|
82 |
||
83 |
QT_BEGIN_NAMESPACE |
|
84 |
||
85 |
// from text/qfont.cpp |
|
86 |
extern Q_GUI_EXPORT int qt_defaultDpiY(); |
|
87 |
||
88 |
const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFlags = |
|
89 |
SkinElementFlags(SF_PointNorth | SF_StateEnabled); |
|
90 |
||
91 |
static const qreal goldenRatio = 1.618; |
|
92 |
||
93 |
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
|
94 |
// *** generated layout data *** |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
95 |
{240,320,1,19,"QVGA Landscape"}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
96 |
{320,240,1,19,"QVGA Portrait"}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
97 |
{360,640,1,19,"NHD Landscape"}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
98 |
{640,360,1,19,"NHD Portrait"}, |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
{352,800,1,12,"E90 Landscape"} |
0 | 100 |
// *** End of generated data *** |
101 |
}; |
|
102 |
const int QS60StylePrivate::m_numberOfLayouts = |
|
103 |
(int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
|
104 |
||
105 |
const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
|
106 |
// *** generated pixel metrics *** |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
107 |
{5,0,-909,0,0,2,0,0,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,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}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
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,28,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}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
109 |
{7,0,-909,0,0,2,0,0,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,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}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
110 |
{7,0,-909,0,0,2,0,0,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,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}, |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
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,30,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} |
0 | 112 |
// *** End of generated data *** |
113 |
}; |
|
114 |
||
115 |
const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
|
116 |
||
117 |
// theme background texture |
|
118 |
QPixmap *QS60StylePrivate::m_background = 0; |
|
119 |
||
120 |
// theme palette |
|
121 |
QPalette *QS60StylePrivate::m_themePalette = 0; |
|
122 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
123 |
qint64 QS60StylePrivate::m_webPaletteKey = 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
124 |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
125 |
QPointer<QWidget> QS60StylePrivate::m_pressedWidget = 0; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
126 |
|
0 | 127 |
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
128 |
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
|
129 |
{SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
|
130 |
{SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
|
131 |
{SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
132 |
{SE_PopupBackground, QS60StyleEnums::SP_QsnFrPopupCenter}, |
0 | 133 |
{SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
134 |
{SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, |
|
135 |
{SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, |
|
136 |
{SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, |
|
137 |
{SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
138 |
{SE_ToolBarButton, QS60StyleEnums::SP_QgnFrSctrlButtonCenter}, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
139 |
{SE_ToolBarButtonPressed, QS60StyleEnums::SP_QgnFrSctrlButtonCenterPressed}, |
0 | 140 |
{SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
141 |
{SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
{SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
143 |
{SE_TableItemPressed, QS60StyleEnums::SP_QsnFrGridCenterPressed}, |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
144 |
{SE_ListItemPressed, QS60StyleEnums::SP_QsnFrListCenterPressed}, |
0 | 145 |
}; |
146 |
||
147 |
static const int frameElementsCount = |
|
148 |
int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); |
|
149 |
||
150 |
const int KNotFound = -909; |
|
151 |
const double KTabFontMul = 0.72; |
|
152 |
||
153 |
QS60StylePrivate::~QS60StylePrivate() |
|
154 |
{ |
|
155 |
clearCaches(); //deletes also background image |
|
156 |
deleteThemePalette(); |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
157 |
#ifdef Q_WS_S60 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
158 |
removeAnimations(); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
159 |
#endif |
0 | 160 |
} |
161 |
||
162 |
void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, |
|
163 |
const QRect &rect, SkinElementFlags flags) |
|
164 |
{ |
|
165 |
switch (element) { |
|
166 |
case SE_ButtonNormal: |
|
167 |
drawFrame(SF_ButtonNormal, painter, rect, flags | SF_PointNorth); |
|
168 |
break; |
|
169 |
case SE_ButtonPressed: |
|
170 |
drawFrame(SF_ButtonPressed, painter, rect, flags | SF_PointNorth); |
|
171 |
break; |
|
172 |
case SE_FrameLineEdit: |
|
173 |
drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
|
174 |
break; |
|
175 |
case SE_ProgressBarGrooveHorizontal: |
|
176 |
drawRow(QS60StyleEnums::SP_QgnGrafBarFrameSideL, QS60StyleEnums::SP_QgnGrafBarFrameCenter, |
|
177 |
QS60StyleEnums::SP_QgnGrafBarFrameSideR, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
178 |
break; |
|
179 |
case SE_ProgressBarGrooveVertical: |
|
180 |
drawRow(QS60StyleEnums::SP_QgnGrafBarFrameSideL, QS60StyleEnums::SP_QgnGrafBarFrameCenter, |
|
181 |
QS60StyleEnums::SP_QgnGrafBarFrameSideR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
182 |
break; |
|
183 |
case SE_ProgressBarIndicatorHorizontal: |
|
184 |
drawPart(QS60StyleEnums::SP_QgnGrafBarProgress, painter, rect, flags | SF_PointNorth); |
|
185 |
break; |
|
186 |
case SE_ProgressBarIndicatorVertical: |
|
187 |
drawPart(QS60StyleEnums::SP_QgnGrafBarProgress, painter, rect, flags | SF_PointWest); |
|
188 |
break; |
|
189 |
case SE_ScrollBarGrooveHorizontal: |
|
190 |
drawRow(QS60StyleEnums::SP_QsnCpScrollBgBottom, QS60StyleEnums::SP_QsnCpScrollBgMiddle, |
|
191 |
QS60StyleEnums::SP_QsnCpScrollBgTop, Qt::Horizontal, painter, rect, flags | SF_PointEast); |
|
192 |
break; |
|
193 |
case SE_ScrollBarGrooveVertical: |
|
194 |
drawRow(QS60StyleEnums::SP_QsnCpScrollBgTop, QS60StyleEnums::SP_QsnCpScrollBgMiddle, |
|
195 |
QS60StyleEnums::SP_QsnCpScrollBgBottom, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
|
196 |
break; |
|
197 |
case SE_ScrollBarHandleHorizontal: |
|
198 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleBottom, QS60StyleEnums::SP_QsnCpScrollHandleMiddle, |
|
199 |
QS60StyleEnums::SP_QsnCpScrollHandleTop, Qt::Horizontal, painter, rect, flags | SF_PointEast); |
|
200 |
break; |
|
201 |
case SE_ScrollBarHandleVertical: |
|
202 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTop, QS60StyleEnums::SP_QsnCpScrollHandleMiddle, |
|
203 |
QS60StyleEnums::SP_QsnCpScrollHandleBottom, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
|
204 |
break; |
|
205 |
case SE_SliderHandleHorizontal: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarker, painter, rect, flags | SF_PointNorth); |
0 | 207 |
break; |
208 |
case SE_SliderHandleVertical: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarker, painter, rect, flags | SF_PointEast); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
case SE_SliderHandleSelectedHorizontal: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected, painter, rect, flags | SF_PointNorth); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
case SE_SliderHandleSelectedVertical: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected, painter, rect, flags | SF_PointEast); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
case SE_SliderGrooveVertical: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
drawRow(QS60StyleEnums::SP_QgnGrafNsliderEndLeft, QS60StyleEnums::SP_QgnGrafNsliderMiddle, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
QS60StyleEnums::SP_QgnGrafNsliderEndRight, Qt::Vertical, painter, rect, flags | SF_PointEast); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
case SE_SliderGrooveHorizontal: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
drawRow(QS60StyleEnums::SP_QgnGrafNsliderEndLeft, QS60StyleEnums::SP_QgnGrafNsliderMiddle, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
QS60StyleEnums::SP_QgnGrafNsliderEndRight, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
0 | 224 |
break; |
225 |
case SE_TabBarTabEastActive: |
|
226 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveL, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
227 |
QS60StyleEnums::SP_QgnGrafTabActiveR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
228 |
break; |
|
229 |
case SE_TabBarTabEastInactive: |
|
230 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveL, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
231 |
QS60StyleEnums::SP_QgnGrafTabPassiveR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
232 |
break; |
|
233 |
case SE_TabBarTabNorthActive: |
|
234 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveL, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
235 |
QS60StyleEnums::SP_QgnGrafTabActiveR, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
236 |
break; |
|
237 |
case SE_TabBarTabNorthInactive: |
|
238 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveL, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
239 |
QS60StyleEnums::SP_QgnGrafTabPassiveR, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
240 |
break; |
|
241 |
case SE_TabBarTabSouthActive: |
|
242 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveR, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
243 |
QS60StyleEnums::SP_QgnGrafTabActiveL, Qt::Horizontal, painter, rect, flags | SF_PointSouth); |
|
244 |
break; |
|
245 |
case SE_TabBarTabSouthInactive: |
|
246 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveR, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
247 |
QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Horizontal, painter, rect, flags | SF_PointSouth); |
|
248 |
break; |
|
249 |
case SE_TabBarTabWestActive: |
|
250 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveR, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
251 |
QS60StyleEnums::SP_QgnGrafTabActiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
|
252 |
break; |
|
253 |
case SE_TabBarTabWestInactive: |
|
254 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveR, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
255 |
QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
|
256 |
break; |
|
257 |
case SE_ListHighlight: |
|
258 |
drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); |
|
259 |
break; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
260 |
case SE_PopupBackground: |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
261 |
drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth); |
0 | 262 |
break; |
263 |
case SE_SettingsList: |
|
264 |
drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); |
|
265 |
break; |
|
266 |
case SE_TableItem: |
|
267 |
drawFrame(SF_TableItem, painter, rect, flags | SF_PointNorth); |
|
268 |
break; |
|
269 |
case SE_TableHeaderItem: |
|
270 |
drawFrame(SF_TableHeaderItem, painter, rect, flags | SF_PointNorth); |
|
271 |
break; |
|
272 |
case SE_ToolTip: |
|
273 |
drawFrame(SF_ToolTip, painter, rect, flags | SF_PointNorth); |
|
274 |
break; |
|
275 |
case SE_ToolBar: |
|
276 |
drawFrame(SF_ToolBar, painter, rect, flags | SF_PointNorth); |
|
277 |
break; |
|
278 |
case SE_ToolBarButton: |
|
279 |
drawFrame(SF_ToolBarButton, painter, rect, flags | SF_PointNorth); |
|
280 |
break; |
|
281 |
case SE_ToolBarButtonPressed: |
|
282 |
drawFrame(SF_ToolBarButtonPressed, painter, rect, flags | SF_PointNorth); |
|
283 |
break; |
|
284 |
case SE_PanelBackground: |
|
285 |
drawFrame(SF_PanelBackground, painter, rect, flags | SF_PointNorth); |
|
286 |
break; |
|
287 |
case SE_ScrollBarHandlePressedHorizontal: |
|
288 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, |
|
289 |
QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, Qt::Horizontal, painter, rect, flags | SF_PointEast); |
|
290 |
break; |
|
291 |
case SE_ScrollBarHandlePressedVertical: |
|
292 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, |
|
293 |
QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
|
294 |
break; |
|
295 |
case SE_ButtonInactive: |
|
296 |
drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
|
297 |
break; |
|
298 |
case SE_Editor: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
0 | 300 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
301 |
case SE_DropArea: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
302 |
drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
303 |
break; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
304 |
case SE_TableItemPressed: |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
305 |
drawFrame(SF_TableItemPressed, painter, rect, flags | SF_PointNorth); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
306 |
break; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
307 |
case SE_ListItemPressed: |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
308 |
drawFrame(SF_ListItemPressed, painter, rect, flags | SF_PointNorth); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
309 |
break; |
0 | 310 |
default: |
311 |
break; |
|
312 |
} |
|
313 |
} |
|
314 |
||
315 |
void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, |
|
316 |
QPainter *painter, const QRect &rect, SkinElementFlags flags) |
|
317 |
{ |
|
318 |
drawPart(part, painter, rect, flags); |
|
319 |
} |
|
320 |
||
321 |
short QS60StylePrivate::pixelMetric(int metric) |
|
322 |
{ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
323 |
//If it is a custom value, need to strip away the base to map to internal |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
324 |
//pixel metric value table |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
325 |
if (metric & QStyle::PM_CustomBase) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
326 |
metric -= QStyle::PM_CustomBase; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
327 |
metric += MAX_NON_CUSTOM_PIXELMETRICS - 1; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
328 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
329 |
|
0 | 330 |
Q_ASSERT(metric < MAX_PIXELMETRICS); |
331 |
const short returnValue = m_pmPointer[metric]; |
|
332 |
return returnValue; |
|
333 |
} |
|
334 |
||
335 |
QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option) |
|
336 |
{ |
|
337 |
QColor retColor (color); |
|
338 |
if (option && !(option->state & QStyle::State_Enabled)) { |
|
339 |
QColor hsvColor = retColor.toHsv(); |
|
340 |
int colorSat = hsvColor.saturation(); |
|
341 |
int colorVal = hsvColor.value(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
342 |
colorSat = (colorSat != 0) ? (colorSat >> 1) : 128; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
343 |
colorVal = (colorVal != 0) ? (colorVal >> 1) : 128; |
0 | 344 |
hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); |
345 |
retColor = hsvColor.toRgb(); |
|
346 |
} |
|
347 |
return retColor; |
|
348 |
} |
|
349 |
||
350 |
QColor QS60StylePrivate::lighterColor(const QColor &baseColor) |
|
351 |
{ |
|
352 |
QColor result(baseColor); |
|
353 |
bool modifyColor = false; |
|
354 |
if (result.saturation() == 0) { |
|
355 |
result.setHsv(result.hue(), 128, result.value()); |
|
356 |
modifyColor = true; |
|
357 |
} |
|
358 |
if (result.value() == 0) { |
|
359 |
result.setHsv(result.hue(), result.saturation(), 128); |
|
360 |
modifyColor = true; |
|
361 |
} |
|
362 |
if (modifyColor) |
|
363 |
result = result.lighter(175); |
|
364 |
else |
|
365 |
result = result.lighter(225); |
|
366 |
return result; |
|
367 |
} |
|
368 |
||
369 |
bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget) |
|
370 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
371 |
return (widget ? (widget->windowType() == Qt::Dialog) : false); |
0 | 372 |
} |
373 |
||
374 |
QFont QS60StylePrivate::s60Font( |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
375 |
QS60StyleEnums::FontCategories fontCategory, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
376 |
int pointSize, bool resolveFontSize) const |
0 | 377 |
{ |
378 |
QFont result; |
|
379 |
int actualPointSize = pointSize; |
|
380 |
if (actualPointSize <= 0) { |
|
381 |
const QFont appFont = QApplication::font(); |
|
382 |
actualPointSize = appFont.pointSize(); |
|
383 |
if (actualPointSize <= 0) |
|
384 |
actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); |
|
385 |
} |
|
386 |
Q_ASSERT(actualPointSize > 0); |
|
387 |
const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); |
|
388 |
if (!m_mappedFontsCache.contains(key)) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
389 |
result = s60Font_specific(fontCategory, actualPointSize, resolveFontSize); |
0 | 390 |
m_mappedFontsCache.insert(key, result); |
391 |
} else { |
|
392 |
result = m_mappedFontsCache.value(key); |
|
393 |
if (result.pointSize() != actualPointSize) |
|
394 |
result.setPointSize(actualPointSize); |
|
395 |
} |
|
396 |
return result; |
|
397 |
} |
|
398 |
||
399 |
void QS60StylePrivate::clearCaches(CacheClearReason reason) |
|
400 |
{ |
|
401 |
switch(reason){ |
|
402 |
case CC_LayoutChange: |
|
403 |
// when layout changes, the colors remain in cache, but graphics and fonts can change |
|
404 |
m_mappedFontsCache.clear(); |
|
405 |
QPixmapCache::clear(); |
|
406 |
break; |
|
407 |
case CC_ThemeChange: |
|
408 |
m_colorCache.clear(); |
|
409 |
QPixmapCache::clear(); |
|
410 |
deleteBackground(); |
|
411 |
break; |
|
412 |
case CC_UndefinedChange: |
|
413 |
default: |
|
414 |
m_colorCache.clear(); |
|
415 |
m_mappedFontsCache.clear(); |
|
416 |
QPixmapCache::clear(); |
|
417 |
deleteBackground(); |
|
418 |
break; |
|
419 |
} |
|
420 |
} |
|
421 |
||
422 |
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use |
|
423 |
// for QPalette::Button and QPalette::ToolTipBase. Therefore S60Style needs to guesstimate |
|
424 |
// palette colors by calculating average rgb values for button pixels. |
|
425 |
// Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). |
|
426 |
QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const |
|
427 |
{ |
|
428 |
const bool cachedColorExists = m_colorCache.contains(frame); |
|
429 |
if (!cachedColorExists) { |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
430 |
const int frameCornerWidth = pixelMetric(PM_FrameCornerWidth); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
431 |
const int frameCornerHeight = pixelMetric(PM_FrameCornerHeight); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
432 |
Q_ASSERT(2 * frameCornerWidth < 32); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
433 |
Q_ASSERT(2 * frameCornerHeight < 32); |
0 | 434 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
435 |
const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
0 | 436 |
Q_ASSERT(frameImage.bytesPerLine() > 0); |
437 |
if (frameImage.isNull()) |
|
438 |
return Qt::black; |
|
439 |
||
440 |
const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
441 |
const int pixels = frameImage.byteCount()/sizeof(QRgb); |
0 | 442 |
|
443 |
int estimatedRed = 0; |
|
444 |
int estimatedGreen = 0; |
|
445 |
int estimatedBlue = 0; |
|
446 |
||
447 |
int skips = 0; |
|
448 |
int estimations = 0; |
|
449 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
450 |
const int topBorderLastPixel = frameCornerHeight*frameImage.width() - 1; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
451 |
const int bottomBorderFirstPixel = frameImage.width() * frameImage.height() - frameCornerHeight*frameImage.width() - 1; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
452 |
const int rightBorderFirstPixel = frameImage.width() - frameCornerWidth; |
0 | 453 |
const int leftBorderLastPixel = frameCornerWidth; |
454 |
||
455 |
while ((skips + estimations) < pixels) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
456 |
if ((skips + estimations) > topBorderLastPixel && |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
457 |
(skips + estimations) < bottomBorderFirstPixel) { |
0 | 458 |
for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) { |
459 |
if (rowIndex > leftBorderLastPixel && |
|
460 |
rowIndex < rightBorderFirstPixel) { |
|
461 |
estimatedRed += qRed(*pixelRgb); |
|
462 |
estimatedGreen += qGreen(*pixelRgb); |
|
463 |
estimatedBlue += qBlue(*pixelRgb); |
|
464 |
} |
|
465 |
pixelRgb++; |
|
466 |
estimations++; |
|
467 |
} |
|
468 |
} else { |
|
469 |
pixelRgb++; |
|
470 |
skips++; |
|
471 |
} |
|
472 |
} |
|
473 |
QColor frameColor(estimatedRed/estimations, estimatedGreen/estimations, estimatedBlue/estimations); |
|
474 |
m_colorCache.insert(frame, frameColor); |
|
475 |
return !estimations ? Qt::black : frameColor; |
|
476 |
} else { |
|
477 |
return m_colorCache.value(frame); |
|
478 |
} |
|
479 |
||
480 |
} |
|
481 |
||
482 |
void QS60StylePrivate::setThemePalette(QApplication *app) const |
|
483 |
{ |
|
484 |
Q_UNUSED(app) |
|
485 |
QPalette widgetPalette = QPalette(Qt::white); |
|
486 |
setThemePalette(&widgetPalette); |
|
487 |
} |
|
488 |
||
489 |
QPalette* QS60StylePrivate::themePalette() |
|
490 |
{ |
|
491 |
return m_themePalette; |
|
492 |
} |
|
493 |
||
494 |
void QS60StylePrivate::setBackgroundTexture(QApplication *app) const |
|
495 |
{ |
|
496 |
Q_UNUSED(app) |
|
497 |
QPalette applicationPalette = QApplication::palette(); |
|
498 |
applicationPalette.setBrush(QPalette::Window, backgroundTexture()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
setThemePalette(&applicationPalette); |
0 | 500 |
} |
501 |
||
502 |
void QS60StylePrivate::deleteBackground() |
|
503 |
{ |
|
504 |
if (m_background) { |
|
505 |
delete m_background; |
|
506 |
m_background = 0; |
|
507 |
} |
|
508 |
} |
|
509 |
||
510 |
void QS60StylePrivate::setCurrentLayout(int index) |
|
511 |
{ |
|
512 |
m_pmPointer = data[index]; |
|
513 |
} |
|
514 |
||
515 |
void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, |
|
516 |
QPainter *painter, const QRect &rect, SkinElementFlags flags) |
|
517 |
{ |
|
518 |
static const bool doCache = |
|
519 |
#if defined(Q_WS_S60) |
|
520 |
// Freezes on 3.1. Anyways, caching is only really needed on touch UI |
|
521 |
!(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); |
|
522 |
#else |
|
523 |
true; |
|
524 |
#endif |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
525 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
526 |
const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), painter, flags)); |
0 | 527 |
if (!skinPartPixMap.isNull()) |
528 |
painter->drawPixmap(rect.topLeft(), skinPartPixMap); |
|
529 |
} |
|
530 |
||
531 |
void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags) |
|
532 |
{ |
|
533 |
static const bool doCache = |
|
534 |
#if defined(Q_WS_S60) |
|
535 |
// Freezes on 3.1. Anyways, caching is only really needed on touch UI |
|
536 |
!(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); |
|
537 |
#else |
|
538 |
true; |
|
539 |
#endif |
|
540 |
const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags)); |
|
541 |
if (!frameElementPixMap.isNull()) |
|
542 |
painter->drawPixmap(rect.topLeft(), frameElementPixMap); |
|
543 |
} |
|
544 |
||
545 |
void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, |
|
546 |
QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end, |
|
547 |
Qt::Orientation orientation, QPainter *painter, const QRect &rect, |
|
548 |
SkinElementFlags flags) |
|
549 |
{ |
|
550 |
QSize startEndSize(partSize(start, flags)); |
|
551 |
startEndSize.scale(rect.size(), Qt::KeepAspectRatio); |
|
552 |
||
553 |
QRect startRect = QRect(rect.topLeft(), startEndSize); |
|
554 |
QRect middleRect = rect; |
|
555 |
QRect endRect; |
|
556 |
||
557 |
if (orientation == Qt::Horizontal) { |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
558 |
startRect.setHeight(rect.height()); |
0 | 559 |
startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
560 |
endRect = startRect.translated(rect.width() - startRect.width(), 0); |
|
561 |
middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
|
562 |
if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
563 |
const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
564 |
startRect.setWidth(startRect.width() - overlap); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
565 |
endRect.adjust(overlap, 0, 0, 0); |
0 | 566 |
} |
567 |
} else { |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
568 |
startRect.setWidth(rect.width()); |
0 | 569 |
startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
570 |
endRect = startRect.translated(0, rect.height() - startRect.height()); |
|
571 |
middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
|
572 |
if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
573 |
const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
574 |
startRect.setHeight(startRect.height() - overlap); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
575 |
endRect.adjust(0, overlap, 0, 0); |
0 | 576 |
} |
577 |
} |
|
578 |
||
579 |
#if 0 |
|
580 |
painter->save(); |
|
581 |
painter->setOpacity(.3); |
|
582 |
painter->fillRect(startRect, Qt::red); |
|
583 |
painter->fillRect(middleRect, Qt::green); |
|
584 |
painter->fillRect(endRect, Qt::blue); |
|
585 |
painter->restore(); |
|
586 |
#else |
|
587 |
drawPart(start, painter, startRect, flags); |
|
588 |
if (middleRect.isValid()) |
|
589 |
drawPart(middle, painter, middleRect, flags); |
|
590 |
drawPart(end, painter, endRect, flags); |
|
591 |
#endif |
|
592 |
} |
|
593 |
||
594 |
QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
595 |
const QSize &size, QPainter *painter, SkinElementFlags flags) |
0 | 596 |
{ |
597 |
QPixmap result; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
598 |
const int animationFrame = (flags & SF_Animation) ? currentAnimationFrame(part) : 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
599 |
|
0 | 600 |
const QString cacheKey = |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
601 |
QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4 AnimationFrame=%5") |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
602 |
.arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags).arg(animationFrame); |
0 | 603 |
if (!QPixmapCache::find(cacheKey, result)) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
604 |
result = QS60StylePrivate::part(part, size, painter, flags); |
0 | 605 |
QPixmapCache::insert(cacheKey, result); |
606 |
} |
|
607 |
return result; |
|
608 |
} |
|
609 |
||
610 |
QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags) |
|
611 |
{ |
|
612 |
QPixmap result; |
|
613 |
const QString cacheKey = |
|
614 |
QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4") |
|
615 |
.arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags); |
|
616 |
if (!QPixmapCache::find(cacheKey, result)) { |
|
617 |
result = QS60StylePrivate::frame(frame, size, flags); |
|
618 |
QPixmapCache::insert(cacheKey, result); |
|
619 |
} |
|
620 |
return result; |
|
621 |
} |
|
622 |
||
623 |
void QS60StylePrivate::refreshUI() |
|
624 |
{ |
|
625 |
QList<QWidget *> widgets = QApplication::allWidgets(); |
|
626 |
||
627 |
for (int i = 0; i < widgets.size(); ++i) { |
|
628 |
QWidget *widget = widgets.at(i); |
|
629 |
if (widget == 0) |
|
630 |
continue; |
|
631 |
||
632 |
if (widget->style()) { |
|
633 |
widget->style()->polish(widget); |
|
634 |
QEvent event(QEvent::StyleChange); |
|
635 |
qApp->sendEvent(widget, &event); |
|
636 |
} |
|
637 |
widget->update(); |
|
638 |
widget->updateGeometry(); |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
void QS60StylePrivate::setFont(QWidget *widget) const |
|
643 |
{ |
|
644 |
QS60StyleEnums::FontCategories fontCategory = QS60StyleEnums::FC_Undefined; |
|
645 |
if (!widget) |
|
646 |
return; |
|
647 |
if (qobject_cast<QPushButton *>(widget)){ |
|
648 |
fontCategory = QS60StyleEnums::FC_Primary; |
|
649 |
} else if (qobject_cast<QToolButton *>(widget)){ |
|
650 |
fontCategory = QS60StyleEnums::FC_Primary; |
|
651 |
} else if (qobject_cast<QHeaderView *>(widget)){ |
|
652 |
fontCategory = QS60StyleEnums::FC_Secondary; |
|
653 |
} else if (qobject_cast<QGroupBox *>(widget)){ |
|
654 |
fontCategory = QS60StyleEnums::FC_Title; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
655 |
} else if (qobject_cast<QMessageBox *>(widget)){ |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
656 |
fontCategory = QS60StyleEnums::FC_Primary; |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
657 |
} else if (qobject_cast<QMenu *>(widget)){ |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
658 |
fontCategory = QS60StyleEnums::FC_Primary; |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
659 |
} else if (qobject_cast<QCalendarWidget *>(widget)){ |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
660 |
fontCategory = QS60StyleEnums::FC_Secondary; |
0 | 661 |
} |
662 |
if (fontCategory != QS60StyleEnums::FC_Undefined) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
663 |
const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
664 |
&& (widget->font().resolve() & QFont::SizeResolved); |
0 | 665 |
const QFont suggestedFont = |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
666 |
s60Font(fontCategory, widget->font().pointSizeF(), resolveFontSize); |
0 | 667 |
widget->setFont(suggestedFont); |
668 |
} |
|
669 |
} |
|
670 |
||
671 |
void QS60StylePrivate::setThemePalette(QWidget *widget) const |
|
672 |
{ |
|
673 |
if(!widget) |
|
674 |
return; |
|
675 |
||
676 |
//header view and its viewport need to be set 100% transparent button color, since drawing code will |
|
677 |
//draw transparent theme graphics to table column and row headers. |
|
678 |
if (qobject_cast<QHeaderView *>(widget)){ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
679 |
QPalette widgetPalette = QApplication::palette(widget); |
0 | 680 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
681 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
|
682 |
QHeaderView* header = qobject_cast<QHeaderView *>(widget); |
|
683 |
widgetPalette.setColor(QPalette::Button, Qt::transparent ); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
684 |
if (header->viewport()) |
0 | 685 |
header->viewport()->setPalette(widgetPalette); |
686 |
QApplication::setPalette(widgetPalette, "QHeaderView"); |
|
687 |
} |
|
688 |
} |
|
689 |
||
690 |
void QS60StylePrivate::setThemePalette(QPalette *palette) const |
|
691 |
{ |
|
692 |
if (!palette) |
|
693 |
return; |
|
694 |
||
695 |
// basic colors |
|
696 |
palette->setColor(QPalette::WindowText, |
|
697 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
|
698 |
palette->setColor(QPalette::ButtonText, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
699 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 20, 0)); |
0 | 700 |
palette->setColor(QPalette::Text, |
701 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
|
702 |
palette->setColor(QPalette::ToolTipText, |
|
703 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); |
|
704 |
palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter()); |
|
705 |
palette->setColor(QPalette::HighlightedText, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
706 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
0 | 707 |
palette->setColor(QPalette::Link, |
708 |
s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); |
|
709 |
palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); |
|
710 |
palette->setColor(QPalette::Highlight, |
|
711 |
s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); |
|
712 |
// set background image as a texture brush |
|
713 |
palette->setBrush(QPalette::Window, backgroundTexture()); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
714 |
// set as transparent so that styled full screen theme background is visible |
0 | 715 |
palette->setBrush(QPalette::Base, Qt::transparent); |
716 |
// set button and tooltipbase based on pixel colors |
|
717 |
const QColor buttonColor = colorFromFrameGraphics(SF_ButtonNormal); |
|
718 |
palette->setColor(QPalette::Button, buttonColor); |
|
719 |
const QColor toolTipColor = colorFromFrameGraphics(SF_ToolTip); |
|
720 |
palette->setColor(QPalette::ToolTipBase, toolTipColor); |
|
721 |
palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); |
|
722 |
palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); |
|
723 |
palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); |
|
724 |
palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); |
|
725 |
palette->setColor(QPalette::Shadow, Qt::black); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
726 |
QColor alternateBase = palette->light().color(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
727 |
alternateBase.setAlphaF(0.8); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
728 |
palette->setColor(QPalette::AlternateBase, alternateBase); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
730 |
QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
731 |
setThemePaletteHash(palette); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
storeThemePalette(palette); |
0 | 733 |
} |
734 |
||
735 |
void QS60StylePrivate::deleteThemePalette() |
|
736 |
{ |
|
737 |
if (m_themePalette) { |
|
738 |
delete m_themePalette; |
|
739 |
m_themePalette = 0; |
|
740 |
} |
|
741 |
} |
|
742 |
||
743 |
void QS60StylePrivate::storeThemePalette(QPalette *palette) |
|
744 |
{ |
|
745 |
deleteThemePalette(); |
|
746 |
//store specified palette for latter use. |
|
747 |
m_themePalette = new QPalette(*palette); |
|
748 |
} |
|
749 |
||
750 |
// set widget specific palettes |
|
751 |
void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const |
|
752 |
{ |
|
753 |
if (!palette) |
|
754 |
return; |
|
755 |
||
756 |
//store the original palette |
|
757 |
QPalette widgetPalette = *palette; |
|
758 |
const QColor mainAreaTextColor = |
|
759 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); |
|
760 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
761 |
widgetPalette.setColor(QPalette::WindowText, |
0 | 762 |
s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); |
763 |
QApplication::setPalette(widgetPalette, "QSlider"); |
|
764 |
// return to original palette after each widget |
|
765 |
widgetPalette = *palette; |
|
766 |
||
767 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor); |
|
768 |
widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); |
|
769 |
const QStyleOption opt; |
|
770 |
widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText, |
|
771 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); |
|
772 |
QApplication::setPalette(widgetPalette, "QPushButton"); |
|
773 |
widgetPalette = *palette; |
|
774 |
||
775 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor); |
|
776 |
widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); |
|
777 |
QApplication::setPalette(widgetPalette, "QToolButton"); |
|
778 |
widgetPalette = *palette; |
|
779 |
||
780 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
|
781 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
|
782 |
QApplication::setPalette(widgetPalette, "QHeaderView"); |
|
783 |
widgetPalette = *palette; |
|
784 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
785 |
widgetPalette.setColor(QPalette::ButtonText, |
0 | 786 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
787 |
QApplication::setPalette(widgetPalette, "QMenuBar"); |
|
788 |
widgetPalette = *palette; |
|
789 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
790 |
widgetPalette.setColor(QPalette::Text, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
791 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
792 |
widgetPalette.setColor(QPalette::HighlightedText, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
793 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
794 |
QApplication::setPalette(widgetPalette, "QMenu"); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
795 |
widgetPalette = *palette; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
796 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
797 |
widgetPalette.setColor(QPalette::WindowText, |
0 | 798 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
799 |
widgetPalette.setColor(QPalette::HighlightedText, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
800 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 3, 0)); |
0 | 801 |
QApplication::setPalette(widgetPalette, "QTabBar"); |
802 |
widgetPalette = *palette; |
|
803 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
804 |
widgetPalette.setColor(QPalette::HighlightedText, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
805 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
806 |
QApplication::setPalette(widgetPalette, "QListView"); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
807 |
widgetPalette = *palette; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
808 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
widgetPalette.setColor(QPalette::Text, |
0 | 810 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
811 |
widgetPalette.setColor(QPalette::HighlightedText, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
812 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
0 | 813 |
QApplication::setPalette(widgetPalette, "QTableView"); |
814 |
widgetPalette = *palette; |
|
815 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
816 |
widgetPalette.setColor(QPalette::Text, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
817 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
818 |
widgetPalette.setColor(QPalette::HighlightedText, |
0 | 819 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
820 |
QApplication::setPalette(widgetPalette, "QLineEdit"); |
|
821 |
QApplication::setPalette(widgetPalette, "QTextEdit"); |
|
822 |
widgetPalette = *palette; |
|
823 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
widgetPalette.setColor(QPalette::HighlightedText, |
0 | 825 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
826 |
QApplication::setPalette(widgetPalette, "QComboBox"); |
|
827 |
widgetPalette = *palette; |
|
828 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
829 |
widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
830 |
widgetPalette.setColor(QPalette::HighlightedText, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
831 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
832 |
QApplication::setPalette(widgetPalette, "QRadioButton"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
833 |
QApplication::setPalette(widgetPalette, "QCheckBox"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
834 |
widgetPalette = *palette; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
835 |
|
0 | 836 |
widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
837 |
widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); |
|
838 |
widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); |
|
839 |
widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter()); |
|
840 |
QApplication::setPalette(widgetPalette, "QDial"); |
|
841 |
widgetPalette = *palette; |
|
842 |
||
843 |
widgetPalette.setBrush(QPalette::Window, QBrush()); |
|
844 |
QApplication::setPalette(widgetPalette, "QScrollArea"); |
|
845 |
widgetPalette = *palette; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
846 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
//Webpages should not use S60 theme colors as they are designed to work |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
848 |
//with themeBackground and do not generally mesh well with web page backgrounds. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
QPalette webPalette = *palette; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
webPalette.setColor(QPalette::WindowText, Qt::black); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
851 |
webPalette.setColor(QPalette::Text, Qt::black); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
852 |
webPalette.setBrush(QPalette::Base, Qt::white); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
853 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
854 |
QApplication::setPalette(webPalette, "QWebView"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
855 |
QApplication::setPalette(webPalette, "QGraphicsWebView"); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
856 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
857 |
m_webPaletteKey = webPalette.cacheKey(); |
0 | 858 |
} |
859 |
||
860 |
QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
|
861 |
{ |
|
862 |
QSize result(20, 20); |
|
863 |
switch (part) |
|
864 |
{ |
|
865 |
case QS60StyleEnums::SP_QgnGrafBarProgress: |
|
866 |
result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth)); |
|
867 |
break; |
|
868 |
case QS60StyleEnums::SP_QgnGrafTabActiveM: |
|
869 |
case QS60StyleEnums::SP_QgnGrafTabPassiveM: |
|
870 |
case QS60StyleEnums::SP_QgnGrafTabActiveR: |
|
871 |
case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
|
872 |
case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
|
873 |
case QS60StyleEnums::SP_QgnGrafTabActiveL: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
874 |
//Returned QSize for tabs must not be square, but narrow rectangle with width:height |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
//ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
876 |
result.setWidth(result.height() >> 1); |
0 | 877 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
878 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
879 |
case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
883 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
884 |
case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
0 | 886 |
result.scale(pixelMetric(QStyle::PM_SliderLength), |
887 |
pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
|
888 |
break; |
|
889 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
890 |
case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
891 |
case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
892 |
result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
893 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
894 |
|
0 | 895 |
case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
896 |
case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
|
897 |
case QS60StyleEnums::SP_QsnCpScrollBgTop: |
|
898 |
case QS60StyleEnums::SP_QsnCpScrollHandleBottom: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
899 |
case QS60StyleEnums::SP_QsnCpScrollHandleTop: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
900 |
case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
901 |
result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
902 |
result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
903 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
904 |
case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
905 |
case QS60StyleEnums::SP_QsnCpScrollBgMiddle: |
0 | 906 |
case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: |
907 |
result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
|
908 |
result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); |
|
909 |
break; |
|
910 |
default: |
|
911 |
// Generic frame part size gathering. |
|
912 |
for (int i = 0; i < frameElementsCount; ++i) |
|
913 |
{ |
|
914 |
switch (m_frameElementsData[i].center - part) { |
|
915 |
case 8: /* CornerTl */ |
|
916 |
case 7: /* CornerTr */ |
|
917 |
case 6: /* CornerBl */ |
|
918 |
case 5: /* CornerBr */ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
919 |
result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
0 | 920 |
// Falltrough intended... |
921 |
case 4: /* SideT */ |
|
922 |
case 3: /* SideB */ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
923 |
result.setHeight(pixelMetric(PM_FrameCornerHeight)); |
0 | 924 |
break; |
925 |
case 2: /* SideL */ |
|
926 |
case 1: /* SideR */ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
927 |
result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
0 | 928 |
break; |
929 |
case 0: /* center */ |
|
930 |
default: |
|
931 |
break; |
|
932 |
} |
|
933 |
} |
|
934 |
break; |
|
935 |
} |
|
936 |
if (flags & (SF_PointEast | SF_PointWest)) { |
|
937 |
const int temp = result.width(); |
|
938 |
result.setWidth(result.height()); |
|
939 |
result.setHeight(temp); |
|
940 |
} |
|
941 |
return result; |
|
942 |
} |
|
943 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
944 |
bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
945 |
{ |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
946 |
// Always return true for web pages. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
947 |
if (widget && m_webPaletteKey == QApplication::palette(widget).cacheKey()) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
948 |
return true; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
949 |
//If brush is not changed from style's default values, draw theme graphics. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
950 |
return (backgroundBrush.color() == Qt::transparent || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
951 |
backgroundBrush.style() == Qt::NoBrush) ? true : false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
952 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
953 |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
954 |
bool QS60StylePrivate::isWidgetPressed(const QWidget *widget) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
955 |
{ |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
956 |
return (widget && widget == m_pressedWidget); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
957 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
958 |
|
0 | 959 |
/*! |
960 |
\class QS60Style |
|
961 |
\brief The QS60Style class provides a look and feel suitable for applications on S60. |
|
962 |
\since 4.6 |
|
963 |
\ingroup appearance |
|
964 |
||
965 |
\sa QMacStyle, QWindowsStyle, QWindowsXPStyle, QWindowsVistaStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle |
|
966 |
*/ |
|
967 |
||
968 |
||
969 |
/*! |
|
970 |
Destroys the style. |
|
971 |
*/ |
|
972 |
QS60Style::~QS60Style() |
|
973 |
{ |
|
974 |
} |
|
975 |
||
976 |
/*! |
|
977 |
\reimp |
|
978 |
*/ |
|
979 |
void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const |
|
980 |
{ |
|
981 |
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
|
982 |
SubControls sub = option->subControls; |
|
983 |
||
984 |
switch (control) { |
|
985 |
#ifndef QT_NO_SCROLLBAR |
|
986 |
case CC_ScrollBar: |
|
987 |
if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
988 |
const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
989 |
||
990 |
const QRect scrollBarSlider = subControlRect(control, optionSlider, SC_ScrollBarSlider, widget); |
|
991 |
const QRect grooveRect = subControlRect(control, optionSlider, SC_ScrollBarGroove, widget); |
|
992 |
||
993 |
const QS60StylePrivate::SkinElements grooveElement = |
|
994 |
horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; |
|
995 |
QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); |
|
996 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
997 |
const SubControls subControls = optionSlider->subControls; |
0 | 998 |
|
999 |
// select correct slider (horizontal/vertical/pressed) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1000 |
const bool sliderPressed = ((optionSlider->state & State_Sunken) && (subControls & SC_ScrollBarSlider)); |
0 | 1001 |
const QS60StylePrivate::SkinElements handleElement = |
1002 |
horizontal ? |
|
1003 |
( sliderPressed ? |
|
1004 |
QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : |
|
1005 |
QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : |
|
1006 |
( sliderPressed ? |
|
1007 |
QS60StylePrivate::SE_ScrollBarHandlePressedVertical : |
|
1008 |
QS60StylePrivate::SE_ScrollBarHandleVertical); |
|
1009 |
QS60StylePrivate::drawSkinElement(handleElement, painter, scrollBarSlider, flags); |
|
1010 |
} |
|
1011 |
break; |
|
1012 |
#endif // QT_NO_SCROLLBAR |
|
1013 |
#ifndef QT_NO_SLIDER |
|
1014 |
case CC_Slider: |
|
1015 |
if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1016 |
||
1017 |
const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
|
1018 |
const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
1019 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
//Highlight |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1021 |
/* if (optionSlider->state & State_HasFocus) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1023 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1024 |
//Groove graphics |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1025 |
if (QS60StylePrivate::hasSliderGrooveGraphic()) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1026 |
const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1027 |
QS60StylePrivate::SE_SliderGrooveHorizontal : |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1028 |
QS60StylePrivate::SE_SliderGrooveVertical; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1029 |
QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1030 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1031 |
const QPoint sliderGrooveCenter = sliderGroove.center(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1032 |
const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1033 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1034 |
if (widget) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1035 |
painter->setPen(widget->palette().windowText().color()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1036 |
if (horizontal) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1037 |
painter->drawLine(0, sliderGrooveCenter.y(), sliderGroove.right(), sliderGrooveCenter.y()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1038 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1039 |
painter->drawLine(sliderGrooveCenter.x(), 0, sliderGrooveCenter.x(), sliderGroove.bottom()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1040 |
painter->restore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1041 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1042 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1043 |
//Handle graphics |
0 | 1044 |
const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1045 |
QS60StylePrivate::SkinElements handleElement; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1046 |
if (optionSlider->state & State_Sunken) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1047 |
handleElement = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1048 |
horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1049 |
else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1050 |
handleElement = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1051 |
horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; |
0 | 1052 |
QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); |
1053 |
} |
|
1054 |
break; |
|
1055 |
#endif // QT_NO_SLIDER |
|
1056 |
#ifndef QT_NO_COMBOBOX |
|
1057 |
case CC_ComboBox: |
|
1058 |
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1059 |
const QRect cmbxEditField = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget); |
|
1060 |
const QRect cmbxFrame = subControlRect(CC_ComboBox, option, SC_ComboBoxFrame, widget); |
|
1061 |
const bool direction = cmb->direction == Qt::LeftToRight; |
|
1062 |
||
1063 |
// Button frame |
|
1064 |
QStyleOptionFrame buttonOption; |
|
1065 |
buttonOption.QStyleOption::operator=(*cmb); |
|
1066 |
const int maxHeight = cmbxFrame.height(); |
|
1067 |
const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1068 |
const int topLeftPoint = direction ? |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1069 |
(cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); |
0 | 1070 |
const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); |
1071 |
buttonOption.rect = buttonRect; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1072 |
buttonOption.state = cmb->state; |
0 | 1073 |
drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
1074 |
||
1075 |
// draw label background - label itself is drawn separately |
|
1076 |
const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; |
|
1077 |
QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); |
|
1078 |
||
1079 |
// Draw the combobox arrow |
|
1080 |
if (sub & SC_ComboBoxArrow) { |
|
1081 |
// Make rect slightly smaller |
|
1082 |
buttonOption.rect.adjust(1, 1, -1, -1); |
|
1083 |
painter->save(); |
|
1084 |
painter->setPen(option->palette.buttonText().color()); |
|
1085 |
drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget); |
|
1086 |
painter->restore(); |
|
1087 |
} |
|
1088 |
} |
|
1089 |
break; |
|
1090 |
#endif // QT_NO_COMBOBOX |
|
1091 |
#ifndef QT_NO_TOOLBUTTON |
|
1092 |
case CC_ToolButton: |
|
1093 |
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1094 |
State bflags = toolBtn->state & ~State_Sunken; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1095 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1096 |
if (bflags & State_AutoRaise) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1097 |
if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1098 |
bflags &= ~State_Raised; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1099 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1100 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1101 |
State mflags = bflags; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1102 |
if (toolBtn->state & State_Sunken) { |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1103 |
bflags |= State_Sunken; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1104 |
mflags |= State_Sunken; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1105 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1106 |
|
0 | 1107 |
const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1108 |
QRect menuRect = QRect(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1109 |
if (toolBtn->subControls & SC_ToolButtonMenu) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1110 |
menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1111 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1112 |
if (toolBtn->subControls & SC_ToolButton) { |
0 | 1113 |
QStyleOption tool(0); |
1114 |
tool.palette = toolBtn->palette; |
|
1115 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1116 |
if (bflags & (State_Sunken | State_On | State_Raised | State_Enabled)) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1117 |
tool.rect = button.unite(menuRect); |
0 | 1118 |
tool.state = bflags; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1119 |
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1120 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1121 |
if (toolBtn->subControls & SC_ToolButtonMenu) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1122 |
tool.rect = menuRect; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1123 |
tool.state = mflags; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1124 |
drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
0 | 1125 |
} |
1126 |
} |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1127 |
QStyleOptionToolButton toolButton = *toolBtn; |
0 | 1128 |
if (toolBtn->features & QStyleOptionToolButton::Arrow) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1129 |
PrimitiveElement pe; |
0 | 1130 |
switch (toolBtn->arrowType) { |
1131 |
case Qt::LeftArrow: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1132 |
pe = PE_IndicatorArrowLeft; |
0 | 1133 |
break; |
1134 |
case Qt::RightArrow: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1135 |
pe = PE_IndicatorArrowRight; |
0 | 1136 |
break; |
1137 |
case Qt::UpArrow: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1138 |
pe = PE_IndicatorArrowUp; |
0 | 1139 |
break; |
1140 |
case Qt::DownArrow: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1141 |
pe = PE_IndicatorArrowDown; |
0 | 1142 |
break; |
1143 |
default: |
|
1144 |
break; } |
|
1145 |
toolButton.rect = button; |
|
1146 |
drawPrimitive(pe, &toolButton, painter, widget); |
|
1147 |
} |
|
1148 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1149 |
if (toolBtn->text.length() > 0 || |
0 | 1150 |
!toolBtn->icon.isNull()) { |
1151 |
const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
|
1152 |
toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
|
1153 |
drawControl(CE_ToolButtonLabel, &toolButton, painter, widget); |
|
1154 |
} |
|
1155 |
} |
|
1156 |
break; |
|
1157 |
#endif //QT_NO_TOOLBUTTON |
|
1158 |
#ifndef QT_NO_SPINBOX |
|
1159 |
case CC_SpinBox: |
|
1160 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1161 |
QStyleOptionSpinBox copy = *spinBox; |
|
1162 |
PrimitiveElement pe; |
|
1163 |
||
1164 |
if (spinBox->subControls & SC_SpinBoxUp) { |
|
1165 |
copy.subControls = SC_SpinBoxUp; |
|
1166 |
QPalette spinBoxPal = spinBox->palette; |
|
1167 |
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { |
|
1168 |
spinBoxPal.setCurrentColorGroup(QPalette::Disabled); |
|
1169 |
copy.state &= ~State_Enabled; |
|
1170 |
copy.palette = spinBoxPal; |
|
1171 |
} |
|
1172 |
||
1173 |
if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) { |
|
1174 |
copy.state |= State_On; |
|
1175 |
copy.state |= State_Sunken; |
|
1176 |
} else { |
|
1177 |
copy.state |= State_Raised; |
|
1178 |
copy.state &= ~State_Sunken; |
|
1179 |
} |
|
1180 |
pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ? |
|
1181 |
PE_IndicatorSpinPlus : |
|
1182 |
PE_IndicatorSpinUp; |
|
1183 |
||
1184 |
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget); |
|
1185 |
drawPrimitive(PE_PanelButtonBevel, ©, painter, widget); |
|
1186 |
copy.rect.adjust(1, 1, -1, -1); |
|
1187 |
drawPrimitive(pe, ©, painter, widget); |
|
1188 |
} |
|
1189 |
||
1190 |
if (spinBox->subControls & SC_SpinBoxDown) { |
|
1191 |
copy.subControls = SC_SpinBoxDown; |
|
1192 |
copy.state = spinBox->state; |
|
1193 |
QPalette spinBoxPal = spinBox->palette; |
|
1194 |
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { |
|
1195 |
spinBoxPal.setCurrentColorGroup(QPalette::Disabled); |
|
1196 |
copy.state &= ~State_Enabled; |
|
1197 |
copy.palette = spinBoxPal; |
|
1198 |
} |
|
1199 |
||
1200 |
if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) { |
|
1201 |
copy.state |= State_On; |
|
1202 |
copy.state |= State_Sunken; |
|
1203 |
} else { |
|
1204 |
copy.state |= State_Raised; |
|
1205 |
copy.state &= ~State_Sunken; |
|
1206 |
} |
|
1207 |
pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ? |
|
1208 |
PE_IndicatorSpinMinus : |
|
1209 |
PE_IndicatorSpinDown; |
|
1210 |
||
1211 |
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget); |
|
1212 |
drawPrimitive(PE_PanelButtonBevel, ©, painter, widget); |
|
1213 |
copy.rect.adjust(1, 1, -1, -1); |
|
1214 |
drawPrimitive(pe, ©, painter, widget); |
|
1215 |
} |
|
1216 |
} |
|
1217 |
break; |
|
1218 |
#endif //QT_NO_SPINBOX |
|
1219 |
#ifndef QT_NO_GROUPBOX |
|
1220 |
case CC_GroupBox: |
|
1221 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1222 |
// Draw frame |
|
1223 |
const QRect textRect = subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); |
|
1224 |
const QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1225 |
if (groupBox->subControls & SC_GroupBoxFrame) { |
0 | 1226 |
QStyleOptionFrameV2 frame; |
1227 |
frame.QStyleOption::operator=(*groupBox); |
|
1228 |
frame.features = groupBox->features; |
|
1229 |
frame.lineWidth = groupBox->lineWidth; |
|
1230 |
frame.midLineWidth = groupBox->midLineWidth; |
|
1231 |
frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); |
|
1232 |
drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); |
|
1233 |
} |
|
1234 |
||
1235 |
// Draw title |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1236 |
if ((groupBox->subControls & SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
0 | 1237 |
const QColor textColor = groupBox->textColor; |
1238 |
painter->save(); |
|
1239 |
||
1240 |
if (textColor.isValid()) |
|
1241 |
painter->setPen(textColor); |
|
1242 |
int alignment = int(groupBox->textAlignment); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1243 |
if (!styleHint(SH_UnderlineShortcut, option, widget)) |
0 | 1244 |
alignment |= Qt::TextHideMnemonic; |
1245 |
||
1246 |
drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | Qt::AlignVCenter | alignment, |
|
1247 |
groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
|
1248 |
textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
|
1249 |
painter->restore(); |
|
1250 |
} |
|
1251 |
||
1252 |
// Draw checkbox |
|
1253 |
if (groupBox->subControls & SC_GroupBoxCheckBox) { |
|
1254 |
QStyleOptionButton box; |
|
1255 |
box.QStyleOption::operator=(*groupBox); |
|
1256 |
box.rect = checkBoxRect; |
|
1257 |
drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); |
|
1258 |
} |
|
1259 |
} |
|
1260 |
break; |
|
1261 |
#endif //QT_NO_GROUPBOX |
|
1262 |
default: |
|
1263 |
QCommonStyle::drawComplexControl(control, option, painter, widget); |
|
1264 |
} |
|
1265 |
} |
|
1266 |
||
1267 |
/*! |
|
1268 |
\reimp |
|
1269 |
*/ |
|
1270 |
void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
|
1271 |
{ |
|
1272 |
Q_D(const QS60Style); |
|
1273 |
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
|
1274 |
switch (element) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1275 |
case CE_CheckBox: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1276 |
case CE_RadioButton: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1277 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1278 |
bool isRadio = (element == CE_RadioButton); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1279 |
QStyleOptionButton subopt = *btn; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1280 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1281 |
// Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1282 |
if (btn->state & State_HasFocus) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1283 |
QStyleOptionFocusRect fropt; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1284 |
fropt.QStyleOption::operator=(*btn); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1285 |
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1286 |
: SE_CheckBoxFocusRect, btn, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1287 |
drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1288 |
|
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1289 |
subopt.palette.setColor(QPalette::Active, QPalette::WindowText, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1290 |
subopt.palette.highlightedText().color()); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1291 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1292 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1293 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1294 |
: SE_CheckBoxIndicator, btn, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1295 |
drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1296 |
&subopt, painter, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1297 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1298 |
: SE_CheckBoxContents, btn, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1299 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1300 |
drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1301 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1302 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1303 |
|
0 | 1304 |
case CE_PushButton: |
1305 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1306 |
||
1307 |
drawControl(CE_PushButtonBevel, btn, painter, widget); |
|
1308 |
QStyleOptionButton subopt = *btn; |
|
1309 |
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); |
|
1310 |
||
1311 |
drawControl(CE_PushButtonLabel, &subopt, painter, widget); |
|
1312 |
} |
|
1313 |
break; |
|
1314 |
case CE_PushButtonBevel: |
|
1315 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1316 |
const bool isDisabled = !(option->state & State_Enabled); |
0 | 1317 |
const bool isFlat = button->features & QStyleOptionButton::Flat; |
1318 |
QS60StyleEnums::SkinParts skinPart; |
|
1319 |
QS60StylePrivate::SkinElements skinElement; |
|
1320 |
if (!isDisabled) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1321 |
const bool isPressed = (option->state & State_Sunken) || |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1322 |
(option->state & State_On); |
0 | 1323 |
if (isFlat) { |
1324 |
skinPart = |
|
1325 |
isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; |
|
1326 |
} else { |
|
1327 |
skinElement = |
|
1328 |
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
|
1329 |
} |
|
1330 |
} else { |
|
1331 |
if (isFlat) |
|
1332 |
skinPart =QS60StyleEnums::SP_QsnFrButtonCenterInactive; |
|
1333 |
else |
|
1334 |
skinElement = QS60StylePrivate::SE_ButtonInactive; |
|
1335 |
} |
|
1336 |
if (isFlat) |
|
1337 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
|
1338 |
else |
|
1339 |
QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
|
1340 |
} |
|
1341 |
break; |
|
1342 |
#ifndef QT_NO_TOOLBUTTON |
|
1343 |
case CE_ToolButtonLabel: |
|
1344 |
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
1345 |
QStyleOptionToolButton optionToolButton = *toolBtn; |
|
1346 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1347 |
if (!optionToolButton.icon.isNull() && (optionToolButton.state & State_Sunken) |
0 | 1348 |
&& (optionToolButton.state & State_Enabled)) { |
1349 |
||
1350 |
const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; |
|
1351 |
const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize), |
|
1352 |
QIcon::Normal, state)); |
|
1353 |
optionToolButton.icon = generatedIconPixmap(QIcon::Selected, pm, &optionToolButton); |
|
1354 |
} |
|
1355 |
||
1356 |
QCommonStyle::drawControl(element, &optionToolButton, painter, widget); |
|
1357 |
} |
|
1358 |
break; |
|
1359 |
#endif //QT_NO_TOOLBUTTON |
|
1360 |
#ifndef QT_NO_COMBOBOX |
|
1361 |
case CE_ComboBoxLabel: |
|
1362 |
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1363 |
QStyleOption optionComboBox = *comboBox; |
|
1364 |
optionComboBox.palette.setColor(QPalette::Active, QPalette::WindowText, |
|
1365 |
optionComboBox.palette.text().color() ); |
|
1366 |
optionComboBox.palette.setColor(QPalette::Inactive, QPalette::WindowText, |
|
1367 |
optionComboBox.palette.text().color() ); |
|
1368 |
QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1369 |
const int frameW = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); |
0 | 1370 |
|
1371 |
if (!comboBox->currentIcon.isNull()) { |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1372 |
const QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1373 |
const QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); |
0 | 1374 |
QRect iconRect(editRect); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1375 |
iconRect.setWidth(comboBox->iconSize.width() + frameW); |
0 | 1376 |
iconRect = alignedRect(comboBox->direction, |
1377 |
Qt::AlignLeft | Qt::AlignVCenter, |
|
1378 |
iconRect.size(), editRect); |
|
1379 |
if (comboBox->editable) |
|
1380 |
painter->fillRect(iconRect, optionComboBox.palette.brush(QPalette::Base)); |
|
1381 |
drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
|
1382 |
||
1383 |
if (comboBox->direction == Qt::RightToLeft) |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1384 |
editRect.setRight(editRect.right() - frameW - comboBox->iconSize.width()); |
0 | 1385 |
else |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1386 |
editRect.setLeft(comboBox->iconSize.width() + frameW); |
0 | 1387 |
} |
1388 |
if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1389 |
const Qt::TextElideMode elideMode = (comboBox->direction == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1390 |
const QString text = comboBox->fontMetrics.elidedText(comboBox->currentText, elideMode, editRect.width()); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1391 |
|
0 | 1392 |
QCommonStyle::drawItemText(painter, |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1393 |
editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), |
0 | 1394 |
visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1395 |
comboBox->palette, comboBox->state & State_Enabled, text); |
0 | 1396 |
} |
1397 |
} |
|
1398 |
break; |
|
1399 |
#endif //QT_NO_COMBOBOX |
|
1400 |
#ifndef QT_NO_ITEMVIEWS |
|
1401 |
case CE_ItemViewItem: |
|
1402 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
1403 |
QStyleOptionViewItemV4 voptAdj = *vopt; |
|
1404 |
painter->save(); |
|
1405 |
||
1406 |
painter->setClipRect(voptAdj.rect); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1407 |
const bool isSelected = (vopt->state & State_Selected); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1408 |
const bool hasFocus = (vopt->state & State_HasFocus); |
0 | 1409 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1410 |
bool isScrollBarVisible = false; |
0 | 1411 |
int scrollBarWidth = 0; |
1412 |
QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget); |
|
1413 |
for (int i = 0; i < scrollBars.size(); ++i) { |
|
1414 |
QScrollBar *scrollBar = scrollBars.at(i); |
|
1415 |
if (scrollBar && scrollBar->orientation() == Qt::Vertical) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1416 |
isScrollBarVisible = scrollBar->isVisible(); |
0 | 1417 |
scrollBarWidth = scrollBar->size().width(); |
1418 |
break; |
|
1419 |
} |
|
1420 |
} |
|
1421 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1422 |
int rightValue = widget ? widget->contentsRect().right() : voptAdj.rect.right(); |
0 | 1423 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1424 |
if (isScrollBarVisible) |
0 | 1425 |
rightValue -= scrollBarWidth; |
1426 |
||
1427 |
if (voptAdj.rect.right() > rightValue) |
|
1428 |
voptAdj.rect.setRight(rightValue); |
|
1429 |
||
1430 |
const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); |
|
1431 |
QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1432 |
const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
0 | 1433 |
|
1434 |
// draw themed background for table unless background brush has been defined. |
|
1435 |
if (vopt->backgroundBrush == Qt::NoBrush) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1436 |
if (itemView) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1437 |
drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
0 | 1438 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1439 |
} else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
0 | 1440 |
|
1441 |
// draw the icon |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1442 |
const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1443 |
const QIcon::State state = (voptAdj.state & State_Open) ? QIcon::On : QIcon::Off; |
0 | 1444 |
voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1445 |
||
1446 |
// Draw selection check mark. Show check mark only in multi selection modes. |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1447 |
if (itemView) { |
0 | 1448 |
const bool singleSelection = |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1449 |
(itemView->selectionMode() == QAbstractItemView::SingleSelection || |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1450 |
itemView->selectionMode() == QAbstractItemView::NoSelection)|| |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1451 |
(itemView->selectionModel()->selectedIndexes().count() < 2 ); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1452 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1453 |
const bool selectItemsOnly = (itemView->selectionBehavior() == QAbstractItemView::SelectItems); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1454 |
|
0 | 1455 |
const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1456 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1457 |
QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1458 |
if (selectionRect.isValid()) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1459 |
checkMarkOption.rect = selectionRect; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1460 |
// Draw selection mark. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1461 |
if (isSelected && !singleSelection && selectItemsOnly) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1462 |
proxy()->drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1463 |
// @todo: this should happen in the rect retrievel i.e. subElementRect() |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1464 |
if (textRect.right() > selectionRect.left()) |
0 | 1465 |
textRect.setRight(selectionRect.left()); |
1466 |
} else if (singleSelection && |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1467 |
voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1468 |
checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; |
0 | 1469 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1470 |
switch (vopt->checkState) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1471 |
case Qt::Unchecked: |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1472 |
checkMarkOption.state |= State_Off; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1473 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1474 |
case Qt::PartiallyChecked: |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1475 |
checkMarkOption.state |= State_NoChange; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1476 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1477 |
case Qt::Checked: |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1478 |
checkMarkOption.state |= State_On; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1479 |
break; |
0 | 1480 |
} |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1481 |
drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
0 | 1482 |
} |
1483 |
} |
|
1484 |
||
1485 |
// draw the text |
|
1486 |
if (!voptAdj.text.isEmpty()) { |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1487 |
if (isSelected || hasFocus ) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1488 |
painter->setPen(voptAdj.palette.highlightedText().color()); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1489 |
else |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1490 |
painter->setPen(voptAdj.palette.text().color()); |
0 | 1491 |
d->viewItemDrawText(painter, &voptAdj, textRect); |
1492 |
} |
|
1493 |
painter->restore(); |
|
1494 |
} |
|
1495 |
break; |
|
1496 |
#endif // QT_NO_ITEMVIEWS |
|
1497 |
#ifndef QT_NO_TABBAR |
|
1498 |
case CE_TabBarTabShape: |
|
1499 |
if (const QStyleOptionTabV3 *optionTab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
|
1500 |
QStyleOptionTabV3 optionTabAdj = *optionTab; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1501 |
const bool isSelected = optionTab->state & State_Selected; |
0 | 1502 |
const bool directionMirrored = (optionTab->direction == Qt::RightToLeft); |
1503 |
QS60StylePrivate::SkinElements skinElement; |
|
1504 |
switch (optionTab->shape) { |
|
1505 |
case QTabBar::TriangularEast: |
|
1506 |
case QTabBar::RoundedEast: |
|
1507 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabEastActive: |
|
1508 |
QS60StylePrivate::SE_TabBarTabEastInactive; |
|
1509 |
break; |
|
1510 |
case QTabBar::TriangularSouth: |
|
1511 |
case QTabBar::RoundedSouth: |
|
1512 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabSouthActive: |
|
1513 |
QS60StylePrivate::SE_TabBarTabSouthInactive; |
|
1514 |
break; |
|
1515 |
case QTabBar::TriangularWest: |
|
1516 |
case QTabBar::RoundedWest: |
|
1517 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabWestActive: |
|
1518 |
QS60StylePrivate::SE_TabBarTabWestInactive; |
|
1519 |
break; |
|
1520 |
case QTabBar::TriangularNorth: |
|
1521 |
case QTabBar::RoundedNorth: |
|
1522 |
default: |
|
1523 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabNorthActive: |
|
1524 |
QS60StylePrivate::SE_TabBarTabNorthInactive; |
|
1525 |
break; |
|
1526 |
} |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1527 |
if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1528 |
skinElement == QS60StylePrivate::SE_TabBarTabNorthInactive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1529 |
skinElement == QS60StylePrivate::SE_TabBarTabSouthInactive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1530 |
skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1531 |
skinElement == QS60StylePrivate::SE_TabBarTabEastActive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1532 |
skinElement == QS60StylePrivate::SE_TabBarTabNorthActive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1533 |
skinElement == QS60StylePrivate::SE_TabBarTabSouthActive || |
0 | 1534 |
skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { |
1535 |
const int borderThickness = |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1536 |
QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
0 | 1537 |
const int tabOverlap = |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1538 |
QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1539 |
const bool usesScrollButtons = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1540 |
(widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1541 |
const int roomForScrollButton = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1542 |
usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; |
0 | 1543 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1544 |
// adjust for overlapping tabs and scrollbuttons, if necessary |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1545 |
if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1546 |
skinElement == QS60StylePrivate::SE_TabBarTabEastActive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1547 |
skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1548 |
skinElement == QS60StylePrivate::SE_TabBarTabWestActive){ |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1549 |
if (optionTabAdj.position == QStyleOptionTabV3::Beginning) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1550 |
optionTabAdj.rect.adjust(0, roomForScrollButton, 0, tabOverlap); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1551 |
else if (optionTabAdj.position == QStyleOptionTabV3::End) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1552 |
optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1553 |
else |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1554 |
optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); |
0 | 1555 |
} else { |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1556 |
if (directionMirrored) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1557 |
if (optionTabAdj.position == QStyleOptionTabV3::Beginning) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1558 |
optionTabAdj.rect.adjust(-tabOverlap, 0, -roomForScrollButton, 0); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1559 |
else |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1560 |
optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1561 |
} else { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1562 |
if (optionTabAdj.position == QStyleOptionTabV3::Beginning) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1563 |
optionTabAdj.rect.adjust(roomForScrollButton, 0, tabOverlap, 0); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1564 |
else |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1565 |
optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); |
0 | 1566 |
} |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1567 |
} |
0 | 1568 |
} |
1569 |
QS60StylePrivate::drawSkinElement(skinElement, painter, optionTabAdj.rect, flags); |
|
1570 |
} |
|
1571 |
break; |
|
1572 |
case CE_TabBarTabLabel: |
|
1573 |
if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
|
1574 |
QStyleOptionTabV3 optionTab = *tab; |
|
1575 |
QRect tr = optionTab.rect; |
|
1576 |
const bool directionMirrored = (optionTab.direction == Qt::RightToLeft); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1577 |
const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
0 | 1578 |
const int tabOverlap = |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1579 |
QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1580 |
const bool usesScrollButtons = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1581 |
(widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1582 |
const int roomForScrollButton = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1583 |
usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; |
0 | 1584 |
|
1585 |
switch (tab->shape) { |
|
1586 |
case QTabBar::TriangularWest: |
|
1587 |
case QTabBar::RoundedWest: |
|
1588 |
case QTabBar::TriangularEast: |
|
1589 |
case QTabBar::RoundedEast: |
|
1590 |
tr.adjust(0, 0, 0, tabOverlap); |
|
1591 |
break; |
|
1592 |
case QTabBar::TriangularSouth: |
|
1593 |
case QTabBar::RoundedSouth: |
|
1594 |
case QTabBar::TriangularNorth: |
|
1595 |
case QTabBar::RoundedNorth: |
|
1596 |
default: |
|
1597 |
if (directionMirrored) |
|
1598 |
tr.adjust(-tabOverlap, 0, 0, 0); |
|
1599 |
else |
|
1600 |
tr.adjust(0, 0, tabOverlap, 0); |
|
1601 |
break; |
|
1602 |
} |
|
1603 |
painter->save(); |
|
1604 |
QFont f = painter->font(); |
|
1605 |
f.setPointSizeF(f.pointSizeF() * KTabFontMul); |
|
1606 |
painter->setFont(f); |
|
1607 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1608 |
const bool selected = optionTab.state & State_Selected; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1609 |
if (selected) |
0 | 1610 |
optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1611 |
optionTab.palette.highlightedText().color()); |
0 | 1612 |
|
1613 |
const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
|
1614 |
|| optionTab.shape == QTabBar::RoundedWest |
|
1615 |
|| optionTab.shape == QTabBar::TriangularEast |
|
1616 |
|| optionTab.shape == QTabBar::TriangularWest; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1617 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1618 |
//make room for scrollbuttons |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1619 |
if (!verticalTabs) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1620 |
if ((tab->position == QStyleOptionTabV3::Beginning && !directionMirrored)) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1621 |
tr.adjust(roomForScrollButton, 0, 0, 0); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1622 |
else if ((tab->position == QStyleOptionTabV3::Beginning && directionMirrored)) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1623 |
tr.adjust(0, 0, -roomForScrollButton, 0); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1624 |
} else { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1625 |
if (tab->position == QStyleOptionTabV3::Beginning) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1626 |
tr.adjust(0, roomForScrollButton, 0, 0); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1627 |
} |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1628 |
|
0 | 1629 |
if (verticalTabs) { |
1630 |
painter->save(); |
|
1631 |
int newX, newY, newRotation; |
|
1632 |
if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { |
|
1633 |
newX = tr.width(); |
|
1634 |
newY = tr.y(); |
|
1635 |
newRotation = 90; |
|
1636 |
} else { |
|
1637 |
newX = 0; |
|
1638 |
newY = tr.y() + tr.height(); |
|
1639 |
newRotation = -90; |
|
1640 |
} |
|
1641 |
tr.setRect(0, 0, tr.height(), tr.width()); |
|
1642 |
QTransform m; |
|
1643 |
m.translate(newX, newY); |
|
1644 |
m.rotate(newRotation); |
|
1645 |
painter->setTransform(m, true); |
|
1646 |
} |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1647 |
tr.adjust(0, 0, pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget), |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1648 |
pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); |
0 | 1649 |
|
1650 |
if (selected) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1651 |
tr.setBottom(tr.bottom() - pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1652 |
tr.setRight(tr.right() - pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget)); |
0 | 1653 |
} |
1654 |
||
1655 |
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; |
|
1656 |
if (!styleHint(SH_UnderlineShortcut, &optionTab, widget)) |
|
1657 |
alignment |= Qt::TextHideMnemonic; |
|
1658 |
if (!optionTab.icon.isNull()) { |
|
1659 |
QSize iconSize = optionTab.iconSize; |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1660 |
if (!iconSize.isValid()) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1661 |
const int iconExtent = pixelMetric(PM_TabBarIconSize); |
0 | 1662 |
iconSize = QSize(iconExtent, iconExtent); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
1663 |
} |
0 | 1664 |
QPixmap tabIcon = optionTab.icon.pixmap(iconSize, |
1665 |
(optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
|
1666 |
if (tab->text.isEmpty()) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1667 |
painter->drawPixmap(tr.center().x() - (tabIcon.height() >> 1), |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1668 |
tr.center().y() - (tabIcon.height() >> 1), |
0 | 1669 |
tabIcon); |
1670 |
else |
|
1671 |
painter->drawPixmap(tr.left() + tabOverlap, |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1672 |
tr.center().y() - (tabIcon.height() >> 1), |
0 | 1673 |
tabIcon); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1674 |
tr.setLeft(tr.left() + iconSize.width() + 4); //todo: magic four |
0 | 1675 |
} |
1676 |
||
1677 |
QCommonStyle::drawItemText(painter, tr, alignment, optionTab.palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
|
1678 |
if (verticalTabs) |
|
1679 |
painter->restore(); |
|
1680 |
||
1681 |
painter->restore(); |
|
1682 |
} |
|
1683 |
break; |
|
1684 |
#endif // QT_NO_TABBAR |
|
1685 |
#ifndef QT_NO_PROGRESSBAR |
|
1686 |
case CE_ProgressBarContents: |
|
1687 |
if (const QStyleOptionProgressBarV2 *optionProgressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1688 |
QRect progressRect = optionProgressBar->rect; |
|
1689 |
||
1690 |
if (optionProgressBar->minimum == optionProgressBar->maximum && optionProgressBar->minimum == 0) { |
|
1691 |
// busy indicator |
|
1692 |
const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ? |
|
1693 |
QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1694 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1695 |
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWaitAnim, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1696 |
painter, progressRect, flags | orientationFlag | QS60StylePrivate::SF_Animation ); |
0 | 1697 |
} else { |
1698 |
const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 |
|
1699 |
: (qreal)optionProgressBar->progress / optionProgressBar->maximum; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1700 |
const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
0 | 1701 |
if (optionProgressBar->orientation == Qt::Horizontal) { |
1702 |
progressRect.setWidth(int(progressRect.width() * progressFactor)); |
|
1703 |
if(optionProgressBar->direction == Qt::RightToLeft) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1704 |
progressRect.translate(optionProgressBar->rect.width() - progressRect.width(), 0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1705 |
progressRect.adjust(frameWidth, 0, -frameWidth, 0); |
0 | 1706 |
} else { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1707 |
progressRect.adjust(0, frameWidth, 0, -frameWidth); |
0 | 1708 |
progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); |
1709 |
} |
|
1710 |
||
1711 |
const QS60StylePrivate::SkinElements skinElement = optionProgressBar->orientation == Qt::Horizontal ? |
|
1712 |
QS60StylePrivate::SE_ProgressBarIndicatorHorizontal : QS60StylePrivate::SE_ProgressBarIndicatorVertical; |
|
1713 |
QS60StylePrivate::drawSkinElement(skinElement, painter, progressRect, flags); |
|
1714 |
} |
|
1715 |
} |
|
1716 |
break; |
|
1717 |
case CE_ProgressBarGroove: |
|
1718 |
if (const QStyleOptionProgressBarV2 *optionProgressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1719 |
const QS60StylePrivate::SkinElements skinElement = optionProgressBar->orientation == Qt::Horizontal ? |
|
1720 |
QS60StylePrivate::SE_ProgressBarGrooveHorizontal : QS60StylePrivate::SE_ProgressBarGrooveVertical; |
|
1721 |
QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
|
1722 |
} |
|
1723 |
break; |
|
1724 |
case CE_ProgressBarLabel: |
|
1725 |
if (const QStyleOptionProgressBarV2 *progressbar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1726 |
QStyleOptionProgressBarV2 optionProgressBar = *progressbar; |
|
1727 |
QCommonStyle::drawItemText(painter, progressbar->rect, flags | Qt::AlignCenter | Qt::TextSingleLine, optionProgressBar.palette, |
|
1728 |
progressbar->state & State_Enabled, progressbar->text, QPalette::WindowText); |
|
1729 |
} |
|
1730 |
break; |
|
1731 |
#endif // QT_NO_PROGRESSBAR |
|
1732 |
#ifndef QT_NO_MENU |
|
1733 |
case CE_MenuItem: |
|
1734 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
1735 |
QStyleOptionMenuItem optionMenuItem = *menuItem; |
|
1736 |
||
1737 |
bool drawSubMenuIndicator = false; |
|
1738 |
switch(menuItem->menuItemType) { |
|
1739 |
case QStyleOptionMenuItem::Scroller: |
|
1740 |
case QStyleOptionMenuItem::Separator: |
|
1741 |
return; // no separators or scrollers in S60 menus |
|
1742 |
case QStyleOptionMenuItem::SubMenu: |
|
1743 |
drawSubMenuIndicator = true; |
|
1744 |
break; |
|
1745 |
default: |
|
1746 |
break; |
|
1747 |
} |
|
1748 |
const bool enabled = optionMenuItem.state & State_Enabled; |
|
1749 |
const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable; |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1750 |
bool ignoreCheckMark = false; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1751 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1752 |
#ifndef QT_NO_COMBOBOX |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1753 |
if (qobject_cast<const QComboBox*>(widget)) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1754 |
ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1755 |
#endif |
0 | 1756 |
|
1757 |
uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
|
1758 |
| Qt::TextSingleLine | Qt::AlignVCenter; |
|
1759 |
if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
|
1760 |
text_flags |= Qt::TextHideMnemonic; |
|
1761 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1762 |
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1763 |
QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1764 |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1765 |
QStyleOptionMenuItem optionCheckBox; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1766 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1767 |
//Regardless of checkbox visibility, make room for it, this mirrors native implementation, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1768 |
//where text and icon placement is static regardless of content of menu item. |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1769 |
optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1770 |
optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1771 |
optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1772 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1773 |
const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1774 |
//The vertical spacing is doubled; it needs one spacing to separate checkbox from |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1775 |
//highlight and then it needs one to separate it whatever is shown after it (text/icon/both). |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1776 |
const int moveByX = optionCheckBox.rect.width() + 2 * vSpacing; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1777 |
optionCheckBox.rect.moveCenter(QPoint( |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1778 |
optionCheckBox.rect.center().x() + moveByX >> 1, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1779 |
menuItem->rect.center().y())); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1780 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1781 |
if (optionMenuItem.direction != Qt::LeftToRight) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1782 |
optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1783 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1784 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1785 |
const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1786 |
if (selected) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1787 |
const int spacing = ignoreCheckMark ? (vSpacing + QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth)) : 0; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1788 |
const int start = optionMenuItem.rect.left() + spacing; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1789 |
const int end = optionMenuItem.rect.right() - spacing; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1790 |
//-1 adjustment to avoid highlight being on top of possible separator item |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1791 |
const QRect highlightRect = QRect( |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1792 |
QPoint(start, option->rect.top()), |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1793 |
QPoint(end, option->rect.bottom() - 1)); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1794 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1795 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1796 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1797 |
if (checkable && !ignoreCheckMark) |
0 | 1798 |
drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1799 |
|
0 | 1800 |
//draw icon and/or checkState |
1801 |
QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
|
1802 |
enabled ? QIcon::Normal : QIcon::Disabled); |
|
1803 |
const bool itemWithIcon = !pix.isNull(); |
|
1804 |
if (itemWithIcon) { |
|
1805 |
drawItemPixmap(painter, iconRect, text_flags, pix); |
|
1806 |
if (optionMenuItem.direction == Qt::LeftToRight) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1807 |
textRect.translate(vSpacing, 0); |
0 | 1808 |
else |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1809 |
textRect.translate(-vSpacing, 0); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1810 |
textRect.setWidth(textRect.width() - vSpacing); |
0 | 1811 |
} |
1812 |
||
1813 |
//draw indicators |
|
1814 |
if (drawSubMenuIndicator) { |
|
1815 |
QStyleOptionMenuItem arrowOptions; |
|
1816 |
arrowOptions.QStyleOption::operator=(*menuItem); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1817 |
const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget) >> 1) + |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1818 |
pixelMetric(PM_LayoutVerticalSpacing, option, widget); |
0 | 1819 |
if (optionMenuItem.direction == Qt::LeftToRight) |
1820 |
arrowOptions.rect.setLeft(textRect.right()); |
|
1821 |
arrowOptions.rect.setWidth(indicatorWidth); |
|
1822 |
//by default sub menu indicator in S60 points to east,so here icon |
|
1823 |
// direction is set to north (and south when in RightToLeft) |
|
1824 |
const QS60StylePrivate::SkinElementFlag arrowDirection = (arrowOptions.direction == Qt::LeftToRight) ? |
|
1825 |
QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointSouth; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1826 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1827 |
painter->setPen(option->palette.windowText().color()); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1828 |
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnIndiSubmenu, painter, arrowOptions.rect, |
0 | 1829 |
(flags | QS60StylePrivate::SF_ColorSkinned | arrowDirection)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1830 |
painter->restore(); |
0 | 1831 |
} |
1832 |
||
1833 |
//draw text |
|
1834 |
if (!enabled){ |
|
1835 |
//In s60, if something becomes disabled, it is removed from menu, so no native look-alike available. |
|
1836 |
optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor( |
|
1837 |
optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); |
|
1838 |
painter->save(); |
|
1839 |
painter->setOpacity(0.5); |
|
1840 |
} |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1841 |
if (selected) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1842 |
optionMenuItem.palette.setColor( |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1843 |
QPalette::Active, QPalette::Text, optionMenuItem.palette.highlightedText().color()); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1844 |
|
0 | 1845 |
QCommonStyle::drawItemText(painter, textRect, text_flags, |
1846 |
optionMenuItem.palette, enabled, |
|
1847 |
optionMenuItem.text, QPalette::Text); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1848 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1849 |
//In Sym^3, native menu items have "lines" between them |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1850 |
if (QS60StylePrivate::isSingleClickUi()) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1851 |
const QColor lineColorAlpha = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 15, 0); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1852 |
const int spacing = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1853 |
//native platform sets each color byte to same value for "line 16" which just defines alpha for |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1854 |
//menuitem lines; lets use first byte "red". |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1855 |
QColor lineColor = optionMenuItem.palette.text().color(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1856 |
if (lineColorAlpha.isValid()) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1857 |
lineColor.setAlpha(lineColorAlpha.red()); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1858 |
painter->save(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1859 |
painter->setPen(lineColor); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1860 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1861 |
const int lineStartX = optionMenuItem.rect.left() + (QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - 2) + spacing; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1862 |
const int lineEndX = optionMenuItem.rect.right() - (QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - 2) - spacing; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1863 |
painter->drawLine(QPoint(lineStartX, optionMenuItem.rect.bottom()), QPoint(lineEndX, optionMenuItem.rect.bottom())); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1864 |
painter->restore(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
1865 |
} |
0 | 1866 |
if (!enabled) |
1867 |
painter->restore(); |
|
1868 |
} |
|
1869 |
break; |
|
1870 |
case CE_MenuEmptyArea: |
|
1871 |
break; |
|
1872 |
#endif //QT_NO_MENU |
|
1873 |
||
1874 |
#ifndef QT_NO_MENUBAR |
|
1875 |
case CE_MenuBarEmptyArea: |
|
1876 |
break; |
|
1877 |
#endif //QT_NO_MENUBAR |
|
1878 |
||
1879 |
case CE_HeaderSection: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1880 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
0 | 1881 |
painter->save(); |
1882 |
QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
|
1883 |
const int penWidth = (header->orientation == Qt::Horizontal) ? |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1884 |
linePen.width() + QS60StylePrivate::pixelMetric(PM_BoldLineWidth) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1885 |
: linePen.width() + QS60StylePrivate::pixelMetric(PM_ThinLineWidth); |
0 | 1886 |
linePen.setWidth(penWidth); |
1887 |
painter->setPen(linePen); |
|
1888 |
if (header->orientation == Qt::Horizontal){ |
|
1889 |
painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
|
1890 |
} else { |
|
1891 |
if ( header->direction == Qt::LeftToRight ) { |
|
1892 |
painter->drawLine(header->rect.topRight(), header->rect.bottomRight()); |
|
1893 |
} else { |
|
1894 |
painter->drawLine(header->rect.topLeft(), header->rect.bottomLeft()); |
|
1895 |
} |
|
1896 |
} |
|
1897 |
painter->restore(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1898 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1899 |
//Draw corner button as normal pushButton. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1900 |
if (qobject_cast<const QAbstractButton *>(widget)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1901 |
//Make cornerButton slightly smaller so that it is not on top of table border graphic. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1902 |
QStyleOptionHeader subopt = *header; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1903 |
const int borderTweak = |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1904 |
QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1905 |
if (subopt.direction == Qt::LeftToRight) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1906 |
subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1907 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1908 |
subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1909 |
drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1910 |
} else if ((header->palette.brush(QPalette::Button) != Qt::transparent)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1911 |
//Draw non-themed background. Background for theme is drawn in CE_ShapedFrame |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1912 |
//to get continuous theme graphic across all the header cells. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1913 |
qDrawShadePanel(painter, header->rect, header->palette, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1914 |
header->state & (State_Sunken | State_On), penWidth, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1915 |
&header->palette.brush(QPalette::Button)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1916 |
} |
0 | 1917 |
} |
1918 |
break; |
|
1919 |
case CE_HeaderEmptyArea: // no need to draw this |
|
1920 |
break; |
|
1921 |
case CE_Header: |
|
1922 |
if ( const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
1923 |
drawControl(CE_HeaderSection, header, painter, widget); |
|
1924 |
QStyleOptionHeader subopt = *header; |
|
1925 |
subopt.rect = subElementRect(SE_HeaderLabel, header, widget); |
|
1926 |
if (subopt.rect.isValid()) |
|
1927 |
drawControl(CE_HeaderLabel, &subopt, painter, widget); |
|
1928 |
if (header->sortIndicator != QStyleOptionHeader::None) { |
|
1929 |
subopt.rect = subElementRect(SE_HeaderArrow, option, widget); |
|
1930 |
drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget); |
|
1931 |
} |
|
1932 |
} |
|
1933 |
break; |
|
1934 |
#ifndef QT_NO_TOOLBAR |
|
1935 |
case CE_ToolBar: |
|
1936 |
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { |
|
1937 |
const QToolBar *tbWidget = qobject_cast<const QToolBar *>(widget); |
|
1938 |
||
1939 |
//toolbar within a toolbar, skip |
|
1940 |
if (!tbWidget || (widget && qobject_cast<QToolBar *>(widget->parentWidget()))) |
|
1941 |
break; |
|
1942 |
||
1943 |
// Normally in S60 5.0+ there is no background for toolbar, but in some cases with versatile QToolBar, |
|
1944 |
// it looks a bit strange. So, lets fillRect with Button. |
|
1945 |
if (!QS60StylePrivate::isToolBarBackground()) { |
|
1946 |
QList<QAction *> actions = tbWidget->actions(); |
|
1947 |
bool justToolButtonsInToolBar = true; |
|
1948 |
for (int i = 0; i < actions.size(); ++i) { |
|
1949 |
QWidget *childWidget = tbWidget->widgetForAction(actions.at(i)); |
|
1950 |
const QToolButton *button = qobject_cast<const QToolButton *>(childWidget); |
|
1951 |
if (!button){ |
|
1952 |
justToolButtonsInToolBar = false; |
|
1953 |
} |
|
1954 |
} |
|
1955 |
||
1956 |
// Draw frame background |
|
1957 |
// for vertical toolbars with text only and |
|
1958 |
// for toolbars with extension buttons and |
|
1959 |
// for toolbars with widgets in them. |
|
1960 |
if (!justToolButtonsInToolBar || |
|
1961 |
(tbWidget && |
|
1962 |
(tbWidget->orientation() == Qt::Vertical) && |
|
1963 |
(tbWidget->toolButtonStyle() == Qt::ToolButtonTextOnly))) { |
|
1964 |
painter->save(); |
|
1965 |
if (widget) |
|
1966 |
painter->setBrush(widget->palette().button()); |
|
1967 |
painter->setOpacity(0.3); |
|
1968 |
painter->fillRect(toolBar->rect, painter->brush()); |
|
1969 |
painter->restore(); |
|
1970 |
} |
|
1971 |
} else { |
|
1972 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBar, painter, toolBar->rect, flags); |
|
1973 |
} |
|
1974 |
} |
|
1975 |
break; |
|
1976 |
#endif //QT_NO_TOOLBAR |
|
1977 |
case CE_ShapedFrame: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1978 |
if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1979 |
const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1980 |
if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base(), widget)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1981 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1982 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1983 |
QCommonStyle::drawControl(element, option, painter, widget); |
0 | 1984 |
} else if (qobject_cast<const QTableView *>(widget)) { |
1985 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
|
1986 |
} else if (const QHeaderView *header = qobject_cast<const QHeaderView *>(widget)) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1987 |
//QS60style draws header background here instead of in each headersection, to get |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1988 |
//continuous graphic from section to section. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1989 |
QS60StylePrivate::SkinElementFlags adjustableFlags = flags; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1990 |
QRect headerRect = option->rect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1991 |
if (header->orientation() != Qt::Horizontal) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1992 |
//todo: update to horizontal table graphic |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1993 |
adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1994 |
} else { |
0 | 1995 |
const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1996 |
if (option->direction == Qt::LeftToRight) |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1997 |
headerRect.adjust(-2 * frameWidth, 0, 0, 0); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1998 |
else |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1999 |
headerRect.adjust(0, 0, 2 * frameWidth, 0); |
0 | 2000 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2001 |
if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2002 |
QS60StylePrivate::drawSkinElement( |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2003 |
QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2004 |
|
0 | 2005 |
} else if (qobject_cast<const QFrame *>(widget)) { |
2006 |
QCommonStyle::drawControl(element, option, painter, widget); |
|
2007 |
} |
|
2008 |
break; |
|
2009 |
case CE_MenuScroller: |
|
2010 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2011 |
case CE_FocusFrame: { |
0 | 2012 |
#ifdef QT_KEYPAD_NAVIGATION |
2013 |
bool editFocus = false; |
|
2014 |
if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { |
|
2015 |
if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) |
|
2016 |
editFocus = true; |
|
2017 |
} |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2018 |
const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve. |
0 | 2019 |
#else |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2020 |
const qreal opacity = 0.85; |
0 | 2021 |
#endif |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2022 |
// We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2023 |
// Otherwise, we would overlay adjacent widgets. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2024 |
const int frameHeightReduction = |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2025 |
qMin(0, pixelMetric(PM_LayoutVerticalSpacing) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2026 |
- pixelMetric(PM_FocusFrameVMargin)); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2027 |
const int frameWidthReduction = |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2028 |
qMin(0, pixelMetric(PM_LayoutHorizontalSpacing) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2029 |
- pixelMetric(PM_FocusFrameHMargin)); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2030 |
const int rounding = |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2031 |
qMin(pixelMetric(PM_FocusFrameVMargin), |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2032 |
pixelMetric(PM_LayoutVerticalSpacing)); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2033 |
const QRect frameRect = |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2034 |
option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2035 |
frameWidthReduction, frameHeightReduction); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2036 |
QPainterPath framePath; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2037 |
framePath.addRoundedRect(frameRect, rounding, rounding); |
0 | 2038 |
|
2039 |
painter->save(); |
|
2040 |
painter->setRenderHint(QPainter::Antialiasing); |
|
2041 |
painter->setOpacity(opacity); |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2042 |
painter->fillPath(framePath, option->palette.color(QPalette::Text)); |
0 | 2043 |
painter->restore(); |
2044 |
} |
|
2045 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2046 |
case CE_Splitter: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2047 |
if (option->state & State_Sunken && option->state & State_Enabled) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2048 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2049 |
painter->setOpacity(0.5); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2050 |
painter->setBrush(QS60StylePrivate::themePalette()->light()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2051 |
painter->setRenderHint(QPainter::Antialiasing); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2052 |
const qreal roundRectRadius = 4 * goldenRatio; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2053 |
painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2054 |
painter->restore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2055 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2056 |
break; |
0 | 2057 |
default: |
2058 |
QCommonStyle::drawControl(element, option, painter, widget); |
|
2059 |
} |
|
2060 |
} |
|
2061 |
||
2062 |
/*! |
|
2063 |
\reimp |
|
2064 |
*/ |
|
2065 |
void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
|
2066 |
{ |
|
2067 |
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2068 |
bool commonStyleDraws = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2069 |
|
0 | 2070 |
switch (element) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2071 |
case PE_FrameFocusRect: { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2072 |
//Draw themed highlight to radiobuttons and checkboxes. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2073 |
//For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2074 |
if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2075 |
if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2076 |
(qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2077 |
QS60StylePrivate::drawSkinElement( |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2078 |
QS60StylePrivate::isWidgetPressed(widget) ? |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2079 |
QS60StylePrivate::SE_ListItemPressed : |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2080 |
QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2081 |
} else { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2082 |
commonStyleDraws = true; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2083 |
} |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2084 |
} |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2085 |
break; |
0 | 2086 |
#ifndef QT_NO_LINEEDIT |
2087 |
case PE_PanelLineEdit: |
|
2088 |
if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
2089 |
#ifndef QT_NO_COMBOBOX |
|
2090 |
if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
|
2091 |
break; |
|
2092 |
#endif |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2093 |
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2094 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2095 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2096 |
commonStyleDraws = true; |
0 | 2097 |
} |
2098 |
break; |
|
2099 |
#endif // QT_NO_LINEEDIT |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2100 |
case PE_IndicatorCheckBox: { |
0 | 2101 |
// Draw checkbox indicator as color skinned graphics. |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2102 |
const QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? |
0 | 2103 |
QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2104 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2105 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2106 |
const QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2107 |
const QColor windowTextColor = option->palette.windowText().color(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2108 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2109 |
if (themeColor != windowTextColor) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2110 |
painter->setPen(windowTextColor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2111 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2112 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned ); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2113 |
painter->restore(); |
0 | 2114 |
} |
2115 |
break; |
|
2116 |
case PE_IndicatorViewItemCheck: |
|
2117 |
#ifndef QT_NO_ITEMVIEWS |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2118 |
if (const QAbstractItemView *itemView = (qobject_cast<const QAbstractItemView *>(widget))) { |
0 | 2119 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2120 |
const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2121 |
const bool singleSelection = itemView->selectionMode() == |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2122 |
QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection; |
0 | 2123 |
// draw either checkbox at the beginning |
2124 |
if (checkBoxVisible && singleSelection) { |
|
2125 |
drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
|
2126 |
// ... or normal "tick" selection at the end. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2127 |
} else if (option->state & State_Selected) { |
0 | 2128 |
QRect tickRect = option->rect; |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2129 |
const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); |
0 | 2130 |
// adjust tickmark rect to exclude frame border |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2131 |
tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
0 | 2132 |
QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2133 |
QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
|
2134 |
(flags | QS60StylePrivate::SF_ColorSkinned)); |
|
2135 |
} |
|
2136 |
} |
|
2137 |
} |
|
2138 |
#endif //QT_NO_ITEMVIEWS |
|
2139 |
break; |
|
2140 |
case PE_IndicatorRadioButton: { |
|
2141 |
QRect buttonRect = option->rect; |
|
2142 |
//there is empty (a. 33%) space in svg graphics for radiobutton |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2143 |
const qreal reduceWidth = (qreal)buttonRect.width() / 3.0; |
0 | 2144 |
const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0; |
2145 |
// Try to occupy the full area |
|
2146 |
const qreal scaler = 1 + (reduceWidth/rectWidth); |
|
2147 |
buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
|
2148 |
buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
|
2149 |
// move the rect up for half of the new height-gain |
|
2150 |
const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2151 |
buttonRect.adjust(0, -newY, -1, -newY); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2152 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2153 |
painter->save(); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2154 |
const QColor themeColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2155 |
const QColor buttonTextColor = option->palette.buttonText().color(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2156 |
if (themeColor != buttonTextColor) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2157 |
painter->setPen(buttonTextColor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2158 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2159 |
painter->setPen(themeColor); |
0 | 2160 |
|
2161 |
// Draw radiobutton indicator as color skinned graphics. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2162 |
QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? |
0 | 2163 |
QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; |
2164 |
QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, |
|
2165 |
(flags | QS60StylePrivate::SF_ColorSkinned)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2166 |
painter->restore(); |
0 | 2167 |
} |
2168 |
break; |
|
2169 |
case PE_PanelButtonCommand: |
|
2170 |
case PE_PanelButtonTool: |
|
2171 |
case PE_PanelButtonBevel: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2172 |
case PE_FrameButtonBevel: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2173 |
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) { |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2174 |
const bool isPressed = (option->state & State_Sunken) || (option->state & State_On); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2175 |
QS60StylePrivate::SkinElements skinElement; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2176 |
if (element == PE_PanelButtonTool) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2177 |
skinElement = isPressed ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2178 |
else |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2179 |
skinElement = isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2180 |
QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2181 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2182 |
commonStyleDraws = true; |
0 | 2183 |
} |
2184 |
break; |
|
2185 |
#ifndef QT_NO_TOOLBUTTON |
|
2186 |
case PE_IndicatorArrowDown: |
|
2187 |
case PE_IndicatorArrowLeft: |
|
2188 |
case PE_IndicatorArrowRight: |
|
2189 |
case PE_IndicatorArrowUp: { |
|
2190 |
QS60StyleEnums::SkinParts skinPart; |
|
2191 |
if (element==PE_IndicatorArrowDown) |
|
2192 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
|
2193 |
else if (element==PE_IndicatorArrowLeft) |
|
2194 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowLeft; |
|
2195 |
else if (element==PE_IndicatorArrowRight) |
|
2196 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowRight; |
|
2197 |
else if (element==PE_IndicatorArrowUp) |
|
2198 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowUp; |
|
2199 |
||
2200 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
|
2201 |
} |
|
2202 |
break; |
|
2203 |
#endif //QT_NO_TOOLBUTTON |
|
2204 |
#ifndef QT_NO_SPINBOX |
|
2205 |
case PE_IndicatorSpinDown: |
|
2206 |
case PE_IndicatorSpinUp: |
|
2207 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2208 |
if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2209 |
QStyleOptionSpinBox optionSpinBox = *spinBox; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2210 |
const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2211 |
QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2212 |
QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2213 |
const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2214 |
optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2215 |
QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2216 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2217 |
commonStyleDraws = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2218 |
} |
0 | 2219 |
} |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2220 |
#endif //QT_NO_SPINBOX |
0 | 2221 |
#ifndef QT_NO_COMBOBOX |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2222 |
if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2223 |
if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2224 |
// We want to draw down arrow here for comboboxes as well. |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2225 |
QStyleOptionFrame optionsComboBox = *cmb; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2226 |
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2227 |
const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2228 |
optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2229 |
QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2230 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2231 |
commonStyleDraws = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2232 |
} |
0 | 2233 |
} |
2234 |
#endif //QT_NO_COMBOBOX |
|
2235 |
break; |
|
2236 |
case PE_IndicatorSpinMinus: |
|
2237 |
case PE_IndicatorSpinPlus: |
|
2238 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
2239 |
QStyleOptionSpinBox optionSpinBox = *spinBox; |
|
2240 |
QCommonStyle::drawPrimitive(element, &optionSpinBox, painter, widget); |
|
2241 |
} |
|
2242 |
#ifndef QT_NO_COMBOBOX |
|
2243 |
else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
2244 |
// We want to draw down arrow here for comboboxes as well. |
|
2245 |
QStyleOptionFrame comboBox = *cmb; |
|
2246 |
const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2247 |
comboBox.rect.adjust(0, frameWidth, 0, -frameWidth); |
0 | 2248 |
QCommonStyle::drawPrimitive(element, &comboBox, painter, widget); |
2249 |
} |
|
2250 |
#endif //QT_NO_COMBOBOX |
|
2251 |
break; |
|
2252 |
case PE_Widget: |
|
2253 |
if (QS60StylePrivate::drawsOwnThemeBackground(widget) |
|
2254 |
#ifndef QT_NO_COMBOBOX |
|
2255 |
|| qobject_cast<const QComboBoxListView *>(widget) |
|
2256 |
#endif //QT_NO_COMBOBOX |
|
2257 |
#ifndef QT_NO_MENU |
|
2258 |
|| qobject_cast<const QMenu *> (widget) |
|
2259 |
#endif //QT_NO_MENU |
|
2260 |
) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2261 |
//Need extra check since dialogs have their own theme background |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2262 |
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2263 |
option->palette.window().texture().cacheKey() == |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2264 |
QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
2265 |
//todo: for combobox listviews, the background should include area for menu scrollers, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
2266 |
//but this produces drawing issues as we need to turn clipping off. |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2267 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2268 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2269 |
commonStyleDraws = true; |
0 | 2270 |
} |
2271 |
break; |
|
2272 |
case PE_FrameWindow: |
|
2273 |
case PE_FrameTabWidget: |
|
2274 |
if (const QStyleOptionTabWidgetFrame *tabFrame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { |
|
2275 |
QStyleOptionTabWidgetFrame optionTabFrame = *tabFrame; |
|
2276 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PanelBackground, painter, optionTabFrame.rect, flags); |
|
2277 |
} |
|
2278 |
break; |
|
2279 |
case PE_IndicatorHeaderArrow: |
|
2280 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
2281 |
if (header->sortIndicator & QStyleOptionHeader::SortUp) |
|
2282 |
drawPrimitive(PE_IndicatorArrowUp, header, painter, widget); |
|
2283 |
else if (header->sortIndicator & QStyleOptionHeader::SortDown) |
|
2284 |
drawPrimitive(PE_IndicatorArrowDown, header, painter, widget); |
|
2285 |
} // QStyleOptionHeader::None is not drawn => not needed |
|
2286 |
break; |
|
2287 |
#ifndef QT_NO_GROUPBOX |
|
2288 |
case PE_FrameGroupBox: |
|
2289 |
if (const QStyleOptionFrameV2 *frame = qstyleoption_cast<const QStyleOptionFrameV2 *>(option)) |
|
2290 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_SettingsList, painter, frame->rect, flags); |
|
2291 |
break; |
|
2292 |
#endif //QT_NO_GROUPBOX |
|
2293 |
||
2294 |
// Qt3 primitives are not supported |
|
2295 |
case PE_Q3CheckListController: |
|
2296 |
case PE_Q3CheckListExclusiveIndicator: |
|
2297 |
case PE_Q3CheckListIndicator: |
|
2298 |
case PE_Q3DockWindowSeparator: |
|
2299 |
case PE_Q3Separator: |
|
2300 |
Q_ASSERT(false); |
|
2301 |
break; |
|
2302 |
case PE_Frame: |
|
2303 |
break; |
|
2304 |
#ifndef QT_NO_ITEMVIEWS |
|
2305 |
case PE_PanelItemViewItem: |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2306 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2307 |
const bool isSelected = (vopt->state & State_Selected); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2308 |
const bool hasFocus = (vopt->state & State_HasFocus); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2309 |
const bool isPressed = QS60StylePrivate::isWidgetPressed(widget); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2310 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2311 |
if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2312 |
QRect highlightRect = vopt->rect.adjusted(1,1,-1,-1); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2313 |
const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2314 |
QAbstractItemView::SelectionBehavior selectionBehavior = |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2315 |
itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2316 |
// Set the draw area for highlights (focus, select rect or pressed rect) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2317 |
if (hasFocus || isSelected || isPressed) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2318 |
if (selectionBehavior != QAbstractItemView::SelectItems) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2319 |
// set highlight rect so that it is continuous from cell to cell, yet sligthly |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2320 |
// smaller than cell rect |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2321 |
int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2322 |
if (selectionBehavior == QAbstractItemView::SelectRows) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2323 |
yBeginning = 1; yEnd = -1; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2324 |
if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2325 |
xBeginning = 1; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2326 |
else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2327 |
xEnd = -1; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2328 |
} else if (selectionBehavior == QAbstractItemView::SelectColumns) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2329 |
xBeginning = 1; xEnd = -1; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2330 |
if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2331 |
yBeginning = 1; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2332 |
else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2333 |
yEnd = -1; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2334 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2335 |
highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2336 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2337 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2338 |
bool tableView = false; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2339 |
if (itemView && qobject_cast<const QTableView *>(widget)) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2340 |
tableView = true; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2341 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2342 |
QS60StylePrivate::SkinElements element; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2343 |
bool themeGraphicDefined = false; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2344 |
QRect elementRect = option->rect; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2345 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2346 |
//draw item is drawn as pressed, if it already has focus. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2347 |
if (isPressed && (hasFocus || isSelected)) { |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2348 |
themeGraphicDefined = true; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2349 |
element = tableView ? QS60StylePrivate::SE_TableItemPressed : QS60StylePrivate::SE_ListItemPressed; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2350 |
} else if (hasFocus || (isSelected && selectionBehavior != QAbstractItemView::SelectItems)) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2351 |
element = QS60StylePrivate::SE_ListHighlight; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2352 |
elementRect = highlightRect; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2353 |
themeGraphicDefined = true; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2354 |
} |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2355 |
if (themeGraphicDefined) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2356 |
QS60StylePrivate::drawSkinElement(element, painter, elementRect, flags); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2357 |
} else { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2358 |
QCommonStyle::drawPrimitive(element, option, painter, widget); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2359 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2360 |
} |
0 | 2361 |
break; |
2362 |
#endif //QT_NO_ITEMVIEWS |
|
2363 |
||
2364 |
case PE_IndicatorMenuCheckMark: |
|
2365 |
if (const QStyleOptionMenuItem *checkBox = qstyleoption_cast<const QStyleOptionMenuItem *>(option)){ |
|
2366 |
QStyleOptionMenuItem optionCheckBox = *checkBox; |
|
2367 |
if (optionCheckBox.checked) |
|
2368 |
optionCheckBox.state = (optionCheckBox.state | State_On); |
|
2369 |
drawPrimitive(PE_IndicatorCheckBox, &optionCheckBox, painter, widget); |
|
2370 |
} |
|
2371 |
break; |
|
2372 |
#ifndef QT_NO_TOOLBAR |
|
2373 |
case PE_IndicatorToolBarHandle: |
|
2374 |
// no toolbar handles in S60/AVKON UI |
|
2375 |
case PE_IndicatorToolBarSeparator: |
|
2376 |
// no separators in S60/AVKON UI |
|
2377 |
break; |
|
2378 |
#endif //QT_NO_TOOLBAR |
|
2379 |
||
2380 |
case PE_PanelMenuBar: |
|
2381 |
case PE_FrameMenu: |
|
2382 |
break; //disable frame in menu |
|
2383 |
||
2384 |
case PE_IndicatorBranch: |
|
2385 |
#if defined(Q_WS_S60) |
|
2386 |
// 3.1 AVKON UI does not have tree view component, use common style for drawing there |
|
2387 |
if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1) { |
|
2388 |
#else |
|
2389 |
if (true) { |
|
2390 |
#endif |
|
2391 |
QCommonStyle::drawPrimitive(element, option, painter, widget); |
|
2392 |
} else { |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2393 |
if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast<const QStyleOptionViewItemV2 *>(option)) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2394 |
const bool rightLine = option->state & State_Item; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2395 |
const bool downLine = option->state & State_Sibling; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2396 |
const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2397 |
QS60StylePrivate::SkinElementFlags adjustedFlags = flags; |
0 | 2398 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2399 |
QS60StyleEnums::SkinParts skinPart; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2400 |
bool drawSkinPart = false; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2401 |
if (rightLine && downLine && upLine) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2402 |
skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2403 |
drawSkinPart = true; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2404 |
} else if (rightLine && upLine) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2405 |
skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2406 |
drawSkinPart = true; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2407 |
} else if (upLine && downLine) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2408 |
skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2409 |
drawSkinPart = true; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2410 |
} |
0 | 2411 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2412 |
if (option->direction == Qt::RightToLeft) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2413 |
adjustedFlags |= QS60StylePrivate::SF_Mirrored_X_Axis; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2414 |
|
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2415 |
if (drawSkinPart) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2416 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, adjustedFlags); |
0 | 2417 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2418 |
if (option->state & State_Children) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2419 |
QS60StyleEnums::SkinParts skinPart = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2420 |
(option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2421 |
const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2422 |
const int minDimension = qMin(option->rect.width(), option->rect.height()); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2423 |
const int magicTweak = (option->direction == Qt::RightToLeft) ? -3 : 3; //@todo: magic |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2424 |
//The branch indicator icon in S60 is supposed to be superimposed on top of branch lines. |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2425 |
QRect iconRect(QPoint(option->rect.left() + magicTweak, selectionRect.top() + 1), QSize(minDimension, minDimension)); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2426 |
if (!QS60StylePrivate::isTouchSupported()) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2427 |
iconRect.translate(0, -4); //@todo: magic |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2428 |
QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, adjustedFlags); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2429 |
} |
0 | 2430 |
} |
2431 |
} |
|
2432 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2433 |
case PE_PanelItemViewRow: // ### Qt 5: remove |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2434 |
#ifndef QT_NO_ITEMVIEWS |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2435 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2436 |
if (vopt->palette.base().texture().cacheKey() != QS60StylePrivate::m_themePalette->base().texture().cacheKey()) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2437 |
//QPalette::Base has been changed, let commonstyle draw the item |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2438 |
commonStyleDraws = true; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2439 |
} else { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2440 |
QPalette::ColorGroup cg = vopt->state & State_Enabled ? QPalette::Normal : QPalette::Disabled; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2441 |
if (cg == QPalette::Normal && !(vopt->state & State_Active)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2442 |
cg = QPalette::Inactive; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2443 |
if (vopt->features & QStyleOptionViewItemV2::Alternate) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2444 |
painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2445 |
//apart from alternate base, no background for list item is drawn for S60Style |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2446 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2447 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2448 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2449 |
break; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2450 |
case PE_PanelScrollAreaCorner: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2451 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2452 |
case PE_IndicatorItemViewItemDrop: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2453 |
if (QS60StylePrivate::isTouchSupported()) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2454 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DropArea, painter, option->rect, flags); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2455 |
else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2456 |
commonStyleDraws = true; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2457 |
break; |
0 | 2458 |
// todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2459 |
case PE_FrameLineEdit: |
|
2460 |
case PE_IndicatorDockWidgetResizeHandle: |
|
2461 |
case PE_PanelTipLabel: |
|
2462 |
||
2463 |
#ifndef QT_NO_TABBAR |
|
2464 |
case PE_IndicatorTabTear: // No tab tear in S60 |
|
2465 |
#endif // QT_NO_TABBAR |
|
2466 |
case PE_FrameDefaultButton: |
|
2467 |
#ifndef QT_NO_DOCKWIDGET |
|
2468 |
case PE_FrameDockWidget: |
|
2469 |
#endif //QT_NO_DOCKWIDGET |
|
2470 |
#ifndef QT_NO_PROGRESSBAR |
|
2471 |
case PE_IndicatorProgressChunk: |
|
2472 |
#endif //QT_NO_PROGRESSBAR |
|
2473 |
#ifndef QT_NO_TOOLBAR |
|
2474 |
case PE_PanelToolBar: |
|
2475 |
#endif //QT_NO_TOOLBAR |
|
2476 |
#ifndef QT_NO_COLUMNVIEW |
|
2477 |
case PE_IndicatorColumnViewArrow: |
|
2478 |
#endif //QT_NO_COLUMNVIEW |
|
2479 |
case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
|
2480 |
default: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2481 |
commonStyleDraws = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2482 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2483 |
if (commonStyleDraws) { |
0 | 2484 |
QCommonStyle::drawPrimitive(element, option, painter, widget); |
2485 |
} |
|
2486 |
} |
|
2487 |
||
2488 |
/*! \reimp */ |
|
2489 |
int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const |
|
2490 |
{ |
|
2491 |
int metricValue = QS60StylePrivate::pixelMetric(metric); |
|
2492 |
if (metricValue == KNotFound) |
|
2493 |
metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
|
2494 |
||
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2495 |
// Menu scrollers should be set to zero height for combobox popups |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2496 |
if (metric == PM_MenuScrollerHeight && !qobject_cast<const QMenu *>(widget)) |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2497 |
metricValue = 0; |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2498 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2499 |
//if layout direction is mirrored, switch left and right border margins |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2500 |
if (option && option->direction == Qt::RightToLeft) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2501 |
if (metric == PM_LayoutLeftMargin) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2502 |
metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2503 |
else if (metric == PM_LayoutRightMargin) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2504 |
metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2505 |
} |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2506 |
|
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2507 |
if (widget && (metric == PM_LayoutTopMargin)) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2508 |
if (widget->windowType() == Qt::Dialog) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2509 |
//double the top layout margin for dialogs, it is very close to real value |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2510 |
//without having to define custom pixel metric |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2511 |
metricValue *= 2; |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2512 |
|
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2513 |
if (widget && (metric == PM_FocusFrameHMargin)) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2514 |
if (qobject_cast<const QTableView *>(widget)) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2515 |
//Halve the focus frame margin for table items |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2516 |
metricValue /= 2; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2517 |
|
0 | 2518 |
return metricValue; |
2519 |
} |
|
2520 |
||
2521 |
/*! \reimp */ |
|
2522 |
QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
|
2523 |
const QSize &csz, const QWidget *widget) const |
|
2524 |
{ |
|
2525 |
QSize sz(csz); |
|
2526 |
switch (ct) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2527 |
case CT_ToolButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2528 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2529 |
//FIXME properly - style should calculate the location of border frame-part |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2530 |
sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2531 |
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2532 |
if (toolBtn->subControls & SC_ToolButtonMenu) |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2533 |
sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2534 |
break; |
0 | 2535 |
case CT_PushButton: |
2536 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2537 |
//FIXME properly - style should calculate the location of border frame-part |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2538 |
if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) { |
0 | 2539 |
if (buttonWidget->isCheckable()) |
2540 |
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2541 |
const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2542 |
const int textHeight = (buttonWidget->text().length() > 0) ? |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2543 |
buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : opt->fontMetrics.height(); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2544 |
const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2545 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2546 |
const int contentHeight = |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2547 |
qMax(qMax(iconHeight, decoratorHeight) + pixelMetric(PM_ButtonMargin), |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2548 |
textHeight + 2*pixelMetric(PM_ButtonMargin)); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2549 |
sz.setHeight(qMax(sz.height(), contentHeight)); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2550 |
sz += QSize(2 * pixelMetric(PM_ButtonMargin), 0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2551 |
} |
0 | 2552 |
break; |
2553 |
case CT_LineEdit: |
|
2554 |
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2555 |
sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); |
0 | 2556 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2557 |
case CT_TabBarTab: { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2558 |
const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2559 |
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2560 |
if (naviPaneSize.height() > sz.height()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2561 |
sz.setHeight(naviPaneSize.height()); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2562 |
// Adjust beginning tabbar item size, if scrollbuttons are used. This is to ensure that the |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2563 |
// tabbar item content fits, since scrollbuttons are making beginning tabbar item smaller. |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2564 |
int scrollButtonSize = 0; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2565 |
if (const QTabBar *tabBar = qobject_cast<const QTabBar *>(widget)) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2566 |
scrollButtonSize = tabBar->usesScrollButtons() ? pixelMetric(PM_TabBarScrollButtonWidth) : 0; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2567 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2568 |
const bool verticalTabs = tab->shape == QTabBar::RoundedEast |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2569 |
|| tab->shape == QTabBar::RoundedWest |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2570 |
|| tab->shape == QTabBar::TriangularEast |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2571 |
|| tab->shape == QTabBar::TriangularWest; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2572 |
if (tab->position == QStyleOptionTab::Beginning) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2573 |
sz += QSize(verticalTabs ? 0 : scrollButtonSize, !verticalTabs ? 0 : scrollButtonSize); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
2574 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2575 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2576 |
break; |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2577 |
case CT_MenuItem: |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2578 |
case CT_ItemViewItem: |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2579 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2580 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2581 |
sz = QSize(); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2582 |
break; |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2583 |
} |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2584 |
} |
0 | 2585 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
2586 |
//native items have small empty areas at the beginning and end of menu item |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
2587 |
sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin) + 2 * QS60StylePrivate::pixelMetric(PM_FrameCornerWidth)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2588 |
if (QS60StylePrivate::isTouchSupported()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2589 |
//Make itemview easier to use in touch devices |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2590 |
//QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
2591 |
sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin) - 8); //QCommonstyle adds 8 to height that this style handles through PM values |
0 | 2592 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2593 |
#ifndef QT_NO_COMBOBOX |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2594 |
case CT_ComboBox: { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2595 |
// Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2596 |
// Make sure, that the combobox stays within the screen. |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2597 |
const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2598 |
- QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2599 |
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2600 |
boundedTo(desktopContentSize); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2601 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2602 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2603 |
#endif |
0 | 2604 |
default: |
2605 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
|
2606 |
break; |
|
2607 |
} |
|
2608 |
return sz; |
|
2609 |
} |
|
2610 |
||
2611 |
/*! \reimp */ |
|
2612 |
int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
|
2613 |
QStyleHintReturn *hret) const |
|
2614 |
{ |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2615 |
int retValue = 0; |
0 | 2616 |
switch (sh) { |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2617 |
case SH_RequestSoftwareInputPanel: |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2618 |
if (QS60StylePrivate::isSingleClickUi()) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2619 |
retValue = RSIP_OnMouseClick; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2620 |
else |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2621 |
retValue = RSIP_OnMouseClickAndAlreadyFocused; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2622 |
break; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2623 |
case SH_ComboBox_Popup: |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2624 |
retValue = true; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2625 |
break; |
0 | 2626 |
case SH_Table_GridLineColor: |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2627 |
retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
0 | 2628 |
break; |
2629 |
case SH_GroupBox_TextLabelColor: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2630 |
retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
0 | 2631 |
break; |
2632 |
case SH_ScrollBar_ScrollWhenPointerLeavesControl: |
|
2633 |
retValue = true; |
|
2634 |
break; |
|
2635 |
case SH_Slider_SnapToValue: |
|
2636 |
retValue = true; |
|
2637 |
break; |
|
2638 |
case SH_Slider_StopMouseOverSlider: |
|
2639 |
retValue = true; |
|
2640 |
break; |
|
2641 |
case SH_LineEdit_PasswordCharacter: |
|
2642 |
retValue = '*'; |
|
2643 |
break; |
|
2644 |
case SH_ComboBox_PopupFrameStyle: |
|
2645 |
retValue = QFrame::NoFrame | QFrame::Plain; |
|
2646 |
break; |
|
2647 |
case SH_Dial_BackgroundRole: |
|
2648 |
retValue = QPalette::Base; |
|
2649 |
break; |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2650 |
case SH_ItemView_ActivateItemOnSingleClick: { |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2651 |
if (QS60StylePrivate::isSingleClickUi()) |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2652 |
retValue = true; |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2653 |
else if (opt && opt->state & QStyle::State_Selected) |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2654 |
retValue = true; |
0 | 2655 |
break; |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2656 |
} |
0 | 2657 |
case SH_ProgressDialog_TextLabelAlignment: |
2658 |
retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? |
|
2659 |
Qt::AlignLeft : |
|
2660 |
Qt::AlignRight; |
|
2661 |
break; |
|
2662 |
case SH_Menu_SubMenuPopupDelay: |
|
2663 |
retValue = 300; |
|
2664 |
break; |
|
2665 |
case SH_Menu_Scrollable: |
|
2666 |
retValue = true; |
|
2667 |
break; |
|
2668 |
case SH_Menu_SelectionWrap: |
|
2669 |
retValue = true; |
|
2670 |
break; |
|
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2671 |
case SH_Menu_MouseTracking: |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2672 |
retValue = true; |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2673 |
break; |
0 | 2674 |
case SH_ItemView_ShowDecorationSelected: |
2675 |
retValue = true; |
|
2676 |
break; |
|
2677 |
case SH_ToolBar_Movable: |
|
2678 |
retValue = false; |
|
2679 |
break; |
|
2680 |
case SH_BlinkCursorWhenTextSelected: |
|
2681 |
retValue = true; |
|
2682 |
break; |
|
2683 |
case SH_UnderlineShortcut: |
|
2684 |
retValue = 0; |
|
2685 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2686 |
case SH_FormLayoutWrapPolicy: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2687 |
retValue = QFormLayout::WrapLongRows; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2688 |
break; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2689 |
case SH_ScrollBar_ContextMenu: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2690 |
retValue = false; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2691 |
break; |
0 | 2692 |
default: |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2693 |
retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
0 | 2694 |
break; |
2695 |
} |
|
2696 |
return retValue; |
|
2697 |
} |
|
2698 |
||
2699 |
/*! \reimp */ |
|
2700 |
QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const |
|
2701 |
{ |
|
2702 |
QRect ret; |
|
2703 |
switch (control) { |
|
2704 |
#ifndef QT_NO_SCROLLBAR |
|
2705 |
// This implementation of subControlRect(CC_ScrollBar..) basically just removes the SC_ScrollBarSubLine and SC_ScrollBarAddLine |
|
2706 |
case CC_ScrollBar: |
|
2707 |
if (const QStyleOptionSlider *scrollbarOption = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
2708 |
const QRect scrollBarRect = scrollbarOption->rect; |
|
2709 |
const bool isHorizontal = scrollbarOption->orientation == Qt::Horizontal; |
|
2710 |
const int maxlen = isHorizontal ? scrollBarRect.width() : scrollBarRect.height(); |
|
2711 |
int sliderlen; |
|
2712 |
||
2713 |
// calculate slider length |
|
2714 |
if (scrollbarOption->maximum != scrollbarOption->minimum) { |
|
2715 |
const uint range = scrollbarOption->maximum - scrollbarOption->minimum; |
|
2716 |
sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep); |
|
2717 |
||
2718 |
const int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2719 |
if (sliderlen < slidermin || range > (INT_MAX >> 1)) |
0 | 2720 |
sliderlen = slidermin; |
2721 |
if (sliderlen > maxlen) |
|
2722 |
sliderlen = maxlen; |
|
2723 |
} else { |
|
2724 |
sliderlen = maxlen; |
|
2725 |
} |
|
2726 |
||
2727 |
const int sliderstart = sliderPositionFromValue(scrollbarOption->minimum, |
|
2728 |
scrollbarOption->maximum, |
|
2729 |
scrollbarOption->sliderPosition, |
|
2730 |
maxlen - sliderlen, |
|
2731 |
scrollbarOption->upsideDown); |
|
2732 |
||
2733 |
switch (scontrol) { |
|
2734 |
case SC_ScrollBarSubPage: // between top/left button and slider |
|
2735 |
if (isHorizontal) |
|
2736 |
ret.setRect(0, 0, sliderstart, scrollBarRect.height()); |
|
2737 |
else |
|
2738 |
ret.setRect(0, 0, scrollBarRect.width(), sliderstart); |
|
2739 |
break; |
|
2740 |
case SC_ScrollBarAddPage: { // between bottom/right button and slider |
|
2741 |
const int addPageLength = sliderstart + sliderlen; |
|
2742 |
if (isHorizontal) |
|
2743 |
ret = scrollBarRect.adjusted(addPageLength, 0, 0, 0); |
|
2744 |
else |
|
2745 |
ret = scrollBarRect.adjusted(0, addPageLength, 0, 0); |
|
2746 |
} |
|
2747 |
break; |
|
2748 |
case SC_ScrollBarGroove: |
|
2749 |
ret = scrollBarRect; |
|
2750 |
break; |
|
2751 |
case SC_ScrollBarSlider: |
|
2752 |
if (scrollbarOption->orientation == Qt::Horizontal) |
|
2753 |
ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); |
|
2754 |
else |
|
2755 |
ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); |
|
2756 |
break; |
|
2757 |
case SC_ScrollBarSubLine: // top/left button |
|
2758 |
case SC_ScrollBarAddLine: // bottom/right button |
|
2759 |
default: |
|
2760 |
break; |
|
2761 |
} |
|
2762 |
ret = visualRect(scrollbarOption->direction, scrollBarRect, ret); |
|
2763 |
} |
|
2764 |
break; |
|
2765 |
#endif // QT_NO_SCROLLBAR |
|
2766 |
case CC_SpinBox: |
|
2767 |
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
2768 |
const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
|
2769 |
const int buttonMargin = spinbox->frame ? 2 : 0; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2770 |
const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2771 |
// Spinbox buttons should be no larger than one fourth of total width. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2772 |
// Thus, side-by-side buttons would take half of the total width. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2773 |
const int maxSize = qMax(spinbox->rect.width() / 4, buttonContentWidth); |
0 | 2774 |
QSize buttonSize; |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2775 |
buttonSize.setHeight(qMin(maxSize, qMax(8, spinbox->rect.height() - frameThickness))); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2776 |
//width should at least be equal to height |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2777 |
buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); |
0 | 2778 |
buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2779 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2780 |
// Normally spinbuttons should be side-by-side, but if spinbox grows very big |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2781 |
// and spinbuttons reach their maximum size, they can be deployed one top of the other. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2782 |
const bool sideBySide = (buttonSize.height() * 2 < spinbox->rect.height()) ? false : true; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2783 |
const int y = frameThickness + spinbox->rect.y() + |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2784 |
(spinbox->rect.height() - (sideBySide ? 1 : 2) * buttonSize.height()) / 2; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2785 |
const int x = spinbox->rect.x() + |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2786 |
spinbox->rect.width() - frameThickness - (sideBySide ? 2 : 1) * buttonSize.width(); |
0 | 2787 |
|
2788 |
switch (scontrol) { |
|
2789 |
case SC_SpinBoxUp: |
|
2790 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
2791 |
return QRect(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2792 |
ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
0 | 2793 |
break; |
2794 |
case SC_SpinBoxDown: |
|
2795 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
2796 |
return QRect(); |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2797 |
ret = QRect(x + (sideBySide ? buttonSize.width() : 0), |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2798 |
y + (sideBySide ? 0 : buttonSize.height()), |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2799 |
buttonSize.width(), buttonSize.height()); |
0 | 2800 |
break; |
2801 |
case SC_SpinBoxEditField: |
|
2802 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
2803 |
ret = QRect( |
|
2804 |
frameThickness, |
|
2805 |
frameThickness, |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2806 |
spinbox->rect.width() - 2 * frameThickness, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2807 |
spinbox->rect.height() - 2 * frameThickness); |
0 | 2808 |
else |
2809 |
ret = QRect( |
|
2810 |
frameThickness, |
|
2811 |
frameThickness, |
|
2812 |
x - frameThickness, |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2813 |
spinbox->rect.height() - 2 * frameThickness); |
0 | 2814 |
break; |
2815 |
case SC_SpinBoxFrame: |
|
2816 |
ret = spinbox->rect; |
|
2817 |
break; |
|
2818 |
default: |
|
2819 |
break; |
|
2820 |
} |
|
2821 |
ret = visualRect(spinbox->direction, spinbox->rect, ret); |
|
2822 |
} |
|
2823 |
break; |
|
2824 |
case CC_ComboBox: |
|
2825 |
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
2826 |
ret = cmb->rect; |
|
2827 |
const int width = cmb->rect.width(); |
|
2828 |
const int height = cmb->rect.height(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2829 |
const int buttonIconSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize); |
0 | 2830 |
const int buttonMargin = cmb->frame ? 2 : 0; |
2831 |
// lets use spinbox frame here as well, as no combobox specific value available. |
|
2832 |
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2833 |
const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); |
0 | 2834 |
|
2835 |
QSize buttonSize; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2836 |
buttonSize.setWidth(buttonWidth + 2 * buttonMargin); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2837 |
buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares |
0 | 2838 |
buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2839 |
switch (scontrol) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2840 |
case SC_ComboBoxArrow: { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2841 |
const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2842 |
const int ypos = cmb->rect.y(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2843 |
ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2844 |
} |
0 | 2845 |
break; |
2846 |
case SC_ComboBoxEditField: { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2847 |
const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2848 |
ret = QRect( |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2849 |
frameThickness, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2850 |
frameThickness, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2851 |
withFrameX - frameThickness, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2852 |
height - 2 * frameThickness); |
0 | 2853 |
} |
2854 |
break; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2855 |
case SC_ComboBoxListBoxPopup: { |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
2856 |
ret = QApplication::desktop()->availableGeometry(); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2857 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2858 |
break; |
0 | 2859 |
default: |
2860 |
break; |
|
2861 |
} |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2862 |
ret = visualRect(cmb->direction, cmb->rect, ret); |
0 | 2863 |
} |
2864 |
break; |
|
2865 |
case CC_GroupBox: |
|
2866 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
2867 |
ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
|
2868 |
switch (scontrol) { |
|
2869 |
case SC_GroupBoxCheckBox: //fallthrough |
|
2870 |
case SC_GroupBoxLabel: { |
|
2871 |
//slightly indent text and boxes, so that dialog border does not mess with them. |
|
2872 |
const int horizontalSpacing = |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2873 |
QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2874 |
ret.adjust(2, horizontalSpacing - 3, 0, 0); |
0 | 2875 |
} |
2876 |
break; |
|
2877 |
case SC_GroupBoxFrame: { |
|
2878 |
const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); |
|
2879 |
const int tbHeight = textBox.height(); |
|
2880 |
ret.translate(0, -ret.y()); |
|
2881 |
// include title to within the groupBox frame |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2882 |
ret.setHeight(ret.height() + tbHeight); |
0 | 2883 |
if (widget && ret.bottom() > widget->rect().bottom()) |
2884 |
ret.setBottom(widget->rect().bottom()); |
|
2885 |
} |
|
2886 |
break; |
|
2887 |
default: |
|
2888 |
break; |
|
2889 |
} |
|
2890 |
} |
|
2891 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2892 |
case CC_ToolButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2893 |
if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2894 |
const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2 * pixelMetric(PM_ButtonMargin); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2895 |
const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2896 |
ret = toolButton->rect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2897 |
const bool popup = (toolButton->features & |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2898 |
(QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2899 |
== QStyleOptionToolButton::MenuButtonPopup; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2900 |
switch (scontrol) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2901 |
case SC_ToolButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2902 |
if (popup) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2903 |
ret.adjust(0, 0, -indicatorRect, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2904 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2905 |
case SC_ToolButtonMenu: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2906 |
if (popup) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2907 |
ret.adjust(ret.width() - indicatorRect, border, -pixelMetric(PM_ButtonMargin), -border); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2908 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2909 |
default: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2910 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2911 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2912 |
ret = visualRect(toolButton->direction, toolButton->rect, ret); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2913 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2914 |
break; |
0 | 2915 |
default: |
2916 |
ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
|
2917 |
} |
|
2918 |
return ret; |
|
2919 |
} |
|
2920 |
||
2921 |
/*! |
|
2922 |
\reimp |
|
2923 |
*/ |
|
2924 |
QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const |
|
2925 |
{ |
|
2926 |
QRect ret; |
|
2927 |
switch (element) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2928 |
case SE_RadioButtonFocusRect: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2929 |
ret = opt->rect; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2930 |
break; |
0 | 2931 |
case SE_LineEditContents: { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2932 |
// in S60 the input text box doesn't start from line Edit's TL, but |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2933 |
// a bit indented (8 pixels). |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2934 |
const int KLineEditDefaultIndention = 8; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2935 |
ret = visualRect( |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2936 |
opt->direction, opt->rect, opt->rect.adjusted(KLineEditDefaultIndention, 0, 0, 0)); |
0 | 2937 |
} |
2938 |
break; |
|
2939 |
case SE_TabBarTearIndicator: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2940 |
ret = QRect(0, 0, 0, 0); |
0 | 2941 |
break; |
2942 |
case SE_TabWidgetTabBar: |
|
2943 |
if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2944 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
2945 |
||
2946 |
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2947 |
const int tabOverlapNoBorder = |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2948 |
QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap); |
0 | 2949 |
const int tabOverlap = |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2950 |
tabOverlapNoBorder - QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
0 | 2951 |
const QTabWidget *tab = qobject_cast<const QTabWidget *>(widget); |
2952 |
int gain = (tab) ? tabOverlap * tab->count() : 0; |
|
2953 |
switch (twf->shape) { |
|
2954 |
case QTabBar::RoundedNorth: |
|
2955 |
case QTabBar::TriangularNorth: |
|
2956 |
case QTabBar::RoundedSouth: |
|
2957 |
case QTabBar::TriangularSouth: { |
|
2958 |
if (widget) { |
|
2959 |
// make sure that gain does not set the rect outside of widget boundaries |
|
2960 |
if (twf->direction == Qt::RightToLeft) { |
|
2961 |
if ((ret.left() - gain) < widget->rect().left()) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2962 |
gain = widget->rect().left() - ret.left(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2963 |
ret.adjust(-gain, 0, 0, 0); |
0 | 2964 |
} else { |
2965 |
if ((ret.right() + gain) > widget->rect().right()) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2966 |
gain = widget->rect().right() - ret.right(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2967 |
ret.adjust(0, 0, gain, 0); |
0 | 2968 |
} |
2969 |
} |
|
2970 |
break; |
|
2971 |
} |
|
2972 |
default: { |
|
2973 |
if (widget) { |
|
2974 |
if ((ret.bottom() + gain) > widget->rect().bottom()) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2975 |
gain = widget->rect().bottom() - ret.bottom(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2976 |
ret.adjust(0, 0, 0, gain); |
0 | 2977 |
} |
2978 |
break; |
|
2979 |
} |
|
2980 |
} |
|
2981 |
} |
|
2982 |
} |
|
2983 |
break; |
|
2984 |
case SE_ItemViewItemText: |
|
2985 |
case SE_ItemViewItemDecoration: |
|
2986 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
2987 |
const QListWidget *listItem = qobject_cast<const QListWidget *>(widget); |
|
2988 |
const bool multiSelection = !listItem ? false : |
|
2989 |
listItem->selectionMode() == QAbstractItemView::MultiSelection || |
|
2990 |
listItem->selectionMode() == QAbstractItemView::ExtendedSelection || |
|
2991 |
listItem->selectionMode() == QAbstractItemView::ContiguousSelection; |
|
2992 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
2993 |
// If both multiselect & check-state, then remove checkbox and move |
|
2994 |
// text and decoration towards the beginning |
|
2995 |
if (listItem && |
|
2996 |
multiSelection && |
|
2997 |
(vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { |
|
2998 |
const int verticalSpacing = |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2999 |
QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3000 |
//const int horizontalSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
0 | 3001 |
const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3002 |
ret.adjust(-checkBoxRectWidth - verticalSpacing, 0, -checkBoxRectWidth - verticalSpacing, 0); |
0 | 3003 |
} |
3004 |
} else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
|
3005 |
const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
|
3006 |
const int indicatorWidth = checkable ? |
|
3007 |
pixelMetric(PM_ListViewIconSize, opt, widget) : |
|
3008 |
pixelMetric(PM_SmallIconSize, opt, widget); |
|
3009 |
ret = menuItem->rect; |
|
3010 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3011 |
QRect checkBoxRect = checkable ? menuItem->rect : QRect(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3012 |
if (checkable) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3013 |
checkBoxRect.setWidth(pixelMetric(PM_IndicatorWidth)); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3014 |
checkBoxRect.setHeight(pixelMetric(PM_IndicatorHeight)); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3015 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3016 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3017 |
const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3018 |
//The vertical spacing is doubled; it needs one spacing to separate checkbox from |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3019 |
//highlight and then it needs one to separate it whatever is shown after it (text/icon/both). |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3020 |
const int moveByX = checkBoxRect.width() + 2 * vSpacing; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3021 |
|
0 | 3022 |
if (element == SE_ItemViewItemDecoration) { |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3023 |
if (menuItem->icon.isNull()) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3024 |
ret = QRect(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3025 |
} else { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3026 |
if (menuItem->direction == Qt::RightToLeft) |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3027 |
ret.translate(ret.width() - indicatorWidth - moveByX, 0); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3028 |
else |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3029 |
ret.translate(moveByX, 0); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3030 |
ret.setWidth(indicatorWidth); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3031 |
} |
0 | 3032 |
} else { |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3033 |
if (!menuItem->icon.isNull()) { |
0 | 3034 |
if (menuItem->direction == Qt::LeftToRight) |
3035 |
ret.adjust(indicatorWidth, 0, 0, 0); |
|
3036 |
else |
|
3037 |
ret.adjust(0, 0, -indicatorWidth, 0); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3038 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3039 |
if (menuItem->direction == Qt::LeftToRight) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3040 |
ret.adjust(moveByX, 0, 0, 0); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3041 |
else |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3042 |
ret.adjust(0, 0, -moveByX, 0); |
0 | 3043 |
|
3044 |
// Make room for submenu indicator |
|
3045 |
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ |
|
3046 |
// submenu indicator is very small, so lets halve the rect |
|
3047 |
if (menuItem->direction == Qt::LeftToRight) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3048 |
ret.adjust(0, 0, -(indicatorWidth >> 1), 0); |
0 | 3049 |
else |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3050 |
ret.adjust((indicatorWidth >> 1), 0, 0, 0); |
0 | 3051 |
} |
3052 |
} |
|
3053 |
} |
|
3054 |
break; |
|
3055 |
case SE_ItemViewItemCheckIndicator: |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
3056 |
if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) { |
0 | 3057 |
const QListWidget *listItem = qobject_cast<const QListWidget *>(widget); |
3058 |
||
3059 |
const bool singleSelection = listItem && |
|
3060 |
(listItem->selectionMode() == QAbstractItemView::SingleSelection || |
|
3061 |
listItem->selectionMode() == QAbstractItemView::NoSelection); |
|
3062 |
const bool checkBoxOnly = (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) && |
|
3063 |
listItem && |
|
3064 |
singleSelection; |
|
3065 |
||
3066 |
// Selection check mark rect. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3067 |
const int indicatorWidth = QS60StylePrivate::pixelMetric(PM_IndicatorWidth); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3068 |
const int indicatorHeight = QS60StylePrivate::pixelMetric(PM_IndicatorHeight); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3069 |
const int spacing = QS60StylePrivate::pixelMetric(PM_CheckBoxLabelSpacing); |
0 | 3070 |
|
3071 |
const int itemHeight = opt->rect.height(); |
|
3072 |
int heightOffset = 0; |
|
3073 |
if (indicatorHeight < itemHeight) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3074 |
heightOffset = ((itemHeight - indicatorHeight) >> 1); |
0 | 3075 |
if (checkBoxOnly) { |
3076 |
// Move rect and make it slightly smaller, so that |
|
3077 |
// a) highlight border does not cross the rect |
|
3078 |
// b) in s60 list checkbox is smaller than normal checkbox |
|
3079 |
//todo; magic three |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3080 |
ret.setRect(opt->rect.left() + 3, opt->rect.top() + heightOffset, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3081 |
indicatorWidth - 3, indicatorHeight - 3); |
0 | 3082 |
} else { |
3083 |
ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, |
|
3084 |
indicatorWidth, indicatorHeight); |
|
3085 |
} |
|
3086 |
} else { |
|
3087 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
3088 |
} |
|
3089 |
break; |
|
3090 |
case SE_HeaderLabel: |
|
3091 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
3092 |
if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
3093 |
// Subtract area needed for line |
|
3094 |
if (opt->state & State_Horizontal) |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3095 |
ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_BoldLineWidth)); |
0 | 3096 |
else |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3097 |
ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_ThinLineWidth)); |
0 | 3098 |
} |
3099 |
ret = visualRect(opt->direction, opt->rect, ret); |
|
3100 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3101 |
case SE_RadioButtonIndicator: { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3102 |
const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3103 |
ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3104 |
pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), height); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3105 |
ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3106 |
ret = visualRect(opt->direction, opt->rect, ret); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3107 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3108 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3109 |
case SE_CheckBoxIndicator: { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3110 |
const int height = pixelMetric(PM_IndicatorHeight, opt, widget); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3111 |
ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3112 |
pixelMetric(PM_IndicatorWidth, opt, widget), height); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3113 |
ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3114 |
ret = visualRect(opt->direction, opt->rect, ret); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3115 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3116 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3117 |
case SE_CheckBoxFocusRect: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3118 |
ret = opt->rect; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3119 |
break; |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3120 |
case SE_ProgressBarLabel: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3121 |
case SE_ProgressBarContents: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3122 |
case SE_ProgressBarGroove: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3123 |
ret = opt->rect; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3124 |
break; |
0 | 3125 |
default: |
3126 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
3127 |
} |
|
3128 |
return ret; |
|
3129 |
} |
|
3130 |
||
3131 |
/*! |
|
3132 |
\reimp |
|
3133 |
*/ |
|
3134 |
void QS60Style::polish(QWidget *widget) |
|
3135 |
{ |
|
3136 |
Q_D(const QS60Style); |
|
3137 |
QCommonStyle::polish(widget); |
|
3138 |
||
3139 |
if (!widget) |
|
3140 |
return; |
|
3141 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3142 |
//Currently we only support animations in QProgressBar. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3143 |
#ifndef QT_NO_PROGRESSBAR |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3144 |
if (qobject_cast<QProgressBar *>(widget)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3145 |
widget->installEventFilter(this); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3146 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3147 |
|
0 | 3148 |
if (false |
3149 |
#ifndef QT_NO_SCROLLBAR |
|
3150 |
|| qobject_cast<QScrollBar *>(widget) |
|
3151 |
#endif |
|
3152 |
) { |
|
3153 |
widget->setAttribute(Qt::WA_OpaquePaintEvent, false); |
|
3154 |
} |
|
3155 |
||
3156 |
if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { |
|
3157 |
widget->setAttribute(Qt::WA_StyledBackground); |
|
3158 |
} else if (false |
|
3159 |
#ifndef QT_NO_MENU |
|
3160 |
|| qobject_cast<const QMenu *> (widget) |
|
3161 |
#endif // QT_NO_MENU |
|
3162 |
) { |
|
3163 |
widget->setAttribute(Qt::WA_StyledBackground); |
|
3164 |
} else if (false |
|
3165 |
#ifndef QT_NO_COMBOBOX |
|
3166 |
|| qobject_cast<const QComboBoxListView *>(widget) |
|
3167 |
#endif //QT_NO_COMBOBOX |
|
3168 |
) { |
|
3169 |
widget->setAttribute(Qt::WA_StyledBackground); |
|
3170 |
} |
|
3171 |
d->setThemePalette(widget); |
|
3172 |
d->setFont(widget); |
|
3173 |
} |
|
3174 |
||
3175 |
/*! |
|
3176 |
\reimp |
|
3177 |
*/ |
|
3178 |
void QS60Style::unpolish(QWidget *widget) |
|
3179 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3180 |
Q_D(QS60Style); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3181 |
|
0 | 3182 |
if (false |
3183 |
#ifndef QT_NO_SCROLLBAR |
|
3184 |
|| qobject_cast<QScrollBar *>(widget) |
|
3185 |
#endif |
|
3186 |
) |
|
3187 |
widget->setAttribute(Qt::WA_OpaquePaintEvent); |
|
3188 |
||
3189 |
if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { |
|
3190 |
widget->setAttribute(Qt::WA_StyledBackground, false); |
|
3191 |
} else if (false |
|
3192 |
#ifndef QT_NO_MENU |
|
3193 |
|| qobject_cast<const QMenu *> (widget) |
|
3194 |
#endif // QT_NO_MENU |
|
3195 |
) { |
|
3196 |
widget->setAttribute(Qt::WA_StyledBackground, false); |
|
3197 |
} else if (false |
|
3198 |
#ifndef QT_NO_COMBOBOX |
|
3199 |
|| qobject_cast<const QComboBoxListView *>(widget) |
|
3200 |
#endif //QT_NO_COMBOBOX |
|
3201 |
) { |
|
3202 |
widget->setAttribute(Qt::WA_StyledBackground, false); |
|
3203 |
} |
|
3204 |
||
3205 |
if (widget) |
|
3206 |
widget->setPalette(QPalette()); |
|
3207 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3208 |
#if defined(Q_WS_S60) && !defined(QT_NO_PROGRESSBAR) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3209 |
if (QProgressBar *bar = qobject_cast<QProgressBar *>(widget)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3210 |
widget->removeEventFilter(this); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3211 |
d->m_bars.removeAll(bar); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3212 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3213 |
#else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3214 |
Q_UNUSED(d) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3215 |
#endif |
0 | 3216 |
QCommonStyle::unpolish(widget); |
3217 |
} |
|
3218 |
||
3219 |
/*! |
|
3220 |
\reimp |
|
3221 |
*/ |
|
3222 |
void QS60Style::polish(QApplication *application) |
|
3223 |
{ |
|
3224 |
Q_D(QS60Style); |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3225 |
QCommonStyle::polish(qApp); |
0 | 3226 |
d->m_originalPalette = application->palette(); |
3227 |
d->setThemePalette(application); |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3228 |
if (QS60StylePrivate::isTouchSupported()) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3229 |
qApp->installEventFilter(this); |
0 | 3230 |
} |
3231 |
||
3232 |
/*! |
|
3233 |
\reimp |
|
3234 |
*/ |
|
3235 |
void QS60Style::unpolish(QApplication *application) |
|
3236 |
{ |
|
3237 |
Q_UNUSED(application) |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3238 |
|
0 | 3239 |
Q_D(QS60Style); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3240 |
QCommonStyle::unpolish(qApp); |
0 | 3241 |
const QPalette newPalette = QApplication::style()->standardPalette(); |
3242 |
QApplication::setPalette(newPalette); |
|
3243 |
QApplicationPrivate::setSystemPalette(d->m_originalPalette); |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3244 |
if (QS60StylePrivate::isTouchSupported()) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3245 |
qApp->removeEventFilter(this); |
0 | 3246 |
} |
3247 |
||
3248 |
/*! |
|
3249 |
\reimp |
|
3250 |
*/ |
|
3251 |
bool QS60Style::event(QEvent *e) |
|
3252 |
{ |
|
3253 |
#ifdef QT_KEYPAD_NAVIGATION |
|
3254 |
Q_D(QS60Style); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3255 |
const QEvent::Type eventType = e->type(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3256 |
if ((eventType == QEvent::FocusIn || |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3257 |
eventType == QEvent::FocusOut || |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3258 |
eventType == QEvent::EnterEditFocus || |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3259 |
eventType == QEvent::LeaveEditFocus) && |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3260 |
QS60StylePrivate::isTouchSupported()) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3261 |
return false; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3262 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3263 |
|
0 | 3264 |
switch (e->type()) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3265 |
case QEvent::Timer: { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3266 |
QTimerEvent *te = static_cast<QTimerEvent*>(e); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3267 |
timerEvent(te); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3268 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3269 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3270 |
#ifdef QT_KEYPAD_NAVIGATION |
0 | 3271 |
case QEvent::FocusIn: |
3272 |
if (QWidget *focusWidget = QApplication::focusWidget()) { |
|
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3273 |
|
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3274 |
// Menus and combobox popups do not draw focus frame around them |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3275 |
if (qobject_cast<QComboBoxListView *>(focusWidget) || |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3276 |
qobject_cast<QMenu *>(focusWidget)) |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3277 |
break; |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3278 |
|
0 | 3279 |
if (!d->m_focusFrame) |
3280 |
d->m_focusFrame = new QFocusFrame(focusWidget); |
|
3281 |
d->m_focusFrame->setWidget(focusWidget); |
|
3282 |
} else if (d->m_focusFrame) { |
|
3283 |
d->m_focusFrame->setWidget(0); |
|
3284 |
} |
|
3285 |
break; |
|
3286 |
case QEvent::FocusOut: |
|
3287 |
if (d->m_focusFrame) |
|
3288 |
d->m_focusFrame->setWidget(0); |
|
3289 |
break; |
|
3290 |
case QEvent::EnterEditFocus: |
|
3291 |
case QEvent::LeaveEditFocus: |
|
3292 |
if (d->m_focusFrame) |
|
3293 |
d->m_focusFrame->update(); |
|
3294 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3295 |
#endif |
0 | 3296 |
default: |
3297 |
break; |
|
3298 |
} |
|
3299 |
return false; |
|
3300 |
} |
|
3301 |
||
3302 |
/*! |
|
3303 |
\internal |
|
3304 |
*/ |
|
3305 |
QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, |
|
3306 |
const QStyleOption *option, const QWidget *widget) const |
|
3307 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3308 |
const int iconDimension = QS60StylePrivate::pixelMetric(PM_ToolBarIconSize); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3309 |
const QRect iconSize = (!option) ? QRect(0, 0, iconDimension, iconDimension) : option->rect; |
0 | 3310 |
QS60StyleEnums::SkinParts part; |
3311 |
QS60StylePrivate::SkinElementFlags adjustedFlags; |
|
3312 |
if (option) |
|
3313 |
adjustedFlags = (option->state & State_Enabled || option->state == 0) ? |
|
3314 |
QS60StylePrivate::SF_StateEnabled : |
|
3315 |
QS60StylePrivate::SF_StateDisabled; |
|
3316 |
||
3317 |
switch(standardIcon) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3318 |
case SP_MessageBoxWarning: |
0 | 3319 |
part = QS60StyleEnums::SP_QgnNoteWarning; |
3320 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3321 |
case SP_MessageBoxInformation: |
0 | 3322 |
part = QS60StyleEnums::SP_QgnNoteInfo; |
3323 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3324 |
case SP_MessageBoxCritical: |
0 | 3325 |
part = QS60StyleEnums::SP_QgnNoteError; |
3326 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3327 |
case SP_MessageBoxQuestion: |
0 | 3328 |
part = QS60StyleEnums::SP_QgnNoteQuery; |
3329 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3330 |
case SP_ArrowRight: |
0 | 3331 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowRight; |
3332 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3333 |
case SP_ArrowLeft: |
0 | 3334 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3335 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3336 |
case SP_ArrowUp: |
0 | 3337 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3338 |
adjustedFlags |= QS60StylePrivate::SF_PointEast; |
|
3339 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3340 |
case SP_ArrowDown: |
0 | 3341 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3342 |
adjustedFlags |= QS60StylePrivate::SF_PointWest; |
|
3343 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3344 |
case SP_ArrowBack: |
0 | 3345 |
if (QApplication::layoutDirection() == Qt::RightToLeft) |
3346 |
return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
|
3347 |
return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3348 |
case SP_ArrowForward: |
0 | 3349 |
if (QApplication::layoutDirection() == Qt::RightToLeft) |
3350 |
return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
|
3351 |
return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3352 |
case SP_ComputerIcon: |
0 | 3353 |
part = QS60StyleEnums::SP_QgnPropPhoneMemcLarge; |
3354 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3355 |
case SP_DirClosedIcon: |
0 | 3356 |
part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3357 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3358 |
case SP_DirOpenIcon: |
0 | 3359 |
part = QS60StyleEnums::SP_QgnPropFolderCurrent; |
3360 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3361 |
case SP_DirIcon: |
0 | 3362 |
part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3363 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3364 |
case SP_FileDialogNewFolder: |
0 | 3365 |
part = QS60StyleEnums::SP_QgnPropFolderSmallNew; |
3366 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3367 |
case SP_FileIcon: |
0 | 3368 |
part = QS60StyleEnums::SP_QgnPropFileSmall; |
3369 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3370 |
case SP_TrashIcon: |
0 | 3371 |
part = QS60StyleEnums::SP_QgnNoteErased; |
3372 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3373 |
case SP_ToolBarHorizontalExtensionButton: |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3374 |
part = QS60StyleEnums::SP_QgnIndiSubmenu; |
0 | 3375 |
if (QApplication::layoutDirection() == Qt::RightToLeft) |
3376 |
adjustedFlags |= QS60StylePrivate::SF_PointSouth; |
|
3377 |
break; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3378 |
case SP_ToolBarVerticalExtensionButton: |
0 | 3379 |
adjustedFlags |= QS60StylePrivate::SF_PointEast; |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
3380 |
part = QS60StyleEnums::SP_QgnIndiSubmenu; |
0 | 3381 |
break; |
3382 |
||
3383 |
default: |
|
3384 |
return QCommonStyle::standardIconImplementation(standardIcon, option, widget); |
|
3385 |
} |
|
3386 |
const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3387 |
const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); |
0 | 3388 |
return cachedPixMap.isNull() ? |
3389 |
QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); |
|
3390 |
} |
|
3391 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3392 |
/*! |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3393 |
\internal |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3394 |
Animate indeterminate progress bars only when visible |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3395 |
*/ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3396 |
bool QS60Style::eventFilter(QObject *object, QEvent *event) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3397 |
{ |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3398 |
Q_D(QS60Style); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3399 |
switch(event->type()) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3400 |
case QEvent::MouseButtonPress: { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3401 |
QWidget *w = QApplication::widgetAt(QCursor::pos()); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3402 |
if (w) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3403 |
QWidget *focusW = w->focusProxy(); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3404 |
if (qobject_cast<QAbstractItemView *>(focusW) || |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3405 |
qobject_cast<QRadioButton *>(focusW) || |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3406 |
qobject_cast<QCheckBox *>(focusW)) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3407 |
d->m_pressedWidget = focusW; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3408 |
else if (qobject_cast<QAbstractItemView *>(w)|| |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3409 |
qobject_cast<QRadioButton *>(w) || |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3410 |
qobject_cast<QCheckBox *>(w)) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3411 |
d->m_pressedWidget = w; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3412 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3413 |
if ( d->m_pressedWidget) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3414 |
d->m_pressedWidget->update(); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3415 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3416 |
break; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3417 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3418 |
case QEvent::MouseButtonRelease: { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3419 |
const QWidget *w = QApplication::widgetAt(QCursor::pos()); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3420 |
if (w && d->m_pressedWidget) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3421 |
d->m_pressedWidget->update(); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3422 |
d->m_pressedWidget = 0; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3423 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3424 |
break; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3425 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3426 |
default: |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3427 |
break; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3428 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3429 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3430 |
#ifdef Q_WS_S60 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3431 |
#ifndef QT_NO_PROGRESSBAR |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3432 |
switch(event->type()) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3433 |
case QEvent::StyleChange: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3434 |
case QEvent::Show: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3435 |
if (QProgressBar *bar = qobject_cast<QProgressBar *>(object)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3436 |
if (!d->m_bars.contains(bar)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3437 |
d->m_bars << bar; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3438 |
if (d->m_bars.size() == 1) //only start with first animated progressbar |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3439 |
d->startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3440 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3441 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3442 |
case QEvent::Destroy: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3443 |
case QEvent::Hide: |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3444 |
if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(object)) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3445 |
d->stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3446 |
d->m_bars.removeAll(bar); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3447 |
} |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3448 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3449 |
default: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3450 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3451 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3452 |
#endif // QT_NO_PROGRESSBAR |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3453 |
#endif // Q_WS_S60 |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3454 |
return QCommonStyle::eventFilter(object, event); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3455 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3456 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3457 |
/*! |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3458 |
\internal |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
3459 |
Handle the timer \a event. |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3460 |
*/ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3461 |
void QS60Style::timerEvent(QTimerEvent *event) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3462 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3463 |
#ifdef Q_WS_S60 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3464 |
#ifndef QT_NO_PROGRESSBAR |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3465 |
Q_D(QS60Style); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3466 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3467 |
QS60StyleAnimation *progressBarAnimation = |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3468 |
QS60StylePrivate::animationDefinition(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3469 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3470 |
if (event->timerId() == progressBarAnimation->timerId()) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3471 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3472 |
Q_ASSERT(progressBarAnimation->interval() > 0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3473 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3474 |
if (progressBarAnimation->currentFrame() == progressBarAnimation->frameCount() ) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3475 |
if (progressBarAnimation->playMode() == QS60StyleEnums::AM_Looping) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3476 |
progressBarAnimation->setCurrentFrame(0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3477 |
else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3478 |
d->stopAnimation(progressBarAnimation->animationId()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3479 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3480 |
foreach (QProgressBar *bar, d->m_bars) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3481 |
if ((bar->minimum() == 0 && bar->maximum() == 0)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3482 |
bar->update(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3483 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3484 |
progressBarAnimation->setCurrentFrame(progressBarAnimation->currentFrame() + 1); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3485 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3486 |
#endif // QT_NO_PROGRESSBAR |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3487 |
#endif // Q_WS_S60 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3488 |
event->ignore(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3489 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3490 |
|
0 | 3491 |
extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); |
3492 |
||
3493 |
bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) |
|
3494 |
{ |
|
3495 |
const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); |
|
3496 |
if (backgroundTexture.cacheKey() != brush.texture().cacheKey()) |
|
3497 |
return false; |
|
3498 |
||
3499 |
const QPaintDevice *target = painter->device(); |
|
3500 |
if (target->devType() == QInternal::Widget) { |
|
3501 |
const QWidget *widget = static_cast<const QWidget *>(target); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3502 |
if (!widget->testAttribute(Qt::WA_TranslucentBackground)) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3503 |
const QVector<QRect> &rects = rgn.rects(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3504 |
for (int i = 0; i < rects.size(); ++i) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3505 |
const QRect rect(rects.at(i)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3506 |
painter->drawPixmap(rect.topLeft(), backgroundTexture, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3507 |
rect.translated(qt_s60_fill_background_offset(widget))); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3508 |
} |
0 | 3509 |
} |
3510 |
} |
|
3511 |
return true; |
|
3512 |
} |
|
3513 |
||
3514 |
QT_END_NAMESPACE |
|
3515 |
||
3516 |
#endif // QT_NO_STYLE_S60 || QT_PLUGIN |