]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQMenuButton.h
f1ef4af71afc77af004b797a3b1fb23dc0c4b392
[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
26
27 class QPushButton;
28 class QPopupMenu;
29
30 class YQMenuButton : public QWidget, public YMenuButton
31 {
32     Q_OBJECT
33
34 public:
35     /**
36      * Constructor.
37      **/
38     YQMenuButton( YWidget *             parent,
39                   const string &        label );
40
41     /**
42      * Destructor.
43      **/
44     virtual ~YQMenuButton();
45
46     /**
47      * Change the label on the button.
48      *
49      * Reimplemented from YMenuButton / YSelectionWidget.
50      **/
51     virtual void setLabel( const string & label );
52
53     /**
54      * Rebuild the displayed menu tree from the internally stored YMenuItems.
55      *
56      * Implemented from YMenuButton.
57      **/
58     virtual void rebuildMenuTree();
59     
60     /**
61      * Set enabled / disabled state.
62      *
63      * Reimplemented from YWidget.
64      **/
65     virtual void setEnabled( bool enabled );
66
67     /**
68      * Preferred width of the widget.
69      *
70      * Reimplemented from YWidget.
71      **/
72     virtual int preferredWidth();
73
74     /**
75      * Preferred height of the widget.
76      *
77      * Reimplemented from YWidget.
78      **/
79     virtual int preferredHeight();
80
81     /**
82      * Set the new size of the widget.
83      *
84      * Reimplemented from YWidget.
85      **/
86     virtual void setSize( int newWidth, int newHeight );
87     
88     /**
89      * Accept the keyboard focus.
90      **/
91     virtual bool setKeyboardFocus();
92
93     
94 protected slots:
95
96     /**
97      * Triggered when any menu item is activated.
98      **/
99     void menuEntryActivated( int menuItemIndex );
100
101     /**
102      * Triggered via menuEntryActivated() by zero timer to get back in sync
103      * with the Qt event loop. 
104      **/
105     void returnNow();
106
107     
108 protected:
109
110     /**
111      * Recursively insert menu items into 'menu' from iterator 'begin' to iterator 'end'.
112      **/
113     void rebuildMenuTree( QPopupMenu * menu, YItemIterator begin, YItemIterator end );
114
115     
116     //
117     // Data members
118     //
119     
120     YMenuItem *         _selectedItem;
121     QPushButton *       _qt_button;
122 };
123
124 #endif // YQMenuButton_h