--- xpdf-qt/XpdfViewer.cc.orig 2024-02-08 04:32:41.000000000 +0800 +++ xpdf-qt/XpdfViewer.cc 2024-07-28 11:58:15.000000000 +0800 @@ -49,6 +49,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#endif #include "GString.h" #include "GList.h" #include "GlobalParams.h" @@ -883,7 +886,11 @@ } QSize hint = sizeHint(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QRect screen = QGuiApplication::primaryScreen()->availableGeometry(); +#else + QRect screen = QApplication::desktop()->availableGeometry(); +#endif int w = hint.width(); int h = hint.height(); if (w > screen.width() - 60) { @@ -2794,6 +2801,7 @@ // for historical reasons xpdf uses X11 button numbering for mouse // wheel events +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QPoint delta = e->angleDelta(); if (delta.y() > 0) { keyCode = xpdfKeyCodeMousePress4; @@ -2804,8 +2812,12 @@ } else if (delta.x() < 0) { keyCode = xpdfKeyCodeMousePress7; } else { +#endif return; +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) } +#endif + if ((cmds = globalParams->getKeyBinding(keyCode, getModifiers(e->modifiers()), getContext(e->modifiers())))) { --- xpdf-qt/XpdfWidget.cc.orig 2024-02-08 04:32:41.000000000 +0800 +++ xpdf-qt/XpdfWidget.cc 2024-07-28 11:56:14.000000000 +0800 @@ -1282,7 +1282,7 @@ } else if (color == pdfImageColorGray) { mode = splashModeMono8; paperColor[0] = 0xff; - format = QImage::Format_Grayscale8; + format = QImage::Format_Indexed8; } else { mode = splashModeRGB8; paperColor[0] = paperColor[1] = paperColor[2] = 0xff; @@ -1388,7 +1388,7 @@ } else if (color == pdfImageColorGray) { mode = splashModeMono8; paperColor[0] = 0xff; - format = QImage::Format_Grayscale8; + format = QImage::Format_Indexed8; } else { mode = splashModeRGB8; paperColor[0] = paperColor[1] = paperColor[2] = 0xff; @@ -2163,7 +2163,9 @@ lastMousePressTime[1] = lastMousePressTime[2]; lastMousePressX[2] = e->pos().x(); lastMousePressY[2] = e->pos().y(); +#if QT_VERSION >= 0x050000 lastMousePressTime[2] = e->timestamp(); +#endif lastMouseEventWasPress = true; if (!mousePassthrough) { x = (int)(e->pos().x() * scaleFactor); @@ -2202,6 +2204,7 @@ // single clicks just have to be "nearby" ulong maxTime = (ulong)QApplication::doubleClickInterval(); int maxDistance = QApplication::startDragDistance(); +#if QT_VERSION >= 0x050000 if (e->timestamp() - lastMousePressTime[0] < 2 * maxTime && abs(e->pos().x() - lastMousePressX[0]) + abs(e->pos().y() - lastMousePressY[0]) <= maxDistance) { @@ -2220,6 +2223,12 @@ + abs(e->pos().y() - lastMousePressY[2]) <= maxDistance) { emit mouseClick(e); } +#else + if (abs(e->pos().x() - lastMousePressX[2]) + + abs(e->pos().y() - lastMousePressY[2]) <= maxDistance) { + emit mouseClick(e); + } +#endif } void XpdfWidget::mouseMoveEvent(QMouseEvent *e) { --- xpdf-qt/QtPDFCore.cc.orig 2024-02-08 04:32:41.000000000 +0800 +++ xpdf-qt/QtPDFCore.cc 2024-07-28 11:59:05.000000000 +0800 @@ -24,6 +24,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#endif #include "gmem.h" #include "gmempp.h" #include "gfile.h" @@ -98,10 +101,10 @@ } double QtPDFCore::computeScaleFactor() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) // get Qt's HiDPI scale factor QGuiApplication *app = (QGuiApplication *)QGuiApplication::instance(); QScreen *screen = app->primaryScreen(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) return screen->devicePixelRatio(); #else return 1; @@ -109,9 +112,13 @@ } int QtPDFCore::computeDisplayDpi() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QGuiApplication *app = (QGuiApplication *)QGuiApplication::instance(); QScreen *screen = app->primaryScreen(); return (int)(screen->logicalDotsPerInch() * computeScaleFactor()); +#else + return (int)(qApp->desktop()->logicalDpiX() * computeScaleFactor()); +#endif } //------------------------------------------------------------------------ --- xpdf-qt/XpdfWidgetPrint.cc.orig 2024-02-08 04:32:41.000000000 +0800 +++ xpdf-qt/XpdfWidgetPrint.cc 2024-07-28 11:54:37.000000000 +0800 @@ -62,7 +62,11 @@ QPrinter::ColorMode colorMode; QSize paperSize; QPrinter::PaperSource paperSource; +#if QT_VERSION >= 0x050000 QPageLayout::Orientation pageOrientation; +#else + QPrinter::Orientation pageOrientation; +#endif FILE *f; GBool deletePDFFile; int startPage, endPage, pg, i; @@ -117,9 +121,14 @@ //--- get other parameters colorMode = prt->colorMode(); +#if QT_VERSION >= 0x050000 paperSize = prt->pageLayout().pageSize().sizePoints(); paperSource = prt->paperSource(); pageOrientation = prt->pageLayout().orientation(); +#else + paperSource = prt->paperSource(); + pageOrientation = prt->orientation(); +#endif //--- create the Session and PrintSettings @@ -232,7 +241,7 @@ //--- set page orientation PMGetAdjustedPaperRect(pageFormat, &paperRect); - if (pageOrientation == QPageLayout::Landscape) { + if (pageOrientation == QPrinter::Landscape) { PMSetOrientation(pageFormat, kPMLandscape, kPMUnlocked); paperRect2 = CGRectMake(paperRect.top, paperRect.left,