diff options
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index a8d35a8..a60d1a7 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -232,12 +232,13 @@ ConnectionFrame* MainWindow::createFrame() * Also connect signals frameMoved() and clicked() with slots. * @return ConnectionFrame* */ -ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint position) +ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint pxCoord, QPoint gridPosition) { // Allocate and resize ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, getTileWidthPx(), getTileHeightPx()); cf->setComputerId(computerId); - cf->setCurrentPosition(position); + cf->setCurrentPosition(pxCoord); + cf->setGridPosition(gridPosition); _clientFrames.append(cf); cf->show(); connect(cf, SIGNAL(frameMoved(bool, ConnectionFrame *)), this, SLOT(onPlaceFrame(bool, ConnectionFrame *))); @@ -359,17 +360,16 @@ void MainWindow::tryToUseRoomTemplate() // Add the frame // Position is given in grid coordinates, createFrame take pixels QString computerId = conf.value("ip").toString(); - QPoint coord = conf.value("pos").toPoint(); + QPoint gridPosition = conf.value("pos").toPoint(); qDebug() << computerId; - qDebug() << coord; + qDebug() << gridPosition; qDebug() << getTileWidthPx() ; qDebug() << getTileHeightPx() ; - coord.setX(coord.x() * getTileWidthPx()); - coord.setY(coord.y() * getTileHeightPx()); - qDebug() << coord ; - ConnectionFrame *cf = createFrame(computerId, coord); + QPoint pxCoord(gridPosition.x() * getTileWidthPx(), gridPosition.y() * getTileHeightPx()); + + ConnectionFrame *cf = createFrame(computerId, pxCoord, gridPosition); cf->move(cf->getCurrentPosition()); onPlaceFrame(false, cf); } @@ -473,9 +473,15 @@ void MainWindow::resizeEvent(QResizeEvent* e) for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); ++it) { const QPoint &oldpos = (*it)->frameGeometry().topLeft(); + int newPosX = (*it)->getGridPosition().x() * getTileWidthPx(); + int newPosY = (*it)->getGridPosition().y() * getTileHeightPx(); + QPoint newPos(newPosX, newPosY); + qDebug("Move C"); - (*it)->move((oldpos.x() / getTileWidthPx()) * nw, (oldpos.y() / getTileHeightPx()) * nh); - (*it)->setSize(nw, nh); + (*it)->setSize(getTileWidthPx(), getTileHeightPx()); + (*it)->move(newPos); + //(*it)->move((oldpos.x() / getTileWidthPx()) * nw, (oldpos.y() / getTileHeightPx()) * nh); + //(*it)->setSize(nw, nh); } // Resize trash and set position. @@ -777,10 +783,9 @@ void MainWindow::onReloadRoomOk() // Transform to pixels for createFrame(computerId, position). - pos.setX(pos.x() * getTileWidthPx()); - pos.setY(pos.y() * getTileHeightPx()); + QPoint pxPos(pos.x() * getTileWidthPx(), pos.y() * getTileHeightPx()); - ConnectionFrame *cf = createFrame(computerId, pos); + ConnectionFrame *cf = createFrame(computerId, pxPos, pos); cf->move(cf->getCurrentPosition()); /* TODO: this affects the placement */ onPlaceFrame(false, cf); } |