-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsappscreenshots.h
100 lines (82 loc) · 3.03 KB
/
qgsappscreenshots.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************************************************************
qgsappscreenshots.h
--------------------------------------
Date : September 2018
Copyright : (C) 2018 by Denis Rouzaud
Email : denis@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSAPPSCREENSHOTS_H
#define QGSAPPSCREENSHOTS_H
#include <QObject>
#include <QRect>
class QScreen;
class QgsVectorLayer;
class QgsRasterLayer;
class QgsAppScreenShots
{
Q_GADGET
public:
enum GrabMode
{
GrabWidget,
GrabWidgetAndFrame,
GrabWholeWindow
};
Q_ENUM( GrabMode )
enum Reference
{
Widget,
QgisApp,
Screen
};
//! Not part of the API to avoid cluttering
enum Category
{
All = 0,
GlobalOptions = 1 << 0,
VectorLayerProperties = 1 << 1,
RasterLayerProperties = 1 << 2,
};
Q_ENUM( Category )
Q_DECLARE_FLAGS( Categories, Category )
Q_FLAG( Categories )
QgsAppScreenShots( const QString &saveDirectory );
//! if categories is null, then takes all categories
void takePicturesOf( Categories categories = Categories() );
//! set gradient size
void setGradientSize( int size );
private:
QScreen *screen( QWidget *widget = nullptr );
void moveWidgetTo( QWidget *widget, Qt::Corner corner, Reference reference = Screen );
//! take and directly save screenshot
void takeScreenshot( const QString &name, const QString &folder, QWidget *widget = nullptr, GrabMode mode = GrabWidgetAndFrame );
//! take screenshot and return pixmap
QPixmap takeScreenshot( QWidget *widget = nullptr, GrabMode mode = GrabWidgetAndFrame, QRect crop = QRect(), bool gradient = false );
/**
* save screenshot from pixmap
* @param pixmap
* @param name
* @param crop the crop can have only one dimension (empty but not null rect)
* @param gradient
*/
void saveScreenshot( QPixmap &pixmap, const QString &name, const QString &folder );
void takeVectorLayerProperties();
void takeVectorLayerProperties25DSymbol();
void takeGlobalOptions();
void takeRasterLayerProperties();
QString mSaveDirectory;
int mGradientSize = 200;
QgsVectorLayer *mLineLayer = nullptr;
QgsVectorLayer *mPolygonLayer = nullptr;
QgsRasterLayer *mRasterLayer = nullptr;
Q_DISABLE_COPY( QgsAppScreenShots )
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAppScreenShots::Categories )
#endif // QGSAPPSCREENSHOTS_H