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 * Set this button's default button state.
101 * Reimplemented from YPushButton.
103 virtual void setDefaultButton( bool def = true );
106 * Accept the keyboard focus.
108 virtual bool setKeyboardFocus();
111 * Set this button's icon.
113 * Reimplemented from YPushButton.
115 virtual void setIcon( const string & iconName );
118 * Returns the button's text (label) - useful for log messages etc.
120 QString text() const;
123 * Returns the internal Qt PushButton.
125 QPushButton * qPushButton() const { return _qPushButton; }
128 * Returns the internal parent dialog.
130 YQDialog * yQDialog() const { return _dialog; }
136 * Activate (animated) this button.
144 * Set the corresponding QPushButton.
146 void setQPushButton( QPushButton * pb );
149 * Redirect events from the _qPushButton member to this object.
151 * Overwritten from QObject.
153 bool eventFilter( QObject * obj, QEvent * event );
156 * Returns the corresponding YQDialog.
157 * Throws an exception if there is none.
166 QPushButton * _qPushButton;
167 bool _setDefaultButtonRecursive;
170 #endif // YQGenericButton_h