Skip to content

Commit

Permalink
show icon if exist for menus in customization dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 6, 2018
1 parent dfaf753 commit 2d9230b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/app/qgscustomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void QgsCustomizationDialog::showHelp()

void QgsCustomization::addTreeItemActions( QTreeWidgetItem *parentItem, const QList<QAction *> &actions )
{
Q_FOREACH ( QAction *action, actions )
for ( const QAction *action : actions )
{
if ( action->isSeparator() )
{
Expand All @@ -500,27 +500,29 @@ void QgsCustomization::addTreeItemActions( QTreeWidgetItem *parentItem, const QL
if ( action->menu() )
{
// it is a submenu
addTreeItemMenu( parentItem, action->menu() );
addTreeItemMenu( parentItem, action->menu(), action );
}
else
{
// it is an ordinary action
QStringList strs;
strs << action->objectName() << action->text();
QTreeWidgetItem *myItem = new QTreeWidgetItem( parentItem, strs );
myItem->setIcon( 0, action->icon() );
myItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
myItem->setCheckState( 0, Qt::Checked );
QTreeWidgetItem *item = new QTreeWidgetItem( parentItem, strs );
item->setIcon( 0, action->icon() );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
item->setCheckState( 0, Qt::Checked );
}
}
}

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

Expand Down Expand Up @@ -921,7 +923,7 @@ void QgsCustomization::preNotify( QObject *receiver, QEvent *event, bool *done )
}
}

QString QgsCustomization::splashPath()
QString QgsCustomization::splashPath() const
{
if ( isEnabled() )
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgscustomization.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ class APP_EXPORT QgsCustomization : public QObject
void setSettings( QSettings *settings ) { mSettings = settings ;}

// Return the path to the splash screen
QString splashPath();
QString splashPath() const;

// Load and set default customization
void loadDefault();

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

QString statusPath() { return mStatusPath; }
QString statusPath() const { return mStatusPath; }

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

0 comments on commit 2d9230b

Please sign in to comment.