1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-24 19:52:37 +01:00

Qt: add ability to style richtext href links

This commit is contained in:
Megamouse 2023-06-01 01:06:30 +02:00
parent 0ebe832f8e
commit fcfca6efda
17 changed files with 95 additions and 20 deletions

View File

@ -384,3 +384,6 @@ QTreeView::branch:open:has-children:has-siblings:hover {
#game_list_grid_item[focus="true"] #game_list_grid_item_title_label {
background-color: #0078D7;
}
/* Richtext link color */
QLabel#richtext_link_color { color: #87cefa; }

View File

@ -680,3 +680,6 @@ QTreeView::branch:open:has-children:has-siblings:hover {
background-color: #2d3038;
color: #8cf944;
}
/* Richtext link color */
QLabel#richtext_link_color { color: #8cf944; }

View File

@ -384,3 +384,6 @@ QTreeView::branch:open:has-children:has-siblings:hover {
color: #e6e6e6;
background-color: #4c4b4b;
}
/* Richtext link color */
QLabel#richtext_link_color { color: #87cefa; }

View File

@ -381,3 +381,6 @@ QTreeView::branch:open:has-children:has-siblings:hover {
#game_list_grid_item[focus="true"] #game_list_grid_item_title_label {
background-color: #0078D7;
}
/* Richtext link color */
QLabel#richtext_link_color { color: #87cefa; }

View File

@ -504,3 +504,6 @@ QWidget#trophy_notification_frame {
background-color: #4d4940;
color: #ffd785;
}
/* Richtext link color */
QLabel#richtext_link_color { color: #87cefa; }

View File

@ -720,3 +720,6 @@ QTreeView::branch:open:has-children:has-siblings:hover {
background-color: #0f1d36;
color: #2397ff;
}
/* Richtext link color */
QLabel#richtext_link_color { color: #0074e7; }

View File

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

View File

@ -123,9 +123,6 @@
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.&lt;br/&gt;It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with &lt;a href=&quot;https://www.patreon.com/Nekotekina&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Patreon&lt;/span&gt;&lt;/a&gt;.&lt;br/&gt;Our developers and contributors are always working hard to ensure this project is the best that it can be.&lt;br/&gt;There are still plenty of implementations to make and optimizations to do.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>

View File

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

View File

@ -13,6 +13,8 @@ LOG_CHANNEL(cfg_log, "CFG");
namespace gui
{
QString stylesheet;
QString get_game_list_column_name(game_list_columns col)
{
switch (col)

View File

@ -10,7 +10,7 @@
namespace gui
{
static QString stylesheet;
extern QString stylesheet;
enum custom_roles
{

View File

@ -274,7 +274,7 @@ bool main_window::OnMissingFw()
{
const QString title = tr("Missing Firmware Detected!");
const QString message = tr("Commercial games require the firmware (PS3UPDAT.PUP file) to be installed."
"\n<br>For information about how to obtain the required firmware read the <a href=\"https://rpcs3.net/quickstart\">quickstart guide</a>.");
"\n<br>For information about how to obtain the required firmware read the <a %0 href=\"https://rpcs3.net/quickstart\">quickstart guide</a>.").arg(gui::utils::get_link_style());
QMessageBox mb(QMessageBox::Question, title, message, QMessageBox::Ok | QMessageBox::Cancel, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
mb.setTextFormat(Qt::RichText);
@ -445,7 +445,7 @@ void main_window::show_boot_error(game_boot_result status)
message = tr("Unknown error.");
break;
}
const QString link = tr("<br /><br />For information on setting up the emulator and dumping your PS3 games, read the <a href=\"https://rpcs3.net/quickstart\">quickstart guide</a>.");
const QString link = tr("<br /><br />For information on setting up the emulator and dumping your PS3 games, read the <a %0 href=\"https://rpcs3.net/quickstart\">quickstart guide</a>.").arg(gui::utils::get_link_style());
QMessageBox msg;
msg.setWindowTitle(tr("Boot Failed"));

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "qt_utils.h"
#include "gui_settings.h"
#include <QApplication>
#include <QBitmap>
#include <QDesktopServices>
@ -198,6 +199,26 @@ namespace gui
return l.sizeHint().width();
}
QColor get_link_color(const QString& name)
{
return gui::utils::get_label_color(name);
}
QString get_link_color_string(const QString& name)
{
return get_link_color(name).name();
}
QString get_link_style(const QString& name)
{
if (!gui::stylesheet.contains(name))
{
return {};
}
return QString("style=\"color: %0;\"").arg(get_link_color_string(name));
}
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

View File

@ -74,6 +74,15 @@ namespace gui
// Returns the width of the text
int get_label_width(const QString& text, const QFont* font = nullptr);
// Returns the color for richtext <a> links.
QColor get_link_color(const QString& name = "richtext_link_color");
// Returns the color string for richtext <a> links.
QString get_link_color_string(const QString& name = "richtext_link_color");
// Returns the style for richtext <a> links. e.g. style="color: #123456;"
QString get_link_style(const QString& name = "richtext_link_color");
template <typename T>
void set_font_size(T& qobj, int size)
{

View File

@ -1,5 +1,6 @@
#pragma once
#include "qt_utils.h"
#include <QString>
#include <QObject>
@ -251,17 +252,17 @@ public:
const QString null = tr("This controller is disabled and will appear as disconnected to software. Choose another handler to enable it.");
const QString ldd_pad = tr("This port is currently assigned to a custom controller by the application and can't be changed.");
const QString keyboard = tr("While it is possible to use a keyboard as a pad in RPCS3, the use of an actual controller is strongly recommended.<br>To bind mouse movement to a button or joystick, click on the desired button to activate it, then click and hold while dragging the mouse to a direction.");
const QString ds3_windows = tr("In order to use the DualShock 3 handler, you need to install the official DualShock 3 driver first.<br>See the <a href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.");
const QString ds3_linux = tr("In order to use the DualShock 3 handler, you might need to add udev rules to let RPCS3 access the controller.<br>See the <a href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.");
const QString ds3_windows = tr("In order to use the DualShock 3 handler, you need to install the official DualShock 3 driver first.<br>See the <a %0 href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.").arg(gui::utils::get_link_style());
const QString ds3_linux = tr("In order to use the DualShock 3 handler, you might need to add udev rules to let RPCS3 access the controller.<br>See the <a %0 href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.").arg(gui::utils::get_link_style());
const QString ds3_other = tr("The DualShock 3 handler is recommended for official DualShock 3 controllers.");
const QString ds4_windows = tr("If you have any issues with the DualShock 4 handler, it might be caused by third-party tools such as DS4Windows. It's recommended that you disable them while using this handler.");
const QString ds4_linux = tr("In order to use the DualShock 4 handler, you might need to add udev rules to let RPCS3 access the controller.<br>See the <a href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.");
const QString ds4_linux = tr("In order to use the DualShock 4 handler, you might need to add udev rules to let RPCS3 access the controller.<br>See the <a %0 href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.").arg(gui::utils::get_link_style());
const QString ds4_other = tr("The DualShock 4 handler is recommended for official DualShock 4 controllers.");
const QString dualsense_windows = tr("The DualSense handler is recommended for official DualSense controllers.");
const QString dualsense_linux = tr("The DualSense handler is recommended for official DualSense controllers.");
const QString dualsense_other = tr("The DualSense handler is recommended for official DualSense controllers.");
const QString xinput = tr("The XInput handler will work with Xbox controllers and many third-party PC-compatible controllers. Pressure sensitive buttons from SCP are supported when SCP's XInput1_3.dll is placed in the main RPCS3 directory. For more details, see the <a href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a>.");
const QString evdev = tr("The evdev handler should work with any controller that has linux support.<br>If your joystick is not being centered properly, read the <a href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.");
const QString xinput = tr("The XInput handler will work with Xbox controllers and many third-party PC-compatible controllers. Pressure sensitive buttons from SCP are supported when SCP's XInput1_3.dll is placed in the main RPCS3 directory. For more details, see the <a %0 href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a>.").arg(gui::utils::get_link_style());
const QString evdev = tr("The evdev handler should work with any controller that has linux support.<br>If your joystick is not being centered properly, read the <a %0 href=\"https://wiki.rpcs3.net/index.php?title=Help:Controller_Configuration\">RPCS3 Wiki</a> for instructions.").arg(gui::utils::get_link_style());
const QString mmjoy = tr("The MMJoystick handler should work with almost any controller recognized by Windows. However, it is recommended that you use the more specific handlers if you have a controller that supports them.");
const QString sdl = tr("The SDL handler supports a variety of controllers across different platforms.");

View File

@ -2,6 +2,7 @@
#include "ui_welcome_dialog.h"
#include "gui_settings.h"
#include "qt_utils.h"
#include <QPushButton>
#include <QCheckBox>
@ -18,6 +19,27 @@ welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, QWidg
ui->okay->setEnabled(false);
ui->icon_label->load(QStringLiteral(":/rpcs3.svg"));
ui->label_3->setText(tr(
R"(
<p style="white-space: nowrap;">
RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.<br>
It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with <a %0 href="https://www.patreon.com/Nekotekina">Patreon</a>.<br>
Our developers and contributors are always working hard to ensure this project is the best that it can be.<br>
There are still plenty of implementations to make and optimizations to do.
</p>
)"
).arg(gui::utils::get_link_style()));
ui->label_info->setText(tr(
R"(
<p style="white-space: nowrap;">
To get started, you must first install the <span style="font-weight:600;">PlayStation 3 firmware</span>.<br>
Please refer to the <a %0 href="https://rpcs3.net/quickstart">Quickstart</a> guide found on the official website for further information.<br>
If you have any further questions, please refer to the <a %0 href="https://rpcs3.net/faq">FAQ</a>.<br>
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.
</p>
)"
).arg(gui::utils::get_link_style()));
connect(ui->i_have_read, &QCheckBox::clicked, [this](bool checked)
{

View File

@ -110,9 +110,6 @@
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;RPCS3 is an open-source Sony PlayStation 3 emulator and debugger.&lt;br/&gt;It is written in C++ for Windows, Linux, FreeBSD and MacOS funded with &lt;a href=&quot;https://www.patreon.com/Nekotekina&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Patreon&lt;/span&gt;&lt;/a&gt;.&lt;br/&gt;Our developers and contributors are always working hard to ensure this project is the best that it can be.&lt;br/&gt;There are still plenty of implementations to make and optimizations to do.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
@ -155,9 +152,6 @@
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;To get started, you must first install the &lt;span style=&quot; font-weight:600;&quot;&gt;PlayStation 3 firmware&lt;/span&gt;.&lt;br/&gt;Please refer to the &lt;a href=&quot;https://rpcs3.net/quickstart&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Quickstart&lt;/span&gt;&lt;/a&gt; guide found on the official website for further information.&lt;br/&gt;If you have any further questions, please refer to the &lt;a href=&quot;https://rpcs3.net/faq&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;FAQ&lt;/span&gt;&lt;/a&gt;.&lt;br/&gt;Otherwise, further discussion and support can be found on the &lt;a href=&quot;https://forums.rpcs3.net&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Forums&lt;/span&gt;&lt;/a&gt; or on our &lt;a href=&quot;https://discord.me/RPCS3&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Discord&lt;/span&gt;&lt;/a&gt; server.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>