From da9afa8cc7c31b47c0ef0ada8e8e881b895e411f Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 7 Mar 2024 13:22:19 +0100 Subject: [PATCH] ModelEditor: Remove multiline text from action text It is supposed to be shown in the tool tip, so set the tool tip instead. Fixes: QTCREATORBUG-29174 Change-Id: Ib2572b71dfccf18276e63fadb7dbe386949b0275 Reviewed-by: Reviewed-by: David Schulz --- src/plugins/modeleditor/actionhandler.cpp | 34 ++++++++++++++++------- src/plugins/modeleditor/actionhandler.h | 12 +++++--- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/plugins/modeleditor/actionhandler.cpp b/src/plugins/modeleditor/actionhandler.cpp index 8dbca707de3..47599413aac 100644 --- a/src/plugins/modeleditor/actionhandler.cpp +++ b/src/plugins/modeleditor/actionhandler.cpp @@ -7,12 +7,13 @@ #include "modeleditor_constants.h" #include "modeleditortr.h" -#include -#include #include +#include +#include #include #include #include +#include #include #include @@ -161,11 +162,17 @@ void ActionHandler::createActions() QKeySequence(), QIcon(":/modelinglib/48x48/class.png")); registerCommand(Constants::ACTION_ADD_CANVAS_DIAGRAM, nullptr, Core::Context(), Tr::tr("Add Canvas Diagram"), QKeySequence(), QIcon(":/modelinglib/48x48/canvas-diagram.png")); - d->synchronizeBrowserAction = registerCommand( - Constants::ACTION_SYNC_BROWSER, nullptr, Core::Context(), - Tr::tr("Synchronize Browser and Diagram") + "
" - + Tr::tr("Press && Hold for Options") + "", QKeySequence(), - Utils::Icons::LINK_TOOLBAR.icon())->action(); + d->synchronizeBrowserAction + = registerCommand( + Constants::ACTION_SYNC_BROWSER, + nullptr, + Core::Context(), + Tr::tr("Synchronize Browser and Diagram"), + QKeySequence(), + Utils::Icons::LINK_TOOLBAR.icon(), + Tr::tr("Synchronize Browser and Diagram") + "
" + + Utils::stripAccelerator(Tr::tr("Press && Hold for Options")) + "") + ->action(); d->synchronizeBrowserAction->setCheckable(true); auto editPropertiesAction = new QAction(Tr::tr("Edit Element Properties"), @@ -205,13 +212,20 @@ std::function invokeOnCurrentModelEditor(void (ModelEditor::*function)() }; } -Core::Command *ActionHandler::registerCommand(const Utils::Id &id, void (ModelEditor::*function)(), - const Core::Context &context, const QString &title, - const QKeySequence &keySequence, const QIcon &icon) +Core::Command *ActionHandler::registerCommand( + const Utils::Id &id, + void (ModelEditor::*function)(), + const Core::Context &context, + const QString &title, + const QKeySequence &keySequence, + const QIcon &icon, + const QString &toolTip) { auto action = new QAction(title, this); if (!icon.isNull()) action->setIcon(icon); + if (!toolTip.isEmpty()) + action->setToolTip(toolTip); Core::Command *command = Core::ActionManager::registerAction(action, id, context, /*scriptable=*/true); if (!keySequence.isEmpty()) command->setDefaultKeySequence(keySequence); diff --git a/src/plugins/modeleditor/actionhandler.h b/src/plugins/modeleditor/actionhandler.h index 6b8d6a4502e..82b7c5321ad 100644 --- a/src/plugins/modeleditor/actionhandler.h +++ b/src/plugins/modeleditor/actionhandler.h @@ -56,10 +56,14 @@ private: void onEditProperties(); void onEditItem(); - Core::Command *registerCommand(const Utils::Id &id, void (ModelEditor::*function)(), - const Core::Context &context, const QString &title = QString(), - const QKeySequence &keySequence = QKeySequence(), - const QIcon &icon = QIcon()); + Core::Command *registerCommand( + const Utils::Id &id, + void (ModelEditor::*function)(), + const Core::Context &context, + const QString &title = QString(), + const QKeySequence &keySequence = QKeySequence(), + const QIcon &icon = QIcon(), + const QString &toolTip = {}); private: ActionHandlerPrivate *d;