ShortcutManager.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. #include "ui/ShortcutManager.h"
  2. #include "core/SearchQuery.h"
  3. #include "engine/PluginHost.h"
  4. #include "ui/I18n.h"
  5. #include "ui/Theme.h"
  6. #include "ui/ToolWindow.h"
  7. namespace lynx
  8. {
  9. juce::File keyMapFile()
  10. {
  11. return PluginHost::settingsFolder().getChildFile ("keys.json");
  12. }
  13. keys::Chord chordFromKeyPress (const juce::KeyPress& key)
  14. {
  15. keys::Chord c;
  16. const auto code = key.getKeyCode();
  17. const auto mods = key.getModifiers();
  18. c.mods = (std::uint8_t) ((mods.isCommandDown() ? keys::ctrl : 0) | (mods.isShiftDown() ? keys::shift : 0) | (mods.isAltDown() ? keys::alt : 0));
  19. struct Pair
  20. {
  21. int juceCode, key;
  22. };
  23. const Pair specials[] = {
  24. { juce::KeyPress::spaceKey, keys::space }, { juce::KeyPress::returnKey, keys::enter }, { juce::KeyPress::escapeKey, keys::escape },
  25. { juce::KeyPress::tabKey, keys::tab }, { juce::KeyPress::backspaceKey, keys::backspace }, { juce::KeyPress::deleteKey, keys::del },
  26. { juce::KeyPress::insertKey, keys::insert }, { juce::KeyPress::upKey, keys::up }, { juce::KeyPress::downKey, keys::down },
  27. { juce::KeyPress::leftKey, keys::left }, { juce::KeyPress::rightKey, keys::right }, { juce::KeyPress::pageUpKey, keys::pageUp },
  28. { juce::KeyPress::pageDownKey, keys::pageDown }, { juce::KeyPress::homeKey, keys::home }, { juce::KeyPress::endKey, keys::end },
  29. { juce::KeyPress::numberPadAdd, keys::numpadPlus }, { juce::KeyPress::numberPadSubtract, keys::numpadMinus },
  30. { juce::KeyPress::numberPadMultiply, keys::numpadMultiply }, { juce::KeyPress::numberPadDivide, keys::numpadDivide },
  31. { juce::KeyPress::F1Key, keys::f1 }, { juce::KeyPress::F2Key, keys::f2 }, { juce::KeyPress::F3Key, keys::f3 },
  32. { juce::KeyPress::F4Key, keys::f4 }, { juce::KeyPress::F5Key, keys::f5 }, { juce::KeyPress::F6Key, keys::f6 },
  33. { juce::KeyPress::F7Key, keys::f7 }, { juce::KeyPress::F8Key, keys::f8 }, { juce::KeyPress::F9Key, keys::f9 },
  34. { juce::KeyPress::F10Key, keys::f10 }, { juce::KeyPress::F11Key, keys::f11 }, { juce::KeyPress::F12Key, keys::f12 },
  35. };
  36. for (const auto& p : specials)
  37. if (code == p.juceCode)
  38. {
  39. c.key = p.key;
  40. return c;
  41. }
  42. if (const auto letter = keys::letterOfKeyCode (code))
  43. c.key = letter;
  44. return c;
  45. }
  46. namespace
  47. {
  48. juce::String contextName (keys::Context c)
  49. {
  50. switch (c)
  51. {
  52. case keys::Context::global: return tr ("Everywhere");
  53. case keys::Context::channelRack: return tr ("Channel Rack");
  54. case keys::Context::pianoRoll: return tr ("Piano Roll");
  55. case keys::Context::playlist: return tr ("Playlist");
  56. case keys::Context::mixer: return tr ("Mixer");
  57. case keys::Context::browser: return tr ("Browser");
  58. }
  59. return {};
  60. }
  61. juce::String chordText (const keys::Chord& c) { return juce::String (keys::displayString (c)); }
  62. // key caps: "Ctrl+Shift+F4" drawn as one rounded pill per chord; returns the width used
  63. int drawChord (juce::Graphics& g, const keys::Chord& chord, int x, int centreY, bool strong)
  64. {
  65. const auto text = chordText (chord);
  66. const juce::Font font (theme::font (theme::type::small, true));
  67. const auto w = juce::GlyphArrangement::getStringWidthInt (font, text) + 14;
  68. const juce::Rectangle<float> r ((float) x, (float) centreY - 10.0f, (float) w, 20.0f);
  69. g.setColour (strong ? theme::colour::bg5 : theme::colour::bg4);
  70. g.fillRoundedRectangle (r, theme::radius::md);
  71. g.setColour (theme::colour::borderStrong);
  72. g.drawRoundedRectangle (r.reduced (0.5f), theme::radius::md, 1.0f);
  73. g.setFont (font);
  74. g.setColour (theme::colour::textPrimary);
  75. g.drawText (text, r, juce::Justification::centred);
  76. return w;
  77. }
  78. // Waits for a key chord (Esc cancels).
  79. class KeyCatcher final : public juce::Component
  80. {
  81. public:
  82. std::function<void (keys::Chord)> onChord;
  83. std::function<void()> onCancel;
  84. KeyCatcher() { setWantsKeyboardFocus (true); }
  85. void paint (juce::Graphics& g) override
  86. {
  87. const auto r = getLocalBounds().toFloat().reduced (0.5f);
  88. g.setColour (theme::colour::bg0);
  89. g.fillRoundedRectangle (r, theme::radius::md);
  90. g.setColour (theme::colour::accent);
  91. g.drawRoundedRectangle (r, theme::radius::md, 1.5f);
  92. g.setFont (theme::font (theme::type::body));
  93. g.setColour (theme::colour::textPrimary);
  94. g.drawText (tr ("Press the new keys now (Esc cancels)"), getLocalBounds().reduced (10, 0), juce::Justification::centredLeft);
  95. }
  96. bool keyPressed (const juce::KeyPress& key) override
  97. {
  98. const auto chord = chordFromKeyPress (key);
  99. if (chord.key == keys::escape && chord.mods == keys::none)
  100. {
  101. if (onCancel)
  102. onCancel();
  103. return true;
  104. }
  105. if (chord.isValid() && onChord)
  106. onChord (chord);
  107. return true;
  108. }
  109. void focusLost (FocusChangeType) override
  110. {
  111. if (onCancel)
  112. juce::MessageManager::callAsync ([safe = juce::Component::SafePointer<KeyCatcher> (this)] {
  113. if (safe != nullptr && safe->isVisible() && ! safe->hasKeyboardFocus (true) && safe->onCancel)
  114. safe->onCancel();
  115. });
  116. }
  117. };
  118. class ShortcutPanel final : public juce::Component,
  119. private juce::ListBoxModel
  120. {
  121. public:
  122. ShortcutPanel (bool keep, std::function<void()> changed) : persistent (keep), onChanged (std::move (changed))
  123. {
  124. if (persistent && keyMapFile().existsAsFile())
  125. map.loadJson (keyMapFile().loadFileAsString().toStdString());
  126. else if (! persistent)
  127. map.setChords ("pattern.next", { { keys::f9, keys::ctrl | keys::shift } }); // a changed one for the snapshot
  128. search.setTextToShowWhenEmpty (tr ("Search an action or a key (e.g. \"Ctrl+L\")"), theme::colour::textDisabled);
  129. search.setFont (theme::font (theme::type::body));
  130. search.setIndents (8, 6);
  131. search.onTextChange = [this] { refilter(); };
  132. addAndMakeVisible (search);
  133. where.addItem (tr ("All places"), 1);
  134. for (int c = 0; c <= (int) keys::Context::browser; ++c)
  135. where.addItem (contextName ((keys::Context) c), c + 2);
  136. where.setSelectedId (1, juce::dontSendNotification);
  137. where.onChange = [this] { refilter(); };
  138. where.setColour (juce::ComboBox::outlineColourId, theme::colour::borderStrong);
  139. addAndMakeVisible (where);
  140. changedOnly.setButtonText (tr ("Changed only"));
  141. changedOnly.onClick = [this] { refilter(); };
  142. addAndMakeVisible (changedOnly);
  143. count.setFont (theme::font (theme::type::small));
  144. count.setColour (juce::Label::textColourId, theme::colour::textSecondary);
  145. count.setJustificationType (juce::Justification::centredRight);
  146. addAndMakeVisible (count);
  147. list.setModel (this);
  148. list.setRowHeight (30);
  149. list.setColour (juce::ListBox::backgroundColourId, theme::colour::bg0);
  150. list.setColour (juce::ListBox::outlineColourId, theme::colour::border);
  151. list.setOutlineThickness (1);
  152. addAndMakeVisible (list);
  153. actionTitle.setFont (theme::font (theme::type::title, true));
  154. actionTitle.setColour (juce::Label::textColourId, theme::colour::textPrimary);
  155. addAndMakeVisible (actionTitle);
  156. actionWhere.setFont (theme::font (theme::type::small));
  157. actionWhere.setColour (juce::Label::textColourId, theme::colour::textSecondary);
  158. addAndMakeVisible (actionWhere);
  159. message.setFont (theme::font (theme::type::small));
  160. message.setColour (juce::Label::textColourId, theme::colour::warning);
  161. addAndMakeVisible (message);
  162. addKey.onClick = [this] { startCatching (false); };
  163. replaceKey.onClick = [this] { startCatching (true); };
  164. clearKeys.onClick = [this] { setChords ({}); };
  165. resetOne.onClick = [this] {
  166. if (const auto* a = selectedAction())
  167. setChords (a->defaults);
  168. };
  169. resetAll.onClick = [this] { confirmResetAll(); };
  170. openFile.onClick = [this] {
  171. save();
  172. if (persistent)
  173. keyMapFile().startAsProcess();
  174. };
  175. assign.onClick = [this] { assignPending (true); };
  176. cancel.onClick = [this] { stopCatching(); };
  177. for (auto* b : { &addKey, &replaceKey, &clearKeys, &resetOne, &resetAll, &openFile, &assign, &cancel })
  178. addAndMakeVisible (b);
  179. addKey.setColour (juce::TextButton::buttonColourId, theme::colour::accent);
  180. addKey.setColour (juce::TextButton::textColourOffId, theme::colour::onAccent);
  181. assign.setColour (juce::TextButton::buttonColourId, theme::colour::accent);
  182. assign.setColour (juce::TextButton::textColourOffId, theme::colour::onAccent);
  183. catcher.onChord = [this] (keys::Chord c) { caught (c); };
  184. catcher.onCancel = [this] { stopCatching(); };
  185. addChildComponent (catcher);
  186. refilter();
  187. if (! persistent)
  188. {
  189. // snapshot: one action selected, its clash shown
  190. for (int i = 0; i < (int) visible.size(); ++i)
  191. if (std::string (keys::actions()[(std::size_t) visible[(std::size_t) i]].id) == "pattern.next")
  192. list.selectRow (i);
  193. }
  194. updateEditor();
  195. setSize (860, 620);
  196. }
  197. void paint (juce::Graphics& g) override
  198. {
  199. g.fillAll (theme::colour::bg2);
  200. g.setColour (theme::colour::bg3);
  201. g.fillRect (editorArea);
  202. g.setColour (theme::colour::border);
  203. g.fillRect (editorArea.getX(), editorArea.getY(), editorArea.getWidth(), 1);
  204. if (const auto* a = selectedAction())
  205. {
  206. // the current keys
  207. auto x = chordsArea.getX();
  208. const auto& chords = map.chordsFor (a->id);
  209. if (chords.empty())
  210. {
  211. g.setFont (theme::font (theme::type::body));
  212. g.setColour (theme::colour::textDisabled);
  213. g.drawText (tr ("(no shortcut)"), chordsArea, juce::Justification::centredLeft);
  214. }
  215. for (const auto& c : chords)
  216. x += drawChord (g, c, x, chordsArea.getCentreY(), true) + 8;
  217. }
  218. }
  219. void resized() override
  220. {
  221. auto area = getLocalBounds();
  222. editorArea = area.removeFromBottom (150);
  223. area.reduce (14, 12);
  224. auto top = area.removeFromTop (30);
  225. search.setBounds (top.removeFromLeft (juce::jmin (340, top.getWidth() / 2)));
  226. top.removeFromLeft (8);
  227. where.setBounds (top.removeFromLeft (150));
  228. top.removeFromLeft (12);
  229. changedOnly.setBounds (top.removeFromLeft (130));
  230. count.setBounds (top);
  231. area.removeFromTop (10);
  232. list.setBounds (area);
  233. auto e = editorArea.reduced (14, 12);
  234. auto titleRow = e.removeFromTop (24);
  235. resetAll.setBounds (titleRow.removeFromRight (110));
  236. titleRow.removeFromRight (8);
  237. openFile.setBounds (titleRow.removeFromRight (120));
  238. actionTitle.setBounds (titleRow);
  239. actionWhere.setBounds (e.removeFromTop (18));
  240. e.removeFromTop (6);
  241. chordsArea = e.removeFromTop (30);
  242. catcher.setBounds (chordsArea.withWidth (juce::jmin (380, chordsArea.getWidth())));
  243. e.removeFromTop (6);
  244. auto buttons = e.removeFromTop (28);
  245. for (auto* b : { &addKey, &replaceKey, &clearKeys, &resetOne })
  246. {
  247. b->setBounds (buttons.removeFromLeft (b == &resetOne ? 140 : 120));
  248. buttons.removeFromLeft (8);
  249. }
  250. e.removeFromTop (6);
  251. auto msg = e.removeFromTop (24);
  252. cancel.setBounds (msg.removeFromRight (90));
  253. msg.removeFromRight (8);
  254. assign.setBounds (msg.removeFromRight (130));
  255. msg.removeFromRight (8);
  256. message.setBounds (msg);
  257. }
  258. private:
  259. // --- list --------------------------------------------------------------------------------------------------
  260. void refilter()
  261. {
  262. const auto& all = keys::actions();
  263. const auto previous = selectedAction();
  264. const auto query = search::parse (search.getText().toStdString());
  265. const auto context = where.getSelectedId() - 2;
  266. visible.clear();
  267. for (int i = 0; i < (int) all.size(); ++i)
  268. {
  269. const auto& a = all[(std::size_t) i];
  270. if (context >= 0 && (int) a.context != context)
  271. continue;
  272. if (changedOnly.getToggleState() && map.isDefault (a.id))
  273. continue;
  274. juce::String text = tr (a.description) + " " + a.description + " " + a.id + " " + contextName (a.context);
  275. for (const auto& c : map.chordsFor (a.id))
  276. text << " " << chordText (c);
  277. if (search::matches (query, text.toStdString()))
  278. visible.push_back (i);
  279. }
  280. list.updateContent();
  281. list.deselectAllRows();
  282. if (previous != nullptr)
  283. for (int i = 0; i < (int) visible.size(); ++i)
  284. if (&all[(std::size_t) visible[(std::size_t) i]] == previous)
  285. list.selectRow (i);
  286. list.repaint();
  287. count.setText (tr ("{0} actions", { juce::String ((int) visible.size()) }), juce::dontSendNotification);
  288. updateEditor();
  289. }
  290. int getNumRows() override { return (int) visible.size(); }
  291. void paintListBoxItem (int row, juce::Graphics& g, int width, int height, bool selected) override
  292. {
  293. if (! juce::isPositiveAndBelow (row, (int) visible.size()))
  294. return;
  295. const auto& a = keys::actions()[(std::size_t) visible[(std::size_t) row]];
  296. if (selected)
  297. g.fillAll (theme::colour::accentMuted);
  298. else if (row % 2 == 1)
  299. g.fillAll (theme::colour::bg1.withAlpha (0.5f));
  300. const auto changed = ! map.isDefault (a.id);
  301. if (changed)
  302. {
  303. g.setColour (theme::colour::accent);
  304. g.fillEllipse (6.0f, height * 0.5f - 3.0f, 6.0f, 6.0f);
  305. }
  306. const auto keysWidth = juce::jmin (260, width / 3);
  307. const auto whereWidth = 120;
  308. g.setFont (theme::font (theme::type::body));
  309. g.setColour (theme::colour::textPrimary);
  310. g.drawText (tr (a.description), 18, 0, width - keysWidth - whereWidth - 30, height, juce::Justification::centredLeft, true);
  311. g.setFont (theme::font (theme::type::small));
  312. g.setColour (theme::colour::textSecondary);
  313. g.drawText (contextName (a.context), width - keysWidth - whereWidth - 8, 0, whereWidth, height, juce::Justification::centredLeft, true);
  314. auto x = width - keysWidth;
  315. const auto& chords = map.chordsFor (a.id);
  316. if (chords.empty())
  317. {
  318. g.setColour (theme::colour::textDisabled);
  319. g.drawText (juce::String::fromUTF8 ("\xe2\x80\x94"), x, 0, 40, height, juce::Justification::centredLeft);
  320. }
  321. for (const auto& c : chords)
  322. {
  323. if (x > width - 40)
  324. break;
  325. x += drawChord (g, c, x, height / 2, false) + 6;
  326. }
  327. }
  328. void selectedRowsChanged (int) override
  329. {
  330. stopCatching();
  331. updateEditor();
  332. }
  333. void listBoxItemDoubleClicked (int, const juce::MouseEvent&) override { startCatching (true); }
  334. const keys::Action* selectedAction() const
  335. {
  336. const auto row = list.getSelectedRow();
  337. return juce::isPositiveAndBelow (row, (int) visible.size()) ? &keys::actions()[(std::size_t) visible[(std::size_t) row]] : nullptr;
  338. }
  339. // --- editing -----------------------------------------------------------------------------------------------
  340. void updateEditor()
  341. {
  342. const auto* a = selectedAction();
  343. actionTitle.setText (a != nullptr ? tr (a->description) : tr ("Select an action to change its shortcut"), juce::dontSendNotification);
  344. actionWhere.setText (a != nullptr ? tr ("Works: {0}", { contextName (a->context) })
  345. + (a->context == keys::Context::global ? juce::String()
  346. : " · " + tr ("wins over a shortcut of the same keys that works everywhere"))
  347. : juce::String(),
  348. juce::dontSendNotification);
  349. const auto has = a != nullptr && ! map.chordsFor (a->id).empty();
  350. addKey.setEnabled (a != nullptr);
  351. replaceKey.setEnabled (has);
  352. clearKeys.setEnabled (has);
  353. resetOne.setEnabled (a != nullptr && ! map.isDefault (a->id));
  354. if (! pending.isValid())
  355. {
  356. assign.setVisible (false);
  357. cancel.setVisible (catcher.isVisible());
  358. if (! catcher.isVisible())
  359. message.setText ({}, juce::dontSendNotification);
  360. }
  361. repaint();
  362. }
  363. void startCatching (bool replace)
  364. {
  365. if (selectedAction() == nullptr)
  366. return;
  367. replacing = replace;
  368. pending = {};
  369. catcher.setVisible (true);
  370. catcher.grabKeyboardFocus();
  371. message.setText ({}, juce::dontSendNotification);
  372. updateEditor();
  373. }
  374. void stopCatching()
  375. {
  376. catcher.setVisible (false);
  377. pending = {};
  378. assign.setVisible (false);
  379. cancel.setVisible (false);
  380. message.setText ({}, juce::dontSendNotification);
  381. repaint();
  382. }
  383. void caught (keys::Chord chord)
  384. {
  385. const auto* a = selectedAction();
  386. if (a == nullptr)
  387. return;
  388. catcher.setVisible (false);
  389. pending = chord;
  390. const auto others = map.actionsWith (chord, a->context, a->id);
  391. if (others.empty())
  392. {
  393. assignPending (false);
  394. explainShadowed (chord, a->id);
  395. return;
  396. }
  397. juce::StringArray names;
  398. for (const auto& id : others)
  399. if (const auto* o = keys::findAction (id))
  400. names.add ("\"" + tr (o->description) + "\"");
  401. message.setText (tr ("{0} is used by {1} in the same place. Assign moves it here.", { chordText (chord), names.joinIntoString (", ") }),
  402. juce::dontSendNotification);
  403. assign.setVisible (true);
  404. cancel.setVisible (true);
  405. }
  406. // the same key on an action of another place (a panel's tool vs a global action): say which one runs there
  407. void explainShadowed (const keys::Chord& chord, const std::string& id)
  408. {
  409. juce::StringArray names;
  410. for (const auto& other : map.shadowedBy (chord, id))
  411. if (const auto* o = keys::findAction (other))
  412. {
  413. // the key the user just chose wins over a default key of the other action; two keys of his own: the panel's
  414. const auto otherIsDefault = std::find (o->defaults.begin(), o->defaults.end(), chord) != o->defaults.end();
  415. if (otherIsDefault)
  416. names.add ("\"" + tr (o->description) + "\" (" + contextName (o->context) + ")");
  417. }
  418. if (! names.isEmpty())
  419. message.setText (tr ("{0} was also {1}: your key wins there now.", { chordText (chord), names.joinIntoString (", ") }),
  420. juce::dontSendNotification);
  421. }
  422. void assignPending (bool takeFromOthers)
  423. {
  424. const auto* a = selectedAction();
  425. if (a == nullptr || ! pending.isValid())
  426. return;
  427. if (takeFromOthers)
  428. for (const auto& id : map.actionsWith (pending, a->context, a->id))
  429. {
  430. auto chords = map.chordsFor (id);
  431. chords.erase (std::remove (chords.begin(), chords.end(), pending), chords.end());
  432. map.setChords (id, chords);
  433. }
  434. auto chords = replacing ? std::vector<keys::Chord> {} : map.chordsFor (a->id);
  435. if (std::find (chords.begin(), chords.end(), pending) == chords.end())
  436. chords.push_back (pending);
  437. pending = {};
  438. setChords (chords);
  439. }
  440. void setChords (std::vector<keys::Chord> chords)
  441. {
  442. const auto* a = selectedAction();
  443. if (a == nullptr)
  444. return;
  445. map.setChords (a->id, std::move (chords));
  446. stopCatching();
  447. save();
  448. list.repaint();
  449. updateEditor();
  450. }
  451. void confirmResetAll()
  452. {
  453. juce::AlertWindow::showOkCancelBox (juce::MessageBoxIconType::QuestionIcon, tr ("Reset all shortcuts"),
  454. tr ("Every shortcut goes back to LYNX SHARE's default keys."), tr ("Reset all"), tr ("Cancel"), this,
  455. juce::ModalCallbackFunction::create ([safe = juce::Component::SafePointer<ShortcutPanel> (this)] (int result) {
  456. if (safe == nullptr || result != 1)
  457. return;
  458. safe->map.resetToDefaults();
  459. safe->save();
  460. safe->refilter();
  461. }));
  462. }
  463. void save()
  464. {
  465. if (! persistent)
  466. return;
  467. keyMapFile().replaceWithText (juce::String (map.overridesJson()));
  468. if (onChanged)
  469. onChanged();
  470. }
  471. bool persistent;
  472. std::function<void()> onChanged;
  473. keys::KeyMap map;
  474. std::vector<int> visible;
  475. keys::Chord pending;
  476. bool replacing = false;
  477. juce::TextEditor search;
  478. juce::ComboBox where;
  479. juce::ToggleButton changedOnly;
  480. juce::Label count, actionTitle, actionWhere, message;
  481. juce::ListBox list;
  482. juce::Rectangle<int> editorArea, chordsArea;
  483. KeyCatcher catcher;
  484. juce::TextButton addKey { tr ("Add shortcut") }, replaceKey { tr ("Change") }, clearKeys { tr ("Remove") }, resetOne { tr ("Reset to default") },
  485. resetAll { tr ("Reset all...") }, openFile { tr ("Open keys.json") }, assign { tr ("Assign anyway") }, cancel { tr ("Cancel") };
  486. };
  487. } // namespace
  488. void showShortcutManager (std::function<void()> onChanged)
  489. {
  490. openToolWindow (std::make_unique<ShortcutPanel> (true, std::move (onChanged)), tr ("Manage shortcuts"), "shortcuts");
  491. }
  492. std::unique_ptr<juce::Component> makeShortcutManagerPanel (bool persistent, std::function<void()> onChanged)
  493. {
  494. return std::make_unique<ShortcutPanel> (persistent, std::move (onChanged));
  495. }
  496. } // namespace lynx