diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 79ee344..902f72c 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -306,8 +306,10 @@ void ToolOptionControlBuilder::visit(TBoolProperty *p) { std::string actionName = "A_ToolOption_" + p->getId(); QAction *a = CommandManager::instance()->getAction(actionName.c_str()); if (a) { + a->setCheckable(true); control->addAction(a); - QObject::connect(a, SIGNAL(triggered()), control, SLOT(doClick())); + QObject::connect(a, SIGNAL(triggered(bool)), control, + SLOT(doClick(bool))); } } hLayout()->addSpacing(5); @@ -553,10 +555,11 @@ ArrowToolOptionsBox::ArrowToolOptionsBox( m_lockNSCenterCheckbox = new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this); - TBoolProperty *prop = + TBoolProperty *globalKeyProp = dynamic_cast(m_pg->getProperty("Global Key")); - if (prop) - m_globalKey = new ToolOptionCheckbox(m_tool, prop, toolHandle, this); + if (globalKeyProp) + m_globalKey = + new ToolOptionCheckbox(m_tool, globalKeyProp, toolHandle, this); m_lockEWPosCheckbox->setObjectName("EditToolLockButton"); m_lockNSPosCheckbox->setObjectName("EditToolLockButton"); @@ -812,6 +815,16 @@ ArrowToolOptionsBox::ArrowToolOptionsBox( connect(m_maintainCombo, SIGNAL(currentIndexChanged(int)), m_scaleVField, SLOT(onScaleTypeChanged(int))); } + + if (globalKeyProp) { + std::string actionName = "A_ToolOption_" + globalKeyProp->getId(); + QAction *a = CommandManager::instance()->getAction(actionName.c_str()); + if (a) { + a->setCheckable(true); + m_globalKey->addAction(a); + connect(a, SIGNAL(triggered(bool)), m_globalKey, SLOT(doClick(bool))); + } + } } //----------------------------------------------------------------------------- diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp index 72bdf8f..ece372e 100644 --- a/toonz/sources/tnztools/tooloptionscontrols.cpp +++ b/toonz/sources/tnztools/tooloptionscontrols.cpp @@ -102,26 +102,28 @@ ToolOptionCheckbox::ToolOptionCheckbox(TTool *tool, TBoolProperty *property, void ToolOptionCheckbox::updateStatus() { bool check = m_property->getValue(); - if (isChecked() == check) return; - setCheckState(check ? Qt::Checked : Qt::Unchecked); -} + if (!actions().isEmpty() && actions()[0]->isCheckable() && + actions()[0]->isChecked() != check) + actions()[0]->setChecked(check); -//----------------------------------------------------------------------------- + if (isChecked() == check) return; -void ToolOptionCheckbox::nextCheckState() { - QAbstractButton::nextCheckState(); - m_property->setValue(checkState() == Qt::Checked); - notifyTool(); + setCheckState(check ? Qt::Checked : Qt::Unchecked); } //----------------------------------------------------------------------------- -void ToolOptionCheckbox::doClick() { +void ToolOptionCheckbox::doClick(bool checked) { if (m_toolHandle && m_toolHandle->getTool() != m_tool) return; // active only if the belonging combo-viewer is visible if (!isInVisibleViewer(this)) return; - click(); + + if (isChecked() == checked) return; + + setChecked(checked); + m_property->setValue(checked); + notifyTool(); } //============================================================================= diff --git a/toonz/sources/tnztools/tooloptionscontrols.h b/toonz/sources/tnztools/tooloptionscontrols.h index f3a26cd..b446e88 100644 --- a/toonz/sources/tnztools/tooloptionscontrols.h +++ b/toonz/sources/tnztools/tooloptionscontrols.h @@ -93,10 +93,7 @@ public: ToolHandle *toolHandle = 0, QWidget *parent = 0); void updateStatus() override; public slots: - void doClick(); - -protected: - void nextCheckState() override; + void doClick(bool); }; //-----------------------------------------------------------------------------