diff --git a/shell/mainwindow.h b/shell/mainwindow.h --- a/shell/mainwindow.h +++ b/shell/mainwindow.h @@ -90,7 +90,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 @@ -320,8 +320,10 @@ void MainWindow::shortcutsChanged() { + updateActionTooltips(); + KTextEditor::View *activeClient = Core::self()->documentController()->activeTextDocumentView(); - if(!activeClient) + if (!activeClient) return; foreach(IDocument * doc, Core::self()->documentController()->openDocuments()) { @@ -388,9 +390,29 @@ void MainWindow::setVisible( bool visible ) { KXmlGuiWindow::setVisible( visible ); + updateActionTooltips(); emit finishedLoading(); } +void KDevelop::MainWindow::updateActionTooltips() +{ + const auto ORIGINAL_TOOLTIP = QByteArrayLiteral("__kdev_original_tooltip"); + + foreach(QAction *action, actionCollection()->actions()) { + QString tooltip = action->property(ORIGINAL_TOOLTIP).toString(); + if (tooltip.isEmpty()) { + tooltip = action->toolTip(); + action->setProperty(ORIGINAL_TOOLTIP, tooltip); + } + + auto shortcut = action->shortcut(); + if (!shortcut.isEmpty()) { + tooltip = i18nc("%1: original tooltip, %2 shortcut", "%1 (%2)", tooltip, shortcut.toString()); + } + action->setToolTip(tooltip); + } +} + bool MainWindow::queryClose() { if (!Core::self()->documentControllerInternal()->saveAllDocumentsForWindow(this, IDocument::Default))