diff options
author | Simon Rettberg | 2020-05-07 18:59:26 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-05-07 18:59:26 +0200 |
commit | 22fa19e903344df0b59ac5e6aef39e5458a43bda (patch) | |
tree | 92b1529ad4ba2f26f549657c95c8ad754232df53 | |
parent | Reintroduce X background generation (diff) | |
download | slxgreeter-22fa19e903344df0b59ac5e6aef39e5458a43bda.tar.gz slxgreeter-22fa19e903344df0b59ac5e6aef39e5458a43bda.tar.xz slxgreeter-22fa19e903344df0b59ac5e6aef39e5458a43bda.zip |
Fix: using svg as background image results in low-res display
-rw-r--r-- | src/mainwindow.cpp | 17 |
1 files 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 <QSvgRenderer> #include <QAbstractTextDocumentLayout> #include <QDateTime> +#include <QPainter> #include <sys/types.h> #include <sys/socket.h> @@ -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"; + } } } |