|
8 | 8 | #include "widgets/server_editor_dialog.h" |
9 | 9 |
|
10 | 10 | #include <QImageReader> |
| 11 | +#include <QMessageBox> |
11 | 12 | #include <QUiLoader> |
| 13 | +#include <QVersionNumber> |
| 14 | +#include <qnamespace.h> |
12 | 15 |
|
13 | 16 | Lobby::Lobby(AOApplication *p_ao_app, NetworkManager *p_net_manager) |
14 | 17 | : QMainWindow{} |
@@ -101,9 +104,8 @@ void Lobby::reset_selection() |
101 | 104 |
|
102 | 105 | void Lobby::loadUI() |
103 | 106 | { |
104 | | - this->setWindowTitle(tr("Attorney Online %1").arg(QApplication::applicationVersion())); |
105 | | - this->setWindowIcon(QIcon(":/logo.png")); |
106 | | - this->setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint)); |
| 107 | + setWindowIcon(QIcon(":/logo.png")); |
| 108 | + setWindowFlags((windowFlags() | Qt::CustomizeWindowHint)); |
107 | 109 |
|
108 | 110 | QUiLoader l_loader(this); |
109 | 111 | QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI)); |
@@ -558,11 +560,16 @@ void Lobby::get_motd() |
558 | 560 | void Lobby::check_for_updates() |
559 | 561 | { |
560 | 562 | net_manager->request_document(MSDocumentType::ClientVersion, [this](QString version) { |
561 | | - const QString current_version = ao_app->get_version_string(); |
562 | | - if (!version.isEmpty() && version != current_version) |
| 563 | + QVersionNumber current_version = QVersionNumber::fromString(ao_app->get_version_string()); |
| 564 | + QVersionNumber master_version = QVersionNumber::fromString(version); |
| 565 | + |
| 566 | + if (current_version < master_version) |
563 | 567 | { |
564 | | - ui_game_version_lbl->setText(tr("Version: %1 (!)").arg(current_version)); |
565 | | - ui_game_version_lbl->setToolTip(tr("New version available: %1").arg(version)); |
| 568 | + ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString())); |
| 569 | + setWindowTitle(tr("[Your client is outdated]")); |
| 570 | + 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>"); |
| 571 | + 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); |
| 572 | + QMessageBox::warning(this, "Your client is outdated!", message); |
566 | 573 | } |
567 | 574 | }); |
568 | 575 | } |
|
0 commit comments