QPixmap ScreenShooter::captureWindow(WindowHandle window) { if(!window.isValid()) return QPixmap(); const QRect &windowGeometry = window.rect(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) return QGuiApplication::primaryScreen()->grabWindow(0, windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height()); #else QDesktopWidget *desktop = QApplication::desktop(); return QPixmap::grabWindow(desktop->winId(), windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height()); #endif }
bool ChooseWindowPushButton::isWindowValid(const WindowHandle &handle) const { if(!handle.isValid()) return false; if(handle == mLastFoundWindow) return false; #ifdef Q_WS_WIN if(!IsWindow(handle.value())) return false; #endif foreach(QWidget *widget, mWindowIgnoreList) { if(widget->winId() == handle.value()) return false; } return true; }