diff --git a/doomsday/libgui/include/de/gui/persistentcanvaswindow.h b/doomsday/libgui/include/de/gui/persistentcanvaswindow.h index 37f67ae612..b9c9070271 100644 --- a/doomsday/libgui/include/de/gui/persistentcanvaswindow.h +++ b/doomsday/libgui/include/de/gui/persistentcanvaswindow.h @@ -144,6 +144,17 @@ class LIBGUI_PUBLIC PersistentCanvasWindow : public CanvasWindow */ void restoreFromConfig(); + /** + * Saves the current state in memory (not persistently). The saved state can + * later be restored with a call to restoreState(). + */ + void saveState(); + + /** + * Restores the attribuets of the window from previously saved state. + */ + void restoreState(); + static PersistentCanvasWindow &main(); // Events. diff --git a/doomsday/libgui/src/persistentcanvaswindow.cpp b/doomsday/libgui/src/persistentcanvaswindow.cpp index 56e8a39115..cd7b260fb8 100644 --- a/doomsday/libgui/src/persistentcanvaswindow.cpp +++ b/doomsday/libgui/src/persistentcanvaswindow.cpp @@ -432,8 +432,7 @@ DENG2_PIMPL(PersistentCanvasWindow) struct Task { - enum Type - { + enum Type { ShowNormal, ShowFullscreen, ShowMaximized, @@ -457,16 +456,18 @@ DENG2_PIMPL(PersistentCanvasWindow) // Logical state. State state; + State savedState; // used by saveState(), restoreState() bool neverShown; typedef QList Tasks; Tasks queue; Instance(Public *i, String const &windowId) - : Base(i), - id(windowId), - state(windowId), - neverShown(true) + : Base(i) + , id(windowId) + , state(windowId) + , savedState(windowId) + , neverShown(true) { // Keep a global pointer to the main window. if(id == MAIN_WINDOW_ID) @@ -818,6 +819,16 @@ void PersistentCanvasWindow::restoreFromConfig() d->applyToWidget(d->state); } +void PersistentCanvasWindow::saveState() +{ + d->savedState = d->widgetState(); +} + +void PersistentCanvasWindow::restoreState() +{ + d->applyToWidget(d->savedState); +} + bool PersistentCanvasWindow::isCentered() const { return d->state.isCentered();