* @brief Enables or disables automatic window layout. */
| 1168 | * @brief Enables or disables automatic window layout. |
| 1169 | */ |
| 1170 | void UI::WindowManager::setAutoLayoutEnabled(const bool enabled) |
| 1171 | { |
| 1172 | if (m_autoLayoutEnabled != enabled) { |
| 1173 | m_layoutRestored = false; |
| 1174 | m_autoLayoutEnabled = enabled; |
| 1175 | |
| 1176 | if (enabled) { |
| 1177 | m_manualGeometries.clear(); |
| 1178 | m_manualMargins.clear(); |
| 1179 | m_manualCanvasWidth = 0; |
| 1180 | m_manualCanvasHeight = 0; |
| 1181 | } |
| 1182 | |
| 1183 | for (auto* win : std::as_const(m_windows)) |
| 1184 | if (win->state() == "maximized") |
| 1185 | QMetaObject::invokeMethod(win, "restoreClicked"); |
| 1186 | |
| 1187 | loadLayout(); |
| 1188 | |
| 1189 | if (!m_autoLayoutEnabled) |
| 1190 | for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) |
| 1191 | storeManualGeometry(it.key(), it.value()); |
| 1192 | |
| 1193 | Q_EMIT autoLayoutEnabledChanged(); |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | /** |
| 1198 | * @brief Stores the preferred manual geometry and anchor margins for a window. |
no test coverage detected