Fix showing keyboard shortcuts on AniControls tooltips

This commit is contained in:
David Capello 2019-04-12 13:49:35 -03:00
parent 61d1e7c46c
commit 7f21deb4d5
2 changed files with 21 additions and 8 deletions

View File

@ -95,6 +95,16 @@ MainWindow::MainWindow()
{ {
m_tooltipManager = new TooltipManager(); m_tooltipManager = new TooltipManager();
m_menuBar = new MainMenuBar(); m_menuBar = new MainMenuBar();
// Register commands to load menus+shortcuts for these commands
Editor::registerCommands();
// Load all menus+keys for the first time
AppMenus::instance()->reload();
// Setup the main menubar
m_menuBar->setMenu(AppMenus::instance()->getRootMenu());
m_notifications = new Notifications(); m_notifications = new Notifications();
m_contextBar = new ContextBar(m_tooltipManager); m_contextBar = new ContextBar(m_tooltipManager);
m_statusBar = new StatusBar(m_tooltipManager); m_statusBar = new StatusBar(m_tooltipManager);
@ -104,9 +114,10 @@ MainWindow::MainWindow()
m_tabsBar = new WorkspaceTabs(this); m_tabsBar = new WorkspaceTabs(this);
m_workspace = new Workspace(); m_workspace = new Workspace();
m_previewEditor = new PreviewEditorWindow(); m_previewEditor = new PreviewEditorWindow();
m_timeline = new Timeline(m_tooltipManager);
Editor::registerCommands(); // The timeline (AniControls) tooltips will use the keyboard
// shortcuts loaded above.
m_timeline = new Timeline(m_tooltipManager);
m_workspace->setTabsBar(m_tabsBar); m_workspace->setTabsBar(m_tabsBar);
m_workspace->ActiveViewChanged.connect(&MainWindow::onActiveViewChange, this); m_workspace->ActiveViewChanged.connect(&MainWindow::onActiveViewChange, this);
@ -123,12 +134,6 @@ MainWindow::MainWindow()
m_workspace->setExpansive(true); m_workspace->setExpansive(true);
m_notifications->setVisible(false); m_notifications->setVisible(false);
// Load all menus by first time.
AppMenus::instance()->reload();
// Setup the menus
m_menuBar->setMenu(AppMenus::instance()->getRootMenu());
// Add the widgets in the boxes // Add the widgets in the boxes
addChild(m_tooltipManager); addChild(m_tooltipManager);
menuBarPlaceholder()->addChild(m_menuBar); menuBarPlaceholder()->addChild(m_menuBar);

View File

@ -120,10 +120,18 @@ std::string AniControls::getTooltipFor(int index) const
tooltip = cmd->friendlyName(); tooltip = cmd->friendlyName();
KeyPtr key = KeyboardShortcuts::instance()->command(cmd->id().c_str()); KeyPtr key = KeyboardShortcuts::instance()->command(cmd->id().c_str());
if (!key || key->accels().empty())
key = KeyboardShortcuts::instance()->command(cmd->id().c_str(),
Params(),
KeyContext::Normal);
if (key && !key->accels().empty()) { if (key && !key->accels().empty()) {
tooltip += "\n\nShortcut: "; tooltip += "\n\nShortcut: ";
tooltip += key->accels().front().toString(); tooltip += key->accels().front().toString();
} }
if (index == ACTION_PLAY) {
tooltip += "\n\nRight-click: Show playback options";
}
} }
return tooltip; return tooltip;