![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
Step E.1 + Step H — free helpers for dialog layout persistence via QSettings and a uniform always-on-top policy. More...
#include <QRect>#include <QtGlobal>#include <QtCore/qnamespace.h>Go to the source code of this file.
Namespaces | |
| namespace | openswmmvis |
| namespace | openswmmvis::ui |
Functions | |
| void | openswmmvis::ui::saveDialogLayout (QWidget *root) |
| Persist the dialog's geometry + every named QSplitter under it. | |
| bool | openswmmvis::ui::restoreDialogLayout (QWidget *root) |
| Inverse of saveDialogLayout — restore geometry + splitter states. | |
| QRect | openswmmvis::ui::clampToVisibleScreen (const QRect &saved, int titleBarStrip=-1) |
| Clamp a saved top-level geometry into currently-available screen space, so a window can never be restored somewhere unreachable. | |
| void | openswmmvis::ui::ensureWindowOnScreen (QWidget *widget, const QScreen *preferred=nullptr) |
Move/resize widget's window so it is reachable on a connected screen, using the live frame geometry to size the title-bar allowance. | |
| void | openswmmvis::ui::applyAlwaysOnTopPolicy (QDialog *d) |
| Step H — pin the dialog above the main window so a map click doesn't hide it. Idempotent. Harmless on modal dialogs and on dialogs that already have the flag set. On macOS this is a no-op (the always-on-top hint would also float above other applications; Qt::Tool already keeps the dialog above the main window). | |
| Qt::WindowFlags | openswmmvis::ui::floatingPanelFlags () |
| Window flags for a modeless "floating panel" dialog that must stay above the application's OWN windows but never above other applications. macOS: a plain Qt::Dialog window (no Qt::Tool — that would hide the dialog when the app is deactivated; no WindowStaysOnTopHint — that floats above every app system-wide). The "stay above the main window" behaviour is instead provided by attaching the dialog as an NSWindow child window (see openswmmvis::platform::attachAsChildWindow, driven from the app-wide show event filter). Windows/X11: Qt::Tool + WindowStaysOnTopHint keeps the dialog above the main window (it does not leak across applications there). | |
| Qt::WindowFlags | openswmmvis::ui::stayAboveAppFlags () |
| Just the "keep above the app's other windows" hint, for full top-level (Qt::Window) dialogs that should NOT be turned into Tool panels. Empty on macOS — those dialogs are kept above the main window by the NSWindow child-window attachment instead; WindowStaysOnTopHint elsewhere. | |
Step E.1 + Step H — free helpers for dialog layout persistence via QSettings and a uniform always-on-top policy.
Iteration 2 (D1): persistence is applied automatically by the app-wide DialogLayoutWatcher (restore on first Show — AFTER the ctor, so hard- coded ctor resize()/defaults become the first-run values; save on Hide/Close, which covers QDialog::done()/exec paths). Wiring a dialog is therefore just NAMING it and the state worth keeping:
setObjectName(QStringLiteral("MyDialog")); // enables persistence m_splitter->setObjectName(QStringLiteral("main")); // + splitter sizes m_table->setObjectName(QStringLiteral("grid")); // + header state m_tabs->setObjectName(QStringLiteral("tabs")); // + current tab m_pages->setObjectName(QStringLiteral("pages")); // + nav page (user nav // ONLY — never stacks // that follow data) viewAction->setObjectName(QStringLiteral("showX")); // + checkable view toggle
Set the "noLayoutPersistence" dynamic property to opt a dialog out. Children named "qt_*" (Qt-internal) are ignored. Multi-instance dialogs share their class key — last close wins.
QSettings keys live under Dialogs/<objectName>/... so they're isolated from main-window state and from one another.