* @brief Returns the next/previous non-closed window in taskbar order. */
| 320 | * @brief Returns the next/previous non-closed window in taskbar order. |
| 321 | */ |
| 322 | QQuickItem* UI::Taskbar::nextActiveWindow(int delta) const |
| 323 | { |
| 324 | if (!m_taskbarButtons || delta == 0) |
| 325 | return nullptr; |
| 326 | |
| 327 | QList<QQuickItem*> windows; |
| 328 | windows.reserve(m_taskbarButtons->rowCount()); |
| 329 | for (int i = 0; i < m_taskbarButtons->rowCount(); ++i) { |
| 330 | auto* row = m_taskbarButtons->item(i); |
| 331 | if (!row) |
| 332 | continue; |
| 333 | |
| 334 | const int wid = row->data(TaskbarModel::WindowIdRole).toInt(); |
| 335 | auto* win = windowData(wid); |
| 336 | if (!win) |
| 337 | continue; |
| 338 | |
| 339 | const auto state = |
| 340 | static_cast<TaskbarModel::WindowState>(row->data(TaskbarModel::WindowStateRole).toInt()); |
| 341 | if (state == TaskbarModel::WindowClosed) |
| 342 | continue; |
| 343 | |
| 344 | windows.append(win); |
| 345 | } |
| 346 | |
| 347 | if (windows.isEmpty()) |
| 348 | return nullptr; |
| 349 | |
| 350 | const int currentIdx = windows.indexOf(m_activeWindow); |
| 351 | const int n = windows.size(); |
| 352 | const int base = currentIdx >= 0 ? currentIdx : (delta > 0 ? -1 : 0); |
| 353 | const int nextIdx = ((base + delta) % n + n) % n; |
| 354 | return windows.at(nextIdx); |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * @brief Serializes the active group's layout and writes it to the project file; |