libyui-qt  2.49.2
YQMainWinDock.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: YQMainWinDock.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQMainWinDock_h
27 #define YQMainWinDock_h
28 
29 #include <deque>
30 #include <qwidget.h>
31 
32 class QWidgetStack;
33 
34 
35 /**
36  * Container window for YQDialogs of type YMainWindowDialog:
37  *
38  * This widget "swallows" any main dialogs it gets so only the topmost of them
39  * is visible at any given time. It acts as a window stack for main dialogs,
40  * making the next lower dialog on the stack visible as when the (previously)
41  * topmost main dialog is closed.
42  *
43  * This widget also handles its own visibility accordingly: It is visible if
44  * and only if it has a main dialog to display. It makes itself invisible when
45  * there is no more main dialog to display, and it makes itself visible again
46  * when a new main dialog appears.
47  *
48  * This widget can swallow an arbitrary number of main dialogs as they are
49  * opened as long as there is no popup dialog in between.
50  **/
51 class YQMainWinDock : public QWidget
52 {
53  friend class YQWizard;
54 
55  Q_OBJECT
56 
57 public:
58  /**
59  * Static method to access the singleton for this class.
60  *
61  * This creates the (one and only) instance of this class in the first
62  * call. Subsequent calls simply return this instance.
63  **/
64  static YQMainWinDock * mainWinDock();
65 
66  /**
67  * Add a dialog (the widgetRep() of a YQDialog) to the MainWinDock (on top
68  * of its widget stack. The widget stack does not assume ownership of the
69  * widget.
70  *
71  * If the MainWinDock is not visible yet, this operation makes it visible.
72  **/
73  void add( YQDialog * dialog );
74 
75  /**
76  * Remove a dialog from the MainWinDock (if it belongs to the
77  * MainWinDock). If dialog is 0, this removes the topmost dialog from the
78  * MainWinDock.
79  *
80  * This can safely be called in the destructor of all dialogs, even those
81  * that were never added to the MainWinDock.
82  *
83  * If that was the last main dialog in the MainWinDock, the MainWinDock
84  * will be hidden (until another main dialog is added).
85  **/
86  void remove( YQDialog * dialog = 0 );
87 
88  /**
89  * Return the current topmost dialog (the widgetRep() of a YQDialog)
90  * or 0 if there is none.
91  **/
92  YQDialog * topmostDialog() const;
93 
94  /**
95  * Return 'true' if the next main dialog could be docked,
96  * i.e., if there is either no open dialog at all or only main dialogs.
97  **/
98  bool couldDock();
99 
100  /**
101  * Show the widget (make it visible).
102  *
103  * Reimplemented from QWidget.
104  **/
105  virtual void show();
106 
107  /**
108  * Window manager close event (Alt-F4):
109  * Send a YCancelEvent and let the application handle that event.
110  *
111  * Reimplemented from QWidget.
112  **/
113  virtual void closeEvent( QCloseEvent * event );
114 
115 
116 protected:
117  /**
118  * Constructor.
119  *
120  * Use the static mainWinDock() method to access the singleton for this
121  * class.
122  **/
123  YQMainWinDock();
124 
125  /**
126  * Destructor.
127  **/
128  virtual ~YQMainWinDock();
129 
130  /**
131  * Paint event.
132  *
133  * Reimplemented from QWidget.
134  **/
135  virtual void paintEvent( QPaintEvent * event );
136 
137  /**
138  * Resize event.
139  *
140  * Reimplemented from QWidget.
141  **/
142  virtual void resizeEvent( QResizeEvent * event );
143 
144  /**
145  * Resize the visible child to the current size of the dock.
146  **/
147  void resizeVisibleChild();
148 
149  /**
150  * For secondary wizards
151  **/
152  void setSideBarWidth( int width );
153 
154  /**
155  * Activate or deactivate the next-lower dialog in the dock when a new
156  * dialog is opened or when a dialog is closed.
157  **/
158  void activateCurrentDialog( bool active );
159 
160 
161 protected slots:
162 
163  /**
164  * Show the current dialog.
165  **/
166  void showCurrentDialog();
167 
168 
169 private:
170 
171  typedef std::deque<YQDialog *> YQWidgetStack;
172 
173  /**
174  * Return an iterator to the specified dialog in the internal
175  * widgetstack or _widgetStack::end() if not found.
176  **/
177  YQWidgetStack::iterator findInStack( YQDialog * dialog );
178 
179 
180  YQWidgetStack _widgetStack;
181 
182  int _sideBarWidth;
183 };
184 
185 
186 #endif // YQMainWinDock_h
void showCurrentDialog()
Show the current dialog.
YQMainWinDock()
Constructor.
virtual ~YQMainWinDock()
Destructor.
void setSideBarWidth(int width)
For secondary wizards.
void activateCurrentDialog(bool active)
Activate or deactivate the next-lower dialog in the dock when a new dialog is opened or when a dialog...
virtual void resizeEvent(QResizeEvent *event)
Resize event.
void add(YQDialog *dialog)
Add a dialog (the widgetRep() of a YQDialog) to the MainWinDock (on top of its widget stack...
Container window for YQDialogs of type YMainWindowDialog:
Definition: YQMainWinDock.h:51
void resizeVisibleChild()
Resize the visible child to the current size of the dock.
bool couldDock()
Return &#39;true&#39; if the next main dialog could be docked, i.e., if there is either no open dialog at all...
static YQMainWinDock * mainWinDock()
Static method to access the singleton for this class.
virtual void paintEvent(QPaintEvent *event)
Paint event.
YQDialog * topmostDialog() const
Return the current topmost dialog (the widgetRep() of a YQDialog) or 0 if there is none...
virtual void show()
Show the widget (make it visible).
virtual void closeEvent(QCloseEvent *event)
Window manager close event (Alt-F4): Send a YCancelEvent and let the application handle that event...