@@ -62,26 +62,23 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
6262 connect ( listItems, SIGNAL ( doubleClicked ( const QModelIndex & ) ), this , SLOT ( editItem () ) );
6363
6464 connect ( btnAddItem, SIGNAL ( clicked () ), this , SLOT ( addItem () ) );
65- connect ( btnEditItem , SIGNAL ( clicked ( ) ), this , SLOT ( editItem () ) );
66- connect ( btnRemoveItem , SIGNAL ( clicked ( ) ), this , SLOT ( removeItem () ) );
65+ connect ( actnEditItem , SIGNAL ( triggered ( bool ) ), this , SLOT ( editItem () ) );
66+ connect ( actnRemoveItem , SIGNAL ( triggered ( bool ) ), this , SLOT ( removeItem () ) );
6767
68- btnRemoveItem->setEnabled ( false );
68+ btnRemoveItem->setDefaultAction ( actnRemoveItem );
69+ btnEditItem->setDefaultAction ( actnEditItem );
6970
7071 QMenu *shareMenu = new QMenu ( tr ( " Share menu" ), this );
71- QAction *exportAsPNGAction = shareMenu->addAction ( tr ( " Export selected symbols as PNG " ) );
72- QAction *exportAsSVGAction = shareMenu->addAction ( tr ( " Export selected symbols as SVG " ) );
72+ shareMenu->addAction ( actnExportAsPNG );
73+ shareMenu->addAction ( actnExportAsSVG );
7374 QAction *exportAction = new QAction ( tr ( " Export..." ), this );
7475 shareMenu->addAction ( exportAction );
7576 QAction *importAction = new QAction ( tr ( " Import..." ), this );
7677 shareMenu->addAction ( importAction );
77- exportAsPNGAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingExport.svg" ) ) );
78- exportAsPNGAction->setEnabled ( false );
79- exportAsSVGAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingExport.svg" ) ) );
80- exportAsSVGAction->setEnabled ( false );
8178 exportAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingExport.svg" ) ) );
8279 importAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingImport.svg" ) ) );
83- connect ( exportAsPNGAction , SIGNAL ( triggered () ), this , SLOT ( exportItemsPNG () ) );
84- connect ( exportAsSVGAction , SIGNAL ( triggered () ), this , SLOT ( exportItemsSVG () ) );
80+ connect ( actnExportAsPNG , SIGNAL ( triggered () ), this , SLOT ( exportItemsPNG () ) );
81+ connect ( actnExportAsSVG , SIGNAL ( triggered () ), this , SLOT ( exportItemsSVG () ) );
8582 connect ( exportAction, SIGNAL ( triggered () ), this , SLOT ( exportItems () ) );
8683 connect ( importAction, SIGNAL ( triggered () ), this , SLOT ( importItems () ) );
8784 btnShare->setMenu ( shareMenu );
@@ -151,6 +148,12 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
151148 mGroupMenu ->addMenu ( mGroupListMenu );
152149 actnUngroup->setData ( 0 );
153150 mGroupMenu ->addAction ( actnUngroup );
151+ mGroupMenu ->addSeparator ()->setParent ( this );
152+ mGroupMenu ->addAction ( actnRemoveItem );
153+ mGroupMenu ->addAction ( actnEditItem );
154+ mGroupMenu ->addSeparator ()->setParent ( this );
155+ mGroupMenu ->addAction ( actnExportAsPNG );
156+ mGroupMenu ->addAction ( actnExportAsSVG );
154157
155158 on_tabItemType_currentChanged ( 0 );
156159}
@@ -213,8 +216,8 @@ void QgsStyleV2ManagerDialog::on_tabItemType_currentChanged( int )
213216 // when in Color Ramp tab, add menu to add item button and hide "Export symbols as PNG/SVG"
214217 bool flag = currentItemType () != 3 ;
215218 btnAddItem->setMenu ( flag ? nullptr : mMenuBtnAddItemColorRamp );
216- btnShare-> menu ()-> actions (). at ( 0 ) ->setVisible ( flag );
217- btnShare-> menu ()-> actions (). at ( 1 ) ->setVisible ( flag );
219+ actnExportAsPNG ->setVisible ( flag );
220+ actnExportAsSVG ->setVisible ( flag );
218221
219222 // set icon and grid size, depending on type
220223 if ( currentItemType () == 1 || currentItemType () == 3 )
@@ -1233,18 +1236,20 @@ void QgsStyleV2ManagerDialog::symbolSelected( const QModelIndex& index )
12331236 mTagList = mStyle ->tagsOfSymbol ( type, item->data ().toString () );
12341237 tagsLineEdit->setText ( mTagList .join ( " ," ) );
12351238 }
1239+
1240+ actnEditItem->setEnabled ( index.isValid () && !mGrouppingMode );
12361241}
12371242
12381243void QgsStyleV2ManagerDialog::selectedSymbolsChanged ( const QItemSelection& selected, const QItemSelection& deselected )
12391244{
12401245 Q_UNUSED ( selected );
12411246 Q_UNUSED ( deselected );
12421247 bool nothingSelected = listItems->selectionModel ()->selectedIndexes ().empty ();
1243- btnRemoveItem ->setDisabled ( nothingSelected );
1248+ actnRemoveItem ->setDisabled ( nothingSelected );
12441249 mGroupListMenu ->setDisabled ( nothingSelected );
12451250 actnUngroup->setDisabled ( nothingSelected );
1246- btnShare-> menu ()-> actions (). at ( 0 ) ->setDisabled ( nothingSelected );
1247- btnShare-> menu ()-> actions (). at ( 1 ) ->setDisabled ( nothingSelected );
1251+ actnExportAsPNG ->setDisabled ( nothingSelected );
1252+ actnExportAsSVG ->setDisabled ( nothingSelected );
12481253}
12491254
12501255void QgsStyleV2ManagerDialog::enableSymbolInputs ( bool enable )
@@ -1300,6 +1305,9 @@ void QgsStyleV2ManagerDialog::enableItemsForGroupingMode( bool enable )
13001305 w->setEnabled ( enable );
13011306 }
13021307
1308+ // The actions
1309+ actnRemoveItem->setEnabled ( enable );
1310+ actnEditItem->setEnabled ( enable );
13031311}
13041312
13051313void QgsStyleV2ManagerDialog::grouptreeContextMenu ( const QPoint& point )
0 commit comments