forked from blue/squawk
first primitive vcard in graphic interface
This commit is contained in:
parent
c4d22c9c14
commit
2a37f36b83
13 changed files with 208 additions and 75 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
|
@ -29,12 +30,15 @@ class Image : public QLabel
|
|||
{
|
||||
public:
|
||||
Image(const QString& path, quint16 minWidth = 50, QWidget* parent = nullptr);
|
||||
Image(const QString& path, quint16 width, quint16 height, quint16 minWidth = 50, QWidget* parent = nullptr);
|
||||
|
||||
~Image();
|
||||
|
||||
int heightForWidth(int width) const override;
|
||||
int widthForHeight(int height) const;
|
||||
bool hasHeightForWidth() const override;
|
||||
void setPath(const QString& path);
|
||||
void setPath(const QString& path, quint16 width, quint16 height);
|
||||
void setMinWidth(quint16 minWidth);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue