2011-09-18 15:35:44 +02:00
|
|
|
#include "globalfunctions.h"
|
|
|
|
|
|
|
|
QByteArray qz_pixmapToByteArray(const QPixmap &pix)
|
|
|
|
{
|
|
|
|
QByteArray bytes;
|
|
|
|
QBuffer buffer(&bytes);
|
|
|
|
buffer.open(QIODevice::WriteOnly);
|
|
|
|
if (pix.save(&buffer, "PNG"))
|
|
|
|
return buffer.buffer().toBase64();
|
|
|
|
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray qz_readAllFileContents(const QString &filename)
|
|
|
|
{
|
|
|
|
QFile file(filename);
|
|
|
|
file.open(QFile::ReadOnly);
|
|
|
|
QByteArray a = file.readAll();
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
2011-09-21 14:20:49 +02:00
|
|
|
|
|
|
|
void qz_centerWidgetOnScreen(QWidget *w)
|
|
|
|
{
|
|
|
|
const QRect screen = QApplication::desktop()->screenGeometry();
|
|
|
|
const QRect &size = w->geometry();
|
|
|
|
w->move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
|
|
|
}
|