Skip to content

Commit

Permalink
Merge pull request #26288 from grliszas14/change_icon_color
Browse files Browse the repository at this point in the history
Added ability to change context menu icon color
  • Loading branch information
Eism authored Jan 31, 2025
2 parents e3eda67 + b7c9de4 commit 97c163c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/framework/ui/uiaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct UiAction
MnemonicString title;
TranslatableString description;
IconCode::Code iconCode = IconCode::Code::NONE;
QString iconColor;
Checkable checkable = Checkable::No;
std::vector<std::string> shortcuts;

Expand All @@ -73,6 +74,10 @@ struct UiAction
const TranslatableString& desc, IconCode::Code icon, Checkable ch = Checkable::No)
: code(code), uiCtx(ctx), scCtx(scCtx), title(title), description(desc), iconCode(icon), checkable(ch) {}

UiAction(const actions::ActionCode& code, UiContext ctx, std::string scCtx, const MnemonicString& title,
const TranslatableString& desc, IconCode::Code icon, QString iconColor, Checkable ch = Checkable::No)
: code(code), uiCtx(ctx), scCtx(scCtx), title(title), description(desc), iconCode(icon), iconColor(iconColor), checkable(ch) {}

UiAction(const actions::ActionCode& code, UiContext ctx, std::string scCtx, const MnemonicString& title, IconCode::Code icon,
Checkable ch = Checkable::No)
: code(code), uiCtx(ctx), scCtx(scCtx), title(title), iconCode(icon), checkable(ch) {}
Expand All @@ -90,6 +95,7 @@ struct UiAction
&& title == other.title
&& description == other.description
&& iconCode == other.iconCode
&& iconColor == other.iconColor
&& checkable == other.checkable
&& shortcuts == other.shortcuts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ ListItemBlank {
id: secondaryIconLabel
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: 16
color: root.modelData.iconColor ? root.modelData.iconColor : ui.theme.fontPrimaryColor
iconCode: root.modelData?.icon ?? IconCode.NONE
visible: root.iconAndCheckMarkMode === StyledMenuItem.ShowBoth
}
Expand Down
5 changes: 5 additions & 0 deletions src/framework/uicomponents/view/menuitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ int MenuItem::icon_property() const
return static_cast<int>(m_action.iconCode);
}

QString MenuItem::iconColor_property() const
{
return m_action.iconColor;
}

bool MenuItem::enabled_property() const
{
return m_state.enabled;
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 @@ -57,6 +57,7 @@ class MenuItem : public QObject, public async::Asyncable
Q_PROPERTY(QString section READ section NOTIFY sectionChanged)

Q_PROPERTY(int icon READ icon_property NOTIFY actionChanged)
Q_PROPERTY(QString iconColor READ iconColor_property NOTIFY actionChanged)

Q_PROPERTY(bool enabled READ enabled_property NOTIFY stateChanged)

Expand Down Expand Up @@ -124,6 +125,7 @@ public slots:
QString description_property() const;

int icon_property() const;
QString iconColor_property() const;

bool enabled_property() const;

Expand Down

0 comments on commit 97c163c

Please sign in to comment.