ginebra2/ActionButton.h
changeset 6 1c3b8676e58c
parent 5 0f2326c2a325
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
    37         ActionButton( ChromeSnippet * snippet, QGraphicsItem * parent = 0 );
    37         ActionButton( ChromeSnippet * snippet, QGraphicsItem * parent = 0 );
    38         virtual ~ActionButton() {};
    38         virtual ~ActionButton() {};
    39         void paint( QPainter * painter, const QStyleOptionGraphicsItem * opt, QWidget * widget );
    39         void paint( QPainter * painter, const QStyleOptionGraphicsItem * opt, QWidget * widget );
    40         void addIcon( const QString & icon, QIcon::Mode mode = QIcon::Normal );
    40         void addIcon( const QString & icon, QIcon::Mode mode = QIcon::Normal );
    41         QIcon icon() {return m_icon;}
    41         QIcon icon() {return m_icon;}
    42         void setAction ( QAction * action, QEvent::Type triggerOn = QEvent::GraphicsSceneMouseRelease );
    42         void setAction ( QAction * action, bool triggerOnDown = false,  bool triggerOnUp = true);
    43         void disconnectAction();
       
    44         void setEnabled(bool);
    43         void setEnabled(bool);
    45         void setChecked(bool);
       
    46         void setActive(bool);
    44         void setActive(bool);
    47         void setInputEvent(QEvent::Type event);
    45         void setActiveOnPress(bool);
    48         QAction * defaultAction();
    46         QAction * defaultAction();
    49         bool isChecked() {return m_internalAction->isChecked();}
    47         bool isChecked() {return m_internalAction->isChecked();}
    50 
    48 
    51     public slots:
    49     public Q_SLOTS:
    52         void onActionChanged();
    50         void onActionChanged();
    53         void onHidden();
    51         void onHidden();
    54         void onShown();
    52         void onShown();
    55 
    53 
    56     signals:
    54    Q_SIGNALS:
    57         void activated();
    55         void activated();
    58         void contextMenuEvent();
    56 
    59     protected:
    57     protected:
    60         void mousePressEvent( QGraphicsSceneMouseEvent * ev );
    58         void mousePressEvent( QGraphicsSceneMouseEvent * ev );
    61         void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev );
    59         void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev );
    62         void contextMenuEvent( QGraphicsSceneContextMenuEvent * ev );
       
    63     private:
    60     private:
    64         QAction * m_internalAction;
    61         QAction * m_internalAction;
    65         QIcon m_icon;
    62         QIcon m_icon;
    66         QEvent::Type m_triggerOn;
    63         bool m_triggerOnUp;
       
    64         bool m_triggerOnDown;
    67         QIcon::Mode m_state;
    65         QIcon::Mode m_state;
    68         bool m_active;
    66         bool m_active;
       
    67         bool m_activeOnPress;
    69     };
    68     };
    70 } // end of namespace GVA
    69 } // end of namespace GVA
    71 
    70 
    72 #endif // ACTIONBUTTON_H
    71 #endif // ACTIONBUTTON_H