Qt: Detach markup from dialog translations

This commit is contained in:
Megamouse 2025-03-12 12:43:47 +01:00
parent b2ed787c3a
commit ff40128df6
6 changed files with 72 additions and 60 deletions

View file

@ -16,16 +16,12 @@ about_dialog::about_dialog(QWidget* parent) : QDialog(parent), ui(new Ui::about_
ui->close->setDefault(true); ui->close->setDefault(true);
ui->icon->load(QStringLiteral(":/rpcs3.svg")); ui->icon->load(QStringLiteral(":/rpcs3.svg"));
ui->version->setText(tr("RPCS3 Version: %1").arg(QString::fromStdString(rpcs3::get_verbose_version()))); ui->version->setText(tr("RPCS3 Version: %1").arg(QString::fromStdString(rpcs3::get_verbose_version())));
ui->description->setText(tr( ui->description->setText(gui::utils::make_paragraph(tr(
R"( "RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.\n"
<p style="white-space: nowrap;"> "It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with %0.\n"
RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.<br> "Our developers and contributors are always working hard to ensure this project is the best that it can be.\n"
It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with <a %0 href="https://rpcs3.net/patreon">Patreon</a>.<br> "There are still plenty of implementations to make and optimizations to do.")
Our developers and contributors are always working hard to ensure this project is the best that it can be.<br> .arg(gui::utils::make_link(tr("Patreon"), "https://rpcs3.net/patreon"))));
There are still plenty of implementations to make and optimizations to do.
</p>
)"
).arg(gui::utils::get_link_style()));
// Events // Events
connect(ui->gitHub, &QPushButton::clicked, [] { QDesktopServices::openUrl(QUrl("https://www.github.com/RPCS3")); }); connect(ui->gitHub, &QPushButton::clicked, [] { QDesktopServices::openUrl(QUrl("https://www.github.com/RPCS3")); });

View file

@ -101,17 +101,15 @@ bool gui_application::Init()
msg.setTextFormat(Qt::RichText); msg.setTextFormat(Qt::RichText);
msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msg.setDefaultButton(QMessageBox::No); msg.setDefaultButton(QMessageBox::No);
msg.setText(tr( msg.setText(gui::utils::make_paragraph(tr(
R"( "Please understand that this build is not an official RPCS3 release.\n"
<p style="white-space: nowrap;"> "This build contains changes that may break games, or even <b>damage</b> your data.\n"
Please understand that this build is not an official RPCS3 release.<br> "We recommend to download and use the official build from the %0.\n"
This build contains changes that may break games, or even <b>damage</b> your data.<br> "\n"
We recommend to download and use the official build from the <a %0 href='https://rpcs3.net/download'>RPCS3 website</a>.<br><br> "Build origin: %1\n"
Build origin: %1<br> "Do you wish to use this build anyway?")
Do you wish to use this build anyway? .arg(gui::utils::make_link(tr("RPCS3 website"), "https://rpcs3.net/download"))
</p> .arg(Qt::convertFromPlainText(branch_name.data()))));
)"
).arg(gui::utils::get_link_style()).arg(Qt::convertFromPlainText(branch_name.data())));
msg.layout()->setSizeConstraint(QLayout::SetFixedSize); msg.layout()->setSizeConstraint(QLayout::SetFixedSize);
if (msg.exec() == QMessageBox::No) if (msg.exec() == QMessageBox::No)

View file

@ -232,6 +232,23 @@ namespace gui
return QString("style=\"color: %0;\"").arg(get_link_color_string(name)); return QString("style=\"color: %0;\"").arg(get_link_color_string(name));
} }
QString make_link(const QString& text, const QString& url)
{
return QString("<a %0 href=\"%1\">%2</a>").arg(get_link_style()).arg(url).arg(text);
}
QString make_bold(const QString& text)
{
return QString("<span style=\"font-weight:600;\">%0</span>").arg(text);
}
QString make_paragraph(QString text, const QString& white_space_style)
{
return QString(R"(<p%0>%1</p>)")
.arg(white_space_style.isEmpty() ? "" : "style=\"white-space: nowrap;\"")
.arg(text.replace("\n", "<br>"));
}
QPixmap get_centered_pixmap(QPixmap pixmap, const QSize& icon_size, int offset_x, int offset_y, qreal device_pixel_ratio, Qt::TransformationMode mode) QPixmap get_centered_pixmap(QPixmap pixmap, const QSize& icon_size, int offset_x, int offset_y, qreal device_pixel_ratio, Qt::TransformationMode mode)
{ {
// Create empty canvas for expanded image // Create empty canvas for expanded image

View file

@ -92,6 +92,15 @@ namespace gui
// Returns the style for richtext <a> links. e.g. style="color: #123456;" // Returns the style for richtext <a> links. e.g. style="color: #123456;"
QString get_link_style(const QString& name = "richtext_link_color"); QString get_link_style(const QString& name = "richtext_link_color");
// Returns a richtext link
QString make_link(const QString& text, const QString& url);
// Returns a bold richtext string
QString make_bold(const QString& text);
// Returns a richtext paragraph with white-space: nowrap;
QString make_paragraph(QString text, const QString& white_space_style = "nowrap");
template <typename T> template <typename T>
void set_font_size(T& qobj, int size) void set_font_size(T& qobj, int size)
{ {

View file

@ -313,29 +313,25 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
if (!utils::has_mpx()) if (!utils::has_mpx())
{ {
title = tr("Haswell/Broadwell TSX Warning"); title = tr("Haswell/Broadwell TSX Warning");
message = tr( message = gui::utils::make_paragraph(tr(
R"( "RPCS3 has detected that you are using TSX functions on a Haswell or Broadwell CPU.\n"
<p style="white-space: nowrap;"> "Intel has deactivated these functions in newer Microcode revisions, since they can lead to unpredicted behaviour.\n"
RPCS3 has detected that you are using TSX functions on a Haswell or Broadwell CPU.<br> "That means using TSX may break games or even <font color=\"red\"><b>damage</b></font> your data.\n"
Intel has deactivated these functions in newer Microcode revisions, since they can lead to unpredicted behaviour.<br> "We recommend to disable this feature and update your computer BIOS.\n"
That means using TSX may break games or even <font color="red"><b>damage</b></font> your data.<br> "\n"
We recommend to disable this feature and update your computer BIOS.<br><br> "Do you wish to use TSX anyway?"
Do you wish to use TSX anyway? ));
</p>
)");
} }
else else
{ {
title = tr("TSX-FA Warning"); title = tr("TSX-FA Warning");
message = tr( message = gui::utils::make_paragraph(tr(
R"( "RPCS3 has detected your CPU only supports TSX-FA.\n"
<p style="white-space: nowrap;"> "That means using TSX may break games or even <font color=\"red\"><b>damage</b></font> your data.\n"
RPCS3 has detected your CPU only supports TSX-FA.<br> "We recommend to disable this feature.\n"
That means using TSX may break games or even <font color="red"><b>damage</b></font> your data.<br> "\n"
We recommend to disable this feature.<br><br> "Do you wish to use TSX anyway?"
Do you wish to use TSX anyway? ));
</p>
)");
} }
if (QMessageBox::No == QMessageBox::critical(this, title, message, QMessageBox::Yes, QMessageBox::No)) if (QMessageBox::No == QMessageBox::critical(this, title, message, QMessageBox::Yes, QMessageBox::No))

View file

@ -24,27 +24,23 @@ welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool
ui->icon_label->load(QStringLiteral(":/rpcs3.svg")); ui->icon_label->load(QStringLiteral(":/rpcs3.svg"));
ui->label_desc->setText(tr( ui->label_desc->setText(gui::utils::make_paragraph(tr(
R"( "RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.\n"
<p style="white-space: nowrap;"> "It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with %0.\n"
RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.<br> "Our developers and contributors are always working hard to ensure this project is the best that it can be.\n"
It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with <a %0 href="https://rpcs3.net/patreon">Patreon</a>.<br> "There are still plenty of implementations to make and optimizations to do.")
Our developers and contributors are always working hard to ensure this project is the best that it can be.<br> .arg(gui::utils::make_link(tr("Patreon"), "https://rpcs3.net/patreon"))));
There are still plenty of implementations to make and optimizations to do.
</p>
)"
).arg(gui::utils::get_link_style()));
ui->label_info->setText(tr( ui->label_info->setText(gui::utils::make_paragraph(tr(
R"( "To get started, you must first install the %0.\n"
<p style="white-space: nowrap;"> "Please refer to the %1 guide found on the official website for further information.\n"
To get started, you must first install the <span style="font-weight:600;">PlayStation 3 firmware</span>.<br> "If you have any further questions, please refer to the %2.\n"
Please refer to the <a %0 href="https://rpcs3.net/quickstart">Quickstart</a> guide found on the official website for further information.<br> "Otherwise, further discussion and support can be found on the %3 or on our %4 server.")
If you have any further questions, please refer to the <a %0 href="https://rpcs3.net/faq">FAQ</a>.<br> .arg(gui::utils::make_bold(tr("PlayStation 3 firmware")))
Otherwise, further discussion and support can be found on the <a %0 href="https://forums.rpcs3.net">Forums</a> or on our <a %0 href="https://discord.me/RPCS3">Discord</a> server. .arg(gui::utils::make_link(tr("Quickstart"), "https://rpcs3.net/quickstart"))
</p> .arg(gui::utils::make_link(tr("FAQ"), "https://rpcs3.net/faq"))
)" .arg(gui::utils::make_link(tr("Forums"), "https://forums.rpcs3.net"))
).arg(gui::utils::get_link_style())); .arg(gui::utils::make_link(tr("Discord"), "https://discord.me/RPCS3"))));
#ifdef __APPLE__ #ifdef __APPLE__
ui->create_applications_menu_shortcut->setText(tr("&Create Launchpad shortcut")); ui->create_applications_menu_shortcut->setText(tr("&Create Launchpad shortcut"));