electron/patches/chromium/allow_setting_secondary_label_via_simplemenumodel.patch
Electron Bot 2eb3bddb05
chore: bump chromium to 92.0.4505.0 (master) (#29058)
* chore: bump chromium in DEPS to 92.0.4500.2

* resolve conflicts

* update patches

* chore: cherry-pick 82434206f306 from chromium (#29060)

* fix patch

* chore: bump chromium in DEPS to 92.0.4501.0

* chore: bump chromium in DEPS to 92.0.4502.0

* chore: bump chromium in DEPS to 92.0.4503.0

* chore: update patches

* 2869869: [Code Health] Refactor ListValue::Insert in gpu compositor

https://chromium-review.googlesource.com/c/chromium/src/+/2869869

* 2877924: Separate InkDropHost from InkDropHostView

https://chromium-review.googlesource.com/c/chromium/src/+/2877924

* chore: bump chromium in DEPS to 92.0.4504.0

* update patches

* Fixup for Separate InkDropHost from InkDropHostView

https://chromium-review.googlesource.com/c/chromium/src/+/2877924

* 2873469: Compute hashes of .pak files during the build, and check it at runtime.

https://chromium-review.googlesource.com/c/chromium/src/+/2873469

* 2874397: Remove flag to disable microtasks scope consistency checks

https://chromium-review.googlesource.com/c/v8/v8/+/2874397

* 2881471: Remove unneeded trace_event.h includes in headers.

https://chromium-review.googlesource.com/c/chromium/src/+/2881471

* 2844717: [Keyboard Tooltip] Rename RWHV*::SetTooltipText to UpdateTooltipUnderCursor

https://chromium-review.googlesource.com/c/chromium/src/+/2844717

* chore: bump chromium in DEPS to 92.0.4505.0

* chore: update patches

* 2883887: Retire ScopedObserver in /chrome/browser/predictors.

https://chromium-review.googlesource.com/c/chromium/src/+/2883887

* 2883694: Retire ScopedObserver in /chrome/browser.

https://chromium-review.googlesource.com/c/chromium/src/+/2883694

* fixup after merge

* fixup: Remove flag to disable microtasks scope consistency checks

* Temporarily disable setcallhandler-test.js nan test

This test should be renabled once https://github.com/electron/electron/pull/29028 lands

* Use gin_helper::MicrotasksScope instead of v8::MicrotasksScope

* chore: bump chromium in DEPS to 92.0.4506.0

* update patches

* Revert "update patches"

This reverts commit 333ec0d4c205bd3cbee28d2bc3d068871dbb900a.

* Revert "chore: bump chromium in DEPS to 92.0.4506.0"

This reverts commit 2bd52f8cd89b173c8b15a61d74fa7539cdbf574b.

* Fixup: Use gin_helper::MicrotasksScope instead of v8::MicrotasksScope

* Fixup: Use gin_helper::MicrotasksScope instead of v8::MicrotasksScope

Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
2021-05-13 21:21:36 -04:00

86 lines
3.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Thu, 21 May 2020 13:58:01 -0700
Subject: Allow setting secondary label via SimpleMenuModel
Builds on https://chromium-review.googlesource.com/c/chromium/src/+/2208976
diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc
index 976a45c49c810b228e7576926979001593de8dcb..2975dcd4a946edd7100789a1c3d8e3637d2bd86c 100644
--- a/ui/base/models/simple_menu_model.cc
+++ b/ui/base/models/simple_menu_model.cc
@@ -53,6 +53,11 @@ std::u16string SimpleMenuModel::Delegate::GetLabelForCommandId(
return std::u16string();
}
+std::u16string SimpleMenuModel::Delegate::GetSecondaryLabelForCommandId(
+ int command_id) const {
+ return std::u16string();
+}
+
ImageModel SimpleMenuModel::Delegate::GetIconForCommandId(
int command_id) const {
return ImageModel();
@@ -295,6 +300,11 @@ void SimpleMenuModel::SetLabel(int index, const std::u16string& label) {
MenuItemsChanged();
}
+void SimpleMenuModel::SetSecondaryLabel(int index, const std::u16string& secondary_label) {
+ items_[ValidateItemIndex(index)].secondary_label = secondary_label;
+ MenuItemsChanged();
+}
+
void SimpleMenuModel::SetMinorText(int index,
const std::u16string& minor_text) {
items_[ValidateItemIndex(index)].minor_text = minor_text;
@@ -382,6 +392,12 @@ std::u16string SimpleMenuModel::GetLabelAt(int index) const {
return items_[ValidateItemIndex(index)].label;
}
+std::u16string SimpleMenuModel::GetSecondaryLabelAt(int index) const {
+ if (IsItemDynamicAt(index))
+ return delegate_->GetSecondaryLabelForCommandId(GetCommandIdAt(index));
+ return items_[ValidateItemIndex(index)].secondary_label;
+}
+
std::u16string SimpleMenuModel::GetMinorTextAt(int index) const {
return items_[ValidateItemIndex(index)].minor_text;
}
diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h
index 6127fb6a161598a58d08fb68f171fd02b9cbb6a7..5297195cb7128106a376818ade66daf0a5f6b868 100644
--- a/ui/base/models/simple_menu_model.h
+++ b/ui/base/models/simple_menu_model.h
@@ -50,6 +50,7 @@ class COMPONENT_EXPORT(UI_BASE) SimpleMenuModel : public MenuModel {
// Some command ids have labels and icons that change over time.
virtual bool IsItemForCommandIdDynamic(int command_id) const;
virtual std::u16string GetLabelForCommandId(int command_id) const;
+ virtual std::u16string GetSecondaryLabelForCommandId(int command_id) const;
// Gets the icon for the item with the specified id.
virtual ImageModel GetIconForCommandId(int command_id) const;
@@ -153,6 +154,9 @@ class COMPONENT_EXPORT(UI_BASE) SimpleMenuModel : public MenuModel {
// Sets the label for the item at |index|.
void SetLabel(int index, const std::u16string& label);
+ // Sets the secondary_label for the item at |index|.
+ void SetSecondaryLabel(int index, const std::u16string& secondary_label);
+
// Sets the minor text for the item at |index|.
void SetMinorText(int index, const std::u16string& minor_text);
@@ -188,6 +192,7 @@ class COMPONENT_EXPORT(UI_BASE) SimpleMenuModel : public MenuModel {
ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override;
int GetCommandIdAt(int index) const override;
std::u16string GetLabelAt(int index) const override;
+ std::u16string GetSecondaryLabelAt(int index) const override;
std::u16string GetMinorTextAt(int index) const override;
ImageModel GetMinorIconAt(int index) const override;
bool IsItemDynamicAt(int index) const override;
@@ -226,6 +231,7 @@ class COMPONENT_EXPORT(UI_BASE) SimpleMenuModel : public MenuModel {
int command_id = 0;
ItemType type = TYPE_COMMAND;
std::u16string label;
+ std::u16string secondary_label;
std::u16string minor_text;
ImageModel minor_icon;
ImageModel icon;