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