fix problem that too large splash image make dialog too large

This commit is contained in:
wmayer
2019-03-12 15:12:18 +01:00
parent b8db3c5fd9
commit b797eb6a70

View File

@@ -26,6 +26,7 @@
# include <cstdlib>
# include <QApplication>
# include <QClipboard>
# include <QDesktopWidget>
# include <QDesktopServices>
# include <QDialogButtonBox>
# include <QLocale>
@@ -245,7 +246,20 @@ AboutDialog::AboutDialog(bool showLic, QWidget* parent)
setModal(true);
ui->setupUi(this);
ui->labelSplashPicture->setPixmap(getMainWindow()->splashImage());
QRect rect = QApplication::desktop()->availableGeometry();
QPixmap image = getMainWindow()->splashImage();
// Make sure the image is not too big
if (image.height() > rect.height()/2 || image.width() > rect.width()/2) {
float scale = static_cast<float>(image.width()) / static_cast<float>(image.height());
int width = std::min(image.width(), rect.width()/2);
int height = std::min(image.height(), rect.height()/2);
height = std::min(height, static_cast<int>(width / scale));
width = static_cast<int>(scale * height);
image = image.scaled(width, height);
}
ui->labelSplashPicture->setPixmap(image);
// if (showLic) { // currently disabled. Additional license blocks are always shown.
QString info(QLatin1String("SUCH DAMAGES.<hr/>"));
// any additional piece of text to be added after the main license text goes below.