Skip to content

Commit 1e16680

Browse files
committedNov 6, 2018
show icon if exist for menus in customization dialog
1 parent 762a15a commit 1e16680

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
 

‎src/app/qgscustomization.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void QgsCustomizationDialog::showHelp()
491491

492492
void QgsCustomization::addTreeItemActions( QTreeWidgetItem *parentItem, const QList<QAction *> &actions )
493493
{
494-
Q_FOREACH ( QAction *action, actions )
494+
for ( const QAction *action : actions )
495495
{
496496
if ( action->isSeparator() )
497497
{
@@ -500,27 +500,29 @@ void QgsCustomization::addTreeItemActions( QTreeWidgetItem *parentItem, const QL
500500
if ( action->menu() )
501501
{
502502
// it is a submenu
503-
addTreeItemMenu( parentItem, action->menu() );
503+
addTreeItemMenu( parentItem, action->menu(), action );
504504
}
505505
else
506506
{
507507
// it is an ordinary action
508508
QStringList strs;
509509
strs << action->objectName() << action->text();
510-
QTreeWidgetItem *myItem = new QTreeWidgetItem( parentItem, strs );
511-
myItem->setIcon( 0, action->icon() );
512-
myItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
513-
myItem->setCheckState( 0, Qt::Checked );
510+
QTreeWidgetItem *item = new QTreeWidgetItem( parentItem, strs );
511+
item->setIcon( 0, action->icon() );
512+
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
513+
item->setCheckState( 0, Qt::Checked );
514514
}
515515
}
516516
}
517517

518-
void QgsCustomization::addTreeItemMenu( QTreeWidgetItem *parentItem, QMenu *menu )
518+
void QgsCustomization::addTreeItemMenu( QTreeWidgetItem *parentItem, const QMenu *menu, const QAction *action )
519519
{
520520
QStringList menustrs;
521521
// remove '&' which are used to mark shortcut key
522522
menustrs << menu->objectName() << menu->title().remove( '&' );
523523
QTreeWidgetItem *menuItem = new QTreeWidgetItem( parentItem, menustrs );
524+
if ( action )
525+
menuItem->setIcon( 0, action->icon() );
524526
menuItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
525527
menuItem->setCheckState( 0, Qt::Checked );
526528

@@ -921,7 +923,7 @@ void QgsCustomization::preNotify( QObject *receiver, QEvent *event, bool *done )
921923
}
922924
}
923925

924-
QString QgsCustomization::splashPath()
926+
QString QgsCustomization::splashPath() const
925927
{
926928
if ( isEnabled() )
927929
{

‎src/app/qgscustomization.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ class APP_EXPORT QgsCustomization : public QObject
133133
void setSettings( QSettings *settings ) { mSettings = settings ;}
134134

135135
// Return the path to the splash screen
136-
QString splashPath();
136+
QString splashPath() const;
137137

138138
// Load and set default customization
139139
void loadDefault();
140140

141141
// Internal Qt widget which has to bes kipped in paths
142142
static QStringList sInternalWidgets;
143143

144-
QString statusPath() { return mStatusPath; }
144+
QString statusPath() const { return mStatusPath; }
145145

146146
public slots:
147147
void preNotify( QObject *receiver, QEvent *event, bool *done );
@@ -160,7 +160,7 @@ class APP_EXPORT QgsCustomization : public QObject
160160
void createTreeItemToolbars();
161161
void createTreeItemDocks();
162162
void createTreeItemStatus();
163-
void addTreeItemMenu( QTreeWidgetItem *parentItem, QMenu *menu );
163+
void addTreeItemMenu( QTreeWidgetItem *parentItem, const QMenu *menu, const QAction *action = nullptr );
164164
void addTreeItemActions( QTreeWidgetItem *parentItem, const QList<QAction *> &actions );
165165
QList<QTreeWidgetItem *> mMainWindowItems;
166166
friend class QgsCustomizationDialog; // in order to access mMainWindowItems

0 commit comments

Comments
 (0)
Please sign in to comment.