forked from qt-creator/qt-creator
QmlDesigner: Add font asset preview tooltip
Refactored item library component preview tooltip to be also suitable for asset previews. Also now using the same image cache for font asset icons. Fixes: QDS-3254 Fixes: QDS-3470 Change-Id: I34c1278be2e5697e01eaedabe2798104507a6ad8 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -36,28 +36,36 @@ PreviewImageTooltip::PreviewImageTooltip(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(std::make_unique<Ui::PreviewImageTooltip>())
|
||||
{
|
||||
// setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
setWindowFlags(Qt::ToolTip);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowTransparentForInput
|
||||
| Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
|
||||
m_ui->setupUi(this);
|
||||
m_ui->nameLabel->setElideMode(Qt::ElideLeft);
|
||||
m_ui->pathLabel->setElideMode(Qt::ElideLeft);
|
||||
m_ui->infoLabel->setElideMode(Qt::ElideLeft);
|
||||
setStyleSheet(QString("QWidget { background-color: %1 }").arg(Utils::creatorTheme()->color(Utils::Theme::BackgroundColorNormal).name()));
|
||||
}
|
||||
|
||||
PreviewImageTooltip::~PreviewImageTooltip() = default;
|
||||
|
||||
void PreviewImageTooltip::setComponentPath(const QString &path)
|
||||
void PreviewImageTooltip::setName(const QString &name)
|
||||
{
|
||||
m_ui->componentPathLabel->setText(path);
|
||||
m_ui->nameLabel->setText(name);
|
||||
}
|
||||
|
||||
void PreviewImageTooltip::setComponentName(const QString &name)
|
||||
void PreviewImageTooltip::setPath(const QString &path)
|
||||
{
|
||||
m_ui->componentNameLabel->setText(name);
|
||||
m_ui->pathLabel->setText(path);
|
||||
}
|
||||
|
||||
void PreviewImageTooltip::setInfo(const QString &info)
|
||||
{
|
||||
m_ui->infoLabel->setText(info);
|
||||
}
|
||||
|
||||
void PreviewImageTooltip::setImage(const QImage &image)
|
||||
{
|
||||
resize(image.width() + 20 + m_ui->componentNameLabel->width(),
|
||||
std::max(image.height() + 20, height()));
|
||||
m_ui->imageLabel->setPixmap(QPixmap::fromImage({image}));
|
||||
m_ui->imageLabel->setPixmap(QPixmap::fromImage({image}).scaled(m_ui->imageLabel->width(),
|
||||
m_ui->imageLabel->height(),
|
||||
Qt::KeepAspectRatio));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user