Example #1
0
void uploadClipboard() {
    QClipboard *clipboard = qApp->clipboard();
    const QMimeData *data = clipboard->mimeData();

    if (data->hasText()) {
        upload(PuushFile{data->text().toUtf8(), generateFilename("clipboard (%1).txt")});
    } else if (data->hasImage()) {
        QImage img = data->imageData().value<QImage>();
        upload(compressImage("clipboard", img));
    } else {
        QStringList formats = data->formats();
        if (formats.isEmpty()) {
            trayicon->showMessage(QObject::tr("Error."), QObject::tr("The clipboard is empty."), QSystemTrayIcon::Critical);
            return;
        }

        QByteArray buffer = data->data(formats.first());
        if (buffer.isEmpty()) {
            trayicon->showMessage(QObject::tr("Error."), QObject::tr("The clipboard is empty."), QSystemTrayIcon::Critical);
            return;
        }

        upload(PuushFile{buffer, generateFilename("clipboard (%1).bin")});
    }
}
Example #2
0
// ".png" or ".jpg"
cv::Mat compressImage2(const cv::Mat & image, const std::string & format)
{
	std::vector<unsigned char> bytes = compressImage(image, format);
	if(bytes.size())
	{
		return cv::Mat(1, (int)bytes.size(), CV_8UC1, bytes.data()).clone();
	}
	return cv::Mat();
}
Example #3
0
QString takeScreenshot(QRect area) {
    QPixmap shot = grabEntireScreen();

    if (area.isValid())
        shot = shot.copy(area);

    PuushFile file = compressImage("ss", shot);

    if (settings.onPuushActions & Settings::SaveToDisk)
        writeFileToDisk(file);

    return upload(file);
}