summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-05-23 12:22:57 +0200
committerChristian Klinger2016-05-23 12:52:03 +0200
commitb98db19af8246775502c74cd676b961b67f6a2c5 (patch)
treef0084ec792f4ced14a2fa486b0a4fdf59d7c1903 /src/server/mainwindow/mainwindow.cpp
parentmove back connectionframes that went out of the window due to resizing. (diff)
downloadpvs2-b98db19af8246775502c74cd676b961b67f6a2c5.tar.gz
pvs2-b98db19af8246775502c74cd676b961b67f6a2c5.tar.xz
pvs2-b98db19af8246775502c74cd676b961b67f6a2c5.zip
may fix the unwanted window growth.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index e6efb1c..c834957 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -592,7 +592,7 @@ void MainWindow::resizeEvent(QResizeEvent* e)
/* Bring back frame that are now out of the screen */
for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
const QPoint gp = (*it)->getGridPosition();
- if ( gp.x() > _tilesX || gp.y() > _tilesY ) {
+ if ( gp.x() >= _tilesX || gp.y() >= _tilesY ) {
qDebug() << "bring frame back";
placeFrameInFreeSlot(*it, (*it)->getCurrentPosition());
}
@@ -609,6 +609,18 @@ void MainWindow::resizeEvent(QResizeEvent* e)
(*it)->setSize(getTileWidthPx() * clientSize.width(), getTileHeightPx() * clientSize.height());
(*it)->move(newPos);
}
+
+ /* update background image label */
+ if (_backgroundImage != NULL) {
+ int w = ui->frmRoom->width() - 5; /* to make sure that we don't enlarge the window */
+ int h = ui->frmRoom->height() - 5;
+ ui->imageLabel->hide();
+ ui->imageLabel->setScaledContents(true);
+ ui->imageLabel->setPixmap(QPixmap::fromImage(*_backgroundImage).scaled(w,h, Qt::IgnoreAspectRatio));
+ ui->imageLabel->show();
+ } else {
+ ui->imageLabel->clear();
+ }
}
@@ -840,25 +852,25 @@ void MainWindow::switchRoomTo(QString roomToReload) {
/* load background image */
QString imgPath = Global::getCurrentRoom()->imagePath;
qDebug() << "imgPath is " << imgPath;
- if (imgPath == "") {
- /* set empty pixmap*/
- QPixmap empty;
- ui->imageLabel->setPixmap(empty);
- } else {
+
+ /* delete old image */
+ if (_backgroundImage != NULL) {delete _backgroundImage; }
+ _backgroundImage = NULL;
+
+ if (imgPath != "") {
qDebug() << "set background image path: " << imgPath;
- 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);
+ _backgroundImage = new QImage(s, QImage::Format_ARGB32);
+ _backgroundImage->fill(Qt::lightGray); /* background color */
+ QPainter painter(_backgroundImage);
renderer.render(&painter);
} else {
- image.load(imgPath);
+ _backgroundImage = new QImage();
+ _backgroundImage->load(imgPath);
}
- ui->imageLabel->setPixmap(QPixmap::fromImage(image));
- ui->imageLabel->setScaledContents(true);
}
/* and force a resize event (this scales the image) */