Mercurial > hg > easaier-soundaccess
diff widgets/RelatedMediaWidget.cpp @ 153:98df77b4f041
add pdf icon for related media and restrain image size
author | lbajardsilogic |
---|---|
date | Thu, 15 Nov 2007 09:44:32 +0000 |
parents | 97fd6148fb8e |
children | 1b8f08375391 |
line wrap: on
line diff
--- a/widgets/RelatedMediaWidget.cpp Thu Nov 15 09:19:15 2007 +0000 +++ b/widgets/RelatedMediaWidget.cpp Thu Nov 15 09:44:32 2007 +0000 @@ -55,8 +55,35 @@ void RelatedMediaWidget::addRelatedMedia(const QString &filename) { + QString imageSource; + QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1)); + + int width; + int height; + int maxHeight = 150; + + if (extension == "pdf") + { + imageSource = ":icons/icon_pdf.png"; + } else + { + imageSource = filename; + } + + QPixmap image(imageSource); + if (image.height() > maxHeight) + { + height = maxHeight; + width = image.width() * maxHeight / image.height(); + } else + { + height = image.height(); + width = image.width(); + } + QLabel *mediaLabel = new QLabel(); - mediaLabel->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + filename + "\"><img src=\"" + filename + "\"> </a></body></html>"); + mediaLabel->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + filename + + "\"><img src=\"" + imageSource + "\" width=\"" + QString::number(width) + "\" height=\"" + QString::number(height) + "\"> </a></body></html>"); connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString)));