summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-05-23 11:12:21 +0200
committerChristian Klinger2016-05-23 11:12:21 +0200
commita6944ce1fe6cc3f80288602825270dba95731089 (patch)
treeae7b231552cb80d5e070d8633ddaff4e6aa34fa2 /src/server/mainwindow/mainwindow.cpp
parentImproved positioning into the grid. (Pixel-precise calculations). (diff)
downloadpvs2-a6944ce1fe6cc3f80288602825270dba95731089.tar.gz
pvs2-a6944ce1fe6cc3f80288602825270dba95731089.tar.xz
pvs2-a6944ce1fe6cc3f80288602825270dba95731089.zip
Render SVG image on loading with screen resolution.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp19
1 files changed, 15 insertions, 4 deletions
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 <QtGui>
#include <QFileDialog>
#include <QNetworkInterface>
+#include <QSvgRenderer>
+#include <QPainter>
+#include <QImage>
// 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);
}