feature/platformbackends (aka cursors) done for all but mac

This commit is contained in:
ArsenArsen 2017-05-15 14:10:00 +02:00
parent 5b6e9c2e36
commit df61acdbb3
6 changed files with 62 additions and 49 deletions

View File

@ -84,6 +84,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
addHotkeyItem("Area image", "area", new std::function<void()>([] { screenshotter::area(); })); addHotkeyItem("Area image", "area", new std::function<void()>([] { screenshotter::area(); }));
ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool()); ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool());
ui->captureCursor->setChecked(settings::settings().value("captureCursor", true).toBool());
} }
MainWindow::~MainWindow() { MainWindow::~MainWindow() {
@ -172,3 +173,7 @@ void MainWindow::on_settingsButton_clicked() {
void MainWindow::on_quickMode_clicked(bool checked) { void MainWindow::on_quickMode_clicked(bool checked) {
settings::settings().setValue("quickMode", checked); settings::settings().setValue("quickMode", checked);
} }
void MainWindow::on_captureCursor_clicked(bool checked) {
settings::settings().setValue("captureCursor", checked);
}

View File

@ -25,14 +25,11 @@ class MainWindow : public QMainWindow {
void on_actionArea_triggered(); void on_actionArea_triggered();
void on_uploaderList_clicked(const QModelIndex &); void on_uploaderList_clicked(const QModelIndex &);
void on_nameScheme_textEdited(const QString &arg1); void on_nameScheme_textEdited(const QString &arg1);
void on_delay_valueChanged(double arg1); void on_delay_valueChanged(double arg1);
void on_hotkeys_doubleClicked(const QModelIndex &index); void on_hotkeys_doubleClicked(const QModelIndex &index);
void on_settingsButton_clicked(); void on_settingsButton_clicked();
void on_quickMode_clicked(bool checked); void on_quickMode_clicked(bool checked);
void on_captureCursor_clicked(bool checked);
public: public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>512</width> <width>483</width>
<height>337</height> <height>368</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -25,7 +25,17 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="7" column="0" colspan="2"> <item row="3" column="0">
<widget class="QLineEdit" name="nameScheme">
<property name="toolTip">
<string>http://doc.qt.io/qt-5/qdatetime.html#toString</string>
</property>
<property name="text">
<string>Screenshot %(yyyy-MM-dd HH:mm:ss)date</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>&lt;a href=&quot;https://github.com/ArsenArsen/KShare&quot;&gt;Source code available free for everyone. Forever.&lt;/a&gt; <string>&lt;a href=&quot;https://github.com/ArsenArsen/KShare&quot;&gt;Source code available free for everyone. Forever.&lt;/a&gt;
@ -37,6 +47,13 @@
<item row="1" column="1" rowspan="5"> <item row="1" column="1" rowspan="5">
<widget class="QListWidget" name="hotkeys"/> <widget class="QListWidget" name="hotkeys"/>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Delay before taking a screenshot</string>
</property>
</widget>
</item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QDoubleSpinBox" name="delay"> <widget class="QDoubleSpinBox" name="delay">
<property name="toolTip"> <property name="toolTip">
@ -50,24 +67,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="6" column="1">
<widget class="QLabel" name="label_2"> <widget class="QPushButton" name="settingsButton">
<property name="text"> <property name="text">
<string>File name scheme:</string> <string>Open settings directory</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Uploader selection:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Delay before taking a screenshot</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -78,19 +81,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QListWidget" name="uploaderList"/> <widget class="QLabel" name="label_2">
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="nameScheme">
<property name="toolTip">
<string>http://doc.qt.io/qt-5/qdatetime.html#toString</string>
</property>
<property name="text"> <property name="text">
<string>Screenshot %(yyyy-MM-dd HH:mm:ss)date</string> <string>File name scheme:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QListWidget" name="uploaderList"/>
</item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="quickMode"> <widget class="QCheckBox" name="quickMode">
<property name="text"> <property name="text">
@ -98,10 +98,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="0" column="0">
<widget class="QPushButton" name="settingsButton"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Open settings directory</string> <string>Uploader selection:</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="captureCursor">
<property name="text">
<string>Capture cursor</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -112,7 +119,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>512</width> <width>483</width>
<height>24</height> <height>24</height>
</rect> </rect>
</property> </property>

View File

@ -5,14 +5,15 @@
#include "uploaders/uploadersingleton.hpp" #include "uploaders/uploadersingleton.hpp"
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QTimer> #include <QTimer>
#include <settings.hpp>
void screenshotter::area() { 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); }); QObject::connect(editor, &CropEditor::cropped, [&](QPixmap *pixmap) { UploaderSingleton::inst().upload(pixmap); });
} }
void screenshotter::fullscreen() { void screenshotter::fullscreen() {
UploaderSingleton::inst().upload(screenshotutil::fullscreen()); UploaderSingleton::inst().upload(screenshotutil::fullscreen(settings::settings().value("captureCursor", true).toBool()));
} }
void screenshotter::areaDelayed() { void screenshotter::areaDelayed() {

View File

@ -7,7 +7,8 @@
#include <QScreen> #include <QScreen>
#include <platformbackend.hpp> #include <platformbackend.hpp>
QPixmap *screenshotutil::fullscreen() { QPixmap *screenshotutil::fullscreen(bool cursor) {
if (cursor) {
QPixmap *noCursor = window(0); QPixmap *noCursor = window(0);
QScopedPointer<QPixmap> p(noCursor); QScopedPointer<QPixmap> p(noCursor);
QPixmap *withCursor = new QPixmap(*noCursor); QPixmap *withCursor = new QPixmap(*noCursor);
@ -16,6 +17,8 @@ QPixmap *screenshotutil::fullscreen() {
painter.drawPixmap(QCursor::pos() - std::get<0>(cursorData), std::get<1>(cursorData)); painter.drawPixmap(QCursor::pos() - std::get<0>(cursorData), std::get<1>(cursorData));
painter.end(); painter.end();
return withCursor; return withCursor;
}
return window(0);
} }
QPixmap *screenshotutil::window(long wid) { QPixmap *screenshotutil::window(long wid) {

View File

@ -4,7 +4,7 @@
#include <QPixmap> #include <QPixmap>
namespace screenshotutil { namespace screenshotutil {
QPixmap *fullscreen(); QPixmap *fullscreen(bool cursor = true);
QPixmap *window(long wid); QPixmap *window(long wid);
void toClipboard(QString value); void toClipboard(QString value);
} }