18 #include <QtGui> |
18 #include <QtGui> |
19 #include <hbstyle.h> |
19 #include <hbstyle.h> |
20 #include <hbframeitem.h> |
20 #include <hbframeitem.h> |
21 #include <hbframedrawer.h> |
21 #include <hbframedrawer.h> |
22 #include "bubblecontainerwidget.h" |
22 #include "bubblecontainerwidget.h" |
23 #include "bubbleprimitives.h" |
|
24 #include "bubblestyleoption.h" |
|
25 |
23 |
26 BubbleContainerWidget::BubbleContainerWidget( |
24 BubbleContainerWidget::BubbleContainerWidget(QGraphicsItem* item) |
27 const QString& stylePluginName, QGraphicsItem* item) |
25 : HbWidget(item), mBackground(0) |
28 : HbWidget(item), mStylePluginName(stylePluginName), |
|
29 mBackground(0) |
|
30 { |
26 { |
31 setPluginBaseId(style()->registerPlugin(mStylePluginName)); |
|
32 Q_ASSERT(pluginBaseId()!=-1); |
|
33 |
|
34 createPrimitives(); |
27 createPrimitives(); |
35 updatePrimitives(); |
28 updatePrimitives(); |
|
29 Q_ASSERT(mBackground); |
36 } |
30 } |
37 |
31 |
38 BubbleContainerWidget::~BubbleContainerWidget() |
32 BubbleContainerWidget::~BubbleContainerWidget() |
39 { |
33 { |
40 style()->unregisterPlugin(mStylePluginName); |
|
41 } |
34 } |
42 |
35 |
43 void BubbleContainerWidget::createPrimitives() |
36 void BubbleContainerWidget::createPrimitives() |
44 { |
37 { |
45 QGraphicsItem *background = style()->createPrimitive( |
38 delete mBackground; |
46 (HbStyle::Primitive)(pluginBaseId()+BP_Bubble_frame), this); |
39 mBackground = new HbFrameItem(this); |
47 style()->setItemName(mBackground, "background"); |
40 style()->setItemName(mBackground, "background"); |
48 |
41 mBackground->setZValue(-1.0); |
49 delete mBackground; |
42 mBackground->setVisible(false); // background in drawn in paint() |
50 mBackground = |
|
51 qgraphicsitem_cast<HbFrameItem*>(background); |
|
52 } |
43 } |
53 |
44 |
54 void BubbleContainerWidget::updatePrimitives() |
45 void BubbleContainerWidget::updatePrimitives() |
55 { |
46 { |
56 if (mBackground) { |
47 mBackground->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
57 BubbleStyleOption option; |
48 mBackground->frameDrawer().setFrameGraphicsName("qtg_fr_list_normal"); |
58 style()->updatePrimitive( |
|
59 mBackground, (HbStyle::Primitive)(pluginBaseId()+BP_Bubble_frame), |
|
60 &option); |
|
61 mBackground->setVisible(false); // background in drawn in paint() |
|
62 } |
|
63 } |
49 } |
64 |
50 |
65 void BubbleContainerWidget::mousePressEvent( |
51 void BubbleContainerWidget::mousePressEvent( |
66 QGraphicsSceneMouseEvent * event) |
52 QGraphicsSceneMouseEvent * event) |
67 { |
53 { |