1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#include "testswapscreen.h"
#include "testhelpers.hh"
#include <QDesktopWidget>
#include <QRect>
using namespace std;
using namespace TestHelpers;
SwapScreensAndCheckAlign::SwapScreensAndCheckAlign(DSPDFViewer& d):
dspdfviewer(d),
screenPrimary( QApplication::desktop()->screenGeometry( 0 ) ),
screenSecondary( QApplication::desktop()->screenGeometry( 1 ) ),
verify(true)
{
DEBUGOUT << "Number of screens:" << QApplication::desktop()->numScreens() ;
DEBUGOUT << "screen 0 [pri]:" << screenPrimary;
DEBUGOUT << "screen 1 [sec]:" << screenSecondary;
if ( QApplication::desktop()->numScreens() != 2 ) {
WARNINGOUT << "Not running in a dual-screen environment";
verify = false;
} else if ( screenPrimary == screenSecondary ) {
WARNINGOUT << "Cannot tell the screens apart";
verify = false;
} else if ( screenPrimary.width() == 0 || screenPrimary.height() == 0 ) {
WARNINGOUT << "Cannot query primary screen size";
verify = false;
} else if ( screenSecondary.width() == 0 || screenSecondary.height() == 0 ) {
WARNINGOUT << "Cannot query secondary screen size";
verify = false;
}
if ( ! verify ) {
WARNINGOUT << "Disabling verification.";
}
// 1 Second time to boot
QTimer::singleShot(1000, this, SLOT(checkStartPositions()));
}
void SwapScreensAndCheckAlign::checkStartPositions() {
DEBUGOUT << "Start positions";
if ( verify ) {
check(dspdfviewer.audienceGeometry(), screenSecondary); // Audience starts on external
check(dspdfviewer.secondGeometry(), screenPrimary); // Presenter starts on internal
}
DEBUGOUT << "Firing screen swap event";
emit screenSwapRequested();
// 0.5 sec to swap
QTimer::singleShot(500, this, SLOT(checkAfterFirstSwap()));
}
void SwapScreensAndCheckAlign::checkAfterFirstSwap() {
DEBUGOUT << "Check after first swap";
if ( verify ) {
check(dspdfviewer.audienceGeometry(), screenPrimary); // Audience window on laptop
check(dspdfviewer.secondGeometry(), screenSecondary); // Presenter window on beamer
}
emit screenSwapRequested();
// 0.5 sec time to swap
QTimer::singleShot(500, this, SLOT(checkAfterSwapBack()));
}
void SwapScreensAndCheckAlign::checkAfterSwapBack() {
DEBUGOUT << "Check after swapping back";
if ( verify ) {
check(dspdfviewer.audienceGeometry(), screenSecondary);
check(dspdfviewer.secondGeometry(), screenPrimary);
emit quitRequested();
}
else {
QCoreApplication::exit(77);
}
}
|