Skip to content

Commit 7f83b12

Browse files
committedMar 1, 2013
Add New from Template to composer's Composer menu
- Show busy indicator dialog while template is loading into hidden composer (much faster loading) - Clean up composer actions' text (title capitalize action text, sentence capitalize tool tips)
1 parent fe898a0 commit 7f83b12

File tree

3 files changed

+108
-19
lines changed

3 files changed

+108
-19
lines changed
 

‎src/app/composer/qgscomposer.cpp

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
179179
composerMenu->addMenu( mPrintComposersMenu );
180180

181181
composerMenu->addSeparator();
182+
composerMenu->addAction( mActionNewFromTemplate );
182183
composerMenu->addAction( mActionLoadFromTemplate );
183184
composerMenu->addAction( mActionSaveAsTemplate );
184185
composerMenu->addSeparator();
@@ -362,6 +363,7 @@ void QgsComposer::setupTheme()
362363
mActionNewComposer->setIcon( QgsApplication::getThemeIcon( "/mActionNewComposer.png" ) );
363364
mActionDuplicateComposer->setIcon( QgsApplication::getThemeIcon( "/mActionDuplicateComposer.png" ) );
364365
mActionComposerManager->setIcon( QgsApplication::getThemeIcon( "/mActionComposerManager.png" ) );
366+
mActionNewFromTemplate->setIcon( QgsApplication::getThemeIcon( "/mActionNewComposer.png" ) );
365367
mActionLoadFromTemplate->setIcon( QgsApplication::getThemeIcon( "/mActionFileOpen.png" ) );
366368
mActionSaveAsTemplate->setIcon( QgsApplication::getThemeIcon( "/mActionFileSaveAs.png" ) );
367369
mActionExportAsImage->setIcon( QgsApplication::getThemeIcon( "/mActionSaveMapAsImage.png" ) );
@@ -1434,7 +1436,17 @@ void QgsComposer::on_mActionSaveAsTemplate_triggered()
14341436
}
14351437
}
14361438

1439+
void QgsComposer::on_mActionNewFromTemplate_triggered()
1440+
{
1441+
loadTemplate( true );
1442+
}
1443+
14371444
void QgsComposer::on_mActionLoadFromTemplate_triggered()
1445+
{
1446+
loadTemplate( false );
1447+
}
1448+
1449+
void QgsComposer::loadTemplate( bool newCompser )
14381450
{
14391451
QSettings settings;
14401452
QString openFileDir = settings.value( "UI/lastComposerTemplateDir", "" ).toString();
@@ -1451,16 +1463,49 @@ void QgsComposer::on_mActionLoadFromTemplate_triggered()
14511463
QFile templateFile( openFileString );
14521464
if ( !templateFile.open( QIODevice::ReadOnly ) )
14531465
{
1454-
QMessageBox::warning( 0, tr( "Read error" ), tr( "Error, could not read file" ) );
1466+
QMessageBox::warning( this, tr( "Read error" ), tr( "Error, could not read file" ) );
14551467
return;
14561468
}
14571469

1458-
if ( mComposition )
1470+
QgsComposer* c = 0;
1471+
QgsComposition* comp = 0;
1472+
1473+
if ( newCompser )
1474+
{
1475+
QString newTitle = mQgis->uniqueComposerTitle( this, true );
1476+
if ( newTitle.isNull() )
1477+
{
1478+
return;
1479+
}
1480+
c = mQgis->createNewComposer( newTitle );
1481+
if ( !c )
1482+
{
1483+
QMessageBox::warning( this, tr( "Composer error" ), tr( "Error, could not create new composer" ) );
1484+
return;
1485+
}
1486+
comp = c->composition();
1487+
}
1488+
else
1489+
{
1490+
c = this;
1491+
comp = mComposition;
1492+
}
1493+
1494+
if ( comp )
14591495
{
14601496
QDomDocument templateDoc;
14611497
if ( templateDoc.setContent( &templateFile ) )
14621498
{
1463-
mComposition->loadFromTemplate( templateDoc, 0, false );
1499+
// provide feedback, since composer will be hidden when loading template (much faster)
1500+
QDialog* dlg = busyIndicatorDialog( tr( "Loading template into composer..." ), 0 );
1501+
dlg->setStyleSheet( mQgis->styleSheet() );
1502+
dlg->show();
1503+
1504+
c->hide();
1505+
comp->loadFromTemplate( templateDoc, 0, false );
1506+
c->activate();
1507+
1508+
dlg->close();
14641509
}
14651510
}
14661511
}

‎src/app/composer/qgscomposer.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
8484
const QString& title() const {return mTitle;}
8585
void setTitle( const QString& title );
8686

87+
//! Load template into current or blank composer
88+
//! @param newCompser whether to create a new composer first
89+
//! @note added in 1.9
90+
void loadTemplate( bool newCompser );
91+
8792
//! Modal busy indicator dialog with no buttons that deletes on close
8893
//! @param message text to show above busy progress indicator
8994
//! @note added in 1.9
@@ -192,6 +197,10 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
192197
//! Save composer as template
193198
void on_mActionSaveAsTemplate_triggered();
194199

200+
//! Load template into blank composer
201+
//! @note added in 1.9
202+
void on_mActionNewFromTemplate_triggered();
203+
195204
void on_mActionLoadFromTemplate_triggered();
196205

197206
//! Set tool to move item content

‎src/ui/qgscomposerbase.ui

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
<property name="text">
144144
<string>Zoom Full</string>
145145
</property>
146+
<property name="toolTip">
147+
<string>Zoom full</string>
148+
</property>
146149
</action>
147150
<action name="mActionZoomIn">
148151
<property name="icon">
@@ -152,6 +155,9 @@
152155
<property name="text">
153156
<string>Zoom In</string>
154157
</property>
158+
<property name="toolTip">
159+
<string>Zoom in</string>
160+
</property>
155161
</action>
156162
<action name="mActionZoomOut">
157163
<property name="icon">
@@ -161,6 +167,9 @@
161167
<property name="text">
162168
<string>Zoom Out</string>
163169
</property>
170+
<property name="toolTip">
171+
<string>Zoom out</string>
172+
</property>
164173
</action>
165174
<action name="mActionAddNewMap">
166175
<property name="icon">
@@ -218,6 +227,9 @@
218227
<property name="text">
219228
<string>Export as Image...</string>
220229
</property>
230+
<property name="toolTip">
231+
<string>Export as image</string>
232+
</property>
221233
</action>
222234
<action name="mActionExportAsPDF">
223235
<property name="icon">
@@ -269,6 +281,9 @@
269281
<property name="text">
270282
<string>Add Image</string>
271283
</property>
284+
<property name="toolTip">
285+
<string>Add image</string>
286+
</property>
272287
</action>
273288
<action name="mActionMoveItemContent">
274289
<property name="text">
@@ -328,57 +343,63 @@
328343
</action>
329344
<action name="mActionLoadFromTemplate">
330345
<property name="text">
331-
<string>Load From template</string>
346+
<string>Load from Template</string>
347+
</property>
348+
<property name="toolTip">
349+
<string>Load from template</string>
332350
</property>
333351
</action>
334352
<action name="mActionSaveAsTemplate">
335353
<property name="text">
354+
<string>Save as Template</string>
355+
</property>
356+
<property name="toolTip">
336357
<string>Save as template</string>
337358
</property>
338359
</action>
339360
<action name="mActionAlignLeft">
340361
<property name="text">
341-
<string>Align left</string>
362+
<string>Align Left</string>
342363
</property>
343364
<property name="toolTip">
344365
<string>Align selected items left</string>
345366
</property>
346367
</action>
347368
<action name="mActionAlignHCenter">
348369
<property name="text">
349-
<string>Align center</string>
370+
<string>Align Center</string>
350371
</property>
351372
<property name="toolTip">
352373
<string>Align center horizontal</string>
353374
</property>
354375
</action>
355376
<action name="mActionAlignRight">
356377
<property name="text">
357-
<string>Align right</string>
378+
<string>Align Right</string>
358379
</property>
359380
<property name="toolTip">
360381
<string>Align selected items right</string>
361382
</property>
362383
</action>
363384
<action name="mActionAlignTop">
364385
<property name="text">
365-
<string>Align top</string>
386+
<string>Align Top</string>
366387
</property>
367388
<property name="toolTip">
368389
<string>Align selected items to top</string>
369390
</property>
370391
</action>
371392
<action name="mActionAlignVCenter">
372393
<property name="text">
373-
<string>Align center vertical</string>
394+
<string>Align Center Vertical</string>
374395
</property>
375396
<property name="toolTip">
376397
<string>Align center vertical</string>
377398
</property>
378399
</action>
379400
<action name="mActionAlignBottom">
380401
<property name="text">
381-
<string>Align bottom</string>
402+
<string>Align Bottom</string>
382403
</property>
383404
<property name="toolTip">
384405
<string>Align selected items bottom</string>
@@ -400,6 +421,9 @@
400421
<bool>true</bool>
401422
</property>
402423
<property name="text">
424+
<string>Add Arrow</string>
425+
</property>
426+
<property name="toolTip">
403427
<string>Add arrow</string>
404428
</property>
405429
</action>
@@ -408,16 +432,19 @@
408432
<bool>true</bool>
409433
</property>
410434
<property name="text">
411-
<string>Add table</string>
435+
<string>Add Table</string>
412436
</property>
413437
<property name="toolTip">
414-
<string>Adds attribute table</string>
438+
<string>Add attribute table</string>
415439
</property>
416440
</action>
417441
<action name="mActionPageSetup">
418442
<property name="text">
419443
<string>Page Setup</string>
420444
</property>
445+
<property name="toolTip">
446+
<string>Page setup</string>
447+
</property>
421448
<property name="shortcut">
422449
<string>Ctrl+Shift+P</string>
423450
</property>
@@ -461,7 +488,7 @@
461488
<string>Add Rectangle</string>
462489
</property>
463490
<property name="toolTip">
464-
<string>Add Rectangle</string>
491+
<string>Add rectangle</string>
465492
</property>
466493
</action>
467494
<action name="mActionAddTriangle">
@@ -472,7 +499,7 @@
472499
<string>Add Triangle</string>
473500
</property>
474501
<property name="toolTip">
475-
<string>Add Triangle</string>
502+
<string>Add triangle</string>
476503
</property>
477504
</action>
478505
<action name="mActionAddEllipse">
@@ -483,7 +510,7 @@
483510
<string>Add Ellipse</string>
484511
</property>
485512
<property name="toolTip">
486-
<string>Add Ellipse</string>
513+
<string>Add ellipse</string>
487514
</property>
488515
</action>
489516
<action name="mActionAddHtml">
@@ -502,15 +529,15 @@
502529
<string>Composer Manager</string>
503530
</property>
504531
<property name="toolTip">
505-
<string>Composer Manager</string>
532+
<string>Composer manager</string>
506533
</property>
507534
</action>
508535
<action name="mActionNewComposer">
509536
<property name="text">
510537
<string>&amp;New Composer</string>
511538
</property>
512539
<property name="toolTip">
513-
<string>New Composer</string>
540+
<string>New composer</string>
514541
</property>
515542
<property name="shortcut">
516543
<string>Ctrl+N</string>
@@ -521,7 +548,7 @@
521548
<string>&amp;Save Project</string>
522549
</property>
523550
<property name="toolTip">
524-
<string>Save Project</string>
551+
<string>Save project</string>
525552
</property>
526553
<property name="shortcut">
527554
<string>Ctrl+S</string>
@@ -532,7 +559,15 @@
532559
<string>&amp;Duplicate Composer</string>
533560
</property>
534561
<property name="toolTip">
535-
<string>Duplicate Composer</string>
562+
<string>Duplicate composer</string>
563+
</property>
564+
</action>
565+
<action name="mActionNewFromTemplate">
566+
<property name="text">
567+
<string>New from Template</string>
568+
</property>
569+
<property name="toolTip">
570+
<string>New from template</string>
536571
</property>
537572
</action>
538573
</widget>

0 commit comments

Comments
 (0)
Please sign in to comment.