2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-14 13:12:27 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_ACCELERATOR_UTIL_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_ACCELERATOR_UTIL_H_
|
2013-05-14 13:12:27 +00:00
|
|
|
|
2014-03-15 08:36:29 +00:00
|
|
|
#include <map>
|
2013-07-01 13:56:46 +00:00
|
|
|
#include <string>
|
2013-05-14 13:12:27 +00:00
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/electron_menu_model.h"
|
2014-03-15 08:36:29 +00:00
|
|
|
#include "ui/base/accelerators/accelerator.h"
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
namespace accelerator_util {
|
|
|
|
|
2018-04-18 01:44:10 +00:00
|
|
|
typedef struct {
|
2022-08-17 18:35:53 +00:00
|
|
|
size_t position;
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<electron::ElectronMenuModel> model;
|
2018-04-18 01:44:10 +00:00
|
|
|
} MenuItem;
|
2014-03-15 08:36:29 +00:00
|
|
|
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
// Parse a string as an accelerator.
|
2021-06-01 01:46:25 +00:00
|
|
|
bool StringToAccelerator(const std::string& shortcut,
|
2013-05-14 13:12:27 +00:00
|
|
|
ui::Accelerator* accelerator);
|
|
|
|
|
2021-06-01 01:42:38 +00:00
|
|
|
// Generate a table that contains menu model's accelerators and command ids.
|
2016-07-06 23:04:18 +00:00
|
|
|
void GenerateAcceleratorTable(AcceleratorTable* table,
|
|
|
|
electron::ElectronMenuModel* model);
|
2014-03-15 08:36:29 +00:00
|
|
|
|
|
|
|
// Trigger command from the accelerators table.
|
|
|
|
bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
|
|
|
|
const ui::Accelerator& accelerator);
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
} // namespace accelerator_util
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_ACCELERATOR_UTIL_H_
|