2017-04-23 15:05:48 +02:00
|
|
|
#include "screenshotter.hpp"
|
|
|
|
#include "cropeditor/cropeditor.hpp"
|
2017-04-25 22:36:33 +02:00
|
|
|
#include "mainwindow.hpp"
|
2017-04-23 15:05:48 +02:00
|
|
|
#include "uploaders/uploadersingleton.hpp"
|
2017-11-23 20:33:49 +01:00
|
|
|
#include "utils.hpp"
|
2017-04-25 22:36:33 +02:00
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QTimer>
|
2017-06-27 11:33:11 +02:00
|
|
|
#include <platformbackend.hpp>
|
2017-05-15 14:10:00 +02:00
|
|
|
#include <settings.hpp>
|
2017-04-23 15:05:48 +02:00
|
|
|
|
2017-12-17 19:59:16 +01:00
|
|
|
void areaScreenshotCallback(QPixmap p) {
|
|
|
|
CropEditor *editor = new CropEditor(p);
|
2017-07-02 20:51:15 +02:00
|
|
|
QObject::connect(editor, &CropEditor::cropped, [&](QPixmap pixmap) { UploaderSingleton::inst().upload(pixmap); });
|
2017-04-23 15:05:48 +02:00
|
|
|
}
|
|
|
|
|
2017-12-17 19:59:16 +01:00
|
|
|
void screenshotter::area() {
|
|
|
|
if (!settings::settings().value("command/fullscreenCommand", "").toString().isEmpty())
|
|
|
|
utils::externalScreenshot(areaScreenshotCallback);
|
|
|
|
else
|
|
|
|
areaScreenshotCallback(utils::fullscreen(settings::settings().value("captureCursor", true).toBool()));
|
|
|
|
}
|
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void screenshotter::fullscreen() {
|
2017-12-17 21:39:57 +01:00
|
|
|
if (!settings::settings().value("command/fullscreenCommand", "").toString().isEmpty())
|
|
|
|
utils::externalScreenshot([](QPixmap p) { UploaderSingleton::inst().upload(p); });
|
|
|
|
else
|
|
|
|
UploaderSingleton::inst().upload(utils::fullscreen(settings::settings().value("captureCursor", true).toBool()));
|
2017-04-23 15:05:48 +02:00
|
|
|
}
|
2017-04-25 22:36:33 +02:00
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void screenshotter::areaDelayed() {
|
2017-06-22 17:41:29 +02:00
|
|
|
QTimer::singleShot(settings::settings().value("delay", 0.5).toFloat() * 1000, &screenshotter::area);
|
2017-04-25 22:36:33 +02:00
|
|
|
}
|
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void screenshotter::fullscreenDelayed() {
|
2017-06-22 17:41:29 +02:00
|
|
|
QTimer::singleShot(settings::settings().value("delay", 0.5).toFloat() * 1000, &screenshotter::fullscreen);
|
2017-04-25 22:36:33 +02:00
|
|
|
}
|
2017-06-27 11:33:11 +02:00
|
|
|
|
|
|
|
void screenshotter::activeDelayed() {
|
2017-06-27 18:29:08 +02:00
|
|
|
QTimer::singleShot(settings::settings().value("delay", 0.5).toFloat() * 1000, &screenshotter::active);
|
2017-06-27 11:33:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void screenshotter::active() {
|
|
|
|
#ifdef PLATFORM_CAPABILITY_ACTIVEWINDOW
|
2017-12-17 19:59:16 +01:00
|
|
|
if (!settings::settings().value("command/activeCommand", "").toString().isEmpty())
|
|
|
|
utils::externalScreenshotActive([](QPixmap p) { UploaderSingleton::inst().upload(p); });
|
|
|
|
else
|
|
|
|
UploaderSingleton::inst().upload(utils::window(PlatformBackend::inst().getActiveWID()));
|
2017-06-27 11:33:11 +02:00
|
|
|
#endif
|
|
|
|
}
|