-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgisapp.cpp
5304 lines (4468 loc) · 167 KB
/
qgisapp.cpp
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
qgisapp.cpp - description
-------------------
begin : Sat Jun 22 2002
copyright : (C) 2002 by Gary E.Sherman
email : sherman at mrcc.com
Romans 3:23=>Romans 6:23=>Romans 10:9,10=>Romans 12
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
/* $Id$ */
//
// QT4 includes make sure to use the new <CamelCase> style!
//
#include <Q3ListViewItem>
#include <QAction>
#include <QApplication>
#include <QBitmap>
#include <QCheckBox>
#include <QClipboard>
#include <QColor>
#include <QCursor>
#include <QDesktopWidget>
#include <QDialog>
#include <QDir>
#include <QEvent>
#include <QFile>
#include <QFileInfo>
#include <QInputDialog>
#include <QKeyEvent>
#include <QLabel>
#include <QLibrary>
#include <QMenu>
#include <QMenuBar>
#include <QMenuItem>
#include <QMessageBox>
#include <QPainter>
#include <QPictureIO>
#include <QPixmap>
#include <QPoint>
#include <QPrinter>
#include <QProcess>
#include <QProgressBar>
#include <QSettings>
#include <QSplashScreen>
#include <QStringList>
#include <QTcpSocket>
#include <QTextStream>
#include <QToolButton>
#include <QToolTip>
#include <QVBoxLayout>
#include <QWhatsThis>
#include <QtGlobal>
//
// QGIS Specific Includes
//
#include "../../images/themes/default/qgis.xpm"
#include "qgisapp.h"
#include "qgis.h"
#include "qgisplugin.h"
#include "qgsabout.h"
#include "qgsapplication.h"
#include "qgsbookmarkitem.h"
#include "qgsbookmarks.h"
#include "qgscomposer.h"
#include <qgscursors.h>
#include "qgscustomprojectiondialog.h"
#include "qgsencodingfiledialog.h"
#include "qgsgeomtypedialog.h"
#include "qgshelpviewer.h"
#include "qgslegend.h"
#include "qgslegendlayerfile.h"
#include "qgslegendlayer.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerinterface.h"
#include "qgsmaplayerregistry.h"
#include "qgsmapoverviewcanvas.h"
#include "qgsmaprender.h"
#include "qgsmessageviewer.h"
#include "qgsoptions.h"
#include "qgspastetransformations.h"
#include "qgspluginitem.h"
#include "qgspluginmanager.h"
#include "qgspluginregistry.h"
#include "qgsproject.h"
#include "qgsprojectproperties.h"
#include "qgsproviderregistry.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsrect.h"
#include "qgsserversourceselect.h"
#include "qgssinglesymbolrenderer.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorfilewriter.h"
#include "qgsvectorlayer.h"
//
// Gdal/Ogr includes
//
#include <ogrsf_frmts.h>
//
// Other includes
//
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <memory>
#include <vector>
//
// Map tools
//
#include "qgsmaptoolcapture.h"
#include "qgsmaptoolidentify.h"
#include "qgsmaptoolpan.h"
#include "qgsmaptoolselect.h"
#include "qgsmaptoolvertexedit.h"
#include "qgsmaptoolzoom.h"
#include "qgsmeasure.h"
//
// Conditional Includes
//
#ifdef Q_OS_MACX
#include <ApplicationServices/ApplicationServices.h>
#endif
#ifdef HAVE_POSTGRESQL
#include "qgsdbsourceselect.h"
#endif
#ifndef WIN32
#include <dlfcn.h>
#endif
using namespace std;
class QTreeWidgetItem;
/* typedefs for plugins */
typedef QgsMapLayerInterface *create_it();
typedef QgisPlugin *create_ui(QgisApp * qgis, QgisIface * qI);
typedef QString name_t();
typedef QString description_t();
typedef int type_t();
// IDs for locating particular menu items
const int BEFORE_RECENT_PATHS = 123;
const int AFTER_RECENT_PATHS = 321;
/// build the vector file filter string for a QFileDialog
/*
called in ctor for initializing mVectorFileFilter
*/
static void buildSupportedVectorFileFilter_(QString & fileFilters);
/** set the application title bar text
If the current project title is null
if the project file is null then
set title text to just application name and version
else
set set title text to the the project file name
else
set the title text to project title
*/
static void setTitleBarText_( QWidget & qgisApp )
{
QString caption = QgisApp::tr("Quantum GIS - ");
caption += QString("%1 ('%2') ").arg(QGis::qgisVersion).arg(QGis::qgisReleaseName) + " ";
if ( QgsProject::instance()->title().isEmpty() )
{
if ( QgsProject::instance()->filename().isEmpty() )
{
// no project title nor file name, so just leave caption with
// application name and version
}
else
{
QFileInfo projectFileInfo( QgsProject::instance()->filename() );
caption += projectFileInfo.baseName();
}
}
else
{
caption += QgsProject::instance()->title();
}
qgisApp.setCaption( caption );
} // setTitleBarText_( QWidget * qgisApp )
// constructor starts here
QgisApp::QgisApp(QSplashScreen *splash, QWidget * parent, Qt::WFlags fl)
: QMainWindow(parent,fl),
mSplash(splash)
{
setupUi(this);
mSplash->showMessage(tr("Checking database"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
// Do this early on before anyone else opens it and prevents us copying it
createDB();
mSplash->showMessage(tr("Reading settings"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
readSettings();
mSplash->showMessage(tr("Setting up the GUI"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
createActions();
createActionGroups();
createMenus();
createToolBars();
createStatusBar();
setTheme(mThemeName);
updateRecentProjectPaths();
createCanvas();
createOverview();
createLegend();
fileNew(); // prepare empty project
qApp->processEvents();
// register all GDAL and OGR plug-ins
// Should this be here? isnt it the job of the provider? Tim
OGRRegisterAll();
QPixmap icon;
icon = QPixmap(qgis_xpm);
setIcon(icon);
// store startup location
QDir *d = new QDir();
mStartupPath = d->absPath();
delete d;
QBitmap zoomincur;
// zoomincur = QBitmap(cursorzoomin);
QBitmap zoomincurmask;
// zoomincurmask = QBitmap(cursorzoomin_mask);
QString caption = tr("Quantum GIS - ");
caption += QString("%1 ('%2')").arg(QGis::qgisVersion).arg(QGis::qgisReleaseName);
setCaption(caption);
// create the interfce
mQgisInterface = new QgisIface(this);
//
// Create the plugin registry and load plugins
//
// Get pointer to the provider registry singleton
QString plib = QgsApplication::pluginPath();
// set the provider plugin path
mProviderRegistry = QgsProviderRegistry::instance(plib);
#ifdef QGISDEBUG
std::cout << "Plugins and providers are installed in " << plib.toLocal8Bit().data() << std::endl;
#endif
// load any plugins that were running in the last session
mSplash->showMessage(tr("Restoring loaded plugins"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
restoreSessionPlugins(plib);
/* Delete this I think - Tim - FIXME
//
// Create the map layer registry. Any layers loaded will
// register themselves here. Deleting layers shouls ONLY
// be done by means of a removeMapLayer call to the regsitry.
// This allows a single layer instance to be shared
// between more than one canvas. The registry is a singleton
// and is constructed using the static instance call.
// syntactic sugar shortcut for instance handle
//QgsMapLayerRegistry * mapLayerRegistry = QgsMapLayerRegistry::instance();
*/
// Map composer
mComposer = new QgsComposer(this);
mSplash->showMessage(tr("Initializing file filters"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
// now build vector file filter
buildSupportedVectorFileFilter_( mVectorFileFilter );
// now build raster file filter
QgsRasterLayer::buildSupportedRasterFileFilter( mRasterFileFilter );
// Set the background colour for toolbox and overview as they default to
// white instead of the window color
QPalette myPalette = toolBox->palette();
myPalette.setColor(QPalette::Button, myPalette.window().color());
toolBox->setPalette(myPalette);
//do the same for legend control
myPalette = toolBox->palette();
myPalette.setColor(QPalette::Button, myPalette.window().color());
mMapLegend->setPalette(myPalette);
//and for overview control this is done in createOverView method
// Do this last in the ctor to ensure that all members are instantiated properly
setupConnections();
//
// Please make sure this is the last thing the ctor does so that we can ensure teh
// widgets are all initialised before trying to restore their state.
//
mSplash->showMessage(tr("Restoring window state"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
restoreWindowState();
mSplash->showMessage(tr("QGIS Ready!"), Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
} // QgisApp ctor
QgisApp::~QgisApp()
{
delete mMapTools.mZoomIn;
delete mMapTools.mZoomOut;
delete mMapTools.mPan;
delete mMapTools.mIdentify;
delete mMapTools.mMeasureDist;
delete mMapTools.mMeasureArea;
delete mMapTools.mCapturePoint;
delete mMapTools.mCaptureLine;
delete mMapTools.mCapturePolygon;
delete mMapTools.mSelect;
delete mMapTools.mVertexAdd;
delete mMapTools.mVertexMove;
delete mMapTools.mVertexDelete;
}
// restore any application settings stored in QSettings
void QgisApp::readSettings()
{
// get the application dir
mAppDir = QgsApplication::prefixPath();
QSettings settings;
// get the users theme preference from the settings
mThemeName = settings.readEntry("/Themes","default");
// Set the initial visibility flag for layers
// This user option allows the user to turn off inital drawing of
// layers when they are added to the map. This is useful when adding
// many layers and the user wants to adjusty symbology, etc prior to
// actually viewing the layer.
mAddedLayersVisible = settings.readBoolEntry("/qgis/new_layers_visible", 1);
// Add the recently accessed project file paths to the File menu
mRecentProjectPaths = settings.readListEntry("/UI/recentProjectsList");
}
//////////////////////////////////////////////////////////////////////
// Set Up the gui toolbars, menus, statusbar etc
//////////////////////////////////////////////////////////////////////
void QgisApp::createActions()
{
QString myIconPath = QgsApplication::themePath();
//
// File Menu Related Items
//
mActionFileNew= new QAction(QIcon(myIconPath+"/mActionFileNew.png"), tr("&New Project"), this);
mActionFileNew->setShortcut(tr("Ctrl+N","New Project"));
mActionFileNew->setStatusTip(tr("New Project"));
connect(mActionFileNew, SIGNAL(triggered()), this, SLOT(fileNew()));
//
mActionFileOpen= new QAction(QIcon(myIconPath+"/mActionFileOpen.png"), tr("&Open Project..."), this);
mActionFileOpen->setShortcut(tr("Ctrl+O","Open a Project"));
mActionFileOpen->setStatusTip(tr("Open a Project"));
connect(mActionFileOpen, SIGNAL(triggered()), this, SLOT(fileOpen()));
//
mActionFileSave= new QAction(QIcon(myIconPath+"/mActionFileSave.png"), tr("&Save Project"), this);
mActionFileSave->setShortcut(tr("Ctrl+S","Save Project"));
mActionFileSave->setStatusTip(tr("Save Project"));
connect(mActionFileSave, SIGNAL(triggered()), this, SLOT(fileSave()));
//
mActionFileSaveAs= new QAction(QIcon(myIconPath+"/mActionFileSaveAs.png"), tr("Save Project &As..."), this);
mActionFileSaveAs->setShortcut(tr("Ctrl+A","Save Project under a new name"));
mActionFileSaveAs->setStatusTip(tr("Save Project under a new name"));
connect(mActionFileSaveAs, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
//
mActionFilePrint= new QAction(QIcon(myIconPath+"/mActionFilePrint.png"), tr("&Print..."), this);
mActionFilePrint->setShortcut(tr("Ctrl+P","Print"));
mActionFilePrint->setStatusTip(tr("Print"));
connect(mActionFilePrint, SIGNAL(triggered()), this, SLOT(filePrint()));
//
mActionSaveMapAsImage= new QAction(QIcon(myIconPath+"/mActionSaveMapAsImage.png"), tr("Save as Image..."), this);
mActionSaveMapAsImage->setShortcut(tr("Ctrl+I","Save map as image"));
mActionSaveMapAsImage->setStatusTip(tr("Save map as image"));
connect(mActionSaveMapAsImage, SIGNAL(triggered()), this, SLOT(saveMapAsImage()));
//
mActionExportMapServer= new QAction(QIcon(myIconPath+"/mActionExportMapServer.png"), tr("Export to MapServer Map..."), this);
mActionExportMapServer->setShortcut(tr("M","Export as MapServer .map file"));
mActionExportMapServer->setStatusTip(tr("Export as MapServer .map file"));
connect(mActionExportMapServer, SIGNAL(triggered()), this, SLOT(exportMapServer()));
//
mActionFileExit= new QAction(QIcon(myIconPath+"/mActionFileExit.png"), tr("Exit"), this);
mActionFileExit->setShortcut(tr("Ctrl+Q","Exit QGIS"));
mActionFileExit->setStatusTip(tr("Exit QGIS"));
connect(mActionFileExit, SIGNAL(triggered()), this, SLOT(fileExit()));
//
// Layer Menu Related Items
//
mActionAddNonDbLayer= new QAction(QIcon(myIconPath+"/mActionAddNonDbLayer.png"), tr("Add a Vector Layer..."), this);
mActionAddNonDbLayer->setShortcut(tr("V","Add a Vector Layer"));
mActionAddNonDbLayer->setStatusTip(tr("Add a Vector Layer"));
connect(mActionAddNonDbLayer, SIGNAL(triggered()), this, SLOT(addLayer()));
//
mActionAddRasterLayer= new QAction(QIcon(myIconPath+"/mActionAddRasterLayer.png"), tr("Add a Raster Layer..."), this);
mActionAddRasterLayer->setShortcut(tr("R","Add a Raster Layer"));
mActionAddRasterLayer->setStatusTip(tr("Add a Raster Layer"));
assert(connect(mActionAddRasterLayer, SIGNAL(triggered()), this, SLOT(addRasterLayer())));
//
mActionAddLayer= new QAction(QIcon(myIconPath+"/mActionAddLayer.png"), tr("Add a PostGIS Layer..."), this);
mActionAddLayer->setShortcut(tr("D","Add a PostGIS Layer"));
mActionAddLayer->setStatusTip(tr("Add a PostGIS Layer"));
//#ifdef HAVE_POSTGRESQL
// std::cout << "HAVE_POSTGRESQL is defined" << std::endl;
// assert(0);
//#else
// std::cout << "HAVE_POSTGRESQL not defined" << std::endl;
// assert(0);
//#endif
assert(connect(mActionAddLayer, SIGNAL(triggered()), this, SLOT(addDatabaseLayer())));
//
mActionNewVectorLayer= new QAction(QIcon(myIconPath+"/mActionNewVectorLayer.png"), tr("New Vector Layer..."), this);
mActionNewVectorLayer->setShortcut(tr("N","Create a New Vector Layer"));
mActionNewVectorLayer->setStatusTip(tr("Create a New Vector Layer"));
connect(mActionNewVectorLayer, SIGNAL(triggered()), this, SLOT(newVectorLayer()));
//
mActionRemoveLayer= new QAction(QIcon(myIconPath+"/mActionRemoveLayer.png"), tr("Remove Layer"), this);
mActionRemoveLayer->setShortcut(tr("Ctrl+D","Remove a Layer"));
mActionRemoveLayer->setStatusTip(tr("Remove a Layer"));
connect(mActionRemoveLayer, SIGNAL(triggered()), this, SLOT(removeLayer()));
//
mActionAddAllToOverview= new QAction(QIcon(myIconPath+"/mActionAddAllToOverview.png"), tr("Add All To Overview"), this);
mActionAddAllToOverview->setShortcut(tr("+","Show all layers in the overview map"));
mActionAddAllToOverview->setStatusTip(tr("Show all layers in the overview map"));
connect(mActionAddAllToOverview, SIGNAL(triggered()), this, SLOT(addAllToOverview()));
//
mActionRemoveAllFromOverview= new QAction(QIcon(myIconPath+"/mActionRemoveAllFromOverview.png"), tr("Remove All From Overview"), this);
mActionRemoveAllFromOverview->setShortcut(tr("-","Remove all layers from overview map"));
mActionRemoveAllFromOverview->setStatusTip(tr("Remove all layers from overview map"));
connect(mActionRemoveAllFromOverview, SIGNAL(triggered()), this, SLOT(removeAllFromOverview()));
//
mActionShowAllLayers= new QAction(QIcon(myIconPath+"/mActionShowAllLayers.png"), tr("Show All Layers"), this);
mActionShowAllLayers->setShortcut(tr("S","Show all layers"));
mActionShowAllLayers->setStatusTip(tr("Show all layers"));
connect(mActionShowAllLayers, SIGNAL(triggered()), this, SLOT(showAllLayers()));
//
mActionHideAllLayers= new QAction(QIcon(myIconPath+"/mActionHideAllLayers.png"), tr("Hide All Layers"), this);
mActionHideAllLayers->setShortcut(tr("H","Hide all layers"));
mActionHideAllLayers->setStatusTip(tr("Hide all layers"));
connect(mActionHideAllLayers, SIGNAL(triggered()), this, SLOT(hideAllLayers()));
//
// Settings Menu Related Items
//
mActionProjectProperties= new QAction(QIcon(myIconPath+"/mActionProjectProperties.png"), tr("Project Properties..."), this);
mActionProjectProperties->setShortcut(tr("P","Set project properties"));
mActionProjectProperties->setStatusTip(tr("Set project properties"));
connect(mActionProjectProperties, SIGNAL(triggered()), this, SLOT(projectProperties()));
//
mActionOptions= new QAction(QIcon(myIconPath+"/mActionOptions.png"), tr("Options..."), this);
// mActionOptions->setShortcut(tr("Alt+O","Change various QGIS options"));
mActionOptions->setStatusTip(tr("Change various QGIS options"));
connect(mActionOptions, SIGNAL(triggered()), this, SLOT(options()));
//
mActionCustomProjection= new QAction(QIcon(myIconPath+"/mActionCustomProjection.png"), tr("Custom Projection..."), this);
// mActionCustomProjection->setShortcut(tr("Alt+I","Manage custom projections"));
mActionCustomProjection->setStatusTip(tr("Manage custom projections"));
connect(mActionCustomProjection, SIGNAL(triggered()), this, SLOT(customProjection()));
//
// Help Menu Related items
//
mActionHelpContents= new QAction(QIcon(myIconPath+"/mActionHelpContents.png"), tr("Help Contents"), this);
#ifdef Q_WS_MAC
mActionHelpContents->setShortcut(tr("Ctrl+?","Help Documentation (Mac)"));
#else
mActionHelpContents->setShortcut(tr("F1","Help Documentation"));
#endif
mActionHelpContents->setStatusTip(tr("Help Documentation"));
connect(mActionHelpContents, SIGNAL(triggered()), this, SLOT(helpContents()));
//
mActionQgisHomePage= new QAction(QIcon(myIconPath+"/mActionQgisHomePage.png"), tr("Qgis Home Page"), this);
#ifndef Q_WS_MAC
mActionQgisHomePage->setShortcut(tr("Ctrl+H","QGIS Home Page"));
#endif
mActionQgisHomePage->setStatusTip(tr("QGIS Home Page"));
connect(mActionQgisHomePage, SIGNAL(triggered()), this, SLOT(helpQgisHomePage()));
//
mActionHelpAbout= new QAction(QIcon(myIconPath+"/mActionHelpAbout.png"), tr("About"), this);
mActionHelpAbout->setStatusTip(tr("About QGIS"));
connect(mActionHelpAbout, SIGNAL(triggered()), this, SLOT(about()));
//
mActionCheckQgisVersion= new QAction(QIcon(myIconPath+"/mActionCheckQgisVersion.png"), tr("Check Qgis Version"), this);
mActionCheckQgisVersion->setStatusTip(tr("Check if your QGIS version is up to date (requires internet access)"));
connect(mActionCheckQgisVersion, SIGNAL(triggered()), this, SLOT(checkQgisVersion()));
//
// View Menu Items
//
mActionDraw= new QAction(QIcon(myIconPath+"/mActionDraw.png"), tr("Refresh"), this);
mActionDraw->setShortcut(tr("Ctrl+R","Refresh Map"));
mActionDraw->setStatusTip(tr("Refresh Map"));
connect(mActionDraw, SIGNAL(triggered()), this, SLOT(refreshMapCanvas()));
//
mActionZoomIn= new QAction(QIcon(myIconPath+"/mActionZoomIn.png"), tr("Zoom In"), this);
mActionZoomIn->setShortcut(tr("Ctrl++","Zoom In"));
mActionZoomIn->setStatusTip(tr("Zoom In"));
connect(mActionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
//
mActionZoomOut= new QAction(QIcon(myIconPath+"/mActionZoomOut.png"), tr("Zoom Out"), this);
mActionZoomOut->setShortcut(tr("Ctrl+-","Zoom Out"));
mActionZoomOut->setStatusTip(tr("Zoom Out"));
connect(mActionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));
//
mActionZoomFullExtent= new QAction(QIcon(myIconPath+"/mActionZoomFullExtent.png"), tr("Zoom Full"), this);
mActionZoomFullExtent->setShortcut(tr("F","Zoom to Full Extents"));
mActionZoomFullExtent->setStatusTip(tr("Zoom to Full Extents"));
connect(mActionZoomFullExtent, SIGNAL(triggered()), this, SLOT(zoomFull()));
//
mActionZoomToSelected= new QAction(QIcon(myIconPath+"/mActionZoomToSelected.png"), tr("Zoom To Selection"), this);
mActionZoomToSelected->setShortcut(tr("Ctrl+F","Zoom to selection"));
mActionZoomToSelected->setStatusTip(tr("Zoom to selection"));
connect(mActionZoomToSelected, SIGNAL(triggered()), this, SLOT(zoomToSelected()));
//
mActionPan= new QAction(QIcon(myIconPath+"/mActionPan.png"), tr("Pan Map"), this);
mActionPan->setStatusTip(tr("Pan the map"));
connect(mActionPan, SIGNAL(triggered()), this, SLOT(pan()));
//
mActionZoomLast= new QAction(QIcon(myIconPath+"/mActionZoomLast.png"), tr("Zoom Last"), this);
//mActionZoomLast->setShortcut(tr("Ctrl+O","Zoom to Last Extent"));
mActionZoomLast->setStatusTip(tr("Zoom to Last Extent"));
connect(mActionZoomLast, SIGNAL(triggered()), this, SLOT(zoomPrevious()));
//
mActionZoomToLayer= new QAction(QIcon(myIconPath+"/mActionZoomToLayer.png"), tr("Zoom To Layer"), this);
//mActionZoomToLayer->setShortcut(tr("Ctrl+O","Zoom to Layer"));
mActionZoomToLayer->setStatusTip(tr("Zoom to Layer"));
connect(mActionZoomToLayer, SIGNAL(triggered()), this, SLOT(zoomToLayerExtent()));
//
mActionIdentify= new QAction(QIcon(myIconPath+"/mActionIdentify.png"), tr("Identify Features"), this);
mActionIdentify->setShortcut(tr("I","Click on features to identify them"));
mActionIdentify->setStatusTip(tr("Click on features to identify them"));
connect(mActionIdentify, SIGNAL(triggered()), this, SLOT(identify()));
//
mActionSelect= new QAction(QIcon(myIconPath+"/mActionSelect.png"), tr("Select Features"), this);
mActionSelect->setStatusTip(tr("Select Features"));
connect(mActionSelect, SIGNAL(triggered()), this, SLOT(select()));
mActionSelect->setEnabled(false);
//
mActionOpenTable= new QAction(QIcon(myIconPath+"/mActionOpenTable.png"), tr("Open Table"), this);
//mActionOpenTable->setShortcut(tr("Ctrl+O","Open Table"));
mActionOpenTable->setStatusTip(tr("Open Table"));
connect(mActionOpenTable, SIGNAL(triggered()), this, SLOT(attributeTable()));
mActionOpenTable->setEnabled(false);
//
mActionMeasure= new QAction(QIcon(myIconPath+"/mActionMeasure.png"), tr("Measure Line "), this);
mActionMeasure->setShortcut(tr("Ctrl+M","Measure a Line"));
mActionMeasure->setStatusTip(tr("Measure a Line"));
connect(mActionMeasure, SIGNAL(triggered()), this, SLOT(measure()));
//
mActionMeasureArea= new QAction(QIcon(myIconPath+"/mActionMeasureArea.png"), tr("Measure Area"), this);
mActionMeasureArea->setShortcut(tr("Ctrl+J","Measure an Area"));
mActionMeasureArea->setStatusTip(tr("Measure an Area"));
connect(mActionMeasureArea, SIGNAL(triggered()), this, SLOT(measureArea()));
//
mActionShowBookmarks= new QAction(QIcon(myIconPath+"/mActionShowBookmarks.png"), tr("Show Bookmarks"), this);
mActionShowBookmarks->setShortcut(tr("B","Show Bookmarks"));
mActionShowBookmarks->setStatusTip(tr("Show Bookmarks"));
connect(mActionShowBookmarks, SIGNAL(triggered()), this, SLOT(showBookmarks()));
//
mActionShowAllToolbars = new QAction(tr("Show most toolbars"), this);
mActionShowAllToolbars->setShortcut(tr("S", "Show most toolbars"));
mActionShowAllToolbars->setStatusTip(tr("Show most toolbars"));
connect(mActionShowAllToolbars, SIGNAL(triggered()), this,
SLOT(showAllToolbars()));
//
mActionHideAllToolbars = new QAction(tr("Hide most toolbars"), this);
mActionHideAllToolbars->setShortcut(tr("H", "Hide most toolbars"));
mActionHideAllToolbars->setStatusTip(tr("Hide most toolbars"));
connect(mActionHideAllToolbars, SIGNAL(triggered()), this,
SLOT(hideAllToolbars()));
//
mActionNewBookmark= new QAction(QIcon(myIconPath+"/mActionNewBookmark.png"), tr("New Bookmark..."), this);
mActionNewBookmark->setShortcut(tr("Ctrl+B","New Bookmark"));
mActionNewBookmark->setStatusTip(tr("New Bookmark"));
connect(mActionNewBookmark, SIGNAL(triggered()), this, SLOT(newBookmark()));
//
mActionAddWmsLayer= new QAction(QIcon(myIconPath+"/mActionAddWmsLayer.png"), tr("Add WMS Layer..."), this);
mActionAddWmsLayer->setShortcut(tr("W","Add Web Mapping Server Layer"));
mActionAddWmsLayer->setStatusTip(tr("Add Web Mapping Server Layer"));
connect(mActionAddWmsLayer, SIGNAL(triggered()), this, SLOT(addWmsLayer()));
//
mActionInOverview= new QAction(QIcon(myIconPath+"/mActionInOverview.png"), tr("In Overview"), this);
mActionInOverview->setShortcut(tr("O","Add current layer to overview map"));
mActionInOverview->setStatusTip(tr("Add current layer to overview map"));
connect(mActionInOverview, SIGNAL(triggered()), this, SLOT(inOverview()));
//
// Plugin Menu Related Items
//
mActionShowPluginManager= new QAction(QIcon(myIconPath+"/mActionShowPluginManager.png"), tr("Plugin Manager..."), this);
// mActionShowPluginManager->setShortcut(tr("Ctrl+P","Open the plugin manager"));
mActionShowPluginManager->setStatusTip(tr("Open the plugin manager"));
connect(mActionShowPluginManager, SIGNAL(triggered()), this, SLOT(showPluginManager()));
//
// Add the whats this toolbar button
// QWhatsThis::whatsThisButton(mHelpToolBar);
//
//
// Digitising Toolbar Items
//
mActionStartEditing = new QAction(QIcon(myIconPath+"/mActionStartEditing.png"),
tr("Start editing the current layer"), this);
connect(mActionStartEditing, SIGNAL(triggered()), this, SLOT(startEditing()));
//
mActionStopEditing = new QAction(QIcon(myIconPath+"/mActionStopEditing.png"),
tr("Stop editing the current layer"), this);
mActionStopEditing->setStatusTip(tr("Stop editing the current layer"));
connect(mActionStopEditing, SIGNAL(triggered()), this, SLOT(stopEditing()));
//
mActionCapturePoint= new QAction(QIcon(myIconPath+"/mActionCapturePoint.png"), tr("Capture Point"), this);
mActionCapturePoint->setShortcut(tr(".","Capture Points"));
mActionCapturePoint->setStatusTip(tr("Capture Points"));
connect(mActionCapturePoint, SIGNAL(triggered()), this, SLOT(capturePoint()));
mActionCapturePoint->setEnabled(false);
//
mActionCaptureLine= new QAction(QIcon(myIconPath+"/mActionCaptureLine.png"), tr("Capture Line"), this);
mActionCaptureLine->setShortcut(tr("/","Capture Lines"));
mActionCaptureLine->setStatusTip(tr("Capture Lines"));
connect(mActionCaptureLine, SIGNAL(triggered()), this, SLOT(captureLine()));
mActionCaptureLine->setEnabled(false);
//
mActionCapturePolygon= new QAction(QIcon(myIconPath+"/mActionCapturePolygon.png"), tr("Capture Polygon"), this);
mActionCapturePolygon->setShortcut(tr("Ctrl+/","Capture Polygons"));
mActionCapturePolygon->setStatusTip(tr("Capture Polygons"));
connect(mActionCapturePolygon, SIGNAL(triggered()), this, SLOT(capturePolygon()));
mActionCapturePolygon->setEnabled(false);
//
mActionDeleteSelected = new QAction(QIcon(myIconPath+"/mActionDeleteSelected.png"), tr("Delete Seleced"), this);
mActionDeleteSelected->setStatusTip(tr("Delete Selected"));
connect(mActionDeleteSelected, SIGNAL(triggered()), this, SLOT(deleteSelected()));
mActionDeleteSelected->setEnabled(false);
//
mActionAddVertex = new QAction(QIcon(myIconPath+"/mActionAddVertex.png"), tr("Add Vertex"), this);
mActionAddVertex->setStatusTip(tr("Add Vertex"));
connect(mActionAddVertex, SIGNAL(triggered()), this, SLOT(addVertex()));
mActionAddVertex->setEnabled(false);
//
mActionDeleteVertex = new QAction(QIcon(myIconPath+"/mActionDeleteVertex.png"), tr("Delete Vertex"), this);
mActionDeleteVertex->setStatusTip(tr("Delete Vertex"));
connect(mActionDeleteVertex, SIGNAL(triggered()), this, SLOT(deleteVertex()));
mActionDeleteVertex->setEnabled(false);
//
mActionMoveVertex = new QAction(QIcon(myIconPath+"/mActionMoveVertex.png"), tr("Move Vertex"), this);
mActionMoveVertex->setStatusTip(tr("Move Vertex"));
connect(mActionMoveVertex, SIGNAL(triggered()), this, SLOT(moveVertex()));
mActionMoveVertex->setEnabled(false);
mActionEditCut = new QAction(QIcon(myIconPath+"/mActionEditCut.png"), tr("Cut Features"), this);
mActionEditCut->setStatusTip(tr("Cut selected features"));
connect(mActionEditCut, SIGNAL(triggered()), this, SLOT(editCut()));
mActionEditCut->setEnabled(false);
mActionEditCopy = new QAction(QIcon(myIconPath+"/mActionEditCopy.png"), tr("Copy Features"), this);
mActionEditCopy->setStatusTip(tr("Copy selected features"));
connect(mActionEditCopy, SIGNAL(triggered()), this, SLOT(editCopy()));
mActionEditCopy->setEnabled(false);
mActionEditPaste = new QAction(QIcon(myIconPath+"/mActionEditPaste.png"), tr("Paste Features"), this);
mActionEditPaste->setStatusTip(tr("Paste selected features"));
connect(mActionEditPaste, SIGNAL(triggered()), this, SLOT(editPaste()));
mActionEditPaste->setEnabled(false);
}
void QgisApp::createActionGroups()
{
//
// Map Tool Group
mMapToolGroup = new QActionGroup(this);
mActionPan->setCheckable(true);
mMapToolGroup->addAction(mActionPan);
mActionZoomIn->setCheckable(true);
mMapToolGroup->addAction(mActionZoomIn);
mActionZoomOut->setCheckable(true);
mMapToolGroup->addAction(mActionZoomOut);
mActionIdentify->setCheckable(true);
mMapToolGroup->addAction(mActionIdentify);
mActionSelect->setCheckable(true);
mMapToolGroup->addAction(mActionSelect);
mActionMeasure->setCheckable(true);
mMapToolGroup->addAction(mActionMeasure);
mActionMeasureArea->setCheckable(true);
mMapToolGroup->addAction(mActionMeasureArea);
mActionCaptureLine->setCheckable(true);
mMapToolGroup->addAction(mActionCaptureLine);
mActionCapturePoint->setCheckable(true);
mMapToolGroup->addAction(mActionCapturePoint);
mActionCapturePolygon->setCheckable(true);
mMapToolGroup->addAction(mActionCapturePolygon);
mMapToolGroup->addAction(mActionDeleteSelected);
mActionAddVertex->setCheckable(true);
mMapToolGroup->addAction(mActionAddVertex);
mActionDeleteVertex->setCheckable(true);
mMapToolGroup->addAction(mActionDeleteVertex);
mActionMoveVertex->setCheckable(true);
mMapToolGroup->addAction(mActionMoveVertex);
}
void QgisApp::createMenus()
{
QString myIconPath = QgsApplication::themePath();
//
// File Menu
mFileMenu = menuBar()->addMenu(tr("&File"));
mFileMenu->addAction(mActionFileNew);
mFileMenu->addAction(mActionFileOpen);
mRecentProjectsMenu = mFileMenu->addMenu(tr("&Open Recent Projects"));
// Connect once for the entire submenu.
connect(mRecentProjectsMenu, SIGNAL(triggered(QAction *)),
this, SLOT(openProject(QAction *)));
mFileMenu->addSeparator();
mFileMenu->addAction(mActionFileSave);
mFileMenu->addAction(mActionFileSaveAs);
mFileMenu->addAction(mActionSaveMapAsImage);
mFileMenu->addAction(mActionExportMapServer);
mFileMenu->addAction(mActionFilePrint);
mFileMenu->addSeparator();
mFileMenu->addAction(mActionFileExit);
//
// View Menu
mViewMenu = menuBar()->addMenu(tr("&View"));
mViewMenu->addAction(mActionZoomFullExtent);
mViewMenu->addAction(mActionZoomToSelected);
mViewMenu->addAction(mActionZoomToLayer);
mViewMenu->addAction(mActionZoomLast);
mViewMenu->addAction(mActionDraw);
mViewMenu->addAction(mActionShowBookmarks);
mViewMenu->addAction(mActionNewBookmark);
mToolbarMenu = mViewMenu->addMenu(QIcon(myIconPath+"/mActionOptions.png"),
tr("&Toolbars..."));
//
// View:toolbars menu
mToolbarMenu->addAction(mActionShowAllToolbars);
mToolbarMenu->addAction(mActionHideAllToolbars);
//
// Layers Menu
mLayerMenu = menuBar()->addMenu(tr("&Layer"));
mLayerMenu->addAction(mActionAddNonDbLayer);
mLayerMenu->addAction(mActionAddRasterLayer);
#ifdef HAVE_POSTGRESQL
mLayerMenu->addAction(mActionAddLayer);
#endif
mLayerMenu->addAction(mActionAddWmsLayer);
mLayerMenu->addAction(mActionRemoveLayer);
mLayerMenu->addAction(mActionNewVectorLayer);
mLayerMenu->addAction(mActionInOverview);
mLayerMenu->addAction(mActionAddAllToOverview);
mLayerMenu->addAction(mActionRemoveAllFromOverview);
mLayerMenu->addAction(mActionHideAllLayers);
mLayerMenu->addAction(mActionShowAllLayers);
//
// Settings Menu
mSettingsMenu = menuBar()->addMenu(tr("&Settings"));
mSettingsMenu->addAction(mActionProjectProperties);
mSettingsMenu->addAction(mActionCustomProjection);
mSettingsMenu->addAction(mActionOptions);
//
// Plugins Menu
mPluginMenu = menuBar()->addMenu(tr("&Plugins"));
mPluginMenu->addAction(mActionShowPluginManager);
// Add the plugin manager action to it
//actionPluginManager->addTo(mPluginMenu);
// Add separator. Plugins will add their menus to this
// menu when they are loaded by the plugin manager
//mPluginMenu->insertSeparator();
// Add to the menubar
//menuBar()->insertItem(tr("&Plugins"), mPluginMenu, -1, menuBar()->count() - 1);
menuBar()->addSeparator();
mHelpMenu = menuBar()->addMenu(tr("&Help"));
mHelpMenu->addAction(mActionHelpContents);
mHelpMenu->addAction(mActionQgisHomePage);
mHelpMenu->addAction(mActionCheckQgisVersion);
mHelpMenu->addAction(mActionHelpAbout);
}
void QgisApp::createToolBars()
{
// Note: we need to set each object name to ensure that
// qmainwindow::saveState and qmainwindow::restoreState
// work properly
//
// File Toolbar
mFileToolBar = addToolBar(tr("File"));
mFileToolBar->setIconSize(QSize(24,24));
mFileToolBar->setObjectName("FileToolBar");
mFileToolBar->addAction(mActionFileNew);
mFileToolBar->addAction(mActionFileNew);
mFileToolBar->addAction(mActionFileSave);
mFileToolBar->addAction(mActionFileSaveAs);
mFileToolBar->addAction(mActionFileOpen);
mFileToolBar->addAction(mActionFilePrint);
//
// Layer Toolbar
mLayerToolBar = addToolBar(tr("Manage Layers"));
mLayerToolBar->setIconSize(QSize(24,24));
mLayerToolBar->setObjectName("LayerToolBar");
mLayerToolBar->addAction(mActionAddNonDbLayer);
mLayerToolBar->addAction(mActionAddRasterLayer);
#ifdef HAVE_POSTGRESQL
mLayerToolBar->addAction(mActionAddLayer);
#endif
mLayerToolBar->addAction(mActionAddWmsLayer);
mLayerToolBar->addAction(mActionNewVectorLayer);
mLayerToolBar->addAction(mActionRemoveLayer);
mLayerToolBar->addAction(mActionInOverview);
mLayerToolBar->addAction(mActionAddAllToOverview);
mLayerToolBar->addAction(mActionRemoveAllFromOverview);
mLayerToolBar->addAction(mActionShowAllLayers);
mLayerToolBar->addAction(mActionHideAllLayers);
//
// Help Toolbar
mHelpToolBar = addToolBar(tr("Help"));
mHelpToolBar->setIconSize(QSize(24,24));
mHelpToolBar->setObjectName("Help");
mHelpToolBar->addAction(mActionHelpContents);
//
// Digitizing Toolbar
mDigitizeToolBar = addToolBar(tr("Digitizing"));
mDigitizeToolBar->setIconSize(QSize(24,24));
mDigitizeToolBar->setObjectName("Digitizing");
mDigitizeToolBar->addAction(mActionStartEditing);
mDigitizeToolBar->addAction(mActionStopEditing);
mDigitizeToolBar->addAction(mActionCapturePoint);
mDigitizeToolBar->addAction(mActionCaptureLine);
mDigitizeToolBar->addAction(mActionCapturePolygon);
mDigitizeToolBar->addAction(mActionDeleteSelected);
mDigitizeToolBar->addAction(mActionAddVertex);
mDigitizeToolBar->addAction(mActionDeleteVertex);
mDigitizeToolBar->addAction(mActionMoveVertex);
mDigitizeToolBar->addAction(mActionEditCut);
mDigitizeToolBar->addAction(mActionEditCopy);
mDigitizeToolBar->addAction(mActionEditPaste);
//
// Map Navigation Toolbar
mMapNavToolBar = addToolBar(tr("Map Navigation"));
mMapNavToolBar->setIconSize(QSize(24,24));
mMapNavToolBar->setObjectName("Map Navigation");
mMapNavToolBar->addAction(mActionPan);
mMapNavToolBar->addAction(mActionZoomIn);
mMapNavToolBar->addAction(mActionZoomOut);
mMapNavToolBar->addAction(mActionZoomFullExtent);
mMapNavToolBar->addAction(mActionZoomToSelected);
mMapNavToolBar->addAction(mActionZoomToLayer);
mMapNavToolBar->addAction(mActionZoomLast);
mMapNavToolBar->addAction(mActionDraw);
//
// Attributes Toolbar
mAttributesToolBar = addToolBar(tr("Attributes"));
mAttributesToolBar->setIconSize(QSize(24,24));
mAttributesToolBar->setObjectName("Attributes");
mAttributesToolBar->addAction(mActionIdentify);
mAttributesToolBar->addAction(mActionSelect);
mAttributesToolBar->addAction(mActionOpenTable);
mAttributesToolBar->addAction(mActionMeasure);
mAttributesToolBar->addAction(mActionMeasureArea);
mAttributesToolBar->addAction(mActionShowBookmarks);
mAttributesToolBar->addAction(mActionNewBookmark);
//
// Plugins Toolbar
mPluginToolBar = addToolBar(tr("Plugins"));
mPluginToolBar->setIconSize(QSize(24,24));
mPluginToolBar->setObjectName("Plugins");
}
void QgisApp::createStatusBar()
{
//
// Add a panel to the status bar for the scale, coords and progress
// And also rendering suppression checkbox
//
mProgressBar = new QProgressBar(statusBar());
mProgressBar->setMaximumWidth(100);
mProgressBar->hide();
QWhatsThis::add(mProgressBar, tr("Progress bar that displays the status of rendering layers and other time-intensive operations"));
statusBar()->addWidget(mProgressBar, 1,true);
// Bumped the font up one point size since 8 was too
// small on some platforms. A point size of 9 still provides
// plenty of display space on 1024x768 resolutions
QFont myFont( "Arial", 9 );
statusBar()->setFont(myFont);
mScaleLabel = new QLabel(QString("Scale"),statusBar());
mScaleLabel->setFont(myFont);
mScaleLabel->setMinimumWidth(10);
mScaleLabel->setMargin(3);
mScaleLabel->setAlignment(Qt::AlignCenter);
QWhatsThis::add(mScaleLabel, tr("Displays the current map scale"));
statusBar()->addWidget(mScaleLabel, 0,true);
//coords status bar widget
mCoordsLabel = new QLabel(QString("Coordinates:"), statusBar());
mCoordsLabel->setMinimumWidth(10);
mCoordsLabel->setFont(myFont);
mCoordsLabel->setMargin(3);
mCoordsLabel->setAlignment(Qt::AlignCenter);
QWhatsThis::add(mCoordsLabel, tr("Shows the map coordinates at the current cursor postion. The display is continuously updated as the mouse is moved."));
statusBar()->addWidget(mCoordsLabel, 0, true);
// render suppression status bar widget
mRenderSuppressionCBox = new QCheckBox(tr("Render"),statusBar());
mRenderSuppressionCBox->setChecked(true);
mRenderSuppressionCBox->setFont(myFont);
QWhatsThis::add(mRenderSuppressionCBox, tr("When checked, the map layers are rendered in response to map navigation commands and other events. When not checked, no rendering is done. This allows you to add a large number of layers and symbolize them before rendering."));
QToolTip::add( mRenderSuppressionCBox, tr("Toggle map rendering") );
statusBar()->addWidget(mRenderSuppressionCBox,0,true);
// On the fly projection status bar icon
// Changed this to a tool button since a QPushButton is
// sculpted on OS X and the icon is never displayed [gsherman]
mOnTheFlyProjectionStatusButton = new QToolButton(statusBar());
mOnTheFlyProjectionStatusButton->setMaximumWidth(20);
// Maintain uniform widget height in status bar by setting button height same as labels
// For Qt/Mac 3.3, the default toolbutton height is 30 and labels were expanding to match
mOnTheFlyProjectionStatusButton->setMaximumHeight(mScaleLabel->height());
QPixmap myProjPixmap;
QString myIconPath = QgsApplication::themePath();
myProjPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
mOnTheFlyProjectionStatusButton->setPixmap(myProjPixmap);
assert(!myProjPixmap.isNull());
QWhatsThis::add(mOnTheFlyProjectionStatusButton, tr("This icon shows whether on the fly projection is enabled or not. Click the icon to bring up the project properties dialog to alter this behaviour."));
QToolTip::add( mOnTheFlyProjectionStatusButton, tr("Projection status - Click to open projection dialog"));
connect(mOnTheFlyProjectionStatusButton, SIGNAL(clicked()),
this, SLOT(projectPropertiesProjections()));//bring up the project props dialog when clicked
statusBar()->addWidget(mOnTheFlyProjectionStatusButton,0,true);
statusBar()->showMessage(tr("Ready"));
}
QString QgisApp::themePath()
{
return mAppDir +"/share/qgis/themes/" + mThemeName + "/";
}
void QgisApp::setTheme(QString theThemeName)
{
/*****************************************************************
// Init the toolbar icons by setting the icon for each action.
// All toolbar/menu items must be a QAction in order for this
// to work.
//
// When new toolbar/menu QAction objects are added to the interface,
// add an entry below to set the icon
//
// PNG names must match those defined for the default theme. The
// default theme is installed in <prefix>/share/qgis/themes/default.
//
// New core themes can be added by creating a subdirectory under src/themes
// and modifying the appropriate Makefile.am files. User contributed themes
// will be installed directly into <prefix>/share/qgis/themes/<themedir>.
//
// Themes can be selected from the preferences dialog. The dialog parses
// the themes directory and builds a list of themes (ie subdirectories)
// for the user to choose from.
//
// TODO: Check as each icon is grabbed and if it doesn't exist, use the
// one from the default theme (which is installed with qgis and should
// always be good)
*/
QgsApplication::selectTheme(theThemeName);
QString myIconPath = QgsApplication::themePath();
mActionFileNew->setIconSet(QIcon(QPixmap(myIconPath + "/mActionFileNew.png")));
mActionFileSave->setIconSet(QIcon(QPixmap(myIconPath + "/mActionFileSave.png")));
mActionFileSaveAs->setIconSet(QIcon(QPixmap(myIconPath + "/mActionFileSaveAs.png")));
mActionFileOpen->setIconSet(QIcon(QPixmap(myIconPath + "/mActionFileOpen.png")));
mActionFilePrint->setIconSet(QIcon(QPixmap(myIconPath + "/mActionFilePrint.png")));