Backport HiDPI fix

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.60@5282 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2018-03-29 14:32:17 +00:00
parent f0d0007a92
commit bcab13fdde
2 changed files with 35 additions and 21 deletions

View File

@@ -354,7 +354,25 @@ void DiagramPrintDialog::browseFilePrintTypeDialog() {
*/
void DiagramPrintDialog::print(const QList<Diagram *> &diagrams, bool fit_page, const ExportProperties options) {
//qDebug() << "Demande d'impression de " << diagrams.count() << "schemas.";
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#ifdef Q_OS_WIN
#ifdef QT_DEBUG
qDebug() << "--";
qDebug() << "DiagramPrintDialog::print printer_->resolution() before " << printer_->resolution();
qDebug() << "DiagramPrintDialog::print screennumber " << QApplication::desktop()->screenNumber();
#endif
QScreen *srn = QApplication::screens().at(QApplication::desktop()->screenNumber());
qreal dotsPerInch = (qreal)srn->logicalDotsPerInch();
printer_->setResolution(dotsPerInch);
#ifdef QT_DEBUG
qDebug() << "DiagramPrintDialog::print dotsPerInch " << dotsPerInch;
qDebug() << "DiagramPrintDialog::print printer_->resolution() after" << printer_->resolution();
qDebug() << "--";
#endif
#endif
#endif
// QPainter utiliser pour effectuer le rendu
QPainter qp(printer_);

View File

@@ -32,14 +32,10 @@ int main(int argc, char **argv)
QCoreApplication::setApplicationName("QElectroTech");
//Creation and execution of the application
//HighDPI
#if QT_VERSION >= QT_VERSION_CHECK (5, 6, 0)
#if defined Q_OS_MAC
QApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
#elif !defined(Q_OS_MAC)
QApplication::setAttribute (Qt::AA_DisableHighDpiScaling);
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#else
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("1"));
#endif
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
#endif
return(QETApp(argc, argv).exec());
}