Gui: Add Action::setBlockedChecked
Remove the second parameter of Action::setChecked and provide Action::setBlockedChecked instead.
This commit is contained in:
@@ -137,16 +137,21 @@ void Action::setCheckable(bool check)
|
||||
}
|
||||
}
|
||||
|
||||
void Action::setChecked(bool check, bool no_signal)
|
||||
void Action::setChecked(bool check)
|
||||
{
|
||||
bool blocked = false;
|
||||
if (no_signal) {
|
||||
blocked = _action->blockSignals(true);
|
||||
}
|
||||
_action->setChecked(check);
|
||||
if (no_signal) {
|
||||
_action->blockSignals(blocked);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Action::setBlockedChecked
|
||||
* \param check
|
||||
* Does the same as \ref setChecked but additionally blocks
|
||||
* any signals.
|
||||
*/
|
||||
void Action::setBlockedChecked(bool check)
|
||||
{
|
||||
QSignalBlocker block(_action);
|
||||
_action->setChecked(check);
|
||||
}
|
||||
|
||||
bool Action::isChecked() const
|
||||
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
virtual void setVisible(bool);
|
||||
|
||||
void setCheckable(bool);
|
||||
void setChecked (bool, bool no_signal=false);
|
||||
void setChecked(bool);
|
||||
void setBlockedChecked(bool);
|
||||
bool isChecked() const;
|
||||
bool isEnabled() const;
|
||||
|
||||
|
||||
@@ -385,7 +385,7 @@ void Command::setupCheckable(int iMsg) {
|
||||
action->setChecked(checked);
|
||||
action->blockSignals(blocked);
|
||||
if(action!=_pcAction->action())
|
||||
_pcAction->setChecked(checked,true);
|
||||
_pcAction->setBlockedChecked(checked);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1637,7 +1637,7 @@ Action * PythonGroupCommand::createAction()
|
||||
qtAction->blockSignals(false);
|
||||
}else if(qtAction->isCheckable()){
|
||||
pcAction->setCheckable(true);
|
||||
pcAction->setChecked(qtAction->isChecked(),true);
|
||||
pcAction->setBlockedChecked(qtAction->isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3301,7 +3301,7 @@ bool StdCmdSelForward::isActive()
|
||||
DEF_STD_CMD_AC(StdTree##_name) \
|
||||
void StdTree##_name::activated(int){ \
|
||||
TreeParams::setDocumentMode(_v);\
|
||||
if(_pcAction) _pcAction->setChecked(true,true);\
|
||||
if(_pcAction) _pcAction->setBlockedChecked(true);\
|
||||
}\
|
||||
Action * StdTree##_name::createAction(void) {\
|
||||
Action *pcAction = Command::createAction();\
|
||||
@@ -3314,7 +3314,7 @@ Action * StdTree##_name::createAction(void) {\
|
||||
bool StdTree##_name::isActive() {\
|
||||
bool checked = TreeParams::getDocumentMode()==_v;\
|
||||
if(_pcAction && _pcAction->isChecked()!=checked)\
|
||||
_pcAction->setChecked(checked,true);\
|
||||
_pcAction->setBlockedChecked(checked);\
|
||||
return true;\
|
||||
}
|
||||
|
||||
@@ -3374,9 +3374,9 @@ DEF_STD_CMD_AC(StdTree##_name) \
|
||||
void StdTree##_name::activated(int){ \
|
||||
auto checked = !TreeParams::get##_name();\
|
||||
TreeParams::set##_name(checked);\
|
||||
if(_pcAction) _pcAction->setChecked(checked,true);\
|
||||
if(_pcAction) _pcAction->setBlockedChecked(checked);\
|
||||
}\
|
||||
Action * StdTree##_name::createAction(void) {\
|
||||
Action * StdTree##_name::createAction() {\
|
||||
Action *pcAction = Command::createAction();\
|
||||
pcAction->setCheckable(true);\
|
||||
pcAction->setIcon(QIcon());\
|
||||
@@ -3387,7 +3387,7 @@ Action * StdTree##_name::createAction(void) {\
|
||||
bool StdTree##_name::isActive() {\
|
||||
bool checked = TreeParams::get##_name();\
|
||||
if(_pcAction && _pcAction->isChecked()!=checked)\
|
||||
_pcAction->setChecked(checked,true);\
|
||||
_pcAction->setBlockedChecked(checked);\
|
||||
return true;\
|
||||
}
|
||||
|
||||
@@ -3576,7 +3576,7 @@ void StdCmdSelBoundingBox::activated(int iMsg)
|
||||
if(checked != ViewParams::instance()->getShowSelectionBoundingBox()) {
|
||||
ViewParams::instance()->setShowSelectionBoundingBox(checked);
|
||||
if(_pcAction)
|
||||
_pcAction->setChecked(checked,true);
|
||||
_pcAction->setBlockedChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3585,7 +3585,7 @@ bool StdCmdSelBoundingBox::isActive()
|
||||
if(_pcAction) {
|
||||
bool checked = _pcAction->isChecked();
|
||||
if(checked != ViewParams::instance()->getShowSelectionBoundingBox())
|
||||
_pcAction->setChecked(!checked,true);
|
||||
_pcAction->setBlockedChecked(!checked);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -3819,10 +3819,10 @@ void StdCmdDockOverlayMouseTransparent::activated(int iMsg)
|
||||
bool checked = !OverlayManager::instance()->isMouseTransparent();
|
||||
OverlayManager::instance()->setMouseTransparent(checked);
|
||||
if(_pcAction)
|
||||
_pcAction->setChecked(checked,true);
|
||||
_pcAction->setBlockedChecked(checked);
|
||||
}
|
||||
|
||||
Action * StdCmdDockOverlayMouseTransparent::createAction(void) {
|
||||
Action * StdCmdDockOverlayMouseTransparent::createAction() {
|
||||
Action *pcAction = Command::createAction();
|
||||
pcAction->setCheckable(true);
|
||||
pcAction->setIcon(QIcon());
|
||||
@@ -3834,7 +3834,7 @@ Action * StdCmdDockOverlayMouseTransparent::createAction(void) {
|
||||
bool StdCmdDockOverlayMouseTransparent::isActive() {
|
||||
bool checked = OverlayManager::instance()->isMouseTransparent();
|
||||
if(_pcAction && _pcAction->isChecked()!=checked)
|
||||
_pcAction->setChecked(checked,true);
|
||||
_pcAction->setBlockedChecked(checked);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ Action* StdCmdToggleToolBarLock::createAction()
|
||||
Action* action = Command::createAction();
|
||||
|
||||
action->setCheckable(true);
|
||||
action->setChecked(ToolBarManager::getInstance()->areToolBarsLocked(), true);
|
||||
action->setBlockedChecked(ToolBarManager::getInstance()->areToolBarsLocked());
|
||||
|
||||
return action;
|
||||
}
|
||||
@@ -420,7 +420,7 @@ Action * StdCmdStatusBar::createAction()
|
||||
{
|
||||
Action *pcAction = Command::createAction();
|
||||
pcAction->setCheckable(true);
|
||||
pcAction->setChecked(false, true);
|
||||
pcAction->setBlockedChecked(false);
|
||||
auto fsb = new FilterStatusBar(pcAction);
|
||||
getMainWindow()->statusBar()->installEventFilter(fsb);
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ void CmdTechDrawToggleFrame::activated(int iMsg)
|
||||
|
||||
Gui::Action *action = this->getAction();
|
||||
if (action) {
|
||||
action->setChecked(!vpPage->getFrameState(), true);
|
||||
action->setBlockedChecked(!vpPage->getFrameState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ bool CmdTechDrawToggleFrame::isActive()
|
||||
|
||||
Gui::Action* action = this->getAction();
|
||||
if (action) {
|
||||
action->setChecked(vpp && !vpp->getFrameState(), true);
|
||||
action->setBlockedChecked(vpp && !vpp->getFrameState());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user