| 191 | } |
| 192 | |
| 193 | [[nodiscard]] QByteArray HandleCycle() { |
| 194 | const auto windows = CollectWindows(); |
| 195 | if (windows.empty()) { |
| 196 | return Error(u"no windows"_q); |
| 197 | } |
| 198 | const auto active = App().activeWindow(); |
| 199 | auto current = 0; |
| 200 | for (auto i = 0, count = int(windows.size()); i != count; ++i) { |
| 201 | if (windows[i].controller.get() == active) { |
| 202 | current = i; |
| 203 | break; |
| 204 | } |
| 205 | } |
| 206 | const auto next = (current + 1) % int(windows.size()); |
| 207 | windows[next].controller->activate(); |
| 208 | auto object = QJsonObject(); |
| 209 | object.insert(u"ok"_q, true); |
| 210 | object.insert(u"activated"_q, next); |
| 211 | return Pack(object); |
| 212 | } |
| 213 | |
| 214 | } // namespace |
| 215 |
no test coverage detected