refactor: implement sublabel fns in MenuModel (#20150)
This commit is contained in:
parent
82ff142f9c
commit
513c8536c0
2 changed files with 16 additions and 2 deletions
|
@ -41,6 +41,17 @@ base::string16 AtomMenuModel::GetRoleAt(int index) {
|
||||||
return iter == std::end(roles_) ? base::string16() : iter->second;
|
return iter == std::end(roles_) ? base::string16() : iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomMenuModel::SetSublabel(int index, const base::string16& sublabel) {
|
||||||
|
int command_id = GetCommandIdAt(index);
|
||||||
|
sublabels_[command_id] = sublabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
base::string16 AtomMenuModel::GetSublabelAt(int index) const {
|
||||||
|
int command_id = GetCommandIdAt(index);
|
||||||
|
const auto iter = sublabels_.find(command_id);
|
||||||
|
return iter == std::end(sublabels_) ? base::string16() : iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
bool AtomMenuModel::GetAcceleratorAtWithParams(
|
bool AtomMenuModel::GetAcceleratorAtWithParams(
|
||||||
int index,
|
int index,
|
||||||
bool use_default_accelerator,
|
bool use_default_accelerator,
|
||||||
|
|
|
@ -57,6 +57,8 @@ class AtomMenuModel : public ui::SimpleMenuModel {
|
||||||
base::string16 GetToolTipAt(int index);
|
base::string16 GetToolTipAt(int index);
|
||||||
void SetRole(int index, const base::string16& role);
|
void SetRole(int index, const base::string16& role);
|
||||||
base::string16 GetRoleAt(int index);
|
base::string16 GetRoleAt(int index);
|
||||||
|
void SetSublabel(int index, const base::string16& sublabel);
|
||||||
|
base::string16 GetSublabelAt(int index) const override;
|
||||||
bool GetAcceleratorAtWithParams(int index,
|
bool GetAcceleratorAtWithParams(int index,
|
||||||
bool use_default_accelerator,
|
bool use_default_accelerator,
|
||||||
ui::Accelerator* accelerator) const;
|
ui::Accelerator* accelerator) const;
|
||||||
|
@ -73,8 +75,9 @@ class AtomMenuModel : public ui::SimpleMenuModel {
|
||||||
private:
|
private:
|
||||||
Delegate* delegate_; // weak ref.
|
Delegate* delegate_; // weak ref.
|
||||||
|
|
||||||
std::map<int, base::string16> toolTips_; // command id -> tooltip
|
std::map<int, base::string16> toolTips_; // command id -> tooltip
|
||||||
std::map<int, base::string16> roles_; // command id -> role
|
std::map<int, base::string16> roles_; // command id -> role
|
||||||
|
std::map<int, base::string16> sublabels_; // command id -> sublabel
|
||||||
base::ObserverList<Observer> observers_;
|
base::ObserverList<Observer> observers_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomMenuModel);
|
DISALLOW_COPY_AND_ASSIGN(AtomMenuModel);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue