22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbprogresssliderhandle_p.h" |
26 #include "hbprogresssliderhandle_p.h" |
|
27 #include "hbstyle_p.h" |
27 #include <hbtooltip.h> |
28 #include <hbtooltip.h> |
28 #include <hbstyleoptionprogresssliderhandle_p.h> |
29 #include <hbstyleoptionprogresssliderhandle_p.h> |
29 #include <hbextendedlocale.h> |
30 #include <hbextendedlocale.h> |
30 #include <QGraphicsSceneMouseEvent> |
31 #include <QGraphicsSceneMouseEvent> |
31 |
32 |
60 mHandleIcon() |
61 mHandleIcon() |
61 { |
62 { |
62 mFlags = 0; |
63 mFlags = 0; |
63 mFlags |= TextVisible; |
64 mFlags |= TextVisible; |
64 |
65 |
65 HbStyle *style = static_cast<HbStyle*>(q->style()); |
66 mHandleIconItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ProgressSliderHandle_icon,this); |
66 |
|
67 mHandleIconItem = style->createPrimitive(HbStyle::P_ProgressSliderHandle_icon,this); |
|
68 HbStyle::setItemName(mHandleIconItem , "icon"); |
67 HbStyle::setItemName(mHandleIconItem , "icon"); |
69 |
68 |
70 mTouchItem = style->createPrimitive(HbStyle::P_ProgressSliderHandle_toucharea, this); |
69 mTouchItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ProgressSliderHandle_toucharea, this); |
71 HbStyle::setItemName(mTouchItem , "toucharea"); |
70 HbStyle::setItemName(mTouchItem , "toucharea"); |
72 setProperty("state","normal"); |
71 setProperty("state","normal"); |
73 |
72 |
74 #ifdef HB_EFFECTS |
73 #ifdef HB_EFFECTS |
75 HbEffectInternal::add(HB_PRGRESSSLIDERHANDLE_ITEM_TYPE,"progressslider_handlepress", "progressslider_handlepress"); |
74 HbEffectInternal::add(HB_PRGRESSSLIDERHANDLE_ITEM_TYPE,"progressslider_handlepress", "progressslider_handlepress"); |
92 { |
91 { |
93 } |
92 } |
94 |
93 |
95 void HbProgressSliderHandle::setHandleIcon(const HbIcon& icon) |
94 void HbProgressSliderHandle::setHandleIcon(const HbIcon& icon) |
96 { |
95 { |
97 if(icon.isNull()) { |
|
98 return; |
|
99 } |
|
100 HbStyle *style = qobject_cast<HbStyle*>(q->style()); |
|
101 mHandleIcon= icon; |
96 mHandleIcon= icon; |
102 |
97 |
103 HbStyleOptionProgressSliderHandle option; |
98 HbStyleOptionProgressSliderHandle option; |
104 initStyleOption(&option); |
99 initStyleOption(&option); |
105 |
100 |
106 style->updatePrimitive(mHandleIconItem, HbStyle::P_ProgressSliderHandle_icon, &option); |
101 HbStylePrivate::updatePrimitive(mHandleIconItem, HbStylePrivate::P_ProgressSliderHandle_icon, &option); |
107 } |
102 } |
108 |
103 |
109 |
104 |
110 void HbProgressSliderHandle::gestureEvent(QGestureEvent *event) |
105 void HbProgressSliderHandle::gestureEvent(QGestureEvent *event) |
111 { |
106 { |
124 |
119 |
125 HbStyleOptionProgressSliderHandle option; |
120 HbStyleOptionProgressSliderHandle option; |
126 initStyleOption(&option); |
121 initStyleOption(&option); |
127 option.pressedState = true; |
122 option.pressedState = true; |
128 if (mHandleIconItem) { |
123 if (mHandleIconItem) { |
129 style()->updatePrimitive(mHandleIconItem, HbStyle::P_ProgressSliderHandle_icon, &option); |
124 HbStylePrivate::updatePrimitive(mHandleIconItem, HbStylePrivate::P_ProgressSliderHandle_icon, &option); |
130 } |
125 } |
131 |
126 |
132 mMousePressPos = event->scenePos(); |
127 mMousePressPos = event->scenePos(); |
133 mItemPosAtPress = pos(); |
128 mItemPosAtPress = pos(); |
134 |
129 |
135 HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantPressed, Hb::ModifierSliderHandle); |
130 HbWidgetFeedback::triggered(q->parentGraphicsWidget(), Hb::InstantPressed, Hb::ModifierSliderHandle); |
136 |
131 |
137 event->accept(); |
132 event->accept(); |
138 q->emitSliderPressed(); |
133 q->emitSliderPressed(); |
139 |
134 |
140 if(q->textVisible()) { |
135 if(q->textVisible()) { // User called it |
141 HbToolTip::showText(q->toolTipText(),this, QRectF(mItemPosAtPress,QSize(0,0)),q->textAlignment()); |
136 if(!q->toolTipText().isNull()) { |
142 } |
137 HbToolTip::showText(q->toolTipText(),this, QRectF(mItemPosAtPress,QSize(0,0)),q->textAlignment()); |
143 else { |
138 } |
144 HbExtendedLocale locale; |
139 } |
145 HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget(); |
140 else { // show default |
146 HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment()); |
141 |
147 } |
142 HbExtendedLocale locale; |
148 |
143 HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget(); |
|
144 HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment()); |
|
145 |
|
146 } |
149 } |
147 } |
150 |
148 |
151 void HbProgressSliderHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
149 void HbProgressSliderHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
152 { |
150 { |
153 HbWidget::mouseReleaseEvent(event); |
151 HbWidget::mouseReleaseEvent(event); |
154 |
152 |
155 HbStyleOptionProgressSliderHandle option; |
153 HbStyleOptionProgressSliderHandle option; |
156 initStyleOption(&option); |
154 initStyleOption(&option); |
157 option.pressedState = false; |
155 option.pressedState = false; |
158 if (mHandleIconItem) { |
156 if (mHandleIconItem) { |
159 style()->updatePrimitive(mHandleIconItem, HbStyle::P_ProgressSliderHandle_icon, &option); |
157 HbStylePrivate::updatePrimitive(mHandleIconItem, HbStylePrivate::P_ProgressSliderHandle_icon, &option); |
160 } |
158 } |
161 |
159 |
162 if (isHandleMoving()) { |
160 if (isHandleMoving()) { |
163 HbWidgetFeedback::continuousStopped(q->parentGraphicsWidget(), Hb::ContinuousDragged); |
161 HbWidgetFeedback::continuousStopped(q->parentGraphicsWidget(), Hb::ContinuousDragged); |
164 } |
162 } |
222 |
220 |
223 event->accept(); |
221 event->accept(); |
224 |
222 |
225 q->emitSliderMoved(pointToValue(mItemCurPos)); |
223 q->emitSliderMoved(pointToValue(mItemCurPos)); |
226 |
224 |
227 if(q->textVisible()) { |
225 if(q->textVisible()) { // User called it |
228 HbToolTip::showText(q->toolTipText(),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment()); |
226 if(q->toolTipText().isNull()) { |
229 } |
227 |
230 else { |
228 // Dont show any tooltip. |
231 HbExtendedLocale locale; |
229 |
232 HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget(); |
230 } |
233 HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment()); |
231 else { |
234 } |
232 |
|
233 HbToolTip::showText(q->toolTipText(),this, QRectF(mItemPosAtPress,QSize(0,0)),q->textAlignment()); |
|
234 |
|
235 } |
|
236 } |
|
237 else { // show default |
|
238 |
|
239 HbExtendedLocale locale; |
|
240 HbProgressSlider *slider = (HbProgressSlider*)q->parentGraphicsWidget(); |
|
241 HbToolTip::showText(locale.toString(slider->sliderValue()),this, QRectF(mItemCurPos,QSize(0,0)),q->textAlignment()); |
|
242 |
|
243 } |
235 } |
244 } |
236 |
245 |
237 int HbProgressSliderHandle::pointToValue(QPointF point) const |
246 int HbProgressSliderHandle::pointToValue(QPointF point) const |
238 { |
247 { |
239 QRectF rect = q->boundingRect(); |
248 QRectF rect = q->boundingRect(); |