on xenial help sign in
rotate screenshots according to the orientation
c9777f7Lukáš Tinkl
plugins/ScreenGrabber/screengrabber.cpp+4−2
@@ -60,8 +60,10 @@ ScreenGrabber::ScreenGrabber(QObject *parent)
60 }
60 }
61}
61}
62
62
63−void ScreenGrabber::captureAndSave()
63+void ScreenGrabber::captureAndSave(int angle)
64{
64{
65+ qDebug() << Q_FUNC_INFO << angle;
66+
65 if (fileNamePrefix.isEmpty())
67 if (fileNamePrefix.isEmpty())
66 {
68 {
67 qWarning() << "ScreenShotter: no directory to save screenshot";
69 qWarning() << "ScreenShotter: no directory to save screenshot";
@@ -82,7 +84,7 @@ void ScreenGrabber::captureAndSave()
82 return;
84 return;
83 }
85 }
84
86
85− const QImage screenshot = main_window->grabWindow();
87+ const QImage screenshot = main_window->grabWindow().transformed(QTransform().rotate(angle));
86 const QString filename = makeFileName();
88 const QString filename = makeFileName();
87 qDebug() << "Saving screenshot to" << filename;
89 qDebug() << "Saving screenshot to" << filename;
88 auto saveOp = QtConcurrent::run(saveScreenshot, screenshot, filename, getFormat(), screenshotQuality);
90 auto saveOp = QtConcurrent::run(saveScreenshot, screenshot, filename, getFormat(), screenshotQuality);
plugins/ScreenGrabber/screengrabber.h+1−1
@@ -29,7 +29,7 @@ public:
29 ~ScreenGrabber() = default;
29 ~ScreenGrabber() = default;
30
30
31public Q_SLOTS:
31public Q_SLOTS:
32− void captureAndSave();
32+ void captureAndSave(int angle = 0);
33
33
34Q_SIGNALS:
34Q_SIGNALS:
35 void screenshotSaved(const QString &filename);
35 void screenshotSaved(const QString &filename);
qml/Components/ScreenGrabber.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.0
18import QtMultimedia 5.0
18import QtMultimedia 5.0
19import ScreenGrabber 0.1
19import ScreenGrabber 0.1
20import GlobalShortcut 1.0
20import GlobalShortcut 1.0
21+import QtQuick.Window 2.2
21
22
22Rectangle {
23Rectangle {
23 id: root
24 id: root
@@ -67,7 +68,7 @@ Rectangle {
67 to: 0.0
68 to: 0.0
68 onStopped: {
69 onStopped: {
69 if (visible) {
70 if (visible) {
70− screenGrabber.captureAndSave();
71+ screenGrabber.captureAndSave(Screen.angleBetween(Screen.orientation, Screen.primaryOrientation));
71 visible = false;
72 visible = false;
72 }
73 }
73 }
74 }