void moveToForeground() { QWindowList l = QGuiApplication::allWindows(); if (l.size() > 0 && l.at(0) != nullptr) { QWindow* w = l.at(0); w->requestActivate(); if (w->windowState() & Qt::WindowMinimized) { w->showNormal(); } } }
/*! Return the given top level window for a given position. Default implementation retrieves a list of all top level windows and finds the first window which contains point \a pos */ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const { QWindowList list = QGuiApplication::topLevelWindows(); for (int i = list.size()-1; i >= 0; --i) { QWindow *w = list[i]; if (w->isVisible() && w->geometry().contains(pos)) return w; } return 0; }
QWindow *QWinEventFilter::findWindow(HWND handle) { QWindow *w = 0; QWindowList list = qApp->topLevelWindows(); for (int i = 0; i < list.size(); i++) { if (list.at(i)->winId() == reinterpret_cast<WId>(handle)) { w = list.at(i); break; } } return w; }
void Nexus::updateWindowsArg(QWindow* closedWindow) { QWindowList windowList = QApplication::topLevelWindows(); delete windowActions; windowActions = new QActionGroup(this); windowMenu->addSeparator(); QAction* dockLast; if (dockMenu->actions().count() != 0) dockLast = dockMenu->actions().first(); else dockLast = nullptr; QWindow* activeWindow; if (QApplication::activeWindow()) activeWindow = QApplication::activeWindow()->windowHandle(); else activeWindow = nullptr; for (int i = 0; i < windowList.size(); ++i) { if (closedWindow == windowList[i]) continue; QAction* action = windowActions->addAction(windowList[i]->title()); action->setCheckable(true); action->setChecked(windowList[i] == activeWindow); connect(action, SIGNAL(triggered()), windowMapper, SLOT(map())); windowMapper->setMapping(action, windowList[i]); windowMenu->addAction(action); dockMenu->insertAction(dockLast, action); } if (dockLast && !dockLast->isSeparator()) dockMenu->insertSeparator(dockLast); }