1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
27 class YQGenericButton;
32 class YQDialog : public QWidget, public YDialog
38 * Constructor: Constructor.
40 YQDialog( const YWidgetOpt & opt,
41 QWidget * qt_parent = 0,
42 bool default_size = false );
45 * Destructor: Cleans up.
50 * Makes this dialog active or inactive
52 void activate( bool active );
55 * Interited from QDialog: The window was closed via the window
56 * manager close button.
58 void closeEvent( QCloseEvent * ev );
61 * Set enabled/disabled state.
63 * Reimplemented from YWidget.
65 virtual void setEnabled( bool enabled );
68 * Preferred width of the widget.
70 * Reimplemented from YWidget.
72 virtual int preferredWidth();
75 * Preferred height of the widget.
77 * Reimplemented from YWidget.
79 virtual int preferredHeight();
82 * Set the new size of the widget.
84 * Reimplemented from YWidget.
86 virtual void setSize( int newWidth, int newHeight );
89 * Returns the size of (artificial) window manager decorations, depending
90 * on the value of YDialog::isDecorated().
92 int decorationWidth();
95 * Return this dialog's (first) default button or 0 if none
97 YQGenericButton * findDefaultButton();
100 * Returns whether or not the user has resized this dialog.
102 bool userResized() { return _userResized; }
105 * Returns the button that has the keyboard focus or 0 if no button has
106 * the keyboard focus.
108 YQGenericButton * focusButton() const { return _focusButton; }
111 * Returns the dialog's default button - the button that is activated with
112 * [Return] if no button has the keyboard focus.
114 YQGenericButton * defaultButton() const { return _defaultButton; }
117 * Notification that a button loses the keyboard focus.
119 * All pushbuttons are required to call this whenever they lose focus so
120 * the dialog can keep track of its focusButton.
122 void losingFocus( YQGenericButton * button );
125 * Notification that a button gets the keyboard focus.
127 * All pushbuttons are required to call this whenever they gain focus so
128 * the dialog can keep track of its focusButton.
130 void gettingFocus( YQGenericButton * button );
133 * Set the dialog's default button - the button that is activated with
134 * [Return] if no other button has the keyboard focus.
135 * 'newDefaultButton' may be 0 if the former default button is destroyed.
137 void setDefaultButton( YQGenericButton * newDefaultButton );
140 * Ensure presence of no more than one single default button.
142 void ensureOnlyOneDefaultButton();
145 * Activate ( i.e. click ) this dialog's default button, if there is any.
146 * Issue a warning to the log file if 'warn' is true.
148 bool activateDefaultButton( bool warn = true );
151 * Find the first wizard in that dialog, if there is any.
152 * Returns 0 if there is none.
154 YQWizard * findWizard() const;
157 * Find a wizard button that would make sense as a default button.
158 * Return 0 if none can be found.
160 YQGenericButton * wizardDefaultButton( YQWizard * wizard ) const;
163 * Center a dialog relative to 'parent'.
165 * If 'parent' is 0, the dialog is centered relative to the application's
166 * main widget. If 'dialog' is the main widget and 'parent' is 0, the
167 * dialog is centered relative to the desktop.
169 static void center( QWidget * dialog, QWidget * parent = 0 );
175 * Return the (first) default button between 'begin' and 'end'
176 * or 0 if there is none.
178 YQGenericButton * findDefaultButton( YWidgetListConstIterator begin,
179 YWidgetListConstIterator end ) const;
182 * Return the (first) wizard widget between 'begin' and 'end'
183 * or 0 if there is none.
185 YQWizard * findWizard( YWidgetListConstIterator begin,
186 YWidgetListConstIterator end ) const;
189 * Helper function for ensureOnlyOneDefaultButton():
190 * Recursively find all normal and wizard buttons between 'begin' and 'end'
191 * and make sure that no more than one button is marked as default.
192 * Return (the first) wizard widget found on the way.
194 YQWizard * ensureOnlyOneDefaultButton( YWidgetListConstIterator begin,
195 YWidgetListConstIterator end );
198 * Event handler for keyboard input.
199 * Only very special keys are processed here.
201 * Inherited from QWidget.
203 void keyPressEvent( QKeyEvent * e );
207 * Event handler for focusIn event.
209 * Inherited from QWidget.
211 void focusInEvent( QFocusEvent * event );
214 * Event handler for window resize.
216 * Inherited from QWidget.
218 void resizeEvent ( QResizeEvent * ev );
222 * Inherited from QWidget: Called when the dialog is shown.
236 YQGenericButton * _focusButton;
237 YQGenericButton * _defaultButton;