18
18
#include < QWindow>
19
19
#include < QScreen>
20
20
#include < QImageWriter>
21
- #include < QTransform >
21
+ #include < QIcon >
22
22
23
23
#include " qgsappscreenshots.h"
24
24
27
27
#include " qgsproject.h"
28
28
#include " qgsmessagelog.h"
29
29
#include " qgisapp.h"
30
+ #include " qgsrendererpropertiesdialog.h"
31
+ #include " qgs25drendererwidget.h"
32
+ #include " qgsapplication.h"
33
+
30
34
31
35
QgsAppScreenShots::QgsAppScreenShots ( const QString &saveDirectory )
32
36
: mSaveDirectory( saveDirectory )
33
37
{
34
38
QString layerDef = QStringLiteral ( " Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=my_integer:integer&field=my_double:double&key=pk" );
35
- mVectorLayer = new QgsVectorLayer ( layerDef, QStringLiteral ( " Layer" ), QStringLiteral ( " memory" ) );
36
- QgsProject::instance ()->addMapLayer ( mVectorLayer );
39
+ mLineLayer = new QgsVectorLayer ( layerDef, QStringLiteral ( " Line Layer" ), QStringLiteral ( " memory" ) );
40
+ layerDef = QStringLiteral ( " Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
41
+ mPolygonLayer = new QgsVectorLayer ( layerDef, QStringLiteral ( " Polygon Layer" ), QStringLiteral ( " memory" ) );
42
+
43
+ QgsProject::instance ()->addMapLayers ( QList<QgsMapLayer *>()
44
+ << mLineLayer
45
+ << mPolygonLayer );
37
46
}
38
47
39
48
void QgsAppScreenShots::saveScreenshot ( const QString &name, QWidget *widget, GrabMode mode )
@@ -117,6 +126,9 @@ QScreen *QgsAppScreenShots::screen( QWidget *widget )
117
126
118
127
void QgsAppScreenShots::takePicturesOf ( Categories categories )
119
128
{
129
+ if ( !categories || categories.testFlag ( Symbol25D ) )
130
+ take25dSymbol ();
131
+
120
132
if ( !categories || categories.testFlag ( VectorLayerProperties ) )
121
133
takeVectorLayerProperties ();
122
134
}
@@ -128,7 +140,7 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )
128
140
void QgsAppScreenShots::takeVectorLayerProperties ()
129
141
{
130
142
QString rootName = QLatin1String ( " vectorlayerproperties_" );
131
- QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties ( mVectorLayer , QgisApp::instance () );
143
+ QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties ( mLineLayer , QgisApp::instance () );
132
144
dlg->show ();
133
145
// ----------------
134
146
// do all the pages
@@ -159,3 +171,28 @@ void QgsAppScreenShots::takeVectorLayerProperties()
159
171
dlg->deleteLater ();
160
172
}
161
173
174
+ void QgsAppScreenShots::take25dSymbol ()
175
+ {
176
+ QString rootName = QLatin1String ( " vectorlayerproperties_" );
177
+ QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties ( mPolygonLayer , QgisApp::instance () );
178
+ dlg->show ();
179
+ dlg->mOptionsListWidget ->setCurrentRow ( 2 );
180
+ Q_ASSERT ( dlg->mOptionsListWidget ->currentItem ()->icon ().pixmap ( 24 , 24 ).toImage ()
181
+ == QgsApplication::getThemeIcon ( QStringLiteral ( " /propertyicons/symbology.svg" ) ).pixmap ( 24 , 24 ).toImage () );
182
+ int idx = dlg->mRendererDialog ->cboRenderers ->findData ( QLatin1String ( " 25dRenderer" ) );
183
+ Q_ASSERT ( idx >= 0 );
184
+ dlg->mRendererDialog ->cboRenderers ->setCurrentIndex ( idx );
185
+ QCoreApplication::processEvents ();
186
+ Qgs25DRendererWidget *w = dynamic_cast <Qgs25DRendererWidget *>( dlg->mRendererDialog ->mActiveWidget );
187
+ w->mHeightWidget ->setField ( QLatin1String ( " height" ) );
188
+ Q_ASSERT ( w->mHeightWidget ->expression () == QLatin1String ( " \" height\" " ) );
189
+ QCoreApplication::processEvents ();
190
+ dlg->adjustSize ();
191
+ QCoreApplication::processEvents ();
192
+ saveScreenshot ( rootName + QLatin1String ( " 25dsymbol" ), dlg );
193
+
194
+ // exit properly
195
+ dlg->close ();
196
+ dlg->deleteLater ();
197
+ }
198
+
0 commit comments