1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

allow saving qrcode as file (src only, no UI)

This commit is contained in:
agilob 2015-03-08 14:20:15 +00:00
parent 8eb1a6fdb1
commit fd374fa7c4
No known key found for this signature in database
GPG Key ID: 34568050DBCCB997
2 changed files with 18 additions and 2 deletions

View File

@ -22,6 +22,21 @@ void QRWidget::setQRData(QString data)
paintImage(); paintImage();
} }
QImage* QRWidget::getImage()
{
return image;
}
/**
* @brief QRWidget::saveImage
* @param path Full path to the file with extension.
* @return indicate if saving was successful.
*/
bool QRWidget::saveImage(QString path)
{
return image->save(path, 0, 75); //0 - image format same as file extension, 75-quality, png file is ~6.3kb
}
QString QRWidget::getImageAsText() QString QRWidget::getImageAsText()
{ {
paintImage(); paintImage();
@ -32,7 +47,6 @@ QString QRWidget::getImageAsText()
QString iconBase64 = QString::fromLatin1(ba.toBase64().data()); QString iconBase64 = QString::fromLatin1(ba.toBase64().data());
QString base64Image = "<img width=\"300\" heigth=\"300\" src=\"data:image/png;base64," + iconBase64 +"\" />"; QString base64Image = "<img width=\"300\" heigth=\"300\" src=\"data:image/png;base64," + iconBase64 +"\" />";
qDebug() << base64Image;
return QString(base64Image); return QString(base64Image);
} }

View File

@ -13,6 +13,8 @@ public:
explicit QRWidget(QWidget *parent = 0); explicit QRWidget(QWidget *parent = 0);
void setQRData(QString data); void setQRData(QString data);
QString getImageAsText(); QString getImageAsText();
QImage* getImage();
bool saveImage(QString path);
private: private:
QString data; QString data;