|
33 | 33 |
|
34 | 34 | #include <QObject> |
35 | 35 | #include <QThread> |
36 | | -#include <QApplication> |
37 | | -#include <QDesktopWidget> |
| 36 | +#include <QScreen> |
| 37 | +#include <QGuiApplication> |
38 | 38 | #include <QMessageBox> |
39 | 39 | #include <cstdlib> |
40 | 40 | #include <stdio.h> |
@@ -77,7 +77,7 @@ namespace { |
77 | 77 |
|
78 | 78 | const unsigned kBytesPerPixel = 4; |
79 | 79 |
|
80 | | - D3D10GrabberWorker::D3D10GrabberWorker(QObject *parent, LPSECURITY_ATTRIBUTES lpsa) : |
| 80 | + D3D10GrabberWorker::D3D10GrabberWorker(QObject *parent, LPSECURITY_ATTRIBUTES lpsa) : |
81 | 81 | QObject(parent), |
82 | 82 | m_lpsa(lpsa) |
83 | 83 | { |
@@ -171,7 +171,7 @@ namespace { |
171 | 171 | if (m_libraryInjector) { |
172 | 172 | m_libraryInjector->Release(); |
173 | 173 | CoUninitialize(); |
174 | | - } |
| 174 | + } |
175 | 175 | } |
176 | 176 |
|
177 | 177 | void D3D10GrabberInjector::infectCleanDxProcesses() { |
@@ -366,19 +366,20 @@ class D3D10GrabberImpl: public QObject |
366 | 366 | } |
367 | 367 | m_worker->moveToThread(m_workerThread.data()); |
368 | 368 | m_workerThread->start(); |
369 | | - connect(m_worker.data(), SIGNAL(frameGrabbed()), this, SIGNAL(frameGrabbed()), Qt::QueuedConnection); |
| 369 | + connect(m_worker.data(), &D3D10GrabberWorker::frameGrabbed, this, &D3D10GrabberImpl::frameGrabbed, Qt::QueuedConnection); |
370 | 370 | QMetaObject::invokeMethod(m_worker.data(), "runLoop", Qt::QueuedConnection); |
371 | 371 |
|
| 372 | + using namespace std::chrono_literals; |
372 | 373 | m_processesScanAndInfectTimer.reset(new QTimer(this)); |
373 | | - m_processesScanAndInfectTimer->setInterval(5000); |
| 374 | + m_processesScanAndInfectTimer->setInterval(5s); |
374 | 375 | m_processesScanAndInfectTimer->setSingleShot(false); |
375 | | - connect(m_processesScanAndInfectTimer.data(), SIGNAL(timeout()), m_injector.data(), SLOT(infectCleanDxProcesses())); |
| 376 | + connect(m_processesScanAndInfectTimer.data(), &QTimer::timeout, m_injector.data(), &D3D10GrabberInjector::infectCleanDxProcesses); |
376 | 377 | m_processesScanAndInfectTimer->start(); |
377 | 378 |
|
378 | | - m_checkIfFrameGrabbedTimer.reset(new QTimer()); |
| 379 | + m_checkIfFrameGrabbedTimer.reset(new QTimer(this)); |
379 | 380 | m_checkIfFrameGrabbedTimer->setSingleShot(false); |
380 | | - m_checkIfFrameGrabbedTimer->setInterval(1000); |
381 | | - connect(m_checkIfFrameGrabbedTimer.data(), SIGNAL(timeout()), SLOT(handleIfFrameGrabbed())); |
| 381 | + m_checkIfFrameGrabbedTimer->setInterval(1s); |
| 382 | + connect(m_checkIfFrameGrabbedTimer.data(), &QTimer::timeout, this, &D3D10GrabberImpl::handleIfFrameGrabbed); |
382 | 383 | m_checkIfFrameGrabbedTimer->start(); |
383 | 384 | m_isInited = true; |
384 | 385 | return m_isInited; |
@@ -610,7 +611,7 @@ private slots: |
610 | 611 | m_injectorThread->wait(); |
611 | 612 |
|
612 | 613 |
|
613 | | - disconnect(this, SLOT(handleIfFrameGrabbed())); |
| 614 | + disconnect(this, &D3D10GrabberImpl::handleIfFrameGrabbed, nullptr, nullptr); |
614 | 615 | freeIPC(); |
615 | 616 | CoUninitialize(); |
616 | 617 | m_isInited = false; |
@@ -648,18 +649,18 @@ D3D10Grabber::D3D10Grabber(QObject *parent, GrabberContext *context, GetHwndCall |
648 | 649 |
|
649 | 650 | void D3D10Grabber::init() { |
650 | 651 | m_impl->init(); |
651 | | - connect(m_impl.data(), SIGNAL(frameGrabbed()), this, SLOT(grab())); |
| 652 | + connect(m_impl.data(), &D3D10GrabberImpl::frameGrabbed, this, &D3D10Grabber::grab); |
652 | 653 | _screensWithWidgets.clear(); |
653 | 654 | GrabbedScreen grabbedScreen; |
654 | | - grabbedScreen.screenInfo.handle = reinterpret_cast<void *>(QApplication::desktop()->primaryScreen()); |
655 | | - grabbedScreen.screenInfo.rect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen()); |
| 655 | + grabbedScreen.screenInfo.handle = QGuiApplication::primaryScreen();// unused? |
| 656 | + grabbedScreen.screenInfo.rect = QGuiApplication::primaryScreen()->geometry(); |
656 | 657 | _screensWithWidgets.append(grabbedScreen); |
657 | 658 |
|
658 | 659 | if (!WinUtils::IsUserAdmin()) { |
659 | 660 | qWarning() << Q_FUNC_INFO << "DX hooking is enabled but application not running elevated"; |
660 | 661 | // Do not show the message box during initialization (creating a unwanted message loop) |
661 | 662 | // Show as soon as the message loop is established |
662 | | - QTimer::singleShot(0, this, SLOT(showAdminMessage())); |
| 663 | + QTimer::singleShot(0, this, &D3D10Grabber::showAdminMessage); |
663 | 664 | } |
664 | 665 | } |
665 | 666 |
|
|
0 commit comments