mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Finishing of document properties
This commit is contained in:
@ -17,6 +17,13 @@
|
||||
|
||||
#include "pdfwidgetutils.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
int qt_default_dpi_x() { return 72; }
|
||||
int qt_default_dpi_y() { return 72; }
|
||||
#else
|
||||
int qt_default_dpi_x() { return 96; }
|
||||
int qt_default_dpi_y() { return 96; }
|
||||
#endif
|
||||
|
||||
namespace pdfviewer
|
||||
{
|
||||
@ -36,4 +43,24 @@ int PDFWidgetUtils::getPixelSize(QWidget* widget, pdf::PDFReal sizeMM)
|
||||
}
|
||||
}
|
||||
|
||||
int PDFWidgetUtils::scaleDPI_x(QWidget* widget, int unscaledSize)
|
||||
{
|
||||
const double logicalDPI_x = widget->logicalDpiX();
|
||||
const double defaultDPI_x = qt_default_dpi_x();
|
||||
return (logicalDPI_x / defaultDPI_x) * unscaledSize;
|
||||
}
|
||||
|
||||
void PDFWidgetUtils::scaleWidget(QWidget* widget, QSize unscaledSize)
|
||||
{
|
||||
const double logicalDPI_x = widget->logicalDpiX();
|
||||
const double logicalDPI_y = widget->logicalDpiY();
|
||||
const double defaultDPI_x = qt_default_dpi_x();
|
||||
const double defaultDPI_y = qt_default_dpi_y();
|
||||
|
||||
const int width = (logicalDPI_x / defaultDPI_x) * unscaledSize.width();
|
||||
const int height = (logicalDPI_y / defaultDPI_y) * unscaledSize.height();
|
||||
|
||||
widget->resize(width, height);
|
||||
}
|
||||
|
||||
} // namespace pdfviewer
|
||||
|
Reference in New Issue
Block a user