summaryrefslogtreecommitdiffstats
path: root/graphicstoolbar.cpp
diff options
context:
space:
mode:
authorRoopesh Chander <roop@forwardbias.in>2009-10-22 19:39:25 +0530
committerRoopesh Chander <roop@forwardbias.in>2009-10-22 19:47:23 +0530
commitaafe787b3b69465ff923283c2003bbbec7dc8e95 (patch)
tree081ee058ce1d26869acf29ba46f7e03b392d5073 /graphicstoolbar.cpp
parent5575e4ecb25dabeed04524b0dc6f7eccdd3202d0 (diff)
enable/disable graphics effects for toolbar at runtime
Diffstat (limited to 'graphicstoolbar.cpp')
-rw-r--r--graphicstoolbar.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/graphicstoolbar.cpp b/graphicstoolbar.cpp
index 7f3ca58..e4e0901 100644
--- a/graphicstoolbar.cpp
+++ b/graphicstoolbar.cpp
@@ -3,8 +3,6 @@
#include <QGraphicsDropShadowEffect>
#include "graphicstoolbar.h"
-#define ENABLE_EFFECTS
-
GraphicsToolBar::GraphicsToolBar(QGraphicsScene *scene, QGraphicsItem * parent, Qt::WindowFlags wFlags)
: QGraphicsWidget(parent, wFlags)
, m_scene(scene)
@@ -29,14 +27,24 @@ GraphicsToolBar::GraphicsToolBar(QGraphicsScene *scene, QGraphicsItem * parent,
setOpacity(0.7);
-#ifdef ENABLE_EFFECTS
m_blurEffect = new QGraphicsBlurEffect(this);
m_blurEffect->setProperty("blurRadius", 5);
m_shadowEffect = new QGraphicsDropShadowEffect(this);
m_shadowEffect->setProperty("offset", QPointF(8, 8));
m_shadowEffect->setProperty("blurRadius", 5);
- setGraphicsEffect(m_blurEffect);
-#endif
+ setGraphicsEffectsEnabled(true);
+}
+
+void GraphicsToolBar::setGraphicsEffectsEnabled(bool enabled) {
+ m_isGraphicsEffectsEnabled = enabled;
+ if (!enabled)
+ setGraphicsEffect(0);
+ else
+ setGraphicsEffect(m_blurEffect);
+}
+
+bool GraphicsToolBar::graphicsEffectsEnabled() const {
+ return m_isGraphicsEffectsEnabled;
}
void GraphicsToolBar::addWidget(QWidget *widget) {
@@ -63,20 +71,20 @@ void GraphicsToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
void GraphicsToolBar::hoverEnterEvent(QGraphicsSceneHoverEvent* event) {
Q_UNUSED(event);
setOpacity(0.9);
-#ifdef ENABLE_EFFECTS
- setGraphicsEffect(0); // revoke ownership of existing effect
- setGraphicsEffect(m_shadowEffect); // set new effect
-#endif
+ if (graphicsEffectsEnabled()) {
+ setGraphicsEffect(0); // revoke ownership of existing effect
+ setGraphicsEffect(m_shadowEffect); // set new effect
+ }
update();
}
void GraphicsToolBar::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
Q_UNUSED(event);
setOpacity(0.7);
-#ifdef ENABLE_EFFECTS
- setGraphicsEffect(0); // revoke ownership of existing effect
- setGraphicsEffect(m_blurEffect); // set new effect
-#endif
+ if (graphicsEffectsEnabled()) {
+ setGraphicsEffect(0); // revoke ownership of existing effect
+ setGraphicsEffect(m_blurEffect); // set new effect
+ }
update();
}