Ensure lyrics background is at least 300x300px

This commit is contained in:
craig.p.drummond
2013-01-22 18:11:28 +00:00
parent 698c74587a
commit b9a13748e0
3 changed files with 36 additions and 41 deletions

View File

@@ -24,6 +24,33 @@
#include "textbrowser.h"
#include <QtGui/QPainter>
static const int constMinSize=300;
void TextBrowser::setImage(const QImage &img)
{
if (drawImage && (!img.isNull() || (img.isNull()!=image.isNull()))) {
image=img;
if (image.width()<constMinSize || image.height()<constMinSize) {
image=image.scaled(QSize(constMinSize, constMinSize), Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
viewport()->update();
}
}
void TextBrowser::enableImage(bool e)
{
if (e!=drawImage) {
drawImage=e;
if (!drawImage) {
image=QImage();
}
if (e) {
viewport()->setAutoFillBackground(false);
}
viewport()->update();
}
}
void TextBrowser::paintEvent(QPaintEvent *e)
{
if (drawImage && isReadOnly() && !image.isNull()) {