void FlameshotDBusAdapter::fullScreen(
        QString path, bool toClipboard, int delay, uint id)
{
    auto f = [id, path, toClipboard, this]() {
        bool ok = true;
        QPixmap p(ScreenGrabber().grabEntireDesktop(ok));
        if (!ok) {
            SystemNotification().sendMessage(tr("Unable to capture screen"));
            Q_EMIT captureFailed(id);
            return;
        }
        if(toClipboard) {
            ResourceExporter().captureToClipboard(p);
        }
        if(!path.isEmpty()) {
            ResourceExporter().captureToFile(p, path);
        }
        QByteArray byteArray;
        QBuffer buffer(&byteArray);
        p.save(&buffer, "PNG");
        Q_EMIT captureTaken(id, byteArray);
    };
    //QTimer::singleShot(delay, this, f); // // requires Qt 5.4
    doLater(delay, this, f);
}
Example #2
0
void Controller::startFullscreenCapture(const uint id) {
    bool ok = true;
    QPixmap p(ScreenGrabber().grabEntireDesktop(ok));
    if (ok) {
        emit captureTaken(id, p);
    } else {
        emit captureFailed(id);
    }
}
Example #3
0
void Controller::startScreenGrab(const uint id, const int screenNumber) {
    bool ok = true;
    int n = screenNumber;

    if (n < 0) {
        QPoint globalCursorPos = QCursor::pos();
        n = qApp->desktop()->screenNumber(globalCursorPos);
    }
    QPixmap p(ScreenGrabber().grabScreen(n, ok));
    if (ok) {
        emit captureTaken(id, p);
    } else {
        emit captureFailed(id);
    }
}