Skip to content

Commit

Permalink
MenuItem API exposes checkable property directly
Browse files Browse the repository at this point in the history
  • Loading branch information
saintmatthieu authored and igorkorsukov committed Feb 18, 2025
1 parent bba1706 commit 15e88d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/framework/uicomponents/view/menuitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ void MenuItem::setSelected(bool selected)
emit selectedChanged(m_selected);
}

void MenuItem::setCheckable(bool checkable)
{
const Checkable actionCeckable = checkable ? Checkable::Yes : Checkable::No;
if (m_action.checkable == actionCeckable) {
return;
}

m_action.checkable = actionCeckable;
}

void MenuItem::setChecked(bool checked)
{
if (m_state.checked == checked) {
return;
}

m_state.checked = checked;
emit stateChanged();
}

void MenuItem::setRole(MenuItemRole role)
{
if (m_role == role) {
Expand Down
2 changes: 2 additions & 0 deletions src/framework/uicomponents/view/menuitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public slots:
void setState(const ui::UiActionState& state);
void setSelectable(bool selectable);
void setSelected(bool selected);
void setCheckable(bool checkable);
void setChecked(bool checked);
void setRole(muse::uicomponents::MenuItemRole role);
void setSubitems(const QList<uicomponents::MenuItem*>& subitems);
void setAction(const ui::UiAction& action);
Expand Down

0 comments on commit 15e88d1

Please sign in to comment.