From df61acdbb37f85480e79eb76bb9a2cc9076f3b14 Mon Sep 17 00:00:00 2001 From: ArsenArsen Date: Mon, 15 May 2017 14:10:00 +0200 Subject: [PATCH] feature/platformbackends (aka cursors) done for all but mac --- mainwindow.cpp | 5 ++++ mainwindow.hpp | 5 +--- mainwindow.ui | 73 +++++++++++++++++++++++++--------------------- screenshotter.cpp | 5 ++-- screenshotutil.cpp | 21 +++++++------ screenshotutil.hpp | 2 +- 6 files changed, 62 insertions(+), 49 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b3f186b..cc3d16a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -84,6 +84,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi addHotkeyItem("Area image", "area", new std::function([] { screenshotter::area(); })); ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool()); + ui->captureCursor->setChecked(settings::settings().value("captureCursor", true).toBool()); } MainWindow::~MainWindow() { @@ -172,3 +173,7 @@ void MainWindow::on_settingsButton_clicked() { void MainWindow::on_quickMode_clicked(bool checked) { settings::settings().setValue("quickMode", checked); } + +void MainWindow::on_captureCursor_clicked(bool checked) { + settings::settings().setValue("captureCursor", checked); +} diff --git a/mainwindow.hpp b/mainwindow.hpp index 2395741..272631d 100644 --- a/mainwindow.hpp +++ b/mainwindow.hpp @@ -25,14 +25,11 @@ class MainWindow : public QMainWindow { void on_actionArea_triggered(); void on_uploaderList_clicked(const QModelIndex &); void on_nameScheme_textEdited(const QString &arg1); - void on_delay_valueChanged(double arg1); - void on_hotkeys_doubleClicked(const QModelIndex &index); - void on_settingsButton_clicked(); - void on_quickMode_clicked(bool checked); + void on_captureCursor_clicked(bool checked); public: explicit MainWindow(QWidget *parent = 0); diff --git a/mainwindow.ui b/mainwindow.ui index c1af1bf..e049602 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 512 - 337 + 483 + 368 @@ -25,7 +25,17 @@ - + + + + http://doc.qt.io/qt-5/qdatetime.html#toString + + + Screenshot %(yyyy-MM-dd HH:mm:ss)date + + + + <a href="https://github.com/ArsenArsen/KShare">Source code available free for everyone. Forever.</a> @@ -37,6 +47,13 @@ + + + + Delay before taking a screenshot + + + @@ -50,24 +67,10 @@ - - + + - File name scheme: - - - - - - - Uploader selection: - - - - - - - Delay before taking a screenshot + Open settings directory @@ -78,19 +81,16 @@ - - - - - - - http://doc.qt.io/qt-5/qdatetime.html#toString - + + - Screenshot %(yyyy-MM-dd HH:mm:ss)date + File name scheme: + + + @@ -98,10 +98,17 @@ - - + + - Open settings directory + Uploader selection: + + + + + + + Capture cursor @@ -112,7 +119,7 @@ 0 0 - 512 + 483 24 diff --git a/screenshotter.cpp b/screenshotter.cpp index ef0cddc..62ed8b5 100644 --- a/screenshotter.cpp +++ b/screenshotter.cpp @@ -5,14 +5,15 @@ #include "uploaders/uploadersingleton.hpp" #include #include +#include void screenshotter::area() { - CropEditor *editor = new CropEditor(screenshotutil::fullscreen()); + CropEditor *editor = new CropEditor(screenshotutil::fullscreen(settings::settings().value("captureCursor", true).toBool())); QObject::connect(editor, &CropEditor::cropped, [&](QPixmap *pixmap) { UploaderSingleton::inst().upload(pixmap); }); } void screenshotter::fullscreen() { - UploaderSingleton::inst().upload(screenshotutil::fullscreen()); + UploaderSingleton::inst().upload(screenshotutil::fullscreen(settings::settings().value("captureCursor", true).toBool())); } void screenshotter::areaDelayed() { diff --git a/screenshotutil.cpp b/screenshotutil.cpp index 8e5b1db..e79d5bb 100644 --- a/screenshotutil.cpp +++ b/screenshotutil.cpp @@ -7,15 +7,18 @@ #include #include -QPixmap *screenshotutil::fullscreen() { - QPixmap *noCursor = window(0); - QScopedPointer p(noCursor); - 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; +QPixmap *screenshotutil::fullscreen(bool cursor) { + if (cursor) { + QPixmap *noCursor = window(0); + QScopedPointer p(noCursor); + 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 window(0); } QPixmap *screenshotutil::window(long wid) { diff --git a/screenshotutil.hpp b/screenshotutil.hpp index e8778ca..f683bc4 100644 --- a/screenshotutil.hpp +++ b/screenshotutil.hpp @@ -4,7 +4,7 @@ #include namespace screenshotutil { -QPixmap *fullscreen(); +QPixmap *fullscreen(bool cursor = true); QPixmap *window(long wid); void toClipboard(QString value); }