Skip to content

Commit 4d2d001

Browse files
committed
[StyleManager] have separate predefined QActions for start/finish grouping mode
1 parent a9c4179 commit 4d2d001

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

+24-10
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,13 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
108108
this, SLOT( groupRenamed( QStandardItem* ) ) );
109109

110110
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 );
112116
groupMenu->addAction( actnEditSmartGroup );
113117
btnManageGroups->setMenu( groupMenu );
114-
connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
115118

116119
connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
117120
tagsLineEdit->installEventFilter( this );
@@ -894,6 +897,7 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
894897
if ( category == "groups" || category == "smartgroups" )
895898
{
896899
btnAddGroup->setEnabled( true );
900+
actnAddGroup->setEnabled( true );
897901
}
898902
symbolNames = currentItemType() < 3 ? mStyle->symbolNames() : mStyle->colorRampNames();
899903
}
@@ -903,7 +907,9 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
903907
if ( index.parent().data( Qt::UserRole + 1 ) == "smartgroups" )
904908
{
905909
btnAddGroup->setEnabled( false );
910+
actnAddGroup->setEnabled( false );
906911
btnRemoveGroup->setEnabled( true );
912+
actnRemoveGroup->setEnabled( true );
907913
btnManageGroups->setEnabled( true );
908914
int groupId = index.data( Qt::UserRole + 1 ).toInt();
909915
symbolNames = mStyle->symbolsOfSmartgroup( type, groupId );
@@ -938,22 +944,26 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
938944
actnEditSmartGroup->setVisible( false );
939945
actnAddGroup->setVisible( false );
940946
actnRemoveGroup->setVisible( false );
947+
actnGroupSymbols->setVisible( false );
948+
actnFinishGrouping->setVisible( false );
941949

942950
if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
943951
{
944952
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
945953
{
946-
actnEditSmartGroup->setVisible( true );
954+
actnEditSmartGroup->setVisible( !mGrouppingMode );
947955
}
948956
else
949957
{
950-
actnAddGroup->setVisible( true );
958+
actnAddGroup->setVisible( !mGrouppingMode );
959+
actnGroupSymbols->setVisible( !mGrouppingMode );
960+
actnFinishGrouping->setVisible( mGrouppingMode );
951961
}
952962
actnRemoveGroup->setVisible( true );
953963
}
954964
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
955965
{
956-
actnAddGroup->setVisible( true );
966+
actnAddGroup->setVisible( !mGrouppingMode );
957967
}
958968
}
959969

@@ -1086,12 +1096,12 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
10861096

10871097
QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() );
10881098
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
1089-
QAction *senderAction = qobject_cast<QAction*>( sender() );
10901099

10911100
if ( mGrouppingMode )
10921101
{
10931102
mGrouppingMode = false;
1094-
senderAction->setText( tr( "Group symbols" ) );
1103+
actnGroupSymbols->setVisible( true );
1104+
actnFinishGrouping->setVisible( false );
10951105
// disconnect slot which handles regrouping
10961106
disconnect( model, SIGNAL( itemChanged( QStandardItem* ) ),
10971107
this, SLOT( regrouped( QStandardItem* ) ) );
@@ -1127,8 +1137,9 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
11271137
return;
11281138

11291139
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 );
11321143
// Remove all Symbol editing functionalities
11331144
disconnect( treeModel, SIGNAL( itemChanged( QStandardItem* ) ),
11341145
this, SLOT( groupRenamed( QStandardItem* ) ) );
@@ -1283,7 +1294,9 @@ void QgsStyleV2ManagerDialog::enableSymbolInputs( bool enable )
12831294
{
12841295
groupTree->setEnabled( enable );
12851296
btnAddGroup->setEnabled( enable );
1297+
actnAddGroup->setEnabled( enable );
12861298
btnRemoveGroup->setEnabled( enable );
1299+
actnRemoveGroup->setEnabled( enable );
12871300
btnManageGroups->setEnabled( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode
12881301
searchBox->setEnabled( enable );
12891302
tagsLineEdit->setEnabled( enable );
@@ -1293,6 +1306,7 @@ void QgsStyleV2ManagerDialog::enableGroupInputs( bool enable )
12931306
{
12941307
btnAddGroup->setEnabled( enable );
12951308
btnRemoveGroup->setEnabled( enable );
1309+
actnRemoveGroup->setEnabled( enable );
12961310
btnManageGroups->setEnabled( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode
12971311
}
12981312

@@ -1344,7 +1358,7 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
13441358
QModelIndex index = groupTree->indexAt( point );
13451359
QgsDebugMsg( "Now you clicked: " + index.data().toString() );
13461360

1347-
if ( index.isValid() )
1361+
if ( index.isValid() && !mGrouppingMode )
13481362
mGroupTreeContextMenu->popup( globalPos );
13491363
}
13501364

src/ui/qgsstylev2managerdialogbase.ui

+16
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,22 @@ QMenu::item:selected { background-color: gray; } */
484484
<string>Remove group</string>
485485
</property>
486486
</action>
487+
<action name="actnGroupSymbols">
488+
<property name="text">
489+
<string>Group symbols</string>
490+
</property>
491+
</action>
492+
<action name="actnFinishGrouping">
493+
<property name="enabled">
494+
<bool>true</bool>
495+
</property>
496+
<property name="text">
497+
<string>Finish grouping</string>
498+
</property>
499+
<property name="visible">
500+
<bool>true</bool>
501+
</property>
502+
</action>
487503
<action name="actnExportAsPNG">
488504
<property name="enabled">
489505
<bool>false</bool>

0 commit comments

Comments
 (0)