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