equal
deleted
inserted
replaced
125 |
125 |
126 HbEffectPrivate::~HbEffectPrivate() |
126 HbEffectPrivate::~HbEffectPrivate() |
127 { |
127 { |
128 privateDestroyed = true; |
128 privateDestroyed = true; |
129 mDisabledItems.clear(); |
129 mDisabledItems.clear(); |
|
130 // Delete all remaining animated item groups |
|
131 HbAnimatedItemGroup *itemGroup = 0; |
|
132 while (mAnimatedItemGroups.count()) { |
|
133 itemGroup = mAnimatedItemGroups.first(); |
|
134 animatedItemGroupFinished(itemGroup); |
|
135 } |
130 } |
136 } |
131 |
137 |
132 void HbEffectPrivate::connectViewChanges() |
138 void HbEffectPrivate::connectViewChanges() |
133 { |
139 { |
134 // Connect to view change signals if not done yet |
140 // Connect to view change signals if not done yet |
139 connect(window, SIGNAL(currentViewChanged(HbView *)), SLOT(handleViewChanged(HbView *))); |
145 connect(window, SIGNAL(currentViewChanged(HbView *)), SLOT(handleViewChanged(HbView *))); |
140 } |
146 } |
141 // Need a notification when a mainwindow is added in the future. |
147 // Need a notification when a mainwindow is added in the future. |
142 connect(HbInstancePrivate::d_ptr(), SIGNAL(windowAdded(HbMainWindow *)), SLOT(handleWindowAdded(HbMainWindow *))); |
148 connect(HbInstancePrivate::d_ptr(), SIGNAL(windowAdded(HbMainWindow *)), SLOT(handleWindowAdded(HbMainWindow *))); |
143 } |
149 } |
|
150 } |
|
151 |
|
152 void HbEffectPrivate::addAnimatedItemGroup(HbAnimatedItemGroup *newGroup) |
|
153 { |
|
154 // Let HbEffectPrivate handle the deletion of animated item group |
|
155 connect(newGroup, SIGNAL(finished(HbAnimatedItemGroup *)), |
|
156 this, SLOT(animatedItemGroupFinished(HbAnimatedItemGroup *))); |
|
157 mAnimatedItemGroups.append(newGroup); |
144 } |
158 } |
145 |
159 |
146 void HbEffectPrivate::handleWindowAdded(HbMainWindow *window) |
160 void HbEffectPrivate::handleWindowAdded(HbMainWindow *window) |
147 { |
161 { |
148 connect(window, SIGNAL(currentViewChanged(HbView *)), SLOT(handleViewChanged(HbView *))); |
162 connect(window, SIGNAL(currentViewChanged(HbView *)), SLOT(handleViewChanged(HbView *))); |
189 } |
203 } |
190 } |
204 } |
191 } |
205 } |
192 } |
206 } |
193 |
207 |
|
208 void HbEffectPrivate::animatedItemGroupFinished(HbAnimatedItemGroup *itemGroup) |
|
209 { |
|
210 // Called when animated item group is finished - delete later and remove from register |
|
211 if (itemGroup) { |
|
212 int itemIndex = mAnimatedItemGroups.indexOf(itemGroup); |
|
213 if (itemIndex >= 0) { |
|
214 itemGroup->deleteLater(); |
|
215 itemGroup = 0; |
|
216 mAnimatedItemGroups.removeAt(itemIndex); |
|
217 } |
|
218 } |
|
219 } |
194 |
220 |
195 HbAnimatedItemGroup::HbAnimatedItemGroup( |
221 HbAnimatedItemGroup::HbAnimatedItemGroup( |
196 const QList<QGraphicsItem *> &items, |
222 const QList<QGraphicsItem *> &items, |
197 QObject *receiver, |
223 QObject *receiver, |
198 const char *member, |
224 const char *member, |
205 mUserData(userData) |
231 mUserData(userData) |
206 { |
232 { |
207 // Need information of receiver destroyed because this class gets |
233 // Need information of receiver destroyed because this class gets |
208 // the notifications asynchronously so it must not invoke the |
234 // the notifications asynchronously so it must not invoke the |
209 // receiver if it has been destroyed meanwhile. |
235 // receiver if it has been destroyed meanwhile. |
210 connect(mReceiver, SIGNAL(destroyed()), this, SLOT(receiverDestroyed())); |
236 if (mReceiver) { |
|
237 connect(mReceiver, SIGNAL(destroyed()), this, SLOT(receiverDestroyed())); |
|
238 } |
211 } |
239 } |
212 |
240 |
213 void HbAnimatedItemGroup::finished(const HbEffect::EffectStatus &status) |
241 void HbAnimatedItemGroup::finished(const HbEffect::EffectStatus &status) |
214 { |
242 { |
215 if (++mFinishedCount == mItems.count()) { |
243 if (++mFinishedCount == mItems.count()) { |
219 mFunction.toAscii().data(), |
247 mFunction.toAscii().data(), |
220 Qt::AutoConnection, |
248 Qt::AutoConnection, |
221 QGenericReturnArgument(), |
249 QGenericReturnArgument(), |
222 Q_ARG(HbEffect::EffectStatus, status)); |
250 Q_ARG(HbEffect::EffectStatus, status)); |
223 } |
251 } |
224 // We are done, delete self. |
252 // We are done, notify owner |
225 deleteLater(); |
253 emit finished(this); |
226 } |
254 } |
227 } |
255 } |
228 |
256 |
229 void HbAnimatedItemGroup::receiverDestroyed() |
257 void HbAnimatedItemGroup::receiverDestroyed() |
230 { |
258 { |
738 } |
766 } |
739 |
767 |
740 // Connect to view changes if not done yet |
768 // Connect to view changes if not done yet |
741 d.connectViewChanges(); |
769 d.connectViewChanges(); |
742 |
770 |
743 // This object deletes itself when the effect has finished. |
|
744 HbAnimatedItemGroup *group = new HbAnimatedItemGroup(items, receiver, member, userData); |
771 HbAnimatedItemGroup *group = new HbAnimatedItemGroup(items, receiver, member, userData); |
|
772 d.addAnimatedItemGroup(group); |
745 |
773 |
746 bool ret = false; |
774 bool ret = false; |
747 |
775 |
748 QObject *groupReceiver = 0; |
776 QObject *groupReceiver = 0; |
749 const char *groupMember = ""; |
777 const char *groupMember = ""; |
1053 } |
1081 } |
1054 |
1082 |
1055 /*! |
1083 /*! |
1056 \internal |
1084 \internal |
1057 */ |
1085 */ |
|
1086 bool HbEffectInternal::add(const char *itemType[], const char *filePath[], const char *effectEvent[], int count) |
|
1087 { |
|
1088 #ifdef HB_EFFECT_API_OFF |
|
1089 Q_UNUSED(itemType); |
|
1090 Q_UNUSED(filePath); |
|
1091 Q_UNUSED(effectEvent); |
|
1092 return false; |
|
1093 #else |
|
1094 bool ret = false; |
|
1095 // Try to add all the files, stop when one fails. |
|
1096 for (int i = 0; i < count; ++i) { |
|
1097 ret = add(QLatin1String(itemType[i]), QLatin1String(filePath[i]), !effectEvent ? QString() : QLatin1String(effectEvent[i])); |
|
1098 if (!ret) { |
|
1099 break; |
|
1100 } |
|
1101 } |
|
1102 // If any of the files were not added then remove all the others too. |
|
1103 if (!ret) { |
|
1104 for (int i = 0; i < count; ++i) { |
|
1105 remove(QLatin1String(itemType[i]), QLatin1String(filePath[i]), !effectEvent ? QString() : QLatin1String(effectEvent[i])); |
|
1106 } |
|
1107 } |
|
1108 return ret; |
|
1109 #endif // HB_EFFECT_API_OFF |
|
1110 } |
|
1111 |
|
1112 /*! |
|
1113 \internal |
|
1114 */ |
1058 bool HbEffectInternal::add(QGraphicsItem *item, const QString &filePath, const QString &effectEvent) |
1115 bool HbEffectInternal::add(QGraphicsItem *item, const QString &filePath, const QString &effectEvent) |
1059 { |
1116 { |
1060 #ifdef HB_EFFECT_API_OFF |
1117 #ifdef HB_EFFECT_API_OFF |
1061 Q_UNUSED(item); |
1118 Q_UNUSED(item); |
1062 Q_UNUSED(filePath); |
1119 Q_UNUSED(filePath); |