diff --git a/shell/mainwindow.h b/shell/mainwindow.h --- a/shell/mainwindow.h +++ b/shell/mainwindow.h @@ -89,7 +89,7 @@ void dropEvent( QDropEvent* ) override; void applyMainWindowSettings(const KConfigGroup& config) override; void createGUI(KParts::Part* part); - + void updateActionTooltips(); protected Q_SLOTS: void tabContextMenuRequested(Sublime::View* , QMenu* ) override; void tabToolTipRequested(Sublime::View* view, Sublime::Container* container, int tab) override; diff --git a/shell/mainwindow.cpp b/shell/mainwindow.cpp --- a/shell/mainwindow.cpp +++ b/shell/mainwindow.cpp @@ -276,9 +276,6 @@ void MainWindow::shortcutsChanged() { KTextEditor::View *activeClient = Core::self()->documentController()->activeTextDocumentView(); - if(!activeClient) - return; - foreach(IDocument * doc, Core::self()->documentController()->openDocuments()) { KTextEditor::Document *textDocument = doc->textDocument(); if (textDocument) { @@ -289,6 +286,7 @@ } } } + updateActionTooltips(); } @@ -343,9 +341,28 @@ void MainWindow::setVisible( bool visible ) { KXmlGuiWindow::setVisible( visible ); + updateActionTooltips(); emit finishedLoading(); } +void KDevelop::MainWindow::updateActionTooltips() +{ + qCDebug(SHELL) << "Applying the shortcut on the accelerator tooltip"; + foreach(QAction *action, actionCollection()->actions()) { + //First, try to remove the old shortcut from the current string. + QString tooltip = action->toolTip(); + if (tooltip.indexOf("(") != -1) { + tooltip = tooltip.split("(").at(0).trimmed(); + } + + if (!action->shortcut().isEmpty()) { + action->setToolTip(tooltip + " (" + action->shortcut().toString() + ")"); + } else if (!actionCollection()->defaultShortcut(action).isEmpty()) { + action->setToolTip(tooltip + " (" + actionCollection()->defaultShortcut(action).toString() + ")"); + } + } +} + bool MainWindow::queryClose() { if (!Core::self()->documentControllerInternal()->saveAllDocumentsForWindow(this, IDocument::Default))