33 #include "hbaction_p.h" |
33 #include "hbaction_p.h" |
34 #include <hbglobal.h> |
34 #include <hbglobal.h> |
35 #include "hbcolorscheme.h" |
35 #include "hbcolorscheme.h" |
36 #include "hbtextitem.h" |
36 #include "hbtextitem.h" |
37 #include "hbiconitem.h" |
37 #include "hbiconitem.h" |
|
38 #include "hbview.h" |
|
39 #include "hbmainwindow.h" |
|
40 |
|
41 #include "hbglobal_p.h" // remove when removing HB_DEPRECATED |
38 |
42 |
39 #include <QGraphicsSceneHelpEvent> |
43 #include <QGraphicsSceneHelpEvent> |
40 #include <QGraphicsSceneMouseEvent> |
44 #include <QGraphicsSceneMouseEvent> |
41 |
45 |
42 /*! |
46 /*! |
75 \sa HbAction, HbPushButton |
79 \sa HbAction, HbPushButton |
76 */ |
80 */ |
77 |
81 |
78 /*! |
82 /*! |
79 \enum HbToolButton::ToolButtonStyle |
83 \enum HbToolButton::ToolButtonStyle |
|
84 \deprecated HbToolButton::ToolButtonStyle |
80 |
85 |
81 This enum defines available tool button styles. |
86 This enum defines available tool button styles. |
82 |
87 |
83 The tool button style describes how the button's text and icon should be displayed. |
88 The tool button style describes how the button's text and icon should be displayed. |
84 */ |
89 */ |
85 |
90 |
86 /*! |
91 /*! |
87 \var HbToolButton::ToolButtonIcon |
92 \var HbToolButton::ToolButtonIcon |
|
93 \deprecated HbToolButton::ToolButtonIcon |
88 |
94 |
89 Only display the icon. |
95 Only display the icon. |
90 */ |
96 */ |
91 |
97 |
92 /*! |
98 /*! |
93 \var HbToolButton::ToolButtonText |
99 \var HbToolButton::ToolButtonText |
|
100 \deprecated HbToolButton::ToolButtonText |
94 |
101 |
95 Only display the text. |
102 Only display the text. |
96 */ |
103 */ |
97 |
104 |
98 /*! |
105 /*! |
99 \var HbToolButton::ToolButtonTextAndIcon |
106 \var HbToolButton::ToolButtonTextAndIcon |
|
107 \deprecated HbToolButton::ToolButtonTextAndIcon |
100 |
108 |
101 Display both text and icon. |
109 Display both text and icon. |
102 */ |
110 */ |
103 |
111 |
104 /*! |
112 /*! |
121 backgroundVisible(true), |
129 backgroundVisible(true), |
122 buttonStyle(HbToolButton::ToolButtonIcon), |
130 buttonStyle(HbToolButton::ToolButtonIcon), |
123 toolBarPosition(HbStyleOptionToolButton::TB_None), |
131 toolBarPosition(HbStyleOptionToolButton::TB_None), |
124 orientation(Qt::Vertical), |
132 orientation(Qt::Vertical), |
125 mDialogToolBar(false), |
133 mDialogToolBar(false), |
|
134 toolbarExtensionFrame(false), |
126 mButtonSize(QSizeF()) |
135 mButtonSize(QSizeF()) |
127 { |
136 { |
128 } |
137 } |
129 |
138 |
130 HbToolButtonPrivate::~HbToolButtonPrivate() |
139 HbToolButtonPrivate::~HbToolButtonPrivate() |
185 // to work for all cases |
193 // to work for all cases |
186 if (q->isVisible() && polished) { |
194 if (q->isVisible() && polished) { |
187 q->updatePrimitives(); |
195 q->updatePrimitives(); |
188 } |
196 } |
189 } |
197 } |
|
198 } |
|
199 |
|
200 void HbToolButtonPrivate::setExtensionBackgroundVisible(bool visible) |
|
201 { |
|
202 Q_Q(HbToolButton); |
|
203 if (toolbarExtensionFrame != visible) { |
|
204 toolbarExtensionFrame = visible; |
|
205 // required to make extension orientation switch from |
|
206 // landscape to portrait work correctly with automatic more |
|
207 // extension. |
|
208 q->repolish(); |
|
209 } |
190 } |
210 } |
191 |
211 |
192 void HbToolButtonPrivate::setBackgroundVisible(bool visible) |
212 void HbToolButtonPrivate::setBackgroundVisible(bool visible) |
193 { |
213 { |
194 Q_Q(HbToolButton); |
214 Q_Q(HbToolButton); |
354 updatePrimitives(); |
374 updatePrimitives(); |
355 } |
375 } |
356 } |
376 } |
357 |
377 |
358 /*! |
378 /*! |
|
379 \deprecated HbToolButton::toolButtonStyle() const |
|
380 is deprecated. |
|
381 |
359 @beta |
382 @beta |
360 Returns the tool button style. |
383 Returns the tool button style. |
361 |
384 |
362 The default value is \b HbToolButton::ToolButtonIcon. |
385 The default value is \b HbToolButton::ToolButtonIcon. |
363 |
386 |
364 \sa setToolButtonStyle() |
387 \sa setToolButtonStyle() |
365 */ |
388 */ |
366 HbToolButton::ToolButtonStyle HbToolButton::toolButtonStyle() const |
389 HbToolButton::ToolButtonStyle HbToolButton::toolButtonStyle() const |
367 { |
390 { |
|
391 HB_DEPRECATED("HbToolButton::toolButtonStyle() is deprecated."); |
|
392 |
368 Q_D(const HbToolButton); |
393 Q_D(const HbToolButton); |
369 return d->buttonStyle; |
394 return d->buttonStyle; |
370 } |
395 } |
371 |
396 |
372 /*! |
397 /*! |
|
398 \deprecated HbToolButton::setToolButtonStyle(HbToolButton::ToolButtonStyle) |
|
399 is deprecated. |
|
400 |
373 @beta |
401 @beta |
374 Sets the tool button style. |
402 Sets the tool button style. |
375 |
403 |
376 \sa toolButtonStyle() |
404 \sa toolButtonStyle() |
377 */ |
405 */ |
378 void HbToolButton::setToolButtonStyle(HbToolButton::ToolButtonStyle style) |
406 void HbToolButton::setToolButtonStyle(HbToolButton::ToolButtonStyle style) |
379 { |
407 { |
|
408 HB_DEPRECATED("HbToolButton::setToolButtonStyle(HbToolButton::ToolButtonStyle style) is deprecated."); |
|
409 |
380 Q_D(HbToolButton); |
410 Q_D(HbToolButton); |
381 if (d->buttonStyle != style) { |
411 if (d->buttonStyle != style) { |
382 d->buttonStyle = style; |
412 d->buttonStyle = style; |
383 |
413 |
384 // action text/icon may have changed, |
414 // action text/icon may have changed, |
447 /*! |
481 /*! |
448 Initializes \a option with the values from this HbToolButton. This method is useful for |
482 Initializes \a option with the values from this HbToolButton. This method is useful for |
449 subclasses when they need a HbStyleOptionToolButton, but don't want to fill in all the |
483 subclasses when they need a HbStyleOptionToolButton, but don't want to fill in all the |
450 information themselves. |
484 information themselves. |
451 */ |
485 */ |
452 void HbToolButton::initStyleOption(HbStyleOptionToolButton *option) const |
486 void HbToolButton::initStyleOption(HbStyleOptionToolButton *option) |
453 { |
487 { |
454 Q_D(const HbToolButton); |
488 Q_D(HbToolButton); |
455 HbAbstractButton::initStyleOption(option); |
489 HbAbstractButton::initStyleOption(option); |
456 |
490 |
457 Q_ASSERT(option); |
491 Q_ASSERT(option); |
458 option->customBackground = d->customBackground; |
492 option->customBackground = d->customBackground; |
459 option->backgroundVisible = d->backgroundVisible; |
493 option->backgroundVisible = d->backgroundVisible; |
460 option->toolBarPosition = d->toolBarPosition; |
494 option->toolBarPosition = d->toolBarPosition; |
461 option->orientation = d->orientation; |
495 option->orientation = d->orientation; |
462 option->isCheckable = d->checkable; |
496 option->isCheckable = d->checkable; |
463 option->useSecondaryGraphics = d->mDialogToolBar; |
497 option->useSecondaryGraphics = d->mDialogToolBar; |
|
498 option->useTransparentGraphics = false; |
|
499 if (mainWindow() && mainWindow()->currentView()) { |
|
500 if (mainWindow()->currentView()->viewFlags() & HbView::ViewTitleBarTransparent) { |
|
501 option->useTransparentGraphics = true; |
|
502 } |
|
503 } |
464 |
504 |
465 if (d->action) { |
505 if (d->action) { |
466 option->text = d->action->text(); |
506 option->text = d->action->text(); |
467 option->icon = d->action->icon(); |
507 option->icon = d->action->icon(); |
|
508 option->isToolBarExtension = d->toolbarExtensionFrame; |
468 } |
509 } |
469 } |
510 } |
470 |
511 |
471 /*! |
512 /*! |
472 \internal |
513 \internal |
492 } |
533 } |
493 |
534 |
494 /*! |
535 /*! |
495 \reimp |
536 \reimp |
496 */ |
537 */ |
497 void HbToolButton::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
498 { |
|
499 HbAbstractButton::mousePressEvent(event); |
|
500 setProperty("state", "pressed"); |
|
501 updatePrimitives(); |
|
502 } |
|
503 |
|
504 /*! |
|
505 \reimp |
|
506 */ |
|
507 void HbToolButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
508 { |
|
509 HbAbstractButton::mouseReleaseEvent(event); |
|
510 setProperty("state", "normal"); |
|
511 updatePrimitives(); |
|
512 } |
|
513 |
|
514 /*! |
|
515 \reimp |
|
516 */ |
|
517 void HbToolButton::nextCheckState() |
538 void HbToolButton::nextCheckState() |
518 { |
539 { |
519 Q_D(HbToolButton); |
540 Q_D(HbToolButton); |
520 HbAbstractButton::nextCheckState(); |
541 HbAbstractButton::nextCheckState(); |
521 if (!d->action) { |
542 if (!d->action) { |
530 } |
551 } |
531 |
552 |
532 /*! |
553 /*! |
533 \reimp |
554 \reimp |
534 */ |
555 */ |
|
556 bool HbToolButton::sceneEvent(QEvent *event) |
|
557 { |
|
558 if (event->type() == QEvent::GraphicsSceneHelp) { |
|
559 Q_D(HbToolButton); |
|
560 // Check whether toolbutton is inside a toolbar. |
|
561 if (d->toolBarPosition != HbStyleOptionToolButton::TB_None) { |
|
562 d->showToolTip(); |
|
563 event->accept(); |
|
564 return true; |
|
565 } |
|
566 } |
|
567 return HbAbstractButton::sceneEvent(event); |
|
568 } |
|
569 |
|
570 /*! |
|
571 \reimp |
|
572 */ |
535 bool HbToolButton::event(QEvent *event) |
573 bool HbToolButton::event(QEvent *event) |
536 { |
574 { |
537 if (event) { |
575 if (event->type() == QEvent::GraphicsSceneMouseRelease) { |
538 switch (event->type()) { |
576 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(event)); |
539 case QEvent::GraphicsSceneMouseRelease: { |
577 return true; |
540 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(event)); |
|
541 return true; |
|
542 } |
|
543 case QEvent::GraphicsSceneHelp: { |
|
544 Q_D(HbToolButton); |
|
545 // Check whether toolbutton is inside a toolbar. |
|
546 if (d->toolBarPosition != HbStyleOptionToolButton::TB_None) { |
|
547 d->showToolTip(); |
|
548 event->accept(); |
|
549 return true; |
|
550 } |
|
551 } |
|
552 break; |
|
553 |
|
554 default: break; |
|
555 } |
|
556 } |
578 } |
557 |
579 |
558 return HbAbstractButton::event(event); |
580 return HbAbstractButton::event(event); |
559 } |
581 } |
560 |
582 |