|
QtPass 2.0.0
Developer documentation
|
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. | |
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.
| 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.
| dialog | Dialog to place now and record on completion. |
| key | Settings key for this dialog. |
Definition at line 45 of file windowstatestore.cpp.
| 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.
| window | Top-level widget to move. |
Definition at line 51 of file windowstatestore.cpp.
| 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.
| window | Top-level widget to place. |
| key | Settings key the geometry was saved under (see save()). |
Definition at line 32 of file windowstatestore.cpp.
| void WindowStateStore::save | ( | const QWidget & | window, |
| const QString & | key ) |
Save window's geometry under key.
| window | Top-level widget whose geometry to store. |
| key | Settings key, e.g. the dialog's name; restore() reads it back. |
Definition at line 41 of file windowstatestore.cpp.