ginebra2/ActionButton.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
child 5 0f2326c2a325
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __gva_actionbutton_h__
       
    20 #define __gva_actionbutton_h__
       
    21 
       
    22 #include "NativeChromeItem.h"
       
    23 #include "ChromeSnippet.h"
       
    24 #include <QIcon>
       
    25 #include <QImage>
       
    26 
       
    27 namespace GVA {
       
    28 
       
    29 class ActionButton : public NativeChromeItem
       
    30     {
       
    31         Q_OBJECT
       
    32 
       
    33     public:
       
    34         ActionButton( ChromeSnippet * snippet, QGraphicsItem * parent = 0 );
       
    35         virtual ~ActionButton() {};
       
    36         void paint( QPainter * painter, const QStyleOptionGraphicsItem * opt, QWidget * widget );
       
    37         void addIcon( const QString & icon, QIcon::Mode mode = QIcon::Normal );
       
    38         void setAction ( QAction * action, QEvent::Type triggerOn = QEvent::GraphicsSceneMousePress );
       
    39 	void disconnectAction();
       
    40 	void setEnabled(bool);
       
    41 	void setChecked(bool);
       
    42 	void setInputEvent(QEvent::Type event);
       
    43     public slots:
       
    44 	void onActionChanged();
       
    45 	  //For testing only
       
    46 	void onTriggered( bool checked );
       
    47     signals:
       
    48 	void activated();
       
    49         void contextMenuEvent();
       
    50     protected:
       
    51 	void mousePressEvent( QGraphicsSceneMouseEvent * ev );
       
    52 	void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev );
       
    53 	void contextMenuEvent( QGraphicsSceneContextMenuEvent * ev );
       
    54     private:
       
    55         QAction * defaultAction();
       
    56         QAction * m_internalAction;
       
    57         QIcon m_icon;
       
    58 	QEvent::Type m_triggerOn;
       
    59         bool m_active;
       
    60 	QIcon::Mode m_state;
       
    61     };
       
    62 } // end of namespace GVA
       
    63 
       
    64 #endif // ICONWIDGET_H