@@ -108,10 +108,13 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
108
108
this , SLOT ( groupRenamed ( QStandardItem* ) ) );
109
109
110
110
QMenu *groupMenu = new QMenu ( tr ( " Group actions" ), this );
111
- QAction *groupSymbols = groupMenu->addAction ( tr ( " Group symbols" ) );
111
+ connect ( actnGroupSymbols, SIGNAL ( triggered () ), this , SLOT ( groupSymbolsAction () ) );
112
+ groupMenu->addAction ( actnGroupSymbols );
113
+ connect ( actnFinishGrouping, SIGNAL ( triggered () ), this , SLOT ( groupSymbolsAction () ) );
114
+ actnFinishGrouping->setVisible ( false );
115
+ groupMenu->addAction ( actnFinishGrouping );
112
116
groupMenu->addAction ( actnEditSmartGroup );
113
117
btnManageGroups->setMenu ( groupMenu );
114
- connect ( groupSymbols, SIGNAL ( triggered () ), this , SLOT ( groupSymbolsAction () ) );
115
118
116
119
connect ( searchBox, SIGNAL ( textChanged ( QString ) ), this , SLOT ( filterSymbols ( QString ) ) );
117
120
tagsLineEdit->installEventFilter ( this );
@@ -894,6 +897,7 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
894
897
if ( category == " groups" || category == " smartgroups" )
895
898
{
896
899
btnAddGroup->setEnabled ( true );
900
+ actnAddGroup->setEnabled ( true );
897
901
}
898
902
symbolNames = currentItemType () < 3 ? mStyle ->symbolNames () : mStyle ->colorRampNames ();
899
903
}
@@ -903,7 +907,9 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
903
907
if ( index .parent ().data ( Qt::UserRole + 1 ) == " smartgroups" )
904
908
{
905
909
btnAddGroup->setEnabled ( false );
910
+ actnAddGroup->setEnabled ( false );
906
911
btnRemoveGroup->setEnabled ( true );
912
+ actnRemoveGroup->setEnabled ( true );
907
913
btnManageGroups->setEnabled ( true );
908
914
int groupId = index .data ( Qt::UserRole + 1 ).toInt ();
909
915
symbolNames = mStyle ->symbolsOfSmartgroup ( type, groupId );
@@ -938,22 +944,26 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
938
944
actnEditSmartGroup->setVisible ( false );
939
945
actnAddGroup->setVisible ( false );
940
946
actnRemoveGroup->setVisible ( false );
947
+ actnGroupSymbols->setVisible ( false );
948
+ actnFinishGrouping->setVisible ( false );
941
949
942
950
if ( index .parent ().isValid () && ( index .data ().toString () != " Ungrouped" ) )
943
951
{
944
952
if ( index .parent ().data ( Qt::UserRole + 1 ).toString () == " smartgroups" )
945
953
{
946
- actnEditSmartGroup->setVisible ( true );
954
+ actnEditSmartGroup->setVisible ( ! mGrouppingMode );
947
955
}
948
956
else
949
957
{
950
- actnAddGroup->setVisible ( true );
958
+ actnAddGroup->setVisible ( !mGrouppingMode );
959
+ actnGroupSymbols->setVisible ( !mGrouppingMode );
960
+ actnFinishGrouping->setVisible ( mGrouppingMode );
951
961
}
952
962
actnRemoveGroup->setVisible ( true );
953
963
}
954
964
else if ( index .data ( Qt::UserRole + 1 ) == " groups" || index .data ( Qt::UserRole + 1 ) == " smartgroups" )
955
965
{
956
- actnAddGroup->setVisible ( true );
966
+ actnAddGroup->setVisible ( ! mGrouppingMode );
957
967
}
958
968
}
959
969
@@ -1086,12 +1096,12 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
1086
1096
1087
1097
QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model () );
1088
1098
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model () );
1089
- QAction *senderAction = qobject_cast<QAction*>( sender () );
1090
1099
1091
1100
if ( mGrouppingMode )
1092
1101
{
1093
1102
mGrouppingMode = false ;
1094
- senderAction->setText ( tr ( " Group symbols" ) );
1103
+ actnGroupSymbols->setVisible ( true );
1104
+ actnFinishGrouping->setVisible ( false );
1095
1105
// disconnect slot which handles regrouping
1096
1106
disconnect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ),
1097
1107
this , SLOT ( regrouped ( QStandardItem* ) ) );
@@ -1127,8 +1137,9 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
1127
1137
return ;
1128
1138
1129
1139
mGrouppingMode = true ;
1130
- // Change the text menu
1131
- senderAction->setText ( tr ( " Finish grouping" ) );
1140
+ // Change visibility of actions
1141
+ actnGroupSymbols->setVisible ( false );
1142
+ actnFinishGrouping->setVisible ( true );
1132
1143
// Remove all Symbol editing functionalities
1133
1144
disconnect ( treeModel, SIGNAL ( itemChanged ( QStandardItem* ) ),
1134
1145
this , SLOT ( groupRenamed ( QStandardItem* ) ) );
@@ -1283,7 +1294,9 @@ void QgsStyleV2ManagerDialog::enableSymbolInputs( bool enable )
1283
1294
{
1284
1295
groupTree->setEnabled ( enable );
1285
1296
btnAddGroup->setEnabled ( enable );
1297
+ actnAddGroup->setEnabled ( enable );
1286
1298
btnRemoveGroup->setEnabled ( enable );
1299
+ actnRemoveGroup->setEnabled ( enable );
1287
1300
btnManageGroups->setEnabled ( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode
1288
1301
searchBox->setEnabled ( enable );
1289
1302
tagsLineEdit->setEnabled ( enable );
@@ -1293,6 +1306,7 @@ void QgsStyleV2ManagerDialog::enableGroupInputs( bool enable )
1293
1306
{
1294
1307
btnAddGroup->setEnabled ( enable );
1295
1308
btnRemoveGroup->setEnabled ( enable );
1309
+ actnRemoveGroup->setEnabled ( enable );
1296
1310
btnManageGroups->setEnabled ( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode
1297
1311
}
1298
1312
@@ -1344,7 +1358,7 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
1344
1358
QModelIndex index = groupTree->indexAt ( point );
1345
1359
QgsDebugMsg ( " Now you clicked: " + index .data ().toString () );
1346
1360
1347
- if ( index .isValid () )
1361
+ if ( index .isValid () && ! mGrouppingMode )
1348
1362
mGroupTreeContextMenu ->popup ( globalPos );
1349
1363
}
1350
1364
0 commit comments