summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/server_normal/mainwindow.ui25
-rw-r--r--src/server/mainwindow/mainwindow.cpp39
-rw-r--r--src/server/mainwindow/mainwindow.h1
-rw-r--r--src/server/util/global.h6
4 files changed, 56 insertions, 15 deletions
diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui
index 418a63f..19fb791 100644
--- a/gui/server_normal/mainwindow.ui
+++ b/gui/server_normal/mainwindow.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>800</width>
- <height>716</height>
+ <width>846</width>
+ <height>760</height>
</rect>
</property>
<property name="windowTitle">
@@ -37,6 +37,27 @@
<property name="lineWidth">
<number>2</number>
</property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="imageLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
</layout>
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 48e9b18..9f667a6 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -368,6 +368,9 @@ void MainWindow::tryToUseRoomTemplate()
}
conf.endArray();
+ /* read backgroundImage */
+ QString image = conf.contains("backgroundImage") ? conf.value("backgroundImage").toString() : "";
+
// Find the managerIP of current room.
QString mgrIP = conf.value("mgrIP").toString();
@@ -420,8 +423,7 @@ void MainWindow::tryToUseRoomTemplate()
qDebug() << "had to use minimalGridSize(): = " << gridSize;
}
-
- Room* r = new Room(clientPositions, gridSize, clientSize);
+ Room* r = new Room(clientPositions, gridSize, clientSize, image);
qDebug() << "read new room: " << roomName << ": " << gridSize << ", " << clientSize;
roomsList.insert(roomName, r);
}
@@ -564,6 +566,7 @@ void MainWindow::resizeEvent(QResizeEvent* e)
(*it)->setSize(getTileWidthPx() * clientSize.width(), getTileHeightPx() * clientSize.height());
(*it)->move(newPos);
}
+
}
@@ -824,29 +827,43 @@ void MainWindow::onReloadRoomOk()
Room *room = Global::getRooms()[roomToReload];
+ /* set tiles */
_tilesX = room->gridSize.width();
_tilesY = room->gridSize.height();
- qDebug() << "changed room, grid size is now: " << _tilesX << ", " << _tilesY;
- //qDebug() << " Room: " << room;
- //qDebug() << "_rooms: " << _rooms;
+
+ /* place connection frames */
for (QMap<QString, QPoint>::iterator it = room->clientPositions.begin(); it != room->clientPositions.end(); ++it)
{
QString computerId = it.key();
QPoint pos = it.value();
- qDebug() << "ComputerID: " << computerId;
- qDebug() << "Pos: " << pos;
-
-
- // Transform to pixels for createFrame(computerId, position).
+ /* Transform to pixels for createFrame(computerId, position).*/
QPoint pxPos(pos.x() * getTileWidthPx(), pos.y() * getTileHeightPx());
ConnectionFrame *cf = createFrame(computerId, pxPos, pos);
cf->move(cf->getCurrentPosition());
onPlaceFrame(false, cf);
}
- }
+
+ /* load background image */
+ QString imgPath = Global::getRooms()[Global::getCurrentRoom()]->imagePath;
+ if (imgPath == "") {
+ /* set empty pixmap*/
+ QPixmap empty;
+ ui->imageLabel->setPixmap(empty);
+ } else {
+ qDebug() << "set background image path: " << imgPath;
+ QImage backgroundImage;
+ backgroundImage.load(imgPath);
+ ui->imageLabel->setPixmap(QPixmap::fromImage(backgroundImage));
+ ui->imageLabel->setScaledContents(true);
+ }
+
+ /* and force a resize event (this scales the image) */
+ resizeEvent(NULL);
+
+ }
}
int MainWindow::getTileWidthPx() const {
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index a3287f1..3ae1f7c 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -43,6 +43,7 @@ private:
int _tilesX;
int _tilesY;
+
/* virtual columns to preserve the aspect ratio of the loaded room */
int _virtCols;
int _virtRows;
diff --git a/src/server/util/global.h b/src/server/util/global.h
index b6aef1c..c258b4a 100644
--- a/src/server/util/global.h
+++ b/src/server/util/global.h
@@ -17,13 +17,15 @@
#include <QList>
struct Room {
- Room(QMap<QString, QPoint> cPos, QSize grid, QSize client) :
+ Room(QMap<QString, QPoint> cPos, QSize grid, QSize client, QString image) :
clientPositions(cPos),
gridSize(grid),
- clientSize(client) {};
+ clientSize(client),
+ imagePath(image) {};
QMap<QString, QPoint> clientPositions;
QSize gridSize;
QSize clientSize;
+ QString imagePath;
};
class Global