1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQMainWinDock_h
21 #define YQMainWinDock_h
30 * Container window for YQDialogs of type YMainWindowDialog:
32 * This widget "swallows" any main dialogs it gets so only the topmost of them
33 * is visible at any given time. It acts as a window stack for main dialogs,
34 * making the next lower dialog on the stack visible as when the (previously)
35 * topmost main dialog is closed.
37 * This widget also handles its own visibility accordingly: It is visible if
38 * and only if it has a main dialog to display. It makes itself invisible when
39 * there is no more main dialog to display, and it makes itself visible again
40 * when a new main dialog appears.
42 * This widget can swallow an arbitrary number of main dialogs as they are
43 * opened as long as there is no popup dialog in between.
45 class YQMainWinDock : public QWidget
51 * Static method to access the singleton for this class.
53 * This creates the (one and only) instance of this class in the first
54 * call. Subsequent calls simply return this instance.
56 static YQMainWinDock * mainWinDock();
59 * Add a dialog (the widgetRep() of a YQDialog) to the MainWinDock (on top
60 * of its widget stack. The widget stack does not assume ownership of the
63 * If the MainWinDock is not visible yet, this operation makes it visible.
65 void add( QWidget * dialog );
68 * Remove a dialog from the MainWinDock (if it belongs to the
69 * MainWinDock). If dialog is 0, this removes the topmost dialog from the
72 * This can safely be called in the destructor of all dialogs, even those
73 * that were never added to the MainWinDock.
75 * If that was the last main dialog in the MainWinDock, the MainWinDock
76 * will be hidden (until another main dialog is added).
78 void remove( QWidget * dialog = 0 );
81 * Return the current topmost dialog (the widgetRep() of a YQDialog)
82 * or 0 if there is none.
84 QWidget * topmostDialog() const;
87 * Return 'true' if the next main dialog could be docked,
88 * i.e., if there is either no open dialog at all or only main dialogs.
93 * Show the widget (make it visible).
95 * Reimplemented from QWidget.
100 * Window manager close event (Alt-F4):
101 * Send a YCancelEvent and let the application handle that event.
103 * Reimplemented from QWidget.
105 virtual void closeEvent( QCloseEvent * event );
112 * Use the static mainWinDock() method to access the singleton for this
120 virtual ~YQMainWinDock();
127 * Reimplemented from QWidget.
129 virtual void paintEvent( QPaintEvent * event );
134 * Reimplemented from QWidget.
136 virtual void resizeEvent( QResizeEvent * event );
139 * Resize the visible child to the current size of the dock.
141 void resizeVisibleChild();
147 * Show the current dialog.
149 void showCurrentDialog();
154 typedef std::deque<QWidget *> YQWidgetStack;
157 * Return an iterator to the specified dialog in the internal
158 * widgetstack or _widgetStack::end() if not found.
160 YQWidgetStack::iterator findInStack( QWidget * dialog );
163 YQWidgetStack _widgetStack;
167 #endif // YQMainWinDock_h