1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQGenericButton.h
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQGenericButton_h
21 #define YQGenericButton_h
25 #include "YPushButton.h"
35 * Abstract base class for push button and similar widgets -
36 * all that can become a YQDialog's "default button".
38 class YQGenericButton : public QWidget, public YPushButton
47 YQGenericButton( YWidget * parent,
48 const string & label );
55 virtual ~YQGenericButton();
58 * Set enabled/disabled state.
60 * Reimplemented from YWidget.
62 virtual void setEnabled( bool enabled );
65 * Returns 'true' if this button is enabled, 'false' otherwise.
67 bool isEnabled() const;
70 * Changes the label (the text) of the button.
72 void setLabel( const QString & label );
75 * Changes the label (the text) of the button.
77 * Reimplemented from YWidget.
79 virtual void setLabel( const string & label );
82 * Show this button as the dialog's default button. The button never calls
83 * this by itself - the parent dialog is responsible for that.
85 void showAsDefault( bool show = true );
88 * Returns 'true' if this button is shown as a default button - which may
89 * mean that this really is the dialogs's default button or it is the
90 * dialog's focus button (a button that currently has the keyboard focus).
92 * Don't confuse this with YPushButton::isDefaultButton()!
94 bool isShownAsDefault() const;
97 * Set this button's default button state.
99 * Reimplemented from YPushButton.
101 virtual void setDefaultButton( bool def = true );
104 * Accept the keyboard focus.
106 virtual bool setKeyboardFocus();
109 * Set this button's icon.
111 * Reimplemented from YPushButton.
113 virtual void setIcon( const string & iconName );
116 * Returns the button's text (label) - useful for log messages etc.
118 QString text() const;
121 * Returns the internal Qt PushButton.
123 QPushButton * qPushButton() const { return _qPushButton; }
126 * Returns the internal parent dialog.
128 YQDialog * yQDialog() const { return _dialog; }
134 * Activate (animated) this button.
142 * Set the corresponding QPushButton.
144 void setQPushButton( QPushButton * pb );
147 * Redirect events from the _qPushButton member to this object.
149 * Overwritten from QObject.
151 bool eventFilter( QObject * obj, QEvent * event );
154 * Returns the corresponding YQDialog.
155 * Throws an exception if there is none.
163 QPushButton * _qPushButton;
164 bool _setDefaultButtonRecursive;
167 #endif // YQGenericButton_h