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 @@ -316,9 +316,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) { @@ -329,6 +326,7 @@ } } } + updateActionTooltips(); } @@ -383,9 +381,29 @@ void MainWindow::setVisible( bool visible ) { KXmlGuiWindow::setVisible( visible ); + updateActionTooltips(); emit finishedLoading(); } +void KDevelop::MainWindow::updateActionTooltips() +{ + QByteArray original_tooltip = "__kdev_original_tooltip"; + foreach(QAction *action, actionCollection()->actions()) { + if (action->dynamicPropertyNames().indexOf(original_tooltip) == -1) { + action->setProperty(original_tooltip, action->toolTip()); + } + + auto shortcut = action->shortcut(); + if (!shortcut.isEmpty()) { + shortcut = actionCollection()->defaultShortcut(action); + } + if (shortcut.isEmpty()) { + continue; + } + action->setToolTip(action->property(original_tooltip).toString() + " (" + shortcut.toString() + ")"); + } +} + bool MainWindow::queryClose() { if (!Core::self()->documentControllerInternal()->saveAllDocumentsForWindow(this, IDocument::Default))