diff --git a/--force b/--force new file mode 160000 index 0000000..f7839be --- /dev/null +++ b/--force @@ -0,0 +1 @@ +Subproject commit f7839bedd9c9d28d4eb2e9a07c1e30e908783f63 diff --git a/KShare.pro b/KShare.pro index 970ccbe..9e50a65 100644 --- a/KShare.pro +++ b/KShare.pro @@ -73,7 +73,9 @@ HEADERS += mainwindow.hpp \ cropeditor/drawing/lineitem.hpp \ cropeditor/drawing/textitem.hpp \ colorpicker/colorpickerscene.hpp \ - platformbackend.hpp + platformbackend.hpp \ + gif-h/gif.h + mac { SOURCES += $$PWD/platformspecifics/mac/macbackend.cpp HEADERS += $$PWD/platformspecifics/mac/macbackend.hpp diff --git a/main.cpp b/main.cpp index 105d7eb..46ea0f8 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,7 @@ #include "mainwindow.hpp" #include #include -#include #include -#include -#include #include bool verbose = false; @@ -13,10 +10,10 @@ void handler(QtMsgType type, const QMessageLogContext &, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: - if (verbose) fprintf(stderr, "DEBUG: %s\n", localMsg.constData()); + if (verbose) fprintf(stdout, "DEBUG: %s\n", localMsg.constData()); break; case QtInfoMsg: - fprintf(stderr, "INFO: %s\n", localMsg.constData()); + fprintf(stdout, "INFO: %s\n", localMsg.constData()); break; case QtWarningMsg: fprintf(stderr, "WARN: %s\n", localMsg.constData()); diff --git a/screenshotutil.cpp b/screenshotutil.cpp index e79d5bb..1020218 100644 --- a/screenshotutil.cpp +++ b/screenshotutil.cpp @@ -21,7 +21,7 @@ QPixmap *screenshotutil::fullscreen(bool cursor) { return window(0); } -QPixmap *screenshotutil::window(long wid) { +QPixmap *screenshotutil::window(WId wid) { QScreen *w = QApplication::primaryScreen(); QPixmap screen = w->grabWindow(wid); QPixmap *pm = new QPixmap(screen.size()); @@ -32,3 +32,21 @@ QPixmap *screenshotutil::window(long wid) { void screenshotutil::toClipboard(QString value) { QApplication::clipboard()->setText(value); } + +QPixmap *screenshotutil::fullscreenArea(bool cursor, qreal x, qreal y, qreal w, qreal h) { + auto scr = QApplication::primaryScreen(); + QRectF area(x, y, w < 0 ? scr->size().width() : w, h < 0 ? scr->size().height() : h); + if (cursor) { + QPointF point = QCursor::pos(scr); + if (area.contains(point)) { + QPixmap noCursor = scr->grabWindow(0, area.x(), area.y(), area.width(), area.height()); + QPixmap *withCursor = new QPixmap(noCursor); + QPainter painter(withCursor); + auto cursorData = PlatformBackend::inst().getCursor(); + painter.drawPixmap(QCursor::pos() - std::get<0>(cursorData), std::get<1>(cursorData)); + painter.end(); + return withCursor; + } + } + return new QPixmap(scr->grabWindow(0, area.x(), area.y(), area.width(), area.height())); +} diff --git a/screenshotutil.hpp b/screenshotutil.hpp index f683bc4..14e29a6 100644 --- a/screenshotutil.hpp +++ b/screenshotutil.hpp @@ -1,11 +1,12 @@ #ifndef SCREENSHOTUTIL_HPP #define SCREENSHOTUTIL_HPP -#include +#include namespace screenshotutil { QPixmap *fullscreen(bool cursor = true); -QPixmap *window(long wid); +QPixmap *fullscreenArea(bool cursor = true, qreal x = 0, qreal y = 0, qreal w = -1, qreal h = -1); +QPixmap *window(WId wid); void toClipboard(QString value); }