Make Utils::realDpi work on QWindow not on QWidget

Small step towards the goal of okularcore not linking to QWidgets
remotes/origin/work/aacid/mobile_signature_viewing
Albert Astals Cid 4 years ago
parent 5025330a6d
commit 8a36e7350d
  1. 3
      core/document.cpp
  2. 4
      core/utils.cpp
  3. 7
      core/utils.h

@ -880,7 +880,8 @@ Document::OpenResult DocumentPrivate::openDocumentInternal(const KPluginMetaData
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
const QSizeF dpi = Utils::realDpi(m_widget); const QWindow *window = m_widget && m_widget->window() ? m_widget->window()->windowHandle() : nullptr;
const QSizeF dpi = Utils::realDpi(window);
qCDebug(OkularCoreDebug) << "Output DPI:" << dpi; qCDebug(OkularCoreDebug) << "Output DPI:" << dpi;
m_generator->setDPI(dpi); m_generator->setDPI(dpi);

@ -44,9 +44,9 @@ QRect Utils::rotateRect(const QRect source, int width, int height, int orientati
return ret; return ret;
} }
QSizeF Utils::realDpi(QWidget *widgetOnScreen) QSizeF Utils::realDpi(const QWindow *windowOnScreen)
{ {
const QScreen *screen = widgetOnScreen && widgetOnScreen->window() && widgetOnScreen->window()->windowHandle() ? widgetOnScreen->window()->windowHandle()->screen() : qGuiApp->primaryScreen(); const QScreen *screen = windowOnScreen ? windowOnScreen->screen() : qGuiApp->primaryScreen();
if (screen) { if (screen) {
const QSizeF res(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY()); const QSizeF res(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY());

@ -12,7 +12,6 @@
class QRect; class QRect;
class QImage; class QImage;
class QWidget;
namespace Okular namespace Okular
{ {
@ -31,14 +30,14 @@ public:
static QRect rotateRect(const QRect source, int width, int height, int orientation); static QRect rotateRect(const QRect source, int width, int height, int orientation);
/** /**
* Return the real DPI of the display containing given widget * Return the real DPI of the display containing given window
* *
* On X11, it can indicate the real horizontal DPI value without any Xrdb * On X11, it can indicate the real horizontal DPI value without any Xrdb
* setting. Otherwise, returns the same as realDpiX/Y(), * setting. Otherwise, returns the same as realDpiX/Y(),
* *
* @since 0.19 (KDE 4.13) * @since 22.04
*/ */
static QSizeF realDpi(QWidget *widgetOnScreen); static QSizeF realDpi(const QWindow *windowOnScreen);
/** /**
* Compute the smallest rectangle that contains all non-white pixels in image), * Compute the smallest rectangle that contains all non-white pixels in image),

Loading…
Cancel
Save