From 1a982363d4e71b155ca0806828bb0161c5fdb2c3 Mon Sep 17 00:00:00 2001 From: manongjohn <19245851+manongjohn@users.noreply.github.com> Date: Fri, 9 Jun 2023 23:05:56 -0400 Subject: [PATCH] Fix Toggle and Edit Tag shortcuts --- toonz/sources/toonz/xshrowviewer.cpp | 35 +++++++++++++++++++++++++--- toonz/sources/toonz/xshrowviewer.h | 4 ++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/toonz/sources/toonz/xshrowviewer.cpp b/toonz/sources/toonz/xshrowviewer.cpp index e80aa2b3..567047d4 100644 --- a/toonz/sources/toonz/xshrowviewer.cpp +++ b/toonz/sources/toonz/xshrowviewer.cpp @@ -52,9 +52,17 @@ RowArea::RowArea(XsheetViewer *parent, Qt::WindowFlags flags) , m_tooltip(tr("")) , m_r0(0) , m_r1(5) - , m_isPanning(false) { + , m_isPanning(false) + , m_contextMenuRow(-1) + , m_editTagEnabled(false) { setFocusPolicy(Qt::NoFocus); setMouseTracking(true); + + m_resetMenuTimer = new QTimer(this); + m_resetMenuTimer->setSingleShot(true); + + connect(m_resetMenuTimer, SIGNAL(timeout()), this, SLOT(resetContextMenu())); + connect(TApp::instance()->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this, SLOT(update())); // for displaying the pinned center keys when the skeleton tool is selected @@ -1353,6 +1361,8 @@ void RowArea::mouseReleaseEvent(QMouseEvent *event) { //----------------------------------------------------------------------------- void RowArea::contextMenuEvent(QContextMenuEvent *event) { + if (m_resetMenuTimer) m_resetMenuTimer->stop(); + TPoint pos(event->pos().x(), event->pos().y()); m_contextMenuRow = m_viewer->xyToPosition(pos).frame(); @@ -1406,11 +1416,12 @@ void RowArea::contextMenuEvent(QContextMenuEvent *event) { // Tags menu->addSeparator(); menu->addAction(cmdManager->getAction(MI_ToggleTaggedFrame)); - menu->addAction(cmdManager->getAction(MI_EditTaggedFrame)); + QAction *tagAction = cmdManager->getAction(MI_EditTaggedFrame); + menu->addAction(tagAction); + m_editTagEnabled = tagAction->isEnabled(); QMenu *tagMenu = menu->addMenu(tr("Tags")); NavigationTags *navTags = m_viewer->getXsheet()->getNavigationTags(); - QAction *tagAction; if (!navTags->getCount()) { tagAction = tagMenu->addAction("Empty"); tagAction->setEnabled(false); @@ -1431,6 +1442,11 @@ void RowArea::contextMenuEvent(QContextMenuEvent *event) { menu->addAction(cmdManager->getAction(MI_NextTaggedFrame)); menu->addAction(cmdManager->getAction(MI_PrevTaggedFrame)); + CommandManager::instance()->enable(MI_EditTaggedFrame, + navTags->isTagged(m_contextMenuRow)); + + connect(menu, SIGNAL(aboutToHide()), this, SLOT(onHideMenu())); + menu->exec(event->globalPos()); } @@ -1493,4 +1509,17 @@ void RowArea::onJumpToTag() { m_viewer->setCurrentRow(frame); } +//----------------------------------------------------------------------------- + +void RowArea::onHideMenu() { + m_resetMenuTimer->start(300); + CommandManager::instance()->enable(MI_EditTaggedFrame, m_editTagEnabled); +} + +void RowArea::resetContextMenu() { + if (m_resetMenuTimer) m_resetMenuTimer->stop(); + + m_contextMenuRow = -1; +} + } // namespace XsheetGUI diff --git a/toonz/sources/toonz/xshrowviewer.h b/toonz/sources/toonz/xshrowviewer.h index 46399be0..1493687e 100644 --- a/toonz/sources/toonz/xshrowviewer.h +++ b/toonz/sources/toonz/xshrowviewer.h @@ -44,7 +44,9 @@ class RowArea final : public QWidget { // panning by middle-drag bool m_isPanning; + QTimer *m_resetMenuTimer; int m_contextMenuRow; + bool m_editTagEnabled; // returns true if the frame area can have extra space bool checkExpandFrameArea(); @@ -85,6 +87,8 @@ protected: protected slots: void onJumpToTag(); + void onHideMenu(); + void resetContextMenu(); }; } // namespace XsheetGUI;