Optimization for pre-5.9 Qt

This commit is contained in:
ArsenArsen 2017-07-03 16:14:19 +02:00
parent 855d01f489
commit 306245dbc4
1 changed files with 23 additions and 18 deletions

View File

@ -9,24 +9,29 @@
#include <platformbackend.hpp> #include <platformbackend.hpp>
QPixmap screenshotutil::fullscreen(bool cursor) { QPixmap screenshotutil::fullscreen(bool cursor) {
int height = 0, width = 0; QPixmap image;
for (QScreen *screen : QApplication::screens()) {
QRect geo = screen->geometry(); // Hack for https://bugreports.qt.io/browse/QTBUG-58110
width = qMax(geo.left() + geo.width(), width); static QStringList qVer = QString(qVersion()).split('.');
height = qMax(geo.top() + geo.height(), height); if (qVer.at(0).toInt() == 5 && qVer.at(1).toInt() < 9) {
} int height = 0, width = 0;
QPixmap image(width, height); for (QScreen *screen : QApplication::screens()) {
image.fill(Qt::transparent); QRect geo = screen->geometry();
QPainter painter(&image); width = qMax(geo.left() + geo.width(), width);
width = 0; height = qMax(geo.top() + geo.height(), height);
for (QScreen *screen : QApplication::screens()) { }
QPixmap currentScreen = window(0, screen); image = QPixmap(width, height);
// Hack for https://bugreports.qt.io/browse/QTBUG-58110 image.fill(Qt::transparent);
static QStringList qVer = QString(qVersion()).split('.'); QPainter painter(&image);
if (qVer.at(0).toInt() == 5 && qVer.at(1).toInt() < 9) currentScreen = currentScreen.copy(screen->geometry()); width = 0;
painter.drawPixmap(screen->geometry().topLeft(), currentScreen);
width += screen->size().width(); for (QScreen *screen : QApplication::screens()) {
} QPixmap currentScreen = window(0, screen);
painter.drawPixmap(screen->geometry().topLeft(), currentScreen);
width += screen->size().width();
}
} else
image = window(0);
#ifdef PLATFORM_CAPABILITY_CURSOR #ifdef PLATFORM_CAPABILITY_CURSOR
if (cursor) { if (cursor) {
auto cursorData = PlatformBackend::inst().getCursor(); auto cursorData = PlatformBackend::inst().getCursor();