1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
29 class YQGenericButton;
32 class YQDialog : public QWidget, public YDialog
40 * 'dialogType' is one of YMainDialog or YPopupDialog.
42 * 'colorMode' can be set to YDialogWarnColor to use very bright "warning"
43 * colors or YDialogInfoColor to use more prominent, yet not quite as
44 * bright as "warning" colors. Use both only very rarely.
46 YQDialog( QWidget * qParent,
47 YDialogType dialogType,
48 YDialogColorMode colorMode = YDialogNormalColor );
54 * Don't delete a dialog directly, use YDialog::deleteTopmostDialog().
60 * Makes this dialog active or inactive
62 void activate( bool active );
65 * Interited from QDialog: The window was closed via the window
66 * manager close button.
68 void closeEvent( QCloseEvent * ev );
71 * Set enabled/disabled state.
73 * Reimplemented from YWidget.
75 virtual void setEnabled( bool enabled );
78 * Preferred width of the widget.
80 * Reimplemented from YWidget.
82 virtual int preferredWidth();
85 * Preferred height of the widget.
87 * Reimplemented from YWidget.
89 virtual int preferredHeight();
92 * Set the new size of the widget.
94 * Reimplemented from YWidget.
96 virtual void setSize( int newWidth, int newHeight );
99 * Return this dialog's (first) default button or 0 if none
101 YQGenericButton * findDefaultButton();
104 * Returns whether or not the user has resized this dialog.
106 bool userResized() { return _userResized; }
109 * Returns the button that has the keyboard focus or 0 if no button has
110 * the keyboard focus.
112 YQGenericButton * focusButton() const { return _focusButton; }
115 * Returns the dialog's default button - the button that is activated with
116 * [Return] if no button has the keyboard focus.
118 YQGenericButton * defaultButton() const { return _defaultButton; }
121 * Notification that a button loses the keyboard focus.
123 * All pushbuttons are required to call this whenever they lose focus so
124 * the dialog can keep track of its focusButton.
126 void losingFocus( YQGenericButton * button );
129 * Notification that a button gets the keyboard focus.
131 * All pushbuttons are required to call this whenever they gain focus so
132 * the dialog can keep track of its focusButton.
134 void gettingFocus( YQGenericButton * button );
137 * Set the dialog's default button - the button that is activated with
138 * [Return] if no other button has the keyboard focus.
139 * 'newDefaultButton' may be 0 if the former default button is destroyed.
141 void setDefaultButton( YPushButton * newDefaultButton );
144 * Ensure presence of no more than one single default button.
146 void ensureOnlyOneDefaultButton();
149 * Activate ( i.e. click ) this dialog's default button, if there is any.
150 * Issue a warning to the log file if 'warn' is true.
152 bool activateDefaultButton( bool warn = true );
155 * Find the first wizard in that dialog, if there is any.
156 * Returns 0 if there is none.
158 YQWizard * findWizard() const;
161 * Find a wizard button that would make sense as a default button.
162 * Return 0 if none can be found.
164 YQGenericButton * wizardDefaultButton( YQWizard * wizard ) const;
167 * Center a dialog relative to 'parent'.
169 * If 'parent' is 0, the dialog is centered relative to the application's
170 * main widget. If 'dialog' is the main widget and 'parent' is 0, the
171 * dialog is centered relative to the desktop.
173 static void center( QWidget * dialog, QWidget * parent = 0 );
179 * Return the (first) default button between 'begin' and 'end'
180 * or 0 if there is none.
182 YQGenericButton * findDefaultButton( YWidgetListConstIterator begin,
183 YWidgetListConstIterator end ) const;
186 * Return the (first) wizard widget between 'begin' and 'end'
187 * or 0 if there is none.
189 YQWizard * findWizard( YWidgetListConstIterator begin,
190 YWidgetListConstIterator end ) const;
193 * Helper function for ensureOnlyOneDefaultButton():
194 * Recursively find all normal and wizard buttons between 'begin' and 'end'
195 * and make sure that no more than one button is marked as default.
196 * Return (the first) wizard widget found on the way.
198 YQWizard * ensureOnlyOneDefaultButton( YWidgetListConstIterator begin,
199 YWidgetListConstIterator end );
202 * Event handler for keyboard input.
203 * Only very special keys are processed here.
205 * Inherited from QWidget.
207 void keyPressEvent( QKeyEvent * e );
211 * Event handler for focusIn event.
213 * Inherited from QWidget.
215 void focusInEvent( QFocusEvent * event );
218 * Event handler for window resize.
220 * Inherited from QWidget.
222 void resizeEvent ( QResizeEvent * ev );
226 * Inherited from QWidget: Called when the dialog is shown.
238 YQGenericButton * _focusButton;
239 YQGenericButton * _defaultButton;