QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
WindowStateStore Namespace Reference

Persist and restore a top-level window's geometry, one way for the main window and every dialog. More...

Functions

auto restore (QWidget &window, const QString &key) -> bool
 Restore window's geometry saved under key.
void save (const QWidget &window, const QString &key)
 Save window's geometry under key.
void attach (QDialog &dialog, const QString &key)
 restore() now, save() whenever the dialog finishes.
void centreOnCursorScreen (QWidget &window)
 Move window so its frame is centred on the screen under the mouse pointer (the primary screen when there is none). No-op on Wayland.

Detailed Description

Persist and restore a top-level window's geometry, one way for the main window and every dialog.

QWidget::saveGeometry() already encodes position, size, maximized state and the screen, and QWidget::restoreGeometry() clamps to the screens that exist now. Nothing else needs storing: the separate pos/size/maximized keys the dialogs and the main window used to write were either redundant with it or, applied after it, overrode it.

Function Documentation

◆ attach()

void WindowStateStore::attach ( QDialog & dialog,
const QString & key )

restore() now, save() whenever the dialog finishes.

QDialog::finished() fires for OK, Cancel, Escape and the window-manager close alike (the last two go through reject()), so one connection covers every way out; a closeEvent() override would miss the button paths.

Parameters
dialogDialog to place now and record on completion.
keySettings key for this dialog.

Definition at line 45 of file windowstatestore.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ centreOnCursorScreen()

void WindowStateStore::centreOnCursorScreen ( QWidget & window)

Move window so its frame is centred on the screen under the mouse pointer (the primary screen when there is none). No-op on Wayland.

Parameters
windowTop-level widget to move.

Definition at line 51 of file windowstatestore.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ restore()

auto WindowStateStore::restore ( QWidget & window,
const QString & key ) -> bool

Restore window's geometry saved under key.

Without a saved geometry the window is centred on the screen under the mouse pointer, except on Wayland, where placement belongs to the compositor and a client-side move is ignored anyway.

Parameters
windowTop-level widget to place.
keySettings key the geometry was saved under (see save()).
Returns
true if a saved geometry was applied.

Definition at line 32 of file windowstatestore.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

void WindowStateStore::save ( const QWidget & window,
const QString & key )

Save window's geometry under key.

Parameters
windowTop-level widget whose geometry to store.
keySettings key, e.g. the dialog's name; restore() reads it back.

Definition at line 41 of file windowstatestore.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: