75
75
#include < qgsnetworkaccessmanager.h>
76
76
#include < qgsapplication.h>
77
77
#include < qgscomposition.h>
78
+ #include < qgsmapstylingwidget.h>
78
79
79
80
#include < QNetworkReply>
80
81
#include < QNetworkProxy>
@@ -716,6 +717,16 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
716
717
addDockWidget ( Qt::LeftDockWidgetArea, mUndoWidget );
717
718
mUndoWidget ->hide ();
718
719
720
+ mMapStylingDock = new QDockWidget ( this );
721
+ mMapStylingDock ->setWindowTitle ( tr ( " Map Styling" ) );
722
+ mMapStyleWidget = new QgsMapStylingWidget ( mMapCanvas );
723
+ mMapStylingDock ->setWidget ( mMapStyleWidget );
724
+
725
+ connect ( mMapStyleWidget , SIGNAL ( styleChanged ( QgsMapLayer* ) ), this , SLOT ( updateLabelToolButtons () ) );
726
+
727
+ addDockWidget ( Qt::RightDockWidgetArea, mMapStylingDock );
728
+ mMapStylingDock ->hide ();
729
+
719
730
mSnappingDialog = new QgsSnappingDialog ( this , mMapCanvas );
720
731
mSnappingDialog ->setObjectName ( " SnappingOption" );
721
732
@@ -2399,6 +2410,9 @@ void QgisApp::setupConnections()
2399
2410
// connect legend signals
2400
2411
connect ( mLayerTreeView , SIGNAL ( currentLayerChanged ( QgsMapLayer * ) ),
2401
2412
this , SLOT ( activateDeactivateLayerRelatedActions ( QgsMapLayer * ) ) );
2413
+ connect ( mLayerTreeView , SIGNAL ( currentLayerChanged ( QgsMapLayer * ) ),
2414
+ this , SLOT ( setMapStyleDockLayer ( QgsMapLayer* ) ) );
2415
+
2402
2416
connect ( mLayerTreeView ->selectionModel (), SIGNAL ( selectionChanged ( QItemSelection, QItemSelection ) ),
2403
2417
this , SLOT ( legendLayerSelectionChanged () ) );
2404
2418
connect ( mLayerTreeView ->layerTreeModel ()->rootGroup (), SIGNAL ( addedChildren ( QgsLayerTreeNode*, int , int ) ),
@@ -2748,6 +2762,11 @@ void QgisApp::initLayerTreeView()
2748
2762
mLegendExpressionFilterButton ->setToolTip ( tr ( " Filter legend by expression" ) );
2749
2763
connect ( mLegendExpressionFilterButton , SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleFilterLegendByExpression ( bool ) ) );
2750
2764
2765
+ mActionStyleDock = new QAction ( tr ( " Map Styling" ), this );
2766
+ mActionStyleDock ->setToolTip ( tr ( " Open the map styling dock" ) );
2767
+ mActionStyleDock ->setIcon ( QgsApplication::getThemeIcon ( " propertyicons/symbology.png" ) );
2768
+ connect ( mActionStyleDock , SIGNAL ( triggered () ), this , SLOT ( mapStyleDock () ) );
2769
+
2751
2770
// expand / collapse tool buttons
2752
2771
QAction* actionExpandAll = new QAction ( tr ( " Expand All" ), this );
2753
2772
actionExpandAll->setIcon ( QgsApplication::getThemeIcon ( " /mActionExpandTree.svg" ) );
@@ -2758,6 +2777,9 @@ void QgisApp::initLayerTreeView()
2758
2777
actionCollapseAll->setToolTip ( tr ( " Collapse All" ) );
2759
2778
connect ( actionCollapseAll, SIGNAL ( triggered ( bool ) ), mLayerTreeView , SLOT ( collapseAll () ) );
2760
2779
2780
+ QWidget* spacer = new QWidget ();
2781
+ spacer->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding );
2782
+
2761
2783
QToolBar* toolbar = new QToolBar ();
2762
2784
toolbar->setIconSize ( QSize ( 16 , 16 ) );
2763
2785
toolbar->addAction ( actionAddGroup );
@@ -2767,6 +2789,8 @@ void QgisApp::initLayerTreeView()
2767
2789
toolbar->addAction ( actionExpandAll );
2768
2790
toolbar->addAction ( actionCollapseAll );
2769
2791
toolbar->addAction ( mActionRemoveLayer );
2792
+ toolbar->addWidget ( spacer );
2793
+ toolbar->addAction ( mActionStyleDock );
2770
2794
2771
2795
QVBoxLayout* vboxLayout = new QVBoxLayout;
2772
2796
vboxLayout->setMargin ( 0 );
@@ -5460,47 +5484,33 @@ void QgisApp::labeling()
5460
5484
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer*>( activeLayer () );
5461
5485
if ( !vlayer )
5462
5486
{
5463
- messageBar ()->pushMessage ( tr ( " Labeling Options" ),
5464
- tr ( " Please select a vector layer first" ),
5465
- QgsMessageBar::INFO,
5466
- messageTimeout () );
5467
5487
return ;
5468
5488
}
5469
5489
5490
+ mapStyleDock ();
5491
+ }
5470
5492
5471
- QDialog dlg;
5472
- dlg.setWindowTitle ( tr ( " Layer labeling settings" ) );
5473
- QgsLabelingWidget *labelingGui = new QgsLabelingWidget ( vlayer, mMapCanvas , &dlg );
5474
- labelingGui->layout ()->setContentsMargins ( 0 , 0 , 0 , 0 );
5475
- QVBoxLayout *layout = new QVBoxLayout ( &dlg );
5476
- layout->addWidget ( labelingGui );
5477
-
5478
- QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, Qt::Horizontal, &dlg );
5479
- layout->addWidget ( buttonBox );
5480
-
5481
- dlg.setLayout ( layout );
5482
-
5483
- QSettings settings;
5484
- dlg.restoreGeometry ( settings.value ( " /Windows/Labeling/geometry" ).toByteArray () );
5485
-
5486
- connect ( buttonBox->button ( QDialogButtonBox::Ok ), SIGNAL ( clicked () ), &dlg, SLOT ( accept () ) );
5487
- connect ( buttonBox->button ( QDialogButtonBox::Cancel ), SIGNAL ( clicked () ), &dlg, SLOT ( reject () ) );
5488
- connect ( buttonBox->button ( QDialogButtonBox::Apply ), SIGNAL ( clicked () ), labelingGui, SLOT ( apply () ) );
5489
-
5490
- if ( dlg.exec () )
5493
+ void QgisApp::setMapStyleDockLayer ( QgsMapLayer* layer )
5494
+ {
5495
+ if ( !layer )
5491
5496
{
5492
- labelingGui->writeSettingsToLayer ();
5497
+ mMapStylingDock ->setEnabled ( false );
5498
+ return ;
5499
+ }
5493
5500
5494
- settings.setValue ( " /Windows/Labeling/geometry" , dlg.saveGeometry () );
5501
+ mMapStylingDock ->setEnabled ( true );
5502
+ // We don't set the layer if the dock isn't open mainly to save
5503
+ // the extra work if it's not needed
5504
+ if ( mMapStylingDock ->isVisible () )
5505
+ mMapStyleWidget ->setLayer ( layer );
5495
5506
5496
- // trigger refresh
5497
- if ( mMapCanvas )
5498
- {
5499
- mMapCanvas ->refresh ();
5500
- }
5501
- }
5507
+ mMapStylingDock ->setWindowTitle ( tr ( " Map Styling - %1" ).arg ( layer->name () ) );
5508
+ }
5502
5509
5503
- activateDeactivateLayerRelatedActions ( vlayer );
5510
+ void QgisApp::mapStyleDock ()
5511
+ {
5512
+ mMapStylingDock ->show ();
5513
+ setMapStyleDockLayer ( activeLayer () );
5504
5514
}
5505
5515
5506
5516
void QgisApp::diagramProperties ()
@@ -9848,7 +9858,7 @@ void QgisApp::layerEditStateChanged()
9848
9858
}
9849
9859
}
9850
9860
9851
- void QgisApp::activateDeactivateLayerRelatedActions ( QgsMapLayer* layer )
9861
+ void QgisApp::updateLabelToolButtons ( )
9852
9862
{
9853
9863
bool enableMove = false , enableRotate = false , enablePin = false , enableShowHide = false , enableChange = false ;
9854
9864
@@ -9895,6 +9905,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
9895
9905
mActionMoveLabel ->setEnabled ( enableMove );
9896
9906
mActionRotateLabel ->setEnabled ( enableRotate );
9897
9907
mActionChangeLabelProperties ->setEnabled ( enableChange );
9908
+ }
9909
+
9910
+ void QgisApp::activateDeactivateLayerRelatedActions ( QgsMapLayer* layer )
9911
+ {
9912
+ updateLabelToolButtons ();
9898
9913
9899
9914
mMenuPasteAs ->setEnabled ( clipboard () && !clipboard ()->isEmpty () );
9900
9915
mActionPasteAsNewVector ->setEnabled ( clipboard () && !clipboard ()->isEmpty () );
0 commit comments