libyui-qt
YQDialog.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQDialog.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQDialog_h
27 #define YQDialog_h
28 
29 #include <QFrame>
30 #include <QEvent>
31 #include <QWidget>
32 #include <QPalette>
33 #include <yui/YDialog.h>
34 
35 class YQGenericButton;
36 class YQWizard;
37 class QEventLoop;
38 class QTimer;
39 class QY2StyleEditor;
40 
41 
42 class YQDialog : public QWidget, public YDialog
43 {
44  Q_OBJECT
45 
46 public:
62  YQDialog( YDialogType dialogType,
63  YDialogColorMode colorMode = YDialogNormalColor );
64 
65 protected:
66 
71  virtual ~YQDialog();
72 
73 public:
78  void closeEvent( QCloseEvent * ev );
79 
85  virtual void setEnabled( bool enabled );
86 
92  virtual int preferredWidth();
93 
99  virtual int preferredHeight();
100 
106  virtual void setSize( int newWidth, int newHeight );
107 
112 
116  bool userResized() { return _userResized; }
117 
122  YQGenericButton * focusButton() const { return _focusButton; }
123 
128  YQGenericButton * defaultButton() const { return _defaultButton; }
129 
136  void losingFocus( YQGenericButton * button );
137 
144  void gettingFocus( YQGenericButton * button );
145 
151  void setDefaultButton( YPushButton * newDefaultButton );
152 
157 
162  bool activateDefaultButton( bool warn = true );
163 
168  YQWizard * findWizard() const;
169 
174  YQGenericButton * wizardDefaultButton( YQWizard * wizard ) const;
175 
187  virtual void highlight( YWidget * child );
188 
196  static void center( QWidget * dialog, QWidget * parent = 0 );
197 
201  QEventLoop * eventLoop() { return _eventLoop; }
202 
203 
204 protected slots:
205 
209  void waitForEventTimeout();
210 
211 
212 protected:
213 
219  static QWidget * chooseParent( YDialogType dialogType );
220 
225  YQGenericButton * findDefaultButton( YWidgetListConstIterator begin,
226  YWidgetListConstIterator end ) const;
227 
232  YQWizard * findWizard( YWidgetListConstIterator begin,
233  YWidgetListConstIterator end ) const;
234 
241  YQWizard * ensureOnlyOneDefaultButton( YWidgetListConstIterator begin,
242  YWidgetListConstIterator end );
243 
250  virtual void openInternal();
251 
257  virtual YEvent * waitForEventInternal( int timeout_millisec );
258 
265  virtual YEvent * pollEventInternal();
266 
273  virtual void activate();
274 
280  virtual void keyPressEvent ( QKeyEvent * event );
281  virtual void focusInEvent ( QFocusEvent * event );
282  virtual void resizeEvent ( QResizeEvent * event );
283 
284 
285  //
286  // Data members
287  //
288 
289  bool _userResized;
290  QSize _userSize;
291 
292  YQGenericButton * _focusButton;
293  YQGenericButton * _defaultButton;
294 
295  QTimer * _waitForEventTimer;
296  QEventLoop * _eventLoop;
297  YWidget * _highlightedChild;
298  QPalette _preHighlightPalette;
299  bool _preHighlightAutoFill;
300  QY2StyleEditor* _styleEditor;
301 
302 };
303 
304 
305 #endif // YQDialog_h
306 
YQWizard * findWizard() const
Definition: YQDialog.cc:425
YQGenericButton * findDefaultButton()
Definition: YQDialog.cc:297
Stylesheet Editor Dialog.
Definition: QY2StyleEditor.h:38
YQGenericButton * defaultButton() const
Definition: YQDialog.h:128
Definition: YQWizard.h:64
virtual void highlight(YWidget *child)
Definition: YQDialog.cc:861
virtual void keyPressEvent(QKeyEvent *event)
Definition: YQDialog.cc:605
virtual ~YQDialog()
Definition: YQDialog.cc:125
YQGenericButton * focusButton() const
Definition: YQDialog.h:122
virtual int preferredWidth()
Definition: YQDialog.cc:191
virtual YEvent * waitForEventInternal(int timeout_millisec)
Definition: YQDialog.cc:759
static void center(QWidget *dialog, QWidget *parent=0)
Definition: YQDialog.cc:845
QEventLoop * eventLoop()
Definition: YQDialog.h:201
virtual void activate()
Definition: YQDialog.cc:183
virtual void setEnabled(bool enabled)
Definition: YQDialog.cc:253
void gettingFocus(YQGenericButton *button)
Definition: YQDialog.cc:589
void setDefaultButton(YPushButton *newDefaultButton)
Definition: YQDialog.cc:494
Definition: YQGenericButton.h:44
virtual void openInternal()
Definition: YQDialog.cc:173
bool userResized()
Definition: YQDialog.h:116
YQDialog(YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor)
Definition: YQDialog.cc:57
YQGenericButton * wizardDefaultButton(YQWizard *wizard) const
Definition: YQDialog.cc:457
bool activateDefaultButton(bool warn=true)
Definition: YQDialog.cc:534
static QWidget * chooseParent(YDialogType dialogType)
Definition: YQDialog.cc:150
void losingFocus(YQGenericButton *button)
Definition: YQDialog.cc:573
virtual void setSize(int newWidth, int newHeight)
Definition: YQDialog.cc:261
Definition: YQDialog.h:42
virtual YEvent * pollEventInternal()
Definition: YQDialog.cc:809
void ensureOnlyOneDefaultButton()
Definition: YQDialog.cc:400
virtual int preferredHeight()
Definition: YQDialog.cc:222
void closeEvent(QCloseEvent *ev)
Definition: YQDialog.cc:724
void waitForEventTimeout()
Definition: YQDialog.cc:831