Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
toolbutton.h
Go to the documentation of this file.
1 
8 #ifndef TOOLBUTTON_H_
9 #define TOOLBUTTON_H_
10 
11 #include <QToolButton>
12 
14 
15 class QWidget;
16 class CAMainWin;
17 
18 class CAToolButton : public QToolButton {
19  Q_OBJECT
20 public:
21  CAToolButton( QWidget *parent );
22  virtual ~CAToolButton();
23  inline int currentId() { return _currentId; }
24  virtual void setCurrentId(int id) { _currentId = id; }
25  inline bool buttonsVisible() { return (_popupWidget) ? _popupWidget->isVisible() : 0; } // Is the popup widget visible or not
26  void setDefaultAction( QAction* );
27  virtual void showButtons();
28  virtual void hideButtons();
29 
30 private slots:
31  void handleToggled( bool checked );
32  void handleTriggered();
33 
34 signals:
35  void toggled( bool checked, int id );
36 
37 protected:
38  inline CAMainWin *mainWin() { return _mainWin; }
39  inline void setMainWin( CAMainWin *m ) { _mainWin = m; }
40  inline void setPopupWidget(QWidget* w) { _popupWidget->setWidget(w); }
41  virtual void wheelEvent(QWheelEvent*) = 0;
42  void mousePressEvent( QMouseEvent* );
43  QPoint calculateTopLeft( QSize widgetSize );
44 
45  CAMainWin *_mainWin; // Pointer to the main window for toolbar location polling etc.
46  int _currentId; // current ID of the button
47  CAToolButtonPopup *_popupWidget; // container for the floating widget
48 };
49 
50 #endif /* TOOLBUTTON_H_ */