]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQMenuButton.h
a couple of compile warnings removed
[duncan/yast2-qt4.git] / src / YQMenuButton.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQMenuButton.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQMenuButton_h
21 #define YQMenuButton_h
22
23 #include <qwidget.h>
24 #include "YMenuButton.h"
25 #include <QHash>
26
27 class QAction;
28 class QPushButton;
29 class QMenu;
30
31 class YQMenuButton : public QWidget, public YMenuButton
32 {
33     Q_OBJECT
34
35 public:
36     /**
37      * Constructor.
38      **/
39     YQMenuButton( YWidget *             parent,
40                   const string &        label );
41
42     /**
43      * Destructor.
44      **/
45     virtual ~YQMenuButton();
46
47     /**
48      * Change the label on the button.
49      *
50      * Reimplemented from YMenuButton / YSelectionWidget.
51      **/
52     virtual void setLabel( const string & label );
53
54     /**
55      * Rebuild the displayed menu tree from the internally stored YMenuItems.
56      *
57      * Implemented from YMenuButton.
58      **/
59     virtual void rebuildMenuTree();
60     
61     /**
62      * Set enabled / disabled state.
63      *
64      * Reimplemented from YWidget.
65      **/
66     virtual void setEnabled( bool enabled );
67
68     /**
69      * Preferred width of the widget.
70      *
71      * Reimplemented from YWidget.
72      **/
73     virtual int preferredWidth();
74
75     /**
76      * Preferred height of the widget.
77      *
78      * Reimplemented from YWidget.
79      **/
80     virtual int preferredHeight();
81
82     /**
83      * Set the new size of the widget.
84      *
85      * Reimplemented from YWidget.
86      **/
87     virtual void setSize( int newWidth, int newHeight );
88     
89     /**
90      * Accept the keyboard focus.
91      **/
92     virtual bool setKeyboardFocus();
93
94     
95 protected slots:
96
97     /**
98      * Triggered when any menu item is activated.
99      **/
100     void menuEntryActivated( QAction * menuItem );
101
102     /**
103      * Triggered via menuEntryActivated() by zero timer to get back in sync
104      * with the Qt event loop. 
105      **/
106     void returnNow();
107
108     
109 protected:
110
111     /**
112      * Recursively insert menu items into 'menu' from iterator 'begin' to iterator 'end'.
113      **/
114     void rebuildMenuTree( QMenu * menu, YItemIterator begin, YItemIterator end );
115
116     
117     //
118     // Data members
119     //
120     
121     YMenuItem *         _selectedItem;
122     QPushButton *       _qt_button;
123     QHash<QAction*,int> _serials;
124 };
125
126 #endif // YQMenuButton_h