Skip to content

Commit 97c163c

Browse files
authored
Merge pull request #26288 from grliszas14/change_icon_color
Added ability to change context menu icon color
2 parents e3eda67 + b7c9de4 commit 97c163c

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

src/framework/ui/uiaction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct UiAction
5454
MnemonicString title;
5555
TranslatableString description;
5656
IconCode::Code iconCode = IconCode::Code::NONE;
57+
QString iconColor;
5758
Checkable checkable = Checkable::No;
5859
std::vector<std::string> shortcuts;
5960

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

77+
UiAction(const actions::ActionCode& code, UiContext ctx, std::string scCtx, const MnemonicString& title,
78+
const TranslatableString& desc, IconCode::Code icon, QString iconColor, Checkable ch = Checkable::No)
79+
: code(code), uiCtx(ctx), scCtx(scCtx), title(title), description(desc), iconCode(icon), iconColor(iconColor), checkable(ch) {}
80+
7681
UiAction(const actions::ActionCode& code, UiContext ctx, std::string scCtx, const MnemonicString& title, IconCode::Code icon,
7782
Checkable ch = Checkable::No)
7883
: code(code), uiCtx(ctx), scCtx(scCtx), title(title), iconCode(icon), checkable(ch) {}
@@ -90,6 +95,7 @@ struct UiAction
9095
&& title == other.title
9196
&& description == other.description
9297
&& iconCode == other.iconCode
98+
&& iconColor == other.iconColor
9399
&& checkable == other.checkable
94100
&& shortcuts == other.shortcuts;
95101
}

src/framework/uicomponents/qml/Muse/UiComponents/internal/StyledMenuItem.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ ListItemBlank {
202202
id: secondaryIconLabel
203203
Layout.alignment: Qt.AlignLeft
204204
Layout.preferredWidth: 16
205+
color: root.modelData.iconColor ? root.modelData.iconColor : ui.theme.fontPrimaryColor
205206
iconCode: root.modelData?.icon ?? IconCode.NONE
206207
visible: root.iconAndCheckMarkMode === StyledMenuItem.ShowBoth
207208
}

src/framework/uicomponents/view/menuitem.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ int MenuItem::icon_property() const
221221
return static_cast<int>(m_action.iconCode);
222222
}
223223

224+
QString MenuItem::iconColor_property() const
225+
{
226+
return m_action.iconColor;
227+
}
228+
224229
bool MenuItem::enabled_property() const
225230
{
226231
return m_state.enabled;

src/framework/uicomponents/view/menuitem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class MenuItem : public QObject, public async::Asyncable
5757
Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
5858

5959
Q_PROPERTY(int icon READ icon_property NOTIFY actionChanged)
60+
Q_PROPERTY(QString iconColor READ iconColor_property NOTIFY actionChanged)
6061

6162
Q_PROPERTY(bool enabled READ enabled_property NOTIFY stateChanged)
6263

@@ -124,6 +125,7 @@ public slots:
124125
QString description_property() const;
125126

126127
int icon_property() const;
128+
QString iconColor_property() const;
127129

128130
bool enabled_property() const;
129131

0 commit comments

Comments
 (0)