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( YDialogType dialogType,
47 YDialogColorMode colorMode = YDialogNormalColor );
53 * Don't delete a dialog directly, use YDialog::deleteTopmostDialog().
59 * Makes this dialog active or inactive
61 void activate( bool active );
64 * Interited from QDialog: The window was closed via the window
65 * manager close button.
67 void closeEvent( QCloseEvent * ev );
70 * Set enabled/disabled state.
72 * Reimplemented from YWidget.
74 virtual void setEnabled( bool enabled );
77 * Preferred width of the widget.
79 * Reimplemented from YWidget.
81 virtual int preferredWidth();
84 * Preferred height of the widget.
86 * Reimplemented from YWidget.
88 virtual int preferredHeight();
91 * Set the new size of the widget.
93 * Reimplemented from YWidget.
95 virtual void setSize( int newWidth, int newHeight );
98 * Return this dialog's (first) default button or 0 if none
100 YQGenericButton * findDefaultButton();
103 * Return 'true' if the user resized this dialog.
105 bool userResized() { return _userResized; }
108 * Returns the button that has the keyboard focus or 0 if no button has
109 * the keyboard focus.
111 YQGenericButton * focusButton() const { return _focusButton; }
114 * Returns the dialog's default button - the button that is activated with
115 * [Return] if no button has the keyboard focus.
117 YQGenericButton * defaultButton() const { return _defaultButton; }
120 * Notification that a button loses the keyboard focus.
122 * All pushbuttons are required to call this whenever they lose focus so
123 * the dialog can keep track of its focusButton.
125 void losingFocus( YQGenericButton * button );
128 * Notification that a button gets the keyboard focus.
130 * All pushbuttons are required to call this whenever they gain focus so
131 * the dialog can keep track of its focusButton.
133 void gettingFocus( YQGenericButton * button );
136 * Set the dialog's default button - the button that is activated with
137 * [Return] if no other button has the keyboard focus.
138 * 'newDefaultButton' may be 0 if the former default button is destroyed.
140 void setDefaultButton( YPushButton * newDefaultButton );
143 * Ensure presence of no more than one single default button.
145 void ensureOnlyOneDefaultButton();
148 * Activate ( i.e. click ) this dialog's default button, if there is any.
149 * Issue a warning to the log file if 'warn' is true.
151 bool activateDefaultButton( bool warn = true );
154 * Find the first wizard in that dialog, if there is any.
155 * Returns 0 if there is none.
157 YQWizard * findWizard() const;
160 * Find a wizard button that would make sense as a default button.
161 * Return 0 if none can be found.
163 YQGenericButton * wizardDefaultButton( YQWizard * wizard ) const;
166 * Center a dialog relative to 'parent'.
168 * If 'parent' is 0, the dialog is centered relative to the application's
169 * main widget. If 'dialog' is the main widget and 'parent' is 0, the
170 * dialog is centered relative to the desktop.
172 static void center( QWidget * dialog, QWidget * parent = 0 );
178 * Choose a parent widget for a dialog of the specified type:
179 * Either the main window dock (if this is a YMainDialog and the dock
180 * currently accepts child dialogs) or 0.
182 static QWidget * chooseParent( YDialogType dialogType );
185 * Return the (first) default button between 'begin' and 'end'
186 * or 0 if there is none.
188 YQGenericButton * findDefaultButton( YWidgetListConstIterator begin,
189 YWidgetListConstIterator end ) const;
192 * Return the (first) wizard widget between 'begin' and 'end'
193 * or 0 if there is none.
195 YQWizard * findWizard( YWidgetListConstIterator begin,
196 YWidgetListConstIterator end ) const;
199 * Helper function for ensureOnlyOneDefaultButton():
200 * Recursively find all normal and wizard buttons between 'begin' and 'end'
201 * and make sure that no more than one button is marked as default.
202 * Return (the first) wizard widget found on the way.
204 YQWizard * ensureOnlyOneDefaultButton( YWidgetListConstIterator begin,
205 YWidgetListConstIterator end );
210 * All reimplemented from QWidget.
212 virtual void keyPressEvent ( QKeyEvent * event );
213 virtual void focusInEvent ( QFocusEvent * event );
214 virtual void resizeEvent ( QResizeEvent * event );
224 YQGenericButton * _focusButton;
225 YQGenericButton * _defaultButton;