mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-29 20:54:45 +00:00
Make Utils::realDpi work on QWindow not on QWidget
Small step towards the goal of okularcore not linking to QWidgets
This commit is contained in:
parent
5025330a6d
commit
8a36e7350d
|
@ -880,7 +880,8 @@ Document::OpenResult DocumentPrivate::openDocumentInternal(const KPluginMetaData
|
|||
|
||||
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;
|
||||
m_generator->setDPI(dpi);
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ QRect Utils::rotateRect(const QRect source, int width, int height, int orientati
|
|||
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) {
|
||||
const QSizeF res(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY());
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
class QRect;
|
||||
class QImage;
|
||||
class QWidget;
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
|
@ -31,14 +30,14 @@ public:
|
|||
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
|
||||
* 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),
|
||||
|
|
Loading…
Reference in a new issue