first primitive vcard in graphic interface

This commit is contained in:
Blue 2019-10-22 18:13:56 +03:00
parent c4d22c9c14
commit 2a37f36b83
13 changed files with 208 additions and 75 deletions

View file

@ -26,6 +26,17 @@ Image::Image(const QString& path, quint16 p_minWidth, QWidget* parent):
minWidth(p_minWidth)
{
setScaledContents(true);
recalculateAspectRatio();
}
Image::Image(const QString& path, quint16 width, quint16 height, quint16 p_minWidth, QWidget* parent):
QLabel(parent),
pixmap(QIcon(path).pixmap(QSize(width, height))),
aspectRatio(0),
minWidth(p_minWidth)
{
setScaledContents(true);
recalculateAspectRatio();
}
Image::~Image()
@ -39,6 +50,11 @@ int Image::heightForWidth(int width) const
return height;
}
int Image::widthForHeight(int height) const
{
return height * aspectRatio;
}
bool Image::hasHeightForWidth() const
{
return true;
@ -67,3 +83,9 @@ void Image::setPath(const QString& path)
pixmap = QPixmap(path);
recalculateAspectRatio();
}
void Image::setPath(const QString& path, quint16 width, quint16 height)
{
pixmap = QPixmap(QIcon(path).pixmap(QSize(width, height)));
recalculateAspectRatio();
}