summaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a8dbd21..56f927f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -117,7 +117,10 @@ void MainWindow::setBackground()
palette.setColor(QPalette::Background, Qt::black);
}
else {
- QBrush brush(backgroundImage.scaled(rect.width(), rect.height()));
+ backgroundImage = backgroundImage.scaled(rect.width(), rect.height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
+ int xoff = (backgroundImage.width() - rect.width()) / 2;
+ int yoff = (backgroundImage.height() - rect.height()) / 2;
+ QBrush brush(backgroundImage.copy(xoff, yoff, backgroundImage.width(), backgroundImage.height()));
palette.setBrush(this->backgroundRole(), brush);
}
this->setPalette(palette);