MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / removeWidgetFromActiveWorkspace

Method removeWidgetFromActiveWorkspace

app/src/UI/Taskbar.cpp:1703–1742  ·  view source on GitHub ↗

* @brief Removes the widget identified by windowId from the active workspace. */

Source from the content-addressed store, hash-verified

1701 * @brief Removes the widget identified by windowId from the active workspace.
1702 */
1703void UI::Taskbar::removeWidgetFromActiveWorkspace(int windowId)
1704{
1705 if (m_activeGroupId < WorkspaceIds::AutoStart)
1706 return;
1707
1708 auto* item = findItemByWindowId(windowId);
1709 if (!item)
1710 return;
1711
1712 const auto widgetType = item->data(TaskbarModel::WidgetTypeRole).toInt();
1713 const auto groupId = item->data(TaskbarModel::GroupIdRole).toInt();
1714 const int relIdx = relativeIndexForWindow(windowId);
1715 if (relIdx < 0)
1716 return;
1717
1718 auto* pm = &DataModel::ProjectModel::instance();
1719 const auto& workspaces = pm->activeWorkspaces();
1720 for (const auto& ws : workspaces) {
1721 if (ws.workspaceId != m_activeGroupId)
1722 continue;
1723
1724 const int targetUid = UI::Dashboard::instance().groupUniqueIdForGroupId(groupId);
1725 for (size_t i = 0; i < ws.widgetRefs.size(); ++i) {
1726 const auto& ref = ws.widgetRefs[i];
1727 if (ref.widgetType != widgetType || ref.groupUniqueId != targetUid
1728 || ref.relativeIndex != relIdx)
1729 continue;
1730
1731 pm->removeWidgetFromWorkspace(m_activeGroupId, static_cast<int>(i));
1732 if (auto* window = windowData(windowId))
1733 unregisterWindow(window);
1734
1735 removeWorkspaceTaskbarRow(windowId);
1736 Q_EMIT taskbarButtonsChanged();
1737 return;
1738 }
1739
1740 return;
1741 }
1742}
1743
1744/**
1745 * @brief Removes the taskbar-button row matching windowId, if any.

Callers

nothing calls this directly

Calls 4

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected