QmlDesigner: Fix font preview tooltip image

The preview tooltip was recently reduced in size, but font previews
were still being rendered the old size and scaled down, degrading
image quality. The new default size is bit too small to render the
sample text of fonts nicely, so added an option to set unscaled image
to the tooltip, allowing us to use twice as wide preview images for
fonts.

Fixes: QDS-6486
Change-Id: Ieaabfbea11e47509de7cd6aed93464d8595ea541
Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Miikka Heikkinen
2022-03-21 14:06:39 +02:00
parent bd607909a5
commit e40041978e
8 changed files with 51 additions and 27 deletions

View File

@@ -62,10 +62,16 @@ void PreviewImageTooltip::setInfo(const QString &info)
m_ui->infoLabel->setText(info);
}
void PreviewImageTooltip::setImage(const QImage &image)
void PreviewImageTooltip::setImage(const QImage &image, bool scale)
{
m_ui->imageLabel->setPixmap(QPixmap::fromImage({image}).scaled(m_ui->imageLabel->width(),
m_ui->imageLabel->height(),
Qt::KeepAspectRatio));
QPixmap pm = QPixmap::fromImage({image});
if (scale) {
m_ui->imageLabel->setPixmap(pm.scaled(m_ui->imageLabel->width(),
m_ui->imageLabel->height(),
Qt::KeepAspectRatio));
} else {
m_ui->imageLabel->setPixmap(pm);
}
}
}