changeset 5 | 627c4a0fd0e7 |
parent 2 | 06ff229162e9 |
child 21 | 4633027730f5 |
child 34 | ed14f46c0e55 |
3:11d3954df52a | 5:627c4a0fd0e7 |
---|---|
49 |
49 |
50 HbAction extends QAction with support of HbIcon. Future extensions are planned like for |
50 HbAction extends QAction with support of HbIcon. Future extensions are planned like for |
51 instance support of gestures. |
51 instance support of gestures. |
52 |
52 |
53 An action may contain a command role. |
53 An action may contain a command role. |
54 These command roles are used when action is added through HbView::addAction. |
54 These command roles are used when action is added through HbView::addAction. |
55 The command role specifies the action container (options menu, toolbar) |
55 The command role specifies the action container (options menu, toolbar) |
56 to which the action is places and also the position in that container. |
56 to which the action is places and also the position in that container. |
57 \sa QAction::MenuRole |
57 \sa QAction::MenuRole |
58 \sa HbView::addAction |
58 \sa HbView::addAction |
59 |
59 |
60 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,1} |
60 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,1} |
61 |
61 |
64 |
64 |
65 /*! |
65 /*! |
66 \internal |
66 \internal |
67 */ |
67 */ |
68 HbActionPrivate::HbActionPrivate() : menu(0), extension(0) |
68 HbActionPrivate::HbActionPrivate() : menu(0), extension(0) |
69 , commandRole(HbAction::NoRole) |
69 , commandRole(HbAction::NoRole) |
70 { |
70 { |
71 } |
71 } |
72 |
72 |
73 /*! |
73 /*! |
74 \internal |
74 \internal |
105 } |
105 } |
106 |
106 |
107 /*! |
107 /*! |
108 Constructs a new HbAction with the given navigation \a action and \a parent. |
108 Constructs a new HbAction with the given navigation \a action and \a parent. |
109 */ |
109 */ |
110 HbAction::HbAction(Hb::NavigationAction action, QObject* parent) |
110 HbAction::HbAction(Hb::NavigationAction action, QObject *parent) |
111 : QAction(parent), d_ptr(new HbActionPrivate) |
111 : QAction(parent), d_ptr(new HbActionPrivate) |
112 { |
112 { |
113 Q_D(HbAction); |
113 Q_D(HbAction); |
114 switch (action) { |
114 switch (action) { |
115 case Hb::QuitNaviAction: |
115 case Hb::QuitNaviAction: |
116 d->icon = HbIcon("qtg_mono_app_exit"); |
116 d->icon = HbIcon("qtg_mono_app_exit"); |
117 break; |
117 break; |
118 case Hb::BackNaviAction: |
118 case Hb::BackNaviAction: |
119 d->icon = HbIcon("qtg_mono_back"); |
119 d->icon = HbIcon("qtg_mono_back"); |
120 break; |
120 break; |
121 case Hb::ConfirmNaviAction: |
121 case Hb::ConfirmNaviAction: |
122 d->icon = HbIcon("qtg_mono_back"); |
122 d->icon = HbIcon("qtg_mono_back"); |
123 break; |
123 break; |
124 case Hb::DoneNaviAction: |
124 case Hb::DoneNaviAction: |
125 d->icon = HbIcon("qtg_mono_back"); |
125 d->icon = HbIcon("qtg_mono_back"); |
126 break; |
126 break; |
127 default: |
127 default: |
128 qWarning("HbAction: unknown action: %i", action); |
128 qWarning("HbAction: unknown action: %i", action); |
129 break; |
129 break; |
130 } |
130 } |
131 } |
131 } |
132 |
132 |
133 /*! |
133 /*! |
134 Destructs the action. |
134 Destructs the action. |
138 delete d_ptr; |
138 delete d_ptr; |
139 } |
139 } |
140 |
140 |
141 /*! |
141 /*! |
142 Sets the icon of the action. Note that this icon is different from QIcon |
142 Sets the icon of the action. Note that this icon is different from QIcon |
143 setIcon() and icon(). |
143 setIcon() and icon(). |
144 |
144 |
145 \sa icon() |
145 \sa icon() |
146 */ |
146 */ |
147 void HbAction::setIcon(const HbIcon &icon) |
147 void HbAction::setIcon(const HbIcon &icon) |
148 { |
148 { |
163 Q_D(const HbAction); |
163 Q_D(const HbAction); |
164 return d->icon; |
164 return d->icon; |
165 } |
165 } |
166 |
166 |
167 /*! |
167 /*! |
168 Sets the menu of the action. |
168 Sets the menu of the action. |
169 |
169 |
170 \sa menu() |
170 \sa menu() |
171 */ |
171 */ |
172 void HbAction::setMenu(HbMenu *menu) |
172 void HbAction::setMenu(HbMenu *menu) |
173 { |
173 { |
194 \sa toolTip() |
194 \sa toolTip() |
195 */ |
195 */ |
196 void HbAction::setToolTip(const QString &tooltip) |
196 void HbAction::setToolTip(const QString &tooltip) |
197 { |
197 { |
198 Q_D(HbAction); |
198 Q_D(HbAction); |
199 if (d->tooltip == tooltip) |
199 if (d->tooltip == tooltip) { |
200 return; |
200 return; |
201 } |
|
201 |
202 |
202 d->tooltip = tooltip; |
203 d->tooltip = tooltip; |
203 QAction::setToolTip(tooltip); |
204 QAction::setToolTip(tooltip); |
204 } |
205 } |
205 |
206 |
213 Q_D(const HbAction); |
214 Q_D(const HbAction); |
214 return d->tooltip; |
215 return d->tooltip; |
215 } |
216 } |
216 |
217 |
217 /*! |
218 /*! |
218 Sets the toolbar extension of the action. |
219 Sets the toolbar extension of the action. |
219 |
220 |
220 \sa menu() |
221 \sa menu() |
221 */ |
222 */ |
222 void HbAction::setToolBarExtension(HbToolBarExtension *extension) |
223 void HbAction::setToolBarExtension(HbToolBarExtension *extension) |
223 { |
224 { |
240 Q_D(const HbAction); |
241 Q_D(const HbAction); |
241 return d->extension; |
242 return d->extension; |
242 } |
243 } |
243 |
244 |
244 /*! |
245 /*! |
245 Sets the command role identifier of the action. |
246 Sets the command role identifier of the action. |
246 |
247 |
247 \sa commandRole() |
248 \sa commandRole() |
248 */ |
249 */ |
249 void HbAction::setCommandRole(CommandRole commandRole) |
250 void HbAction::setCommandRole(CommandRole commandRole) |
250 { |
251 { |