From 22fa19e903344df0b59ac5e6aef39e5458a43bda Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 7 May 2020 18:59:26 +0200 Subject: Fix: using svg as background image results in low-res display --- src/mainwindow.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c75489..2a56fbc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -403,9 +404,19 @@ void MainWindow::setBackground() Qt::AspectRatioMode arMode = Qt::KeepAspectRatioByExpanding; QString bgPath = Settings::backgrundImageFile(); if (bgPath.length() != 0) { - m_background = QImage(bgPath); - if (m_background.isNull()) { - qWarning() << "Not able to read" << bgPath << "as image"; + QSvgRenderer svg(bgPath); + if (svg.isValid()) { + m_background = QImage(m_ScreenRect.size(), QImage::Format_RGB32); + m_background.fill(QColor(225,225,220)); + QSize size = svg.defaultSize().scaled(m_background.size(), Qt::KeepAspectRatioByExpanding); + QPainter p(&m_background); + QPoint origin((m_background.width() - size.width()) / 2, (m_background.height() - size.height()) / 2); + svg.render(&p, QRect(origin, size)); + } else { + m_background = QImage(bgPath); + if (m_background.isNull()) { + qWarning() << "Not able to read" << bgPath << "as image"; + } } } -- cgit v1.2.3-55-g7522