Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
menutoolbutton.h
Go to the documentation of this file.
1 
8 #ifndef MENUTOOLBUTTON_H_
9 #define MENUTOOLBUTTON_H_
10 
11 #include "widgets/toolbutton.h"
12 #include <QButtonGroup>
13 #include <QGroupBox>
14 #include <QGridLayout>
15 #include <QHash>
16 
17 class CAMainWin;
18 
20 Q_OBJECT
21 public:
23 protected:
24  void paintEvent( QPaintEvent* );
25 };
26 
28  Q_OBJECT
29 public:
30  CAMenuToolButton( QString title, int numIconsRow = 4, QWidget * parent = 0 );
32 
33  void addButton( const QIcon icon, int buttonId, const QString toolTip="" );
34  inline QAbstractButton *getButton( int buttonId ) { return _buttonGroup->button( buttonId ); }
35 
36  inline QList<QToolButton*> buttonList() { return _buttonList; }
37 
38  inline int spacing() { return _spacing; }
39  inline int layoutMargin() { return _layoutMargin; }
40  inline int margin() { return _margin;}
41  inline int numIconsPerRow() { return _numIconsRow; }
42 
43  inline void setSpacing(int spacing) { _spacing = spacing; }
44  inline void setLayoutMargin(int margin) { _layoutMargin = margin; }
45  inline void setMargin(int margin) { _margin = margin; }
46  inline void setNumIconsPerRow( int numIconsRow ) { _numIconsRow = numIconsRow; }
47  void setCurrentId(int id, bool triggerSignal=false);
48  void showButtons();
49 
50 public slots:
51  void onButtonPressed( int );
52 
53 private:
54  void wheelEvent(QWheelEvent*);
55 
56  QButtonGroup *_buttonGroup; // Abstract group for the button actions
57  QGroupBox *_groupBox; // Group box containing title and buttons
58  QGridLayout *_boxLayout; // Layout for the group box
59  QGridLayout *_menuLayout; // Layout for the button menu
60  QList<QToolButton*> _buttonList; // List of created buttons in button box
61  QHash<QString, int> _buttonIds; // hash of IDs of buttons
62  int _buttonXPos; // X position of next button
63  int _buttonYPos; // Y position of next button
64  int _numIconsRow; // Number of icons per row
65  int _spacing; // Space between buttons
66  int _margin; // Margin around the buttons
67  int _layoutMargin; // Margin of layout
68 };
69 #endif /* MENUTOOLBUTTON_H_ */