Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7324

Add support for dynamic re-translation of QUndoStack's QUndoAction prefix.

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.6.0
    • None

      Currently when dynamically changing the translation in use, any QUndoAction objects (a private class not part of the public API) created via QUndoStack::createUndoAction() cannot have their prefix changed and new actions must be created to replace the old actions.

      The only current alternative to replacing the actions I can think of is to not use createUndoAction() and manually re-implement a QUndoAction equivalent that observes the QUndoStack's undoTextChanged() signal... seems like re-implementing too much of what is provided by QUndoStack to me.

      I suggest that perhaps calling setText() on a QUndoAction (if it were to be made virtual) could change the prefix to the newly retranslated text (QUndoAction::setPrefixedText() would need to call QAction::setText() then). Since setText() on a QUndoAction is only effective until the next undoTextChanged() this seems like a reasonable semantic change to me.

      Alternatively the QUndoAction class could be made part of the API and provide a method of changing/retranslating the prefix.

      E.g.:

      void MyMainWindow::setupMenus() {
          // ...
          undoAction = myUndoStack->createUndoAction(this, tr("&Undo"));
          editMenu->addAction(undoAction);
          // ...
      }
      void MyMainWindow::retranslateUi() {
          // ...
      #ifdef NEW
          undoAction->setText(tr("&Undo"));
      #else // currently:
          delete undoAction;
          undoAction = myUndoStack->createUndoAction(this, tr("&Undo"));
          editMenu->insertAction(someBeforeAction, undoAction);
      #endif
          // ...
      }
      

      Thank you.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dchapes Dave Chapeskie
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes