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
40 friend class YQDialog;
49 YQGenericButton( YWidget * parent,
50 const string & label );
57 virtual ~YQGenericButton();
60 * Set enabled/disabled state.
62 * Reimplemented from YWidget.
64 virtual void setEnabled( bool enabled );
67 * Returns 'true' if this button is enabled, 'false' otherwise.
69 bool isEnabled() const;
72 * Changes the label (the text) of the button.
74 void setLabel( const QString & label );
77 * Changes the label (the text) of the button.
79 * Reimplemented from YWidget.
81 virtual void setLabel( const string & label );
84 * Show this button as the dialog's default button. The button never calls
85 * this by itself - the parent dialog is responsible for that.
87 void showAsDefault( bool show = true );
90 * Returns 'true' if this button is shown as a default button - which may
91 * mean that this really is the dialogs's default button or it is the
92 * dialog's focus button (a button that currently has the keyboard focus).
94 * Don't confuse this with YPushButton::isDefaultButton()!
96 bool isShownAsDefault() const;
99 * Accept the keyboard focus.
101 virtual bool setKeyboardFocus();
104 * Set this button's icon.
106 * Reimplemented from YPushButton.
108 virtual void setIcon( const string & iconName );
111 * Returns the button's text (label) - useful for log messages etc.
113 QString text() const;
116 * Returns the internal Qt PushButton.
118 QPushButton * qPushButton() const { return _qPushButton; }
121 * Returns the internal parent dialog.
123 YQDialog * yQDialog() const { return _dialog; }
129 * Activate (animated) this button.
137 * Set the corresponding QPushButton.
139 void setQPushButton( QPushButton * pb );
142 * Redirect events from the _qPushButton member to this object.
144 * Overwritten from QObject.
146 bool eventFilter( QObject * obj, QEvent * event );
149 * Returns the corresponding YQDialog.
150 * Throws an exception if there is none.
159 QPushButton * _qPushButton;
162 #endif // YQGenericButton_h