Standard dialogs example: Fix compilation with QT_NO_CAST_FROM_ASCII
Add missing tr(), use literals. Pick-to: 6.9 6.8 Change-Id: I35387e29ce1b08f9df0ade5ee743b33561639f7a Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
This commit is contained in:
parent
f388ca8841
commit
3e1707d430
@ -20,6 +20,8 @@
|
|||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QStyleHints>
|
#include <QStyleHints>
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
class DialogOptionsWidget : public QGroupBox
|
class DialogOptionsWidget : public QGroupBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -279,7 +281,7 @@ void Dialog::setDouble()
|
|||||||
tr("Amount:"), 37.56, -10000, 10000, 2, &ok,
|
tr("Amount:"), 37.56, -10000, 10000, 2, &ok,
|
||||||
Qt::WindowFlags(), 1);
|
Qt::WindowFlags(), 1);
|
||||||
if (ok)
|
if (ok)
|
||||||
doubleLabel->setText(QString("$%1").arg(d));
|
doubleLabel->setText(QStringLiteral("$%1").arg(d));
|
||||||
//! [1]
|
//! [1]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +315,7 @@ void Dialog::setMultiLineText()
|
|||||||
//! [4]
|
//! [4]
|
||||||
bool ok{};
|
bool ok{};
|
||||||
QString text = QInputDialog::getMultiLineText(this, tr("QInputDialog::getMultiLineText()"),
|
QString text = QInputDialog::getMultiLineText(this, tr("QInputDialog::getMultiLineText()"),
|
||||||
tr("Address:"), "John Doe\nFreedom Street", &ok);
|
tr("Address:"), "John Doe\nFreedom Street"_L1, &ok);
|
||||||
if (ok && !text.isEmpty())
|
if (ok && !text.isEmpty())
|
||||||
multiLineTextLabel->setText(text);
|
multiLineTextLabel->setText(text);
|
||||||
//! [4]
|
//! [4]
|
||||||
@ -322,7 +324,7 @@ void Dialog::setMultiLineText()
|
|||||||
void Dialog::setColor()
|
void Dialog::setColor()
|
||||||
{
|
{
|
||||||
const QColorDialog::ColorDialogOptions options = QFlag(colorDialogOptionsWidget->value());
|
const QColorDialog::ColorDialogOptions options = QFlag(colorDialogOptionsWidget->value());
|
||||||
const QColor color = QColorDialog::getColor(Qt::green, this, "Select Color", options);
|
const QColor color = QColorDialog::getColor(Qt::green, this, tr("Select Color"), options);
|
||||||
|
|
||||||
if (color.isValid()) {
|
if (color.isValid()) {
|
||||||
colorLabel->setText(color.name());
|
colorLabel->setText(color.name());
|
||||||
@ -341,7 +343,7 @@ void Dialog::setFont()
|
|||||||
defaultFont.fromString(description);
|
defaultFont.fromString(description);
|
||||||
|
|
||||||
bool ok{};
|
bool ok{};
|
||||||
QFont font = QFontDialog::getFont(&ok, defaultFont, this, "Select Font", options);
|
QFont font = QFontDialog::getFont(&ok, defaultFont, this, tr("Select Font"), options);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
fontLabel->setText(font.key());
|
fontLabel->setText(font.key());
|
||||||
fontLabel->setFont(font);
|
fontLabel->setFont(font);
|
||||||
@ -386,7 +388,7 @@ void Dialog::setOpenFileNames()
|
|||||||
options);
|
options);
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
openFilesPath = files.constFirst();
|
openFilesPath = files.constFirst();
|
||||||
openFileNamesLabel->setText(QString("[%1]").arg(files.join(", ")));
|
openFileNamesLabel->setText(u'[' + files.join(", "_L1) + u']');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,7 +461,7 @@ void Dialog::warningMessage()
|
|||||||
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
|
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
|
||||||
tr("Delete the only copy of your movie manuscript?"), { }, this);
|
tr("Delete the only copy of your movie manuscript?"), { }, this);
|
||||||
msgBox.setInformativeText(tr("You've been working on this manuscript for 738 days now. Hang in there!"));
|
msgBox.setInformativeText(tr("You've been working on this manuscript for 738 days now. Hang in there!"));
|
||||||
msgBox.setDetailedText("\"A long time ago in a galaxy far, far away....\"");
|
msgBox.setDetailedText("\"A long time ago in a galaxy far, far away....\""_L1);
|
||||||
auto *keepButton = msgBox.addButton(tr("&Keep"), QMessageBox::AcceptRole);
|
auto *keepButton = msgBox.addButton(tr("&Keep"), QMessageBox::AcceptRole);
|
||||||
auto *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::DestructiveRole);
|
auto *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::DestructiveRole);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
@ -468,7 +470,7 @@ void Dialog::warningMessage()
|
|||||||
else if (msgBox.clickedButton() == deleteButton)
|
else if (msgBox.clickedButton() == deleteButton)
|
||||||
warningLabel->setText(tr("Delete"));
|
warningLabel->setText(tr("Delete"));
|
||||||
else
|
else
|
||||||
warningLabel->setText("");
|
warningLabel->setText({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::errorMessage()
|
void Dialog::errorMessage()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user