|
@@ -1,7 +1,7 @@
|
|
|
#include "ui_statuswidget.h"
|
|
|
#include "statuswidget.h"
|
|
|
|
|
|
-#include "models/patchlist.h"
|
|
|
+#include "models/patchdownloader.h"
|
|
|
|
|
|
#include "widgets/mainwindow.h"
|
|
|
|
|
@@ -13,10 +13,9 @@
|
|
|
#include <QMessageBox>
|
|
|
#include <QRandomGenerator>
|
|
|
|
|
|
-StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
|
|
|
+StatusWidget::StatusWidget(QWidget *parent)
|
|
|
: QWidget(parent)
|
|
|
, ui(new Ui::StatusWidget)
|
|
|
- , legacy_patches_(legacy_patches)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
last_statusbar_update_time_.start();
|
|
@@ -32,9 +31,9 @@ StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
|
|
|
connect(ui->server_status_widget, &ServerStatusWidget::showServersTooltip, this, [this](QString message){setToolTipMessage(message, E_INFO);});
|
|
|
connect(ui->server_status_widget, &ServerStatusWidget::showNoTooltip, this, [this](){unsetToolTipMessage(E_INFO);});
|
|
|
|
|
|
-// connect(legacy_patches_, &PatchList::patchOperationsStarted, this, &StatusWidget::onPatchTotalOperationsStarted);
|
|
|
-// connect(legacy_patches_, &PatchList::patchOperationsFinished, this, &StatusWidget::onPatchTotalOperationsFinished);
|
|
|
-// connect(legacy_patches_, &PatchList::progressChanged, this, &StatusWidget::updatePatchProgressStatus);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::started, this, &StatusWidget::onPatchDownloaderStarted);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::progressChanged, this, &StatusWidget::onPatchDownloaderProgressChanged);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &StatusWidget::onPatchDownloaderFinished);
|
|
|
|
|
|
generateRandomTooltipMessage();
|
|
|
random_tooltip_generator_timer_.setInterval(5 * 1000);
|
|
@@ -233,23 +232,34 @@ void StatusWidget::fadeBetweenToolTips(QString tooltip_id)
|
|
|
current_tooltip_message_ = tooltip_id;
|
|
|
}
|
|
|
|
|
|
-void StatusWidget::onPatchTotalOperationsStarted()
|
|
|
-{
|
|
|
+void StatusWidget::onPatchDownloaderStarted() {
|
|
|
all_patch_operations_finished_ = false;
|
|
|
ui->game_button->setEnabled(false);
|
|
|
ui->check_for_updates_button->setEnabled(false);
|
|
|
- setToolTipMessage("Запуск процесса проверки и установки русификации...", E_PROCESS);
|
|
|
+ setToolTipMessage("Проверка обновлений русификации...", E_PROCESS);
|
|
|
}
|
|
|
|
|
|
-void StatusWidget::onPatchTotalOperationsFinished()
|
|
|
-{
|
|
|
+void StatusWidget::onPatchDownloaderFinished() {
|
|
|
all_patch_operations_finished_ = true;
|
|
|
ui->game_button->setEnabled(true);
|
|
|
ui->check_for_updates_button->setEnabled(true);
|
|
|
- setToolTipMessage("Все процессы установки русификации завершены. Можно играть. Mae govannen. Еще какой-то текст...", E_PROCESS);
|
|
|
+ setToolTipMessage("Скачивание данных русификации завершено!", E_PROCESS);
|
|
|
process_completed_tooltip_hide_timer_.start();
|
|
|
}
|
|
|
|
|
|
+void StatusWidget::onPatchDownloaderProgressChanged(Downloader::Status status) {
|
|
|
+ if (last_statusbar_update_time_.elapsed() > 1000) {
|
|
|
+ double download_percent = double(status.downloaded_bytes) * 100.0 / double(status.total_bytes);
|
|
|
+ QString text = "Загрузка данных: " + QString::number(download_percent, 'f', 1) + "% ("
|
|
|
+ + Downloader::getSizeFormatted(status.downloaded_bytes) + "/"
|
|
|
+ + Downloader::getSizeFormatted(status.total_bytes) + ")\n"
|
|
|
+ + "До конца загрузки: " + Downloader::getElapsedTimeFormatted(status.elapsed_time);
|
|
|
+
|
|
|
+ setToolTipMessage(text, E_PROCESS);
|
|
|
+ last_statusbar_update_time_.restart();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void StatusWidget::on_game_button_clicked()
|
|
|
{
|
|
|
MainWindow* window = qobject_cast<MainWindow*>(parentWidget()->parentWidget()->parentWidget());
|
|
@@ -302,5 +312,5 @@ void StatusWidget::createTooltipMessageWidget(QString tooltip_id)
|
|
|
|
|
|
void StatusWidget::on_check_for_updates_button_clicked()
|
|
|
{
|
|
|
- QMetaObject::invokeMethod(legacy_patches_, &PatchList::update, Qt::QueuedConnection);
|
|
|
+ QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::startPatchDownloaderChain, Qt::QueuedConnection);
|
|
|
}
|