1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-23 02:32:10 +02:00
falkonOfficial/src/tools/globalfunctions.cpp

99 lines
2.3 KiB
C++
Raw Normal View History

2011-09-23 22:06:21 +02:00
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2011 nowrep
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#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;
}
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 );
}
QString qz_buildSystem()
{
#ifdef Q_OS_LINUX
return "Linux";
#endif
#ifdef Q_OS_UNIX
return "Unix";
#endif
#ifdef Q_OS_BSD4
return "BSD 4.4";
#endif
#ifdef Q_OS_BSDI
return "BSD/OS";
#endif
#ifdef Q_OS_FREEBSD
return "FreeBSD";
#endif
#ifdef Q_OS_HPUX
return "HP-UX";
#endif
#ifdef Q_OS_HURD
return "GNU Hurd";
#endif
#ifdef Q_OS_LYNX
return "LynxOS";
#endif
#ifdef Q_OS_MAC
return "MAC OS";
#endif
#ifdef Q_OS_NETBSD
return "NetBSD";
#endif
#ifdef Q_OS_OS2
return "OS/2";
#endif
#ifdef Q_OS_OPENBSD
return "OpenBSD";
#endif
#ifdef Q_OS_OSF
return "HP Tru64 UNIX";
#endif
#ifdef Q_OS_SOLARIS
return "Sun Solaris";
#endif
#ifdef Q_OS_UNIXWARE
return "UnixWare 7 / Open UNIX 8";
#endif
#ifdef Q_OS_WIN32
return "Windows";
#endif
}