@@ -992,6 +992,68 @@ void QgisApp::createActions()
992992 mActionAbout ->setStatusTip ( tr ( " About QGIS" ) );
993993 mActionAbout ->setMenuRole ( QAction::AboutRole ); // put in application menu on Mac OS X
994994 connect ( mActionAbout , SIGNAL ( triggered () ), this , SLOT ( about () ) );
995+
996+ // %%%
997+ mActionUseRendererV2 = new QAction ( " V2" , this );
998+ mActionUseRendererV2 ->setStatusTip ( tr ( " Toggles renderer V2 for current layer" ) );
999+ connect ( mActionUseRendererV2 , SIGNAL ( triggered () ), this , SLOT ( toggleRendererV2 () ) );
1000+
1001+ // %%%
1002+ mActionStyleManagerV2 = new QAction ( " MGR" , this );
1003+ mActionStyleManagerV2 ->setStatusTip ( tr ( " Show style manager V2" ) );
1004+ connect ( mActionStyleManagerV2 , SIGNAL ( triggered () ), this , SLOT ( showStyleManagerV2 () ) );
1005+ }
1006+
1007+ #include " qgsstylev2.h"
1008+ #include " qgssymbolv2.h"
1009+ #include " qgsrendererv2.h"
1010+ #include " qgsrendererv2propertiesdialog.h"
1011+ #include " qgsstylev2managerdialog.h"
1012+
1013+ static QgsStyleV2* gStyleV2 = NULL ;
1014+
1015+ static void _initStyle ()
1016+ {
1017+ if (gStyleV2 == NULL )
1018+ {
1019+ QString styleFilename = QgsApplication::userStyleV2Path ();
1020+
1021+ // copy default style if user style doesn't exist
1022+ if ( !QFile::exists ( styleFilename ) )
1023+ {
1024+ QFile::copy ( QgsApplication::defaultStyleV2Path (), styleFilename );
1025+ }
1026+
1027+ gStyleV2 = new QgsStyleV2;
1028+ gStyleV2 ->load ( styleFilename );
1029+ }
1030+ }
1031+
1032+ void QgisApp::toggleRendererV2 ()
1033+ {
1034+ QgsMapLayer* layer = activeLayer ();
1035+ if (layer == NULL || layer->type () != QgsMapLayer::VectorLayer)
1036+ {
1037+ QMessageBox::information (this , " sorry" , " Give me a vector layer!" );
1038+ return ;
1039+ }
1040+ QgsVectorLayer* vlayer = static_cast <QgsVectorLayer*>(layer);
1041+
1042+ _initStyle ();
1043+
1044+ QgsRendererV2PropertiesDialog dlg (vlayer, gStyleV2 , this );
1045+ if (!dlg.exec ())
1046+ return ;
1047+
1048+ refreshMapCanvas ();
1049+ }
1050+
1051+ void QgisApp::showStyleManagerV2 ()
1052+ {
1053+ _initStyle ();
1054+
1055+ QgsStyleV2ManagerDialog dlg (gStyleV2 , QgsApplication::userStyleV2Path (), this );
1056+ dlg.exec ();
9951057}
9961058
9971059void QgisApp::showPythonDialog ()
@@ -1305,6 +1367,8 @@ void QgisApp::createToolBars()
13051367 mFileToolBar ->addAction ( mActionAddSpatiaLiteLayer );
13061368#endif
13071369 mFileToolBar ->addAction ( mActionAddWmsLayer );
1370+ mFileToolBar ->addAction ( mActionUseRendererV2 );
1371+ mFileToolBar ->addAction ( mActionStyleManagerV2 );
13081372 mToolbarMenu ->addAction ( mFileToolBar ->toggleViewAction () );
13091373 //
13101374 // Layer Toolbar
0 commit comments