diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-12-11 10:47:16 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-12-12 12:39:39 +0100 |
| commit | a4d8747d0877b30b0720213026bc705bc8230db5 (patch) | |
| tree | 82518911a4b6008be2d2853e587775862ed17cc7 | |
| parent | 66184515b372306c0d62a46ff63301ca0b96b062 (diff) | |
Qt Linguist: Improve translations of the AI translation dialog
- Remove "Dialog" from the MachineTranslationDialog title
- Remove HTML clutter by using placeholderText for the log display
- Remove the +/- indicators from the tool box texts by moving
the texts into the source.
- Add some comments
- Fix message texts
Pick-to: 6.11
Task-number: QTBUG-141111
Change-Id: If73c20142309f2920c85176efbe9a7a01ca08c3e
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
| -rw-r--r-- | src/linguist/linguist/machinetranslationdialog.cpp | 31 | ||||
| -rw-r--r-- | src/linguist/linguist/machinetranslationdialog.h | 1 | ||||
| -rw-r--r-- | src/linguist/linguist/machinetranslationdialog.ui | 24 |
3 files changed, 29 insertions, 27 deletions
diff --git a/src/linguist/linguist/machinetranslationdialog.cpp b/src/linguist/linguist/machinetranslationdialog.cpp index f64bd403a..e1aef2f4f 100644 --- a/src/linguist/linguist/machinetranslationdialog.cpp +++ b/src/linguist/linguist/machinetranslationdialog.cpp @@ -11,10 +11,18 @@ #include <QtCore/qsettings.h> #include <QtWidgets/qmessagebox.h> +#include <array> + using namespace Qt::Literals::StringLiterals; QT_BEGIN_NAMESPACE +static constexpr std::array<const char *, 3> toolBoxTexts { + QT_TRANSLATE_NOOP("MachineTranslationDialog", "Configuration"), + QT_TRANSLATE_NOOP("MachineTranslationDialog", "Selection"), + QT_TRANSLATE_NOOP("MachineTranslationDialog", "Progress") +}; + MachineTranslationDialog::MachineTranslationDialog(QWidget *parent) : QDialog(parent), m_ui(std::make_unique<Ui::MachineTranslationDialog>()), @@ -22,12 +30,8 @@ MachineTranslationDialog::MachineTranslationDialog(QWidget *parent) { m_ui->setupUi(this); - connect(m_ui->toolBox, &QToolBox::currentChanged, this, [this](int index) { - for (int i = 0; i < m_ui->toolBox->count(); ++i) { - const QString baseText = m_ui->toolBox->itemText(i).mid(2); - m_ui->toolBox->setItemText(i, (i == index ? "- "_L1 : "+ "_L1) + baseText); - } - }); + updateToolBoxTexts(); + connect(m_ui->toolBox, &QToolBox::currentChanged, this, &MachineTranslationDialog::updateToolBoxTexts); m_ui->statusLabel->setWordWrap(true); m_ui->statusLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -80,6 +84,18 @@ MachineTranslationDialog::MachineTranslationDialog(QWidget *parent) &MachineTranslationDialog::onFilterChanged); } +void MachineTranslationDialog::updateToolBoxTexts() +{ + const int count = m_ui->toolBox->count(); + Q_ASSERT(unsigned(count) == toolBoxTexts.size()); + const int index = m_ui->toolBox->currentIndex(); + + for (int i = 0; i < count; ++i) { + const QString baseText = MachineTranslationDialog::tr(toolBoxTexts[i]); + m_ui->toolBox->setItemText(i, (i == index ? "- "_L1 : "+ "_L1) + baseText); + } +} + void MachineTranslationDialog::setDataModel(MultiDataModel *dm) { m_dataModel = dm; @@ -167,7 +183,7 @@ bool MachineTranslationDialog::discardTranslations() return (m_receivedTranslations.empty() || QMessageBox::warning( this, tr("Qt Linguist"), - tr("The already %n translated item(s) will be discarded. Continue?", 0, + tr("%n translated item(s) will be discarded. Continue?", 0, m_receivedTranslations.size()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes); @@ -332,6 +348,7 @@ void MachineTranslationDialog::updateStatus() selectedItems = m_ui->groupListWidget->selectedItems(); if (model < 0 || filter < 0 || (filter > 0 && selectedItems.isEmpty())) { + //: No selected items m_ui->selectionLabel->setText(tr("Selection status: -")); } else if (filter == 0) { int count = 0; diff --git a/src/linguist/linguist/machinetranslationdialog.h b/src/linguist/linguist/machinetranslationdialog.h index 6e0a8d9eb..9b914bf80 100644 --- a/src/linguist/linguist/machinetranslationdialog.h +++ b/src/linguist/linguist/machinetranslationdialog.h @@ -59,6 +59,7 @@ private slots: void applyTranslations(); void onTranslationFailed(QList<const TranslatorMessage *>); void connectToOllama(); + void updateToolBoxTexts(); }; QT_END_NAMESPACE diff --git a/src/linguist/linguist/machinetranslationdialog.ui b/src/linguist/linguist/machinetranslationdialog.ui index a3b448f9b..4750d430f 100644 --- a/src/linguist/linguist/machinetranslationdialog.ui +++ b/src/linguist/linguist/machinetranslationdialog.ui @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>Auto Translation Dialog</string> + <string>Auto Translation</string> </property> <layout class="QVBoxLayout" name="verticalLayout_8"> <item> @@ -34,9 +34,6 @@ <height>432</height> </rect> </property> - <attribute name="label"> - <string>- Configuration</string> - </attribute> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QGroupBox" name="configGroup"> @@ -176,9 +173,6 @@ <height>432</height> </rect> </property> - <attribute name="label"> - <string>+ Selection</string> - </attribute> <layout class="QVBoxLayout" name="verticalLayout_5"> <item> <widget class="QGroupBox" name="selectionGroup"> @@ -325,9 +319,6 @@ <height>460</height> </rect> </property> - <attribute name="label"> - <string>+ Progress</string> - </attribute> <layout class="QVBoxLayout" name="verticalLayout_6"> <item> <widget class="QGroupBox" name="progressGroup"> @@ -380,15 +371,8 @@ <property name="readOnly"> <bool>true</bool> </property> - <property name="html"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> -p, li { white-space: pre-wrap; } -hr { height: 1px; border-width: 0; } -li.unchecked::marker { content: "\2610"; } -li.checked::marker { content: "\2612"; } -</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Translation Log</p></body></html></string> + <property name="placeholderText"> + <string>Translation Log</string> </property> </widget> </item> @@ -401,7 +385,7 @@ li.checked::marker { content: "\2612"; } </sizepolicy> </property> <property name="text"> - <string>Translation status: -</string> + <string extracomment="Default display when no translations have been processed yet">Translation status: -</string> </property> </widget> </item> |
