|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbCore module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBTOOLBUTTON_H |
|
27 #define HBTOOLBUTTON_H |
|
28 |
|
29 #include <hbglobal.h> |
|
30 #include <hbabstractbutton.h> |
|
31 #include <hbicon.h> |
|
32 |
|
33 class HbAction; |
|
34 class HbToolButtonPrivate; |
|
35 class HbStyleOptionToolButton; |
|
36 |
|
37 class HB_CORE_EXPORT HbToolButton : public HbAbstractButton |
|
38 { |
|
39 Q_OBJECT |
|
40 Q_PROPERTY( HbIcon background READ background WRITE setBackground ) |
|
41 Q_PROPERTY( ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle ) |
|
42 Q_ENUMS(ToolButtonStyle) |
|
43 |
|
44 public: |
|
45 enum ToolButtonStyle { |
|
46 ToolButtonIcon = 0x1, |
|
47 ToolButtonText = 0x2, |
|
48 ToolButtonTextAndIcon = 0x3 |
|
49 }; |
|
50 |
|
51 explicit HbToolButton( QGraphicsItem *parent = 0 ); |
|
52 explicit HbToolButton( HbAction *action, QGraphicsItem *parent = 0 ); |
|
53 virtual ~HbToolButton(); |
|
54 |
|
55 HbAction *action() const; |
|
56 void setAction( HbAction *action ); |
|
57 |
|
58 HbIcon background() const; |
|
59 void setBackground( const HbIcon &background ); |
|
60 |
|
61 ToolButtonStyle toolButtonStyle() const; |
|
62 void setToolButtonStyle( ToolButtonStyle style ); |
|
63 |
|
64 QGraphicsItem *primitive( HbStyle::Primitive primitive ) const; |
|
65 |
|
66 enum { Type = Hb::ItemType_ToolButton }; |
|
67 int type() const { return Type; } |
|
68 |
|
69 public slots: |
|
70 void updatePrimitives(); |
|
71 |
|
72 signals: |
|
73 void triggered( HbAction *action ); |
|
74 |
|
75 protected: |
|
76 HbToolButton( HbToolButtonPrivate &dd, QGraphicsItem *parent ); |
|
77 |
|
78 void initStyleOption( HbStyleOptionToolButton *option ) const; |
|
79 void mousePressEvent( QGraphicsSceneMouseEvent *event ); |
|
80 void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ); |
|
81 void resizeEvent( QGraphicsSceneResizeEvent *event ); |
|
82 void nextCheckState(); |
|
83 bool event( QEvent *event ); |
|
84 void polish(HbStyleParameters ¶ms); |
|
85 |
|
86 private: |
|
87 Q_DECLARE_PRIVATE_D( d_ptr, HbToolButton ) |
|
88 Q_DISABLE_COPY(HbToolButton) |
|
89 |
|
90 Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered()) |
|
91 Q_PRIVATE_SLOT(d_func(), void _q_actionChanged()) |
|
92 }; |
|
93 |
|
94 #endif // HBTOOLBUTTON_H |