| 124 | } |
| 125 | |
| 126 | void MacroTreeItem::RunningClicked(bool running) |
| 127 | { |
| 128 | const auto updateWidget = [this](Macro *macro) { |
| 129 | if (!macro) { |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | const auto ¯os = GetTopLevelMacros(); |
| 134 | |
| 135 | bool found = false; |
| 136 | int idx = 0; |
| 137 | for (const auto &m : macros) { |
| 138 | if (m.get() == macro) { |
| 139 | found = true; |
| 140 | break; |
| 141 | } |
| 142 | idx++; |
| 143 | } |
| 144 | |
| 145 | if (!found) { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | const auto widget = _tree->GetItemWidget(idx); |
| 150 | if (widget) { |
| 151 | widget->UpdateRunning(); |
| 152 | } |
| 153 | }; |
| 154 | |
| 155 | if (!_macro->IsGroup()) { |
| 156 | _macro->SetPaused(!running); |
| 157 | if (!_macro->IsSubitem()) { |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | const auto group = _macro->Parent(); |
| 162 | updateWidget(group.get()); |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | const auto macros = GetGroupMacroEntries(_macro.get()); |
| 167 | for (const auto ¯o : macros) { |
| 168 | macro->SetPaused(!running); |
| 169 | } |
| 170 | |
| 171 | // Update backend values before updating UI to prevent flickering in |
| 172 | // running state of the group |
| 173 | for (const auto ¯o : macros) { |
| 174 | updateWidget(macro.get()); |
| 175 | } |
| 176 | UpdateRunning(); |
| 177 | } |
| 178 | |
| 179 | void MacroTreeItem::UpdateRunning() |
| 180 | { |
nothing calls this directly
no test coverage detected