menu_model_adapter.cc 788 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) 2016 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/browser/ui/views/menu_model_adapter.h"
  5. namespace atom {
  6. MenuModelAdapter::MenuModelAdapter(AtomMenuModel* menu_model)
  7. : views::MenuModelAdapter(menu_model), menu_model_(menu_model) {}
  8. MenuModelAdapter::~MenuModelAdapter() {}
  9. bool MenuModelAdapter::GetAccelerator(int id,
  10. ui::Accelerator* accelerator) const {
  11. ui::MenuModel* model = menu_model_;
  12. int index = 0;
  13. if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) {
  14. return static_cast<AtomMenuModel*>(model)->GetAcceleratorAtWithParams(
  15. index, true, accelerator);
  16. }
  17. return false;
  18. }
  19. } // namespace atom