@@ -88,9 +88,12 @@ void usage( std::string const & appName )
88
88
<< " Usage: " << appName << " [options] [FILES]\n "
89
89
<< " options:\n "
90
90
<< " \t [--snapshot filename]\t emit snapshot of loaded datasets to given file\n "
91
+ << " \t [--width width]\t width of snapshot to emit\n "
92
+ << " \t [--height height]\t height of snapshot to emit\n "
91
93
<< " \t [--lang language]\t use language for interface text\n "
92
94
<< " \t [--project projectfile]\t load the given QGIS project\n "
93
95
<< " \t [--extent xmin,ymin,xmax,ymax]\t set initial map extent\n "
96
+ << " \t [--nologo]\t hide splash screen\n "
94
97
<< " \t [--help]\t\t this text\n\n "
95
98
<< " FILES:\n "
96
99
<< " Files specified on the command line can include rasters,\n "
@@ -257,6 +260,10 @@ int main( int argc, char *argv[] )
257
260
// This behaviour is used to load the app, snapshot the map,
258
261
// save the image to disk and then exit
259
262
QString mySnapshotFileName = " " ;
263
+ int mySnapshotWidth = 800 ;
264
+ int mySnapshotHeight = 600 ;
265
+
266
+ bool myHideSplash = false ;
260
267
261
268
// This behaviour will set initial extent of map canvas, but only if
262
269
// there are no command line arguments. This gives a usable map
@@ -284,10 +291,13 @@ int main( int argc, char *argv[] )
284
291
static struct option long_options[] =
285
292
{
286
293
/* These options set a flag. */
287
- {" help" , no_argument, 0 , ' h' },
294
+ {" help" , no_argument, 0 , ' ?' },
295
+ {" nologo" , no_argument, 0 , ' n' },
288
296
/* These options don't set a flag.
289
297
* We distinguish them by their indices. */
290
298
{" snapshot" , required_argument, 0 , ' s' },
299
+ {" width" , required_argument, 0 , ' w' },
300
+ {" height" , required_argument, 0 , ' h' },
291
301
{" lang" , required_argument, 0 , ' l' },
292
302
{" project" , required_argument, 0 , ' p' },
293
303
{" extent" , required_argument, 0 , ' e' },
@@ -297,7 +307,7 @@ int main( int argc, char *argv[] )
297
307
/* getopt_long stores the option index here. */
298
308
int option_index = 0 ;
299
309
300
- optionChar = getopt_long ( argc, argv, " slpe " ,
310
+ optionChar = getopt_long ( argc, argv, " swhlpe " ,
301
311
long_options, &option_index );
302
312
303
313
/* Detect the end of the options. */
@@ -320,6 +330,18 @@ int main( int argc, char *argv[] )
320
330
mySnapshotFileName = QDir::convertSeparators ( QFileInfo ( QFile::decodeName ( optarg ) ).absoluteFilePath () );
321
331
break ;
322
332
333
+ case ' w' :
334
+ mySnapshotWidth = QString ( optarg ).toInt ();
335
+ break ;
336
+
337
+ case ' h' :
338
+ mySnapshotHeight = QString ( optarg ).toInt ();
339
+ break ;
340
+
341
+ case ' n' :
342
+ myHideSplash = true ;
343
+ break ;
344
+
323
345
case ' l' :
324
346
myTranslationCode = optarg ;
325
347
break ;
@@ -332,7 +354,6 @@ int main( int argc, char *argv[] )
332
354
myInitialExtent = optarg ;
333
355
break ;
334
356
335
- case ' h' :
336
357
case ' ?' :
337
358
usage ( argv[0 ] );
338
359
return 2 ; // XXX need standard exit codes
@@ -364,15 +385,27 @@ int main( int argc, char *argv[] )
364
385
{
365
386
QString arg = argv[i];
366
387
367
- if ( arg == " --help" || arg == " -h " || arg == " - ?" )
388
+ if ( arg == " --help" || arg == " -?" )
368
389
{
369
390
usage ( argv[0 ] );
370
391
return 2 ;
371
392
}
393
+ else if ( arg == " -nologo" || arg == " -n" )
394
+ {
395
+ myHideSplash = true ;
396
+ }
372
397
else if ( i + 1 < argc && ( arg == " --snapshot" || arg == " -s" ) )
373
398
{
374
399
mySnapshotFileName = QDir::convertSeparators ( QFileInfo ( QFile::decodeName ( argv[++i] ) ).absoluteFilePath () );
375
400
}
401
+ else if ( i + 1 < argc && ( arg == " -width" || arg == " -w" ) )
402
+ {
403
+ mySnapshotWidth = QString ( argv[++i] ).toInt ();
404
+ }
405
+ else if ( i + 1 < argc && ( arg == " -height" || arg == " -h" ) )
406
+ {
407
+ mySnapshotHeight = QString ( argv[++i] ).toInt ();
408
+ }
376
409
else if ( i + 1 < argc && ( arg == " --lang" || arg == " -l" ) )
377
410
{
378
411
myTranslationCode = argv[++i];
@@ -518,7 +551,7 @@ int main( int argc, char *argv[] )
518
551
QString mySplashPath ( QgsApplication::splashPath () );
519
552
QPixmap myPixmap ( mySplashPath + QString ( " splash.png" ) );
520
553
QSplashScreen *mypSplash = new QSplashScreen ( myPixmap );
521
- if ( mySettings.value ( " /qgis/hideSplash" ).toBool () )
554
+ if ( mySettings.value ( " /qgis/hideSplash" ).toBool () || myHideSplash )
522
555
{
523
556
// splash screen hidden
524
557
}
@@ -701,7 +734,7 @@ int main( int argc, char *argv[] )
701
734
*/
702
735
// qgis->show();
703
736
myApp.processEvents ();
704
- QPixmap * myQPixmap = new QPixmap ( 800 , 600 );
737
+ QPixmap * myQPixmap = new QPixmap ( mySnapshotWidth, mySnapshotHeight );
705
738
myQPixmap->fill ();
706
739
qgis->saveMapAsImage ( mySnapshotFileName, myQPixmap );
707
740
myApp.processEvents ();
0 commit comments