use a static QRegularExpression object
This commit is contained in:
parent
896afaef16
commit
f352579a39
@ -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);
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,8 @@ private:
|
||||
// Optional Widget
|
||||
QTextBrowser *ui_game_changelog_text;
|
||||
|
||||
static QRegularExpression regexp_links;
|
||||
|
||||
void loadUI();
|
||||
void reloadUi();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user