20 #include <HbMarqueeItem> |
20 #include <HbMarqueeItem> |
21 #include <HbIconAnimationManager> |
21 #include <HbIconAnimationManager> |
22 #include <HbIconAnimationDefinition> |
22 #include <HbIconAnimationDefinition> |
23 #include <HbColorScheme> |
23 #include <HbColorScheme> |
24 #include <HbStyleLoader> |
24 #include <HbStyleLoader> |
|
25 #include <HbTapGesture> |
|
26 #include <HbEvent> |
25 |
27 |
26 // User includes |
28 // User includes |
27 #include "irhswidgetmetadatarow.h" |
29 #include "irhswidgetmetadatarow.h" |
28 #include "irhswidgetuiloader.h" |
30 #include "irhswidgetuiloader.h" |
29 |
31 |
30 // Constants |
32 // Constants |
31 static const QString KIrHsWidgetMetaDataRowDocML = ":/resource/irhswidgetmetadatarow.docml"; |
33 static const QString KIrHsWidgetMetaDataRowDocML = ":/resource/irhswidgetmetadatarow.docml"; |
32 static const QString KIrHsWidgetMetaDataRowContainer = "metadatarow_layout"; |
34 static const QString KIrHsWidgetMetaDataRowContainer = "metadatarow_layout"; |
|
35 static const QString KIrHsWidgetMetaDataLayout = "metadata_layout"; |
33 static const QString KIrHsWidgetMetaDataLabel = "metadata_label"; |
36 static const QString KIrHsWidgetMetaDataLabel = "metadata_label"; |
|
37 static const QString KNmHsWidgetControlLayout = "control_layout"; |
34 static const QString KNmHsWidgetControlLabel = "control_label"; |
38 static const QString KNmHsWidgetControlLabel = "control_label"; |
35 |
39 |
36 static const QString KPlayButtonIcon = "qtg_mono_play"; |
40 static const QString KPlayButtonIcon = "qtg_mono_play"; |
37 static const QString KStopButtonIcon = "qtg_mono_stop"; |
41 static const QString KStopButtonIcon = "qtg_mono_stop"; |
38 static const QString KMetaDataColor = "qtc_hs_list_item_title"; |
42 static const QString KMetaDataColor = "qtc_hs_list_item_title_normal"; |
|
43 static const QString KControlLabelDataColor = "qtc_hs_list_item_title_normal"; |
|
44 static const QString KIrHsWidgetCss = ":/resource/irhswidget_color.css"; |
39 |
45 |
40 static const QString KLoadingAnimationPrefix = "qtg_anim_loading_"; |
46 static const QString KLoadingAnimationPrefix = "qtg_anim_loading_"; |
41 static const QString KLoadingIconName = "LoadingAnimation"; |
47 static const QString KLoadingIconName = "LoadingAnimation"; |
42 |
48 |
43 static const int KIrHsWidgetContentsMargin = 0; |
49 static const int KIrHsWidgetContentsMargin = 0; |
46 static const int KLoadingAnimationDuration = 100; // duration for frames to construct a animation, unit : ms |
52 static const int KLoadingAnimationDuration = 100; // duration for frames to construct a animation, unit : ms |
47 |
53 |
48 IrHsWidgetMetaDataRow::IrHsWidgetMetaDataRow(QGraphicsItem *aParent, Qt::WindowFlags aFlags) : |
54 IrHsWidgetMetaDataRow::IrHsWidgetMetaDataRow(QGraphicsItem *aParent, Qt::WindowFlags aFlags) : |
49 HbWidget(aParent, aFlags), |
55 HbWidget(aParent, aFlags), |
50 mMetaData(NULL), |
56 mMetaData(NULL), |
|
57 mControlLayout(NULL), |
51 mControlLabel(NULL) |
58 mControlLabel(NULL) |
52 { |
59 { |
|
60 HbStyleLoader::registerFilePath(KIrHsWidgetCss); |
|
61 |
53 loadUi(); |
62 loadUi(); |
54 createLoadingIcon(); |
63 createLoadingIcon(); |
|
64 grabGesture(Qt::TapGesture); |
55 } |
65 } |
56 |
66 |
57 |
67 |
58 IrHsWidgetMetaDataRow::~IrHsWidgetMetaDataRow() |
68 IrHsWidgetMetaDataRow::~IrHsWidgetMetaDataRow() |
59 { |
69 { |
|
70 HbStyleLoader::unregisterFilePath(KIrHsWidgetCss); |
60 } |
71 } |
61 |
72 |
62 void IrHsWidgetMetaDataRow::loadUi() |
73 void IrHsWidgetMetaDataRow::loadUi() |
63 { |
74 { |
64 IRHsWidgetUiLoader loader; |
75 IRHsWidgetUiLoader loader; |
72 |
83 |
73 QGraphicsWidget *container = loader.findWidget(KIrHsWidgetMetaDataRowContainer); |
84 QGraphicsWidget *container = loader.findWidget(KIrHsWidgetMetaDataRowContainer); |
74 layout->addItem(container); |
85 layout->addItem(container); |
75 |
86 |
76 mMetaData = static_cast<HbMarqueeItem*> (loader.findWidget(KIrHsWidgetMetaDataLabel)); |
87 mMetaData = static_cast<HbMarqueeItem*> (loader.findWidget(KIrHsWidgetMetaDataLabel)); |
77 mControlLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetControlLabel)); |
|
78 mMetaData->setTextColor(HbColorScheme::color(KMetaDataColor)); |
88 mMetaData->setTextColor(HbColorScheme::color(KMetaDataColor)); |
79 mMetaData->setLoopCount(-1); |
89 mMetaData->setLoopCount(-1); |
80 |
90 |
81 mMetaData->installEventFilter(this); |
91 mControlLayout = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetControlLayout)); |
82 mControlLabel->installEventFilter(this); |
92 mControlLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetControlLabel)); |
83 } |
93 } |
84 |
94 |
85 void IrHsWidgetMetaDataRow::setMetaData(const QString &aMetaData) |
95 void IrHsWidgetMetaDataRow::setMetaData(const QString &aMetaData) |
86 { |
96 { |
87 if (mMetaData->text() != aMetaData) |
97 if (mMetaData->text() != aMetaData) |
124 void IrHsWidgetMetaDataRow::setLoadingIcon() |
134 void IrHsWidgetMetaDataRow::setLoadingIcon() |
125 { |
135 { |
126 mControlLabel->setIcon(mLoadingIcon); |
136 mControlLabel->setIcon(mLoadingIcon); |
127 } |
137 } |
128 |
138 |
129 bool IrHsWidgetMetaDataRow::eventFilter(QObject *aObject, QEvent *aEvent) |
|
130 { |
|
131 QString objectName = aObject->objectName(); |
|
132 |
|
133 if (QEvent::GraphicsSceneMousePress == aEvent->type()) |
|
134 { |
|
135 |
|
136 if (KIrHsWidgetMetaDataLabel == objectName) |
|
137 { |
|
138 emit metaDataAreaClicked(); |
|
139 } |
|
140 else if (KNmHsWidgetControlLabel == objectName) |
|
141 { |
|
142 emit controlAreaClicked(); |
|
143 } |
|
144 } |
|
145 |
|
146 return false; |
|
147 } |
|
148 |
|
149 void IrHsWidgetMetaDataRow::createLoadingIcon() |
139 void IrHsWidgetMetaDataRow::createLoadingIcon() |
150 { |
140 { |
151 HbIconAnimationManager *animationManager = HbIconAnimationManager::global(); |
141 HbIconAnimationManager *animationManager = HbIconAnimationManager::global(); |
152 HbIconAnimationDefinition animationDefinition; |
142 HbIconAnimationDefinition animationDefinition; |
153 HbIconAnimationDefinition::AnimationFrame animationFrame; |
143 HbIconAnimationDefinition::AnimationFrame animationFrame; |
167 animationDefinition.setFrameList(animationFrameList); |
157 animationDefinition.setFrameList(animationFrameList); |
168 animationManager->addDefinition(KLoadingIconName, animationDefinition); |
158 animationManager->addDefinition(KLoadingIconName, animationDefinition); |
169 |
159 |
170 mLoadingIcon.setIconName(KLoadingIconName); |
160 mLoadingIcon.setIconName(KLoadingIconName); |
171 } |
161 } |
|
162 |
|
163 void IrHsWidgetMetaDataRow::gestureEvent(QGestureEvent *aEvent) |
|
164 { |
|
165 HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(aEvent->gesture(Qt::TapGesture)); |
|
166 if (!tapGesture) |
|
167 { |
|
168 return; |
|
169 } |
|
170 |
|
171 if (Qt::GestureFinished == tapGesture->state() |
|
172 && HbTapGesture::Tap == tapGesture->tapStyleHint()) |
|
173 { |
|
174 QPointF tapScenePoint = tapGesture->scenePosition(); |
|
175 QPointF tapLocalPoint = mControlLayout->sceneTransform().inverted().map(tapScenePoint); |
|
176 if (mControlLayout->contains(tapLocalPoint)) |
|
177 { |
|
178 emit controlAreaClicked(); |
|
179 } |
|
180 else |
|
181 { |
|
182 emit metaDataAreaClicked(); |
|
183 } |
|
184 } |
|
185 } |
|
186 |
|
187 //Implemented to receive theme change event |
|
188 //@param QEvent, The change events to be received |
|
189 // |
|
190 void IrHsWidgetMetaDataRow::changeEvent(QEvent *event) |
|
191 { |
|
192 if (HbEvent::ThemeChanged == event->type()) |
|
193 { |
|
194 // get the text color from theme and |
|
195 // set it to meta data and control label |
|
196 mMetaData->setTextColor(HbColorScheme::color(KMetaDataColor)); |
|
197 } |
|
198 |
|
199 HbWidget::changeEvent(event); |
|
200 } |