##// END OF EJS Templates
Tuned drop shadow effect
Tero Ahola -
r1014:3f26deedec78
parent child
Show More
1 NO CONTENT: modified file, binary diff hidden
@@ -1,91 +1,99
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "chartbackground_p.h"
22 22 #include "chartconfig_p.h"
23 23 #include <QPen>
24 24 #include <QBrush>
25 25 #include <QPainter>
26 26 #include <QGraphicsDropShadowEffect>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 ChartBackground::ChartBackground(QGraphicsItem* parent) :
31 31 QGraphicsRectItem(parent),
32 32 m_diameter(15),
33 33 m_dropShadow(0)
34 34 {
35 35 }
36 36
37 37 ChartBackground::~ChartBackground()
38 38 {
39 39
40 40 }
41 41
42 42 void ChartBackground::setDropShadowEnabled(bool enabled)
43 43 {
44 44 if (enabled) {
45 45 if (!m_dropShadow) {
46 46 m_dropShadow = new QGraphicsDropShadowEffect();
47 #ifdef Q_OS_MAC
48 m_dropShadow->setBlurRadius(15);
49 m_dropShadow->setOffset(0, 0);
50 #elif defined(Q_OS_WIN)
51 m_dropShadow->setBlurRadius(10);
52 m_dropShadow->setOffset(0, 0);
53 #else
47 54 m_dropShadow->setBlurRadius(10);
48 55 m_dropShadow->setOffset(5, 5);
56 #endif
49 57 setGraphicsEffect(m_dropShadow);
50 58 }
51 59 } else {
52 60 delete m_dropShadow;
53 61 m_dropShadow = 0;
54 62 }
55 63 }
56 64
57 65 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
58 66 {
59 67 Q_UNUSED(option);
60 68 Q_UNUSED(widget);
61 69 painter->save();
62 70 painter->setPen(pen());
63 71 painter->setBrush(brush());
64 72 painter->drawRoundRect(rect(),roundness(rect().width()),roundness(rect().height()));
65 73 #ifndef QT_NO_DEBUG
66 74 painter->setPen(Qt::black);
67 75 QFont font;
68 76 QString build("build %1");
69 77 font.setPointSize(6);
70 78 painter->setFont(font);
71 79 painter->drawText(rect().bottomLeft(),build.arg(ChartConfig::instance()->compilationTime()));
72 80 #endif
73 81 painter->restore();
74 82 }
75 83
76 84 int ChartBackground::roundness(qreal size) const
77 85 {
78 86 return 100*m_diameter/int(size);
79 87 }
80 88
81 89 int ChartBackground::diameter() const
82 90 {
83 91 return m_diameter;
84 92 }
85 93
86 94 void ChartBackground::setDimeter(int dimater)
87 95 {
88 96 m_diameter=dimater;
89 97 }
90 98
91 99 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now