mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
TileLayout: fix a bug (the rect offset was not taken into account)
This commit is contained in:
parent
db6e81a288
commit
b5c36bed26
2 changed files with 6 additions and 5 deletions
|
@ -197,10 +197,11 @@ void BoardWidget::paintEvent(QPaintEvent *)
|
|||
const int size = boardLayout->getSquareSize();
|
||||
const int spacing = boardLayout->spacing();
|
||||
|
||||
// Draw lines between tiles
|
||||
QLine hLine(0, 0, rect.width() + 1, 0);
|
||||
QLine vLine(0, 0, 0, rect.height() + 1);
|
||||
hLine.translate(size, size);
|
||||
vLine.translate(size, size);
|
||||
hLine.translate(rect.left() - 1, rect.top() - 1);
|
||||
vLine.translate(rect.left() - 1, rect.top() - 1);
|
||||
for (int i = 0; i <= BOARD_MAX; ++i)
|
||||
{
|
||||
painter.drawLine(hLine);
|
||||
|
@ -208,7 +209,7 @@ void BoardWidget::paintEvent(QPaintEvent *)
|
|||
hLine.translate(0, size + spacing);
|
||||
vLine.translate(size + spacing, 0);
|
||||
}
|
||||
//painter.drawRect(rect);
|
||||
// Draw a second line around the board, so that it looks nicer
|
||||
painter.drawRect(rect.adjusted(-2, -2, 1, 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -178,12 +178,12 @@ void TileLayout::setGeometry(const QRect &rect)
|
|||
const int squareSize = squareSizeWithSpacing - spacing();
|
||||
|
||||
// Handle margins and alignment
|
||||
int x = contentsMargins().left();
|
||||
int x = contentsRect().left() + contentsMargins().left();
|
||||
if (alignment() & Qt::AlignRight)
|
||||
x += width - m_nbCols * squareSizeWithSpacing;
|
||||
else if (alignment() & Qt::AlignHCenter)
|
||||
x += (width - m_nbCols * squareSizeWithSpacing) / 2;
|
||||
int y = contentsMargins().top();
|
||||
int y = contentsRect().top() + contentsMargins().top();
|
||||
if (alignment() & Qt::AlignBottom)
|
||||
y += height - m_nbRows * squareSizeWithSpacing;
|
||||
else if (alignment() & Qt::AlignVCenter)
|
||||
|
|
Loading…
Reference in a new issue