* @brief Sets the active group and updates taskbar buttons accordingly. */
| 390 | * @brief Sets the active group and updates taskbar buttons accordingly. |
| 391 | */ |
| 392 | void UI::Taskbar::setActiveGroupId(int groupId) |
| 393 | { |
| 394 | m_focusCycleTimer.stop(); |
| 395 | m_focusCycleQueue.clear(); |
| 396 | |
| 397 | saveLayout(); |
| 398 | |
| 399 | if (!m_rebuildInProgress && !m_independentWorkspace) |
| 400 | DataModel::ProjectModel::instance().setActiveGroupId(groupId); |
| 401 | |
| 402 | for (auto it = m_windowConnections.begin(); it != m_windowConnections.end(); ++it) |
| 403 | disconnect(*it); |
| 404 | |
| 405 | m_windowConnections.clear(); |
| 406 | |
| 407 | m_windowIDs.clear(); |
| 408 | m_taskbarButtons->clear(); |
| 409 | if (m_windowManager) |
| 410 | m_windowManager->clear(); |
| 411 | |
| 412 | m_activeWindow = nullptr; |
| 413 | m_activeGroupId = groupId; |
| 414 | |
| 415 | if (m_windowManager && AppState::instance().operationMode() == SerialStudio::ProjectFile) { |
| 416 | const auto layout = DataModel::ProjectModel::instance().groupLayout(m_layoutScope, groupId); |
| 417 | m_windowManager->preloadPendingGeometries(layout); |
| 418 | } |
| 419 | |
| 420 | if (groupId >= WorkspaceIds::AutoStart) |
| 421 | populateTaskbarFromWorkspace(groupId); |
| 422 | |
| 423 | else |
| 424 | populateTaskbarFromGroup(groupId); |
| 425 | |
| 426 | if (m_taskbarButtons->rowCount() > 0) { |
| 427 | auto firstGroup = m_taskbarButtons->item(0); |
| 428 | auto windowId = firstGroup->data(TaskbarModel::WindowIdRole).toInt(); |
| 429 | for (auto it = m_windowIDs.begin(); it != m_windowIDs.end(); ++it) { |
| 430 | if (it.value() == windowId) { |
| 431 | setActiveWindow(it.key()); |
| 432 | break; |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | Q_EMIT activeGroupIdChanged(); |
| 438 | Q_EMIT windowStatesChanged(); |
| 439 | Q_EMIT taskbarButtonsChanged(); |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * @brief Populates the taskbar buttons for a user-defined workspace (id >= 1000). |
no test coverage detected