Skip to content
Snippets Groups Projects
Commit c66354cf authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: property pane adding label for image size

parent 56aeda1b
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,12 @@ void ContextPaneWidgetImage::setProperties(QmlJS::PropertyReader *propertyReader ...@@ -57,7 +57,12 @@ void ContextPaneWidgetImage::setProperties(QmlJS::PropertyReader *propertyReader
if (propertyReader->hasProperty(QLatin1String("source"))) { if (propertyReader->hasProperty(QLatin1String("source"))) {
QString source = propertyReader->readProperty(QLatin1String("source")).toString(); QString source = propertyReader->readProperty(QLatin1String("source")).toString();
ui->fileWidget->setFileName(source); ui->fileWidget->setFileName(source);
setPixmap(m_path + '/' + source); if (QFile::exists(m_path + '/' + source))
setPixmap(m_path + '/' + source);
else
setPixmap(source);
} else {
ui->sizeLabel->setText("");
} }
} }
...@@ -104,6 +109,7 @@ void ContextPaneWidgetImage::setPixmap(const QString &fileName) ...@@ -104,6 +109,7 @@ void ContextPaneWidgetImage::setPixmap(const QString &fileName)
if (QFile(fileName).exists()) { if (QFile(fileName).exists()) {
QPixmap source(fileName); QPixmap source(fileName);
ui->sizeLabel->setText(QString::number(source.width()) + 'x' + QString::number(source.height()));
QPainter p(&pix); QPainter p(&pix);
if (ui->stretchRadioButton->isChecked()) { if (ui->stretchRadioButton->isChecked()) {
p.drawPixmap(0,0,76,76, source); p.drawPixmap(0,0,76,76, source);
...@@ -131,6 +137,8 @@ void ContextPaneWidgetImage::setPixmap(const QString &fileName) ...@@ -131,6 +137,8 @@ void ContextPaneWidgetImage::setPixmap(const QString &fileName)
int offset = (76 - cropped.width()) / 2; int offset = (76 - cropped.width()) / 2;
p.drawPixmap(offset, 0, cropped.width(), 76, source); p.drawPixmap(offset, 0, cropped.width(), 76, source);
} }
} else {
ui->sizeLabel->setText("");
} }
ui->label->setPixmap(pix); ui->label->setPixmap(pix);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment