-
Suggestion
-
Resolution: Unresolved
-
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.
- relates to
-
QTBUG-14442 string "Undo" is used for both unavailable and available menu item (in KDE)
-
- Closed
-