aboutsummaryrefslogtreecommitdiff
path: root/src/lobby.cpp
diff options
context:
space:
mode:
authorin1tiate <32779090+in1tiate@users.noreply.github.com>2025-01-11 02:11:31 -0600
committerin1tiate <32779090+in1tiate@users.noreply.github.com>2025-01-11 02:11:31 -0600
commitf352579a3972b423ca7e199fef5c10206ca3a099 (patch)
treed0ac8401f73fec7b19ed862650adca556238402e /src/lobby.cpp
parent896afaef16cbf42eb662eab899d09daa61821688 (diff)
use a static QRegularExpression object
Diffstat (limited to 'src/lobby.cpp')
-rw-r--r--src/lobby.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lobby.cpp b/src/lobby.cpp
index 202cab7d..9a6d8029 100644
--- a/src/lobby.cpp
+++ b/src/lobby.cpp
@@ -20,6 +20,7 @@ Lobby::Lobby(AOApplication *p_ao_app, NetworkManager *p_net_manager)
{
reloadUi();
setObjectName("lobby");
+ regexp_links = QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b");
}
void Lobby::on_tab_changed(int index)
@@ -567,7 +568,7 @@ void Lobby::check_for_updates()
{
ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString()));
setWindowTitle(tr("[Your client is outdated]"));
- const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "<a href='\\1'>\\1</a>");
+ const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(regexp_links, "<a href='\\1'>\\1</a>");
const QString message = QString("Your client is outdated!<br>Your Version: %1<br>Current Version: %2<br>Download the latest version at<br>%3").arg(current_version.toString(), master_version.toString(), download_url);
QMessageBox::warning(this, "Your client is outdated!", message);
}
@@ -583,7 +584,7 @@ void Lobby::set_player_count(int players_online, int max_players)
void Lobby::set_server_description(const QString &server_description)
{
ui_server_description_text->clear();
- QString result = server_description.toHtmlEscaped().replace("\n", "<br>").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "<a href='\\1'>\\1</a>");
+ QString result = server_description.toHtmlEscaped().replace("\n", "<br>").replace(regexp_links, "<a href='\\1'>\\1</a>");
ui_server_description_text->insertHtml(result);
}