Skip to content
Permalink
Browse files

show icon if exist for menus in customization dialog

  • Loading branch information
3nids committed Nov 6, 2018
1 parent dfaf753 commit 2d9230b949dccefd2a5dd8880c25be5fbccb89e9
Showing with 13 additions and 11 deletions.
  1. +10 −8 src/app/qgscustomization.cpp
  2. +3 −3 src/app/qgscustomization.h
@@ -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() )
{
@@ -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 );

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

QString QgsCustomization::splashPath()
QString QgsCustomization::splashPath() const
{
if ( isEnabled() )
{
@@ -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 );
@@ -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

0 comments on commit 2d9230b

Please sign in to comment.
You can’t perform that action at this time.