diff --git a/toonz/sources/toonz/shortcutpopup.cpp b/toonz/sources/toonz/shortcutpopup.cpp index a3bdc1b..655e6d6 100644 --- a/toonz/sources/toonz/shortcutpopup.cpp +++ b/toonz/sources/toonz/shortcutpopup.cpp @@ -87,8 +87,14 @@ ShortcutViewer::~ShortcutViewer() {} void ShortcutViewer::setAction(QAction *action) { m_action = action; - setKeySequence(m_action->shortcut()); - setFocus(); + if (m_action) { + setEnabled(true); + setKeySequence(m_action->shortcut()); + setFocus(); + } else { + setEnabled(false); + setKeySequence(QKeySequence()); + } } //----------------------------------------------------------------------------- @@ -212,6 +218,8 @@ ShortcutTree::ShortcutTree(QWidget *parent) : QTreeWidget(parent) { connect( this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(onCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + connect(this, SIGNAL(clicked(const QModelIndex &)), this, + SLOT(onItemClicked(const QModelIndex &))); } //----------------------------------------------------------------------------- @@ -329,6 +337,12 @@ void ShortcutTree::onShortcutChanged() { for (i = 0; i < (int)m_items.size(); i++) m_items[i]->updateText(); } +//----------------------------------------------------------------------------- + +void ShortcutTree::onItemClicked(const QModelIndex &index) { + isExpanded(index) ? collapse(index) : expand(index); +} + //============================================================================= // ShortcutPopup //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/shortcutpopup.h b/toonz/sources/toonz/shortcutpopup.h index 7184270..d544c1a 100644 --- a/toonz/sources/toonz/shortcutpopup.h +++ b/toonz/sources/toonz/shortcutpopup.h @@ -76,6 +76,8 @@ public slots: QTreeWidgetItem *previous); void onShortcutChanged(); + void onItemClicked(const QModelIndex &); + signals: void actionSelected(QAction *); void searched(bool haveResult);