31 #define YUILogComponent "qt-ui"
32 #include <yui/YUILog.h>
40 const std::string & imageFileName,
42 : QLabel( (QWidget *) parent->widgetRep() )
43 , YImage( parent, imageFileName, animated )
46 setAlignment( Qt::AlignLeft | Qt::AlignTop );
48 setScaledContents(
false );
65 YImage::setImage ( fileName, animated );
69 QMovie movie ( fromUTF8 ( imageFileName() ) );
71 if ( movie.isValid() )
73 yuiError() <<
"Couldn't load animation from " << imageFileName() << std::endl;
77 yuiDebug() <<
"Loading animation from " << imageFileName() << std::endl;
78 QLabel::setMovie ( &movie );
83 QPixmap pixmap ( fromUTF8 ( imageFileName() ) );
85 if ( pixmap.isNull() )
87 yuiError() <<
"Couldn't load pixmap from " << imageFileName() << std::endl;
93 QImage scaledImg = pixmap.toImage();
94 scaledImg = scaledImg.scaled ( this->width(), this->height(), Qt::KeepAspectRatio );
95 pixmap = pixmap.fromImage ( scaledImg );
97 _pixmapWidth = pixmap.size().width();
98 _pixmapHeight = pixmap.size().height();
100 yuiDebug() <<
"Loading image from " << imageFileName()
101 <<
" (" << pixmap.size().width() <<
" x " << pixmap.size().height() <<
")"
104 QLabel::setPixmap ( pixmap );
111 if ( autoScale() == newAutoScale )
114 YImage::setAutoScale( newAutoScale );
115 setScaledContents( newAutoScale );
118 setImage( imageFileName(), animated() );
124 if ( hasZeroSize( YD_HORIZ ) )
131 return sizeHint().width();
146 if ( hasZeroSize( YD_VERT ) )
153 return sizeHint().height();
161 return _pixmapHeight;
168 resize( newWidth, newHeight );
173 yuiDebug() <<
"setEnabled: " << enable << std::endl;
177 setImage( imageFileName(), animated() );
182 QPixmap pixmap( fromUTF8( imageFileName() ) );
184 QLabel::setPixmap( icon.pixmap( pixmap.size(), QIcon::Disabled, QIcon::Off) );
188 #include "YQImage.moc"
virtual void setImage(const std::string &imageFileName, bool animated=false)
virtual int preferredHeight()
virtual void setAutoScale(bool autoScale=true)
YQImage(YWidget *parent, const std::string &imageFileName, bool animated=false)
virtual void setEnabled(bool enabled)
virtual int preferredWidth()
virtual void setSize(int newWidth, int newHeight)