ginebra2/ActionButton.h
changeset 3 0954f5dd2cd0
parent 0 1450b09d0cfd
child 16 3c88a81ff781
equal deleted inserted replaced
1:b0dd75e285d2 3:0954f5dd2cd0
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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 *
     4 *
     9 * Initial Contributors:
     5 * This program is free software: you can redistribute it and/or modify
    10 * Nokia Corporation - initial contribution.
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
    11 *
     8 *
    12 * Contributors:
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #ifndef __gva_actionbutton_h__
    22 #ifndef __gva_actionbutton_h__
    20 #define __gva_actionbutton_h__
    23 #define __gva_actionbutton_h__
    21 
    24 
    22 #include "NativeChromeItem.h"
    25 #include "NativeChromeItem.h"
    33     public:
    36     public:
    34         ActionButton( ChromeSnippet * snippet, QGraphicsItem * parent = 0 );
    37         ActionButton( ChromeSnippet * snippet, QGraphicsItem * parent = 0 );
    35         virtual ~ActionButton() {};
    38         virtual ~ActionButton() {};
    36         void paint( QPainter * painter, const QStyleOptionGraphicsItem * opt, QWidget * widget );
    39         void paint( QPainter * painter, const QStyleOptionGraphicsItem * opt, QWidget * widget );
    37         void addIcon( const QString & icon, QIcon::Mode mode = QIcon::Normal );
    40         void addIcon( const QString & icon, QIcon::Mode mode = QIcon::Normal );
    38         void setAction ( QAction * action, QEvent::Type triggerOn = QEvent::GraphicsSceneMousePress );
    41         QIcon icon() {return m_icon;}
    39 	void disconnectAction();
    42         void setAction ( QAction * action, bool triggerOnDown = false,  bool triggerOnUp = true);
    40 	void setEnabled(bool);
    43         void setEnabled(bool);
    41 	void setChecked(bool);
    44         void setActive(bool);
    42 	void setInputEvent(QEvent::Type event);
    45         void setActiveOnPress(bool);
    43     public slots:
    46         QAction * defaultAction();
    44 	void onActionChanged();
    47         bool isChecked() {return m_internalAction->isChecked();}
    45 	  //For testing only
    48 
    46 	void onTriggered( bool checked );
    49     public Q_SLOTS:
    47     signals:
    50         void onActionChanged();
    48 	void activated();
    51         void onHidden();
    49         void contextMenuEvent();
    52         void onShown();
       
    53 
       
    54    Q_SIGNALS:
       
    55         void activated();
       
    56 
    50     protected:
    57     protected:
    51 	void mousePressEvent( QGraphicsSceneMouseEvent * ev );
    58         void mousePressEvent( QGraphicsSceneMouseEvent * ev );
    52 	void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev );
    59         void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev );
    53 	void contextMenuEvent( QGraphicsSceneContextMenuEvent * ev );
       
    54     private:
    60     private:
    55         QAction * defaultAction();
       
    56         QAction * m_internalAction;
    61         QAction * m_internalAction;
    57         QIcon m_icon;
    62         QIcon m_icon;
    58 	QEvent::Type m_triggerOn;
    63         bool m_triggerOnUp;
       
    64         bool m_triggerOnDown;
       
    65         QIcon::Mode m_state;
    59         bool m_active;
    66         bool m_active;
    60 	QIcon::Mode m_state;
    67         bool m_activeOnPress;
    61     };
    68     };
    62 } // end of namespace GVA
    69 } // end of namespace GVA
    63 
    70 
    64 #endif // ICONWIDGET_H
    71 #endif // ACTIONBUTTON_H