From 77c6b0c66f3191dd1b15ea052e98e6a16442f8cb Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 5 May 2024 21:09:07 +0200 Subject: QLineEdit: set object names for actions Set object names for actions created by createStandardContextMenu() to be able to access them from the outside. Use the same naming schema as by QWidgetTextControl::createStandardContextMenu() (used by QTextEdit and others). Pick-to: 6.7 6.5 Fixes: QTBUG-112721 Change-Id: Id92f1ba13e7f7e8b1d531678895902374114d167 Reviewed-by: Volker Hilsheimer --- src/widgets/widgets/qlineedit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 8909ac80d9..0db46bf175 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2211,11 +2211,13 @@ QMenu *QLineEdit::createStandardContextMenu() if (!isReadOnly()) { action = popup->addAction(QLineEdit::tr("&Undo") + ACCEL_KEY(QKeySequence::Undo)); action->setEnabled(d->control->isUndoAvailable()); + action->setObjectName(QStringLiteral("edit-undo")); setActionIcon(action, QStringLiteral("edit-undo")); connect(action, &QAction::triggered, this, &QLineEdit::undo); action = popup->addAction(QLineEdit::tr("&Redo") + ACCEL_KEY(QKeySequence::Redo)); action->setEnabled(d->control->isRedoAvailable()); + action->setObjectName(QStringLiteral("edit-redo")); setActionIcon(action, QStringLiteral("edit-redo")); connect(action, &QAction::triggered, this, &QLineEdit::redo); @@ -2227,6 +2229,7 @@ QMenu *QLineEdit::createStandardContextMenu() action = popup->addAction(QLineEdit::tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut)); action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText() && d->control->echoMode() == QLineEdit::Normal); + action->setObjectName(QStringLiteral("edit-cut")); setActionIcon(action, QStringLiteral("edit-cut")); connect(action, &QAction::triggered, this, &QLineEdit::cut); } @@ -2234,12 +2237,14 @@ QMenu *QLineEdit::createStandardContextMenu() action = popup->addAction(QLineEdit::tr("&Copy") + ACCEL_KEY(QKeySequence::Copy)); action->setEnabled(d->control->hasSelectedText() && d->control->echoMode() == QLineEdit::Normal); + action->setObjectName(QStringLiteral("edit-copy")); setActionIcon(action, QStringLiteral("edit-copy")); connect(action, &QAction::triggered, this, &QLineEdit::copy); if (!isReadOnly()) { action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); action->setEnabled(!d->control->isReadOnly() && !QGuiApplication::clipboard()->text().isEmpty()); + action->setObjectName(QStringLiteral("edit-paste")); setActionIcon(action, QStringLiteral("edit-paste")); connect(action, &QAction::triggered, this, &QLineEdit::paste); } @@ -2248,6 +2253,7 @@ QMenu *QLineEdit::createStandardContextMenu() if (!isReadOnly()) { action = popup->addAction(QLineEdit::tr("Delete")); action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText()); + action->setObjectName(QStringLiteral("edit-delete")); setActionIcon(action, QStringLiteral("edit-delete")); connect(action, &QAction::triggered, d->control, &QWidgetLineControl::_q_deleteSelected); @@ -2258,6 +2264,7 @@ QMenu *QLineEdit::createStandardContextMenu() action = popup->addAction(QLineEdit::tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll)); action->setEnabled(!d->control->text().isEmpty() && !d->control->allSelected()); + action->setObjectName(QStringLiteral("select-all")); setActionIcon(action, QStringLiteral("edit-select-all")); d->selectAllAction = action; connect(action, &QAction::triggered, this, &QLineEdit::selectAll); -- cgit v1.2.3