From a6944ce1fe6cc3f80288602825270dba95731089 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Mon, 23 May 2016 11:12:21 +0200 Subject: Render SVG image on loading with screen resolution. --- src/server/mainwindow/mainwindow.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 88ed17d..7b95982 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include // Other custom UI elements #include "../clicklabel/clicklabel.h" #include "../sessionnamewindow/sessionnamewindow.h" @@ -596,7 +599,6 @@ void MainWindow::resizeEvent(QResizeEvent* e) (*it)->setSize(getTileWidthPx() * clientSize.width(), getTileHeightPx() * clientSize.height()); (*it)->move(newPos); } - } @@ -834,9 +836,18 @@ void MainWindow::switchRoomTo(QString roomToReload) { ui->imageLabel->setPixmap(empty); } else { qDebug() << "set background image path: " << imgPath; - QImage backgroundImage; - backgroundImage.load(imgPath); - ui->imageLabel->setPixmap(QPixmap::fromImage(backgroundImage)); + QImage image; + if (imgPath.endsWith("svg")) { + /* render once with maximal screen size */ + const QSize &s = QApplication::desktop()->screenGeometry().size(); // ui->frmRoom->geometry().size(); + QSvgRenderer renderer(imgPath); + image = QImage(s, QImage::Format_ARGB32); + QPainter painter(&image); + renderer.render(&painter); + } else { + image.load(imgPath); + } + ui->imageLabel->setPixmap(QPixmap::fromImage(image)); ui->imageLabel->setScaledContents(true); } -- cgit v1.2.3-55-g7522