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

Method addWidgetToActiveWorkspace

app/src/UI/Taskbar.cpp:1665–1698  ·  view source on GitHub ↗

* @brief Adds the widget identified by windowId to the active workspace. */

Source from the content-addressed store, hash-verified

1663 * @brief Adds the widget identified by windowId to the active workspace.
1664 */
1665void UI::Taskbar::addWidgetToActiveWorkspace(int windowId)
1666{
1667 if (m_activeGroupId < WorkspaceIds::AutoStart)
1668 return;
1669
1670 auto* item = findItemByWindowId(windowId);
1671 if (!item)
1672 return;
1673
1674 const auto widgetType = item->data(TaskbarModel::WidgetTypeRole).toInt();
1675 const auto groupId = item->data(TaskbarModel::GroupIdRole).toInt();
1676
1677 auto& db = UI::Dashboard::instance();
1678 const auto& map = db.widgetMap();
1679 int relIdx = -1;
1680 for (auto it = map.begin(); it != map.end(); ++it) {
1681 if (it.key() == windowId) {
1682 relIdx = it.value().second;
1683 break;
1684 }
1685 }
1686
1687 if (relIdx < 0)
1688 return;
1689
1690 const int groupUid = UI::Dashboard::instance().groupUniqueIdForGroupId(groupId);
1691 DataModel::ProjectModel::instance().addWidgetToWorkspace(
1692 m_activeGroupId, widgetType, groupUid, relIdx);
1693
1694 auto clone = item->clone();
1695 setWindowState(clone->data(TaskbarModel::WindowIdRole).toInt(), TaskbarModel::WindowNormal);
1696 m_taskbarButtons->appendRow(clone);
1697 Q_EMIT taskbarButtonsChanged();
1698}
1699
1700/**
1701 * @brief Removes the widget identified by windowId from the active workspace.

Callers

nothing calls this directly

Calls 7

beginMethod · 0.80
keyMethod · 0.80
addWidgetToWorkspaceMethod · 0.80
cloneMethod · 0.80
dataMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected