瀏覽代碼

Architecture redesign base structure completed

Ivan Arkhipov 5 年之前
父節點
當前提交
94047249a3
共有 39 個文件被更改,包括 1108 次插入836 次删除
  1. 18 6
      src/Legacy/Legacy.pro
  2. 68 0
      src/Legacy/legacyapplication.cpp
  3. 37 0
      src/Legacy/legacyapplication.h
  4. 4 43
      src/Legacy/main.cpp
  5. 3 3
      src/Legacy/models/downloader.h
  6. 1 0
      src/Legacy/models/filesystem.h
  7. 49 26
      src/Legacy/models/lotrodatmanager.cpp
  8. 24 4
      src/Legacy/models/lotrodatmanager.h
  9. 24 0
      src/Legacy/models/lotrodatmanagerobserver.cpp
  10. 28 0
      src/Legacy/models/lotrodatmanagerobserver.h
  11. 40 0
      src/Legacy/models/patch/graphicspatch.cpp
  12. 45 0
      src/Legacy/models/patch/graphicspatch.h
  13. 64 0
      src/Legacy/models/patch/patch.cpp
  14. 65 0
      src/Legacy/models/patch/patch.h
  15. 40 0
      src/Legacy/models/patch/soundspatch.cpp
  16. 44 0
      src/Legacy/models/patch/soundspatch.h
  17. 40 0
      src/Legacy/models/patch/textspatch.cpp
  18. 43 0
      src/Legacy/models/patch/textspatch.h
  19. 40 0
      src/Legacy/models/patch/videospatch.cpp
  20. 44 0
      src/Legacy/models/patch/videospatch.h
  21. 0 299
      src/Legacy/models/patchdownloader.cpp
  22. 0 79
      src/Legacy/models/patchdownloader.h
  23. 87 0
      src/Legacy/models/patchlist.cpp
  24. 51 0
      src/Legacy/models/patchlist.h
  25. 28 16
      src/Legacy/models/settings.h
  26. 15 4
      src/Legacy/object_script.Legacy.Debug
  27. 15 4
      src/Legacy/object_script.Legacy.Release
  28. 9 11
      src/Legacy/widgets/aboutwidget.cpp
  29. 4 8
      src/Legacy/widgets/aboutwidget.h
  30. 4 7
      src/Legacy/widgets/chooseversiondialog.cpp
  31. 1 4
      src/Legacy/widgets/chooseversiondialog.h
  32. 9 4
      src/Legacy/widgets/helpwidget.cpp
  33. 5 6
      src/Legacy/widgets/helpwidget.h
  34. 101 155
      src/Legacy/widgets/mainwindow.cpp
  35. 30 28
      src/Legacy/widgets/mainwindow.h
  36. 10 34
      src/Legacy/widgets/settingswidget.cpp
  37. 5 15
      src/Legacy/widgets/settingswidget.h
  38. 8 63
      src/Legacy/widgets/statuswidget.cpp
  39. 5 17
      src/Legacy/widgets/statuswidget.h

+ 18 - 6
src/Legacy/Legacy.pro

@@ -17,9 +17,7 @@ SOURCES += \
     main.cpp \
     models/downloader.cpp \
     models/lotrodatmanager.cpp \
-    models/patchdownloader.cpp \
     models/selfupdater.cpp \
-    models/internallogicmanager.cpp \
     widgets/helpwidget.cpp \
     widgets/mainwindow.cpp \
     widgets/menuentry.cpp \
@@ -33,15 +31,21 @@ SOURCES += \
     widgets/weeklycodewidget.cpp \
     widgets/dialogwindow.cpp \
     widgets/qsmoothscrollarea.cpp \
-    fonts.cpp
+    fonts.cpp \
+    models/patch/patch.cpp \
+    models/patch/soundspatch.cpp \
+    models/patch/videospatch.cpp \
+    models/patch/textspatch.cpp \
+    models/patch/graphicspatch.cpp \
+    models/lotrodatmanagerobserver.cpp \
+    models/patchlist.cpp \
+    legacyapplication.cpp
 
 HEADERS += \
     models/downloader.h \
     models/filesystem.h \
     models/lotrodatmanager.h \
-    models/patchdownloader.h \
     models/selfupdater.h \
-    models/internallogicmanager.h \
     widgets/helpwidget.h \
     widgets/mainwindow.h \
     widgets/menuentry.h \
@@ -57,7 +61,15 @@ HEADERS += \
     widgets/qsmoothscrollarea.h \
     constants.h \
     fonts.h \
-    models/settings.h
+    models/settings.h \
+    models/patch/patch.h \
+    models/patch/soundspatch.h \
+    models/patch/videospatch.h \
+    models/patch/textspatch.h \
+    models/patch/graphicspatch.h \
+    models/lotrodatmanagerobserver.h \
+    models/patchlist.h \
+    legacyapplication.h
 
 FORMS += \
     widgets/helpwidget.ui \

+ 68 - 0
src/Legacy/legacyapplication.cpp

@@ -0,0 +1,68 @@
+#include "legacyapplication.h"
+
+LegacyApplication::LegacyApplication(int &argc, char **argv)
+    : QApplication(argc, argv)
+    , lotro_dat_manager(nullptr)
+    , lotro_dat_manager_thread(nullptr)
+    , patch_list(nullptr)
+    , gui(nullptr)
+{
+}
+
+LegacyApplication::~LegacyApplication()
+{
+}
+
+bool LegacyApplication::init()
+{
+    qDebug() << __func__ << "Starting initialisation...";
+
+    QCoreApplication::setOrganizationName("LotroLegacy");
+    QCoreApplication::setOrganizationDomain("translate.lotros.ru");
+    QCoreApplication::setApplicationName("Legacy_v2");
+
+    QSettings::setDefaultFormat(QSettings::IniFormat);
+    QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationDirPath());
+    QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QApplication::applicationDirPath());
+
+    qDebug() << __func__ << "Checking if there's another instance of Legacy";
+
+    QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));
+    if(!lockFile.tryLock(1)){
+        qDebug() << __func__ << "Lock file already exists! Some other application is already running...";
+        QMessageBox msgBox;
+        msgBox.setIcon(QMessageBox::Warning);
+        msgBox.setText("Приложение уже запущено.\nРазрешено запускать только один экземпляр приложения.");
+        msgBox.exec();
+        return false;
+    }
+
+    qDebug() << __func__ << "Initialising fonts and resources";
+
+    QResource::registerResource(QApplication::applicationDirPath() + "/data01.gtr");
+    QResource::registerResource(QApplication::applicationDirPath() + "/data02.gtr");
+
+    QFontDatabase::addApplicationFont(":/fonts/trpro.ttf");
+    QFontDatabase::addApplicationFont(":/fonts/CrimsonText.ttf");
+    QFontDatabase::addApplicationFont(":/fonts/EBGaramond.ttf");
+    QFontDatabase::addApplicationFont(":/fonts/aniron.ttf");
+
+    qDebug() << __func__ << "Starting Lotro Manager initialization...";
+
+    lotro_dat_manager = new LotroDatManager();
+    lotro_dat_manager_thread = new QThread();
+    connect(lotro_dat_manager_thread, &QThread::finished, lotro_dat_manager, &LotroDatManager::deleteLater);
+    lotro_dat_manager->moveToThread(lotro_dat_manager_thread);
+    lotro_dat_manager_thread->start();
+
+    qDebug() << __func__ << "Starting Patch list initialisation...";
+
+    patch_list = new PatchList(lotro_dat_manager);
+
+    qDebug() << __func__ << "Starting GUI initialisation...";
+
+    gui = new MainWindow(patch_list);
+    qDebug() << __func__ << "Legacy Initialization finished!";
+
+    return true;
+}

+ 37 - 0
src/Legacy/legacyapplication.h

@@ -0,0 +1,37 @@
+#ifndef LEGACYAPPLICATION_H
+#define LEGACYAPPLICATION_H
+
+#include <QObject>
+#include <QApplication>
+#include <QThread>
+#include <QMessageBox>
+#include <QLockFile>
+#include <QDir>
+#include <QTextCodec>
+#include <QDebug>
+#include <QResource>
+#include <QFontDatabase>
+
+#include "models/lotrodatmanager.h"
+#include "models/patchlist.h"
+#include "widgets/mainwindow.h"
+
+class LegacyApplication : public QApplication
+{
+
+public:
+    LegacyApplication(int &argc, char** argv);
+    virtual ~LegacyApplication() final;
+
+    bool init();
+
+private:
+    LotroDatManager *lotro_dat_manager;
+    QThread *lotro_dat_manager_thread;
+
+    PatchList *patch_list;
+
+    MainWindow *gui;
+};
+
+#endif // LEGACYAPPLICATION_H

+ 4 - 43
src/Legacy/main.cpp

@@ -1,14 +1,4 @@
-#include <QApplication>
-#include <QMessageBox>
-#include <QLockFile>
-#include <QDir>
-
-#include "widgets/mainwindow.h"
-
-#include <QTextCodec>
-#include <QDebug>
-#include <QResource>
-#include <QFontDatabase>
+#include "legacyapplication.h"
 
 // Global. Should be updated only by MainWindow!!!
 double window_height = 1000;
@@ -17,40 +7,11 @@ double window_width = 648;
 int main(int argc, char *argv[])
 {
     setlocale(LC_ALL,"Russian");
-    QApplication a(argc, argv);
-
-    QCoreApplication::setOrganizationName("LotroLegacy");
-    QCoreApplication::setOrganizationDomain("translate.lotros.ru");
-    QCoreApplication::setApplicationName("Legacy_v2");
-    QSettings::setDefaultFormat(QSettings::IniFormat);
-    QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationDirPath());
-    QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QApplication::applicationDirPath());
-
-    qDebug() << "Checking if there's another instance of Legacy";
+    LegacyApplication app(argc, argv);
 
-    QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));
-    if(!lockFile.tryLock(1)){
-        QMessageBox msgBox;
-        msgBox.setIcon(QMessageBox::Warning);
-        msgBox.setText("Приложение уже запущено.\nРазрешено запускать только один экземпляр приложения.");
-        msgBox.exec();
+    if (!app.init()) {
         return 1;
     }
 
-    qDebug() << "Initialising fonts and resources";
-    QResource::registerResource(QApplication::applicationDirPath() + "/data01.gtr");
-    QResource::registerResource(QApplication::applicationDirPath() + "/data02.gtr");
-
-    QFontDatabase::addApplicationFont(":/fonts/trpro.ttf");
-    QFontDatabase::addApplicationFont(":/fonts/CrimsonText.ttf");
-    QFontDatabase::addApplicationFont(":/fonts/EBGaramond.ttf");
-    QFontDatabase::addApplicationFont(":/fonts/aniron.ttf");
-
-    qDebug() << "Starting main frame initialisation...";
-
-    MainWindow* main_window = new MainWindow(nullptr);
-    main_window->setAttribute(Qt::WA_DeleteOnClose);
-
-    qDebug() << "Finished initialisation, starting application...";
-    return a.exec();
+    return app.exec();
 }

+ 3 - 3
src/Legacy/models/downloader.h

@@ -15,7 +15,7 @@ class Downloader : public QObject
 
 public:
     struct Status {
-        bool started;
+        bool running;
         double percent;
 
         quint64 total_bytes;
@@ -25,9 +25,9 @@ public:
         quint64 elapsed_time;
     };
 
-    Status operator+(const Status& a, const Status &b) {
+    friend Status operator+(const Status& a, const Status &b) {
         Status result = {
-            a.started || b.started,
+            a.running || b.running,
             (a.percent + b.percent) / 2.0,
             a.total_bytes + b.total_bytes,
             a.downloaded_bytes + b.downloaded_bytes,

+ 1 - 0
src/Legacy/models/filesystem.h

@@ -7,6 +7,7 @@
 #include <QFileInfo>
 #include <QCryptographicHash>
 #include <QDebug>
+#include <QSettings>
 
 namespace FileSystem {
     static bool fileExists(QString path) {

+ 49 - 26
src/Legacy/models/lotrodatmanager.cpp

@@ -1,6 +1,7 @@
 #include "lotrodatmanager.h"
 #include "models/filesystem.h"
 #include "models/settings.h"
+#include "models/lotrodatmanagerobserver.h"
 
 #include <QDebug>
 #include <QProcess>
@@ -13,21 +14,43 @@ LotroDatManager::LotroDatManager(QObject *parent) :
     QObject(parent) {
 
     qRegisterMetaType<LOTRO_DAT::DatLocaleManager::LOCALE>();
+    observer_ = new LotroDatManagerObserver(this);
+}
+
+LotroDatManager::~LotroDatManager()
+{
+    deinitializeManager();
+    delete observer_;
 }
 
 bool LotroDatManager::Initialised()
 {
-    return client_general_file.Initialized() && client_local_file.Initialized();
+    return client_general_file_.Initialized() && client_local_file_.Initialized();
 }
 
 bool LotroDatManager::NotPatched()
 {
-    return !client_local_file.GetStatusModule().CheckIfNotPatched() && !client_local_file.GetStatusModule().CheckIfNotPatched();
+    return !client_local_file_.GetStatusModule().CheckIfNotPatched() && !client_local_file_.GetStatusModule().CheckIfNotPatched();
+}
+
+LotroDatManager::Status LotroDatManager::getStatus()
+{
+    Status result;
+    result.status = client_local_file_.GetStatusModule().GetStatus();
+    result.percent = client_local_file_.GetStatusModule().GetPercentage();
+    result.dbg_message = QString::fromStdString(client_local_file_.GetStatusModule().GetDebugMessage());
+
+//        client_local_file_.GetStatusModule().GetStatus(),
+//        double(client_local_file_.GetStatusModule().GetPercentage()),
+//        QString::fromStdString(client_local_file_.GetStatusModule().GetDebugMessage())
+//    };
+
+    return result;
 }
 
-unsigned LotroDatManager::getPercent()
+LotroDatManagerObserver *LotroDatManager::getObserver()
 {
-    return client_local_file.GetStatusModule().GetPercentage();
+    return observer_;
 }
 
 void LotroDatManager::initializeManager()
@@ -66,14 +89,14 @@ void LotroDatManager::initializeManager()
 
     // Initialising client_local_*.dat file and client_general.dat
 
-    auto client_local_init_res = client_local_file.Initialise(client_local_filepath.toStdString(), 0);
-    auto client_general_init_res = client_general_file.Initialise(client_general_filepath.toStdString(), 1);
+    auto client_local_init_res = client_local_file_.Initialise(client_local_filepath.toStdString(), 0);
+    auto client_general_init_res = client_general_file_.Initialise(client_general_filepath.toStdString(), 1);
 
     if (client_local_init_res.result != LOTRO_DAT::SUCCESS
         || client_general_init_res.result != LOTRO_DAT::SUCCESS)
     {
-        client_local_file.Deinitialize();
-        client_general_file.Deinitialize();
+        client_local_file_.Deinitialize();
+        client_general_file_.Deinitialize();
 
         qDebug() << __FUNCTION__ << "Finished LotroDatManager initialisation - error: DatFile initialisation error!";
 
@@ -88,8 +111,8 @@ void LotroDatManager::initializeManager()
 void LotroDatManager::deinitializeManager()
 {
     emit operationStarted("deinitializeManager");
-    client_local_file.Deinitialize();
-    client_general_file.Deinitialize();
+    client_local_file_.Deinitialize();
+    client_general_file_.Deinitialize();
     emit operationFinished("deinitializeManager");
 }
 
@@ -97,8 +120,8 @@ void LotroDatManager::startGame(LOTRO_DAT::DatLocaleManager::LOCALE locale)
 {
     emit operationStarted("startGame", {locale});
 
-    client_general_file.GetLocaleManager().SetLocale(locale);
-    client_local_file.GetLocaleManager().SetLocale(locale);
+    client_general_file_.GetLocaleManager().SetLocale(locale);
+    client_local_file_.GetLocaleManager().SetLocale(locale);
 
     QString game_folder = Settings::getValue("Lotro/game_path").toString();
 
@@ -168,14 +191,14 @@ void LotroDatManager::installPatch(QString patch_name, QString database_path)
         return;
     }
 
-    if (client_local_file.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
+    if (client_local_file_.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
         db.CloseDatabase();
         emit errorOccured("installPatch", {patch_name, database_path}, "ErrorPatchClientLocal");
         emit operationFinished("installPatch", {patch_name, database_path}, false);
         return;
     }
 
-    if (client_general_file.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
+    if (client_general_file_.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
         db.CloseDatabase();
         emit errorOccured("installPatch", {patch_name, database_path});
         emit operationFinished("installPatch", {patch_name, database_path}, false);
@@ -190,13 +213,13 @@ void LotroDatManager::enableCategory(QString patch_name, LotroDatManager::Catego
 {
     emit operationStarted("enableCategory", {patch_name, category});
 
-    if (client_local_file.GetLocaleManager().EnableCategory(category).result != LOTRO_DAT::SUCCESS) {
+    if (client_local_file_.GetLocaleManager().EnableCategory(category).result != LOTRO_DAT::SUCCESS) {
         emit errorOccured("enableCategory", {patch_name, category}, "ErrorEnableCategoryClientLocal");
         emit operationFinished("enableCategory", {patch_name, category}, false);
         return;
     }
 
-    if (client_general_file.GetLocaleManager().EnableCategory(category).result != LOTRO_DAT::SUCCESS) {
+    if (client_general_file_.GetLocaleManager().EnableCategory(category).result != LOTRO_DAT::SUCCESS) {
         emit errorOccured("enableCategory", {patch_name, category}, "ErrorEnableCategoryClientGeneral");
         emit operationFinished("enableCategory", {patch_name, category}, false);
         return;
@@ -209,13 +232,13 @@ void LotroDatManager::disableCategory(QString patch_name, LotroDatManager::Categ
 {
     emit operationStarted("disableCategory", {patch_name, category});
 
-    if (client_local_file.GetLocaleManager().DisableCategory(category).result != LOTRO_DAT::SUCCESS) {
+    if (client_local_file_.GetLocaleManager().DisableCategory(category).result != LOTRO_DAT::SUCCESS) {
         emit errorOccured("disableCategory", {patch_name, category}, "ErrorDisableCategoryClientLocal");
         emit operationFinished("disableCategory", {patch_name, category}, false);
         return;
     }
 
-    if (client_general_file.GetLocaleManager().DisableCategory(category).result != LOTRO_DAT::SUCCESS) {
+    if (client_general_file_.GetLocaleManager().DisableCategory(category).result != LOTRO_DAT::SUCCESS) {
         emit errorOccured("disableCategory", {patch_name, category}, "ErrorDisableCategoryClientGeneral");
         emit operationFinished("disableCategory", {patch_name, category}, false);
         return;
@@ -229,8 +252,8 @@ void LotroDatManager::createBackup()
     // TODO: Error handling
     emit operationStarted("createBackup");
     QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
-    client_local_file.GetBackupManager().CreateBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
-    client_general_file.GetBackupManager().CreateBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
+    client_local_file_.GetBackupManager().CreateBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
+    client_general_file_.GetBackupManager().CreateBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
     emit operationFinished("createBackup");
 }
 
@@ -239,8 +262,8 @@ void LotroDatManager::restoreFromBackup()
     // TODO: Error handling
     emit operationStarted("restoreFromBackup");
     QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
-    client_local_file.GetBackupManager().RestoreFromBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
-    client_general_file.GetBackupManager().RestoreFromBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
+    client_local_file_.GetBackupManager().RestoreFromBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
+    client_general_file_.GetBackupManager().RestoreFromBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
     emit operationFinished("restoreFromBackup");
 }
 
@@ -249,8 +272,8 @@ void LotroDatManager::removeBackup()
     // TODO: Error handling
     emit operationStarted("removeBackup");
     QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
-    client_local_file.GetBackupManager().RemoveBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
-    client_general_file.GetBackupManager().RemoveBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
+    client_local_file_.GetBackupManager().RemoveBackup((QApplication::applicationDirPath() + "/backup/client_local_" + locale_prefix + ".dat").toStdString());
+    client_general_file_.GetBackupManager().RemoveBackup((QApplication::applicationDirPath() + "/backup/client_general.dat").toStdString());
     emit operationFinished("removeBackup");
 }
 
@@ -269,8 +292,8 @@ bool LotroDatManager::startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManag
         args << "gamelaunch" << "-disablePatch";
     }
 
-    client_general_file.Deinitialize();
-    client_local_file.Deinitialize();
+    client_general_file_.Deinitialize();
+    client_local_file_.Deinitialize();
 
     QString username = Settings::getValue("Account/username").toString();
     QString password = Settings::getValue("Account/password").toString();

+ 24 - 4
src/Legacy/models/lotrodatmanager.h

@@ -9,16 +9,30 @@
 
 #include <LotroDat/LotroDat.h>
 
+using LOTRO_DAT::DatStatus;
+
+class LotroDatManagerObserver;
+
 class LotroDatManager : public QObject
 {
     Q_OBJECT
 
 public:
+    struct Status {
+        DatStatus::DAT_STATUS status;
+        double percent;
+        QString dbg_message;
+    };
+
+    friend bool operator !=(const Status& a, const Status& b) {
+        return a.status != b.status || a.percent != b.percent;
+    }
+
     enum Category : int {
         E_TEXTS_COMMON = 100,
         E_TEXTS_ITEMS = 101,
         E_TEXTS_EMOTES = 102,
-        E_TEXTS_VIDEOS = 103,
+        E_VIDEOS_PATHS = 103,
         E_MAPS_COMMON = 200,
         E_TEXTURES_COMMON = 201,
         E_AUDIOS_COMMON = 300
@@ -27,11 +41,15 @@ public:
 public:
     explicit LotroDatManager(QObject *parent = nullptr);
 
+    ~LotroDatManager();
+
     bool Initialised();
 
     bool NotPatched();
 
-    unsigned getPercent();
+    Status getStatus();
+
+    LotroDatManagerObserver *getObserver();
 
 public slots:
     void initializeManager();
@@ -61,8 +79,10 @@ signals:
     void operationFinished(QString operation_name, QVector<QVariant> args = {}, bool successful = true);
 
 private:
-    LOTRO_DAT::DatFile client_local_file;
-    LOTRO_DAT::DatFile client_general_file;
+    LotroDatManagerObserver* observer_;
+
+    LOTRO_DAT::DatFile client_local_file_;
+    LOTRO_DAT::DatFile client_general_file_;
 };
 
 #endif // LEGACYAPP_H

+ 24 - 0
src/Legacy/models/lotrodatmanagerobserver.cpp

@@ -0,0 +1,24 @@
+#include "lotrodatmanagerobserver.h"
+
+#include <QDebug>
+
+LotroDatManagerObserver::LotroDatManagerObserver(LotroDatManager *mgr, QObject *parent) : QObject(parent), lotro_manager_(mgr)
+{
+}
+
+void LotroDatManagerObserver::startTimer()
+{
+    connect(&status_update_timer_, &QTimer::timeout, this, &updateStatus);
+    status_update_timer_.setInterval(200);
+    status_update_timer_.start();
+}
+
+void LotroDatManagerObserver::updateStatus()
+{
+    LotroDatManager::Status status = lotro_manager_->getStatus();
+    if (status != status_) {
+        qDebug() << "Dat status changed! Percentage: " << status.percent;
+        status_ = status;
+        emit statusChanged(status);
+    }
+}

+ 28 - 0
src/Legacy/models/lotrodatmanagerobserver.h

@@ -0,0 +1,28 @@
+#ifndef LOTRODATMANAGEROBSERVER_H
+#define LOTRODATMANAGEROBSERVER_H
+
+#include <QObject>
+#include <QTimer>
+
+#include "models/lotrodatmanager.h"
+
+class LotroDatManagerObserver : public QObject
+{
+    Q_OBJECT
+public:
+    explicit LotroDatManagerObserver(LotroDatManager* mgr, QObject *parent = nullptr);
+    void startTimer();
+
+signals:
+    void statusChanged(LotroDatManager::Status status);
+
+private slots:
+    void updateStatus();
+
+private:
+    LotroDatManager* lotro_manager_;
+    LotroDatManager::Status status_;
+    QTimer status_update_timer_;
+};
+
+#endif // LOTRODATMANAGEROBSERVER_H

+ 40 - 0
src/Legacy/models/patch/graphicspatch.cpp

@@ -0,0 +1,40 @@
+#include "graphicspatch.h"
+#include "LotroDat/LotroDat.h"
+#include "LotroDat/Database.h"
+#include "models/lotrodatmanagerobserver.h"
+
+#include <QUrlQuery>
+#include <QSet>
+#include <QThread>
+
+GraphicsPatch::GraphicsPatch(LotroDatManager *mgr, QObject *parent) : Patch("GraphicsPatch", mgr, parent)
+{
+}
+
+void GraphicsPatch::checkForUpdates()
+{
+    emit operationStarted("checkForUpdates", this);
+    QThread::sleep(1);
+    emit operationFinished("checkForUpdates",  this, true);
+}
+
+void GraphicsPatch::download()
+{
+    emit operationStarted("download", this);
+    QThread::sleep(5);
+    emit operationFinished("download", this, true);
+}
+
+void GraphicsPatch::install()
+{
+    emit operationStarted("install", this);
+    QThread::sleep(5);
+    emit operationFinished("install", this, true);
+}
+
+void GraphicsPatch::activate()
+{
+    emit operationStarted("activate", this);
+    QThread::sleep(5);
+    emit operationFinished("activate", this, true);
+}

+ 45 - 0
src/Legacy/models/patch/graphicspatch.h

@@ -0,0 +1,45 @@
+#ifndef IMAGESPATCH_H
+#define IMAGESPATCH_H
+
+#include <QObject>
+
+#include "models/patch/patch.h"
+#include "models/lotrodatmanager.h"
+
+class GraphicsPatch : public Patch
+{
+    Q_OBJECT
+
+public:
+    GraphicsPatch(LotroDatManager* mgr, QObject* parent = nullptr);
+
+public slots:
+    virtual void checkForUpdates() override;
+    virtual void download() override;
+    virtual void install() override;
+    virtual void activate() override;
+
+private slots:
+//    void onDownloaderProgressChanged(Downloader* ptr, Downloader::Status status);
+//    void onDownloaderFinished(Downloader* ptr);
+//    void onLotroDatManagerOperationFinished(QString operation_name, QVector<QVariant> args, bool successful);
+//    void onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args);
+//    void onLotroDatManagerStatusChanged(LotroDatManager::Status status);
+
+private:
+    const QStringList databases_names = {
+        "image",
+        "texture",
+        "loadscreen",
+    };
+
+//    void installLoadscreens();
+//    void enableLoadscreens();
+//    void disableLoadscreens();
+
+//    quint8 elapsed_patches_to_download_ = 0; // for download process
+//    quint8 elapsed_databases_to_install_ = 0; // for install process
+//    quint8 elapsed_categories_to_activate_ = 0; // for activate/deactivate process
+};
+
+#endif // IMAGESPATCH_H

+ 64 - 0
src/Legacy/models/patch/patch.cpp

@@ -0,0 +1,64 @@
+#include "patch.h"
+#include "models/settings.h"
+#include "models/filesystem.h"
+#include "models/lotrodatmanager.h"
+
+#include <QUrlQuery>
+
+Patch::Patch(QString patch_name, LotroDatManager* mgr, QObject *parent)
+    : QObject(parent)
+    , patch_name_(patch_name)
+    , lotro_mgr_(mgr)
+{
+    status_.process = CurrentProcess::E_FINISHED;
+    status_.percent = 0;
+    status_.debug_msg = "";
+}
+
+bool Patch::needDownloadDatabase(QString db_name)
+{
+    QString patch_filename = Settings::getValue("PatchDatabases/" + db_name + "/path").toString();
+    QString current_file_hash = FileSystem::fileHash(patch_filename);
+    QString required_file_hash = Settings::getValue("PatchDatabases/" + db_name + "/hashsum").toString();
+    return isDatabaseDownloadEnabled(db_name) && (current_file_hash != required_file_hash);
+}
+
+bool Patch::isDatabaseDownloadEnabled(QString db_name)
+{
+    if (db_name == "text") {
+        return Settings::getValue("Components/texts_main").toBool() ||
+               Settings::getValue("Components/texts_items").toBool() ||
+               Settings::getValue("Components/texts_emotes").toBool();
+    }
+
+    if (db_name == "font") {
+        return Settings::getValue("Components/fonts").toBool();
+    }
+
+    if (db_name == "image") {
+        return Settings::getValue("Components/maps").toBool();
+    }
+
+    if (db_name == "texture") {
+        return Settings::getValue("Components/logos").toBool();
+    }
+
+    if (db_name == "loadscreen") {
+        return Settings::getValue("Components/loadscreens").toBool();
+    }
+
+    if (db_name == "sound") {
+        return Settings::getValue("Components/sounds").toBool();
+    }
+
+    if (db_name == "video") {
+        return Settings::getValue("Components/video").toBool();
+    }
+
+    return false;
+}
+
+QString Patch::getPatchName()
+{
+    return patch_name_;
+}

+ 65 - 0
src/Legacy/models/patch/patch.h

@@ -0,0 +1,65 @@
+#ifndef LEGACYPATCH_H
+#define LEGACYPATCH_H
+
+#include <QObject>
+
+#include "models/downloader.h"
+#include "models/filesystem.h"
+#include "models/lotrodatmanager.h"
+#include "models/settings.h"
+
+class Patch : public QObject
+{
+    Q_OBJECT
+
+public:
+    enum class CurrentProcess {
+        E_AWAITING_INSTALL,
+        E_INSTALL,
+        E_AWAITING_APPLY,
+        E_APPLY,
+        E_FINISHED
+    };
+
+    struct InstallationStatus {
+        CurrentProcess process;
+        int current_part; // Ex. "installation (current_part/total_parts) percent%"
+        int total_parts;
+        double percent;
+        QString debug_msg;
+    };
+
+public:
+    explicit Patch(QString patch_name, LotroDatManager* mgr, QObject *parent);
+
+    QString getPatchName();
+
+public slots: // WARNING: THESE CAN BE NON-BLOCKING OPERATIONS! Use them in chain only via operationFinished signal handlers.
+
+    virtual void checkForUpdates() = 0; // Checks for updates. Updates patches info in Settings.
+    virtual void download() = 0; // Downloads patch contents, prepared for installation.
+    virtual void install() = 0; // Installs patch into game resources (need to be enabled after install to be activated)
+    virtual void activate() = 0; // Activates (or deactivates) patch components based on user preferences (patch needs to be installed)
+
+signals: // each signal brings with it pointer to this class
+
+    void operationStarted(QString operation_name, Patch* patch);
+    void errorOccured(QString operation_name, Patch* patch, QString msg);
+    void operationFinished(QString operation_name, Patch* patch, bool result);
+
+    void downloadStatusChanged(Patch* patch, Downloader::Status status);
+    void installStatusChanged(Patch* patch, InstallationStatus status);
+
+private:
+    bool needDownloadDatabase(QString db_name);
+
+    static bool isDatabaseDownloadEnabled(QString db_name); // Checks if this database needs to be downloaded (comparing with user parameters)
+
+private:
+    LotroDatManager* lotro_mgr_;
+    QString patch_name_;
+    QSet<Downloader*> downloaders_;
+    InstallationStatus status_;
+};
+
+#endif // LEGACYPATCH_H

+ 40 - 0
src/Legacy/models/patch/soundspatch.cpp

@@ -0,0 +1,40 @@
+#include "soundspatch.h"
+#include "LotroDat/LotroDat.h"
+#include "LotroDat/Database.h"
+#include "models/lotrodatmanagerobserver.h"
+
+#include <QUrlQuery>
+#include <QSet>
+#include <QThread>
+
+SoundsPatch::SoundsPatch(LotroDatManager *mgr, QObject *parent) : Patch("SoundsPatch", mgr, parent)
+{
+}
+
+void SoundsPatch::checkForUpdates()
+{
+    emit operationStarted("checkForUpdates", this);
+    QThread::sleep(1);
+    emit operationFinished("checkForUpdates",  this, true);
+}
+
+void SoundsPatch::download()
+{
+    emit operationStarted("download", this);
+    QThread::sleep(5);
+    emit operationFinished("download", this, true);
+}
+
+void SoundsPatch::install()
+{
+    emit operationStarted("install", this);
+    QThread::sleep(5);
+    emit operationFinished("install", this, true);
+}
+
+void SoundsPatch::activate()
+{
+    emit operationStarted("activate", this);
+    QThread::sleep(5);
+    emit operationFinished("activate", this, true);
+}

+ 44 - 0
src/Legacy/models/patch/soundspatch.h

@@ -0,0 +1,44 @@
+#ifndef SOUNDSPATCH_H
+#define SOUNDSPATCH_H
+
+#include <QObject>
+
+#include "models/patch/patch.h"
+
+class SoundsPatch : public Patch
+{
+    Q_OBJECT
+
+public:
+    SoundsPatch(LotroDatManager* mgr, QObject* parent = nullptr);
+
+public slots:
+    virtual void checkForUpdates() override;
+    virtual void download() override;
+    virtual void install() override;
+    virtual void activate() override;
+
+private slots:
+//    void onDownloaderProgressChanged(Downloader* ptr, Downloader::Status status);
+//    void onDownloaderFinished(Downloader* ptr);
+//    void onLotroDatManagerOperationFinished(QString operation_name, QVector<QVariant> args, bool successful);
+//    void onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args);
+//    void onLotroDatManagerStatusChanged(LotroDatManager::Status status);
+
+private:
+    const QStringList databases_names = {
+        "image",
+        "texture",
+        "loadscreen",
+    };
+
+//    void installLoadscreens();
+//    void enableLoadscreens();
+//    void disableLoadscreens();
+
+//    quint8 elapsed_patches_to_download_ = 0; // for download process
+//    quint8 elapsed_databases_to_install_ = 0; // for install process
+//    quint8 elapsed_categories_to_activate_ = 0; // for activate/deactivate process
+};
+
+#endif // SOUNDSPATCH_H

+ 40 - 0
src/Legacy/models/patch/textspatch.cpp

@@ -0,0 +1,40 @@
+#include "textspatch.h"
+#include "LotroDat/LotroDat.h"
+#include "LotroDat/Database.h"
+#include "models/lotrodatmanagerobserver.h"
+
+#include <QUrlQuery>
+#include <QSet>
+#include <QThread>
+
+TextsPatch::TextsPatch(LotroDatManager *mgr, QObject *parent) : Patch("TextsPatch", mgr, parent)
+{
+}
+
+void TextsPatch::checkForUpdates()
+{
+    emit operationStarted("checkForUpdates", this);
+    QThread::sleep(1);
+    emit operationFinished("checkForUpdates",  this, true);
+}
+
+void TextsPatch::download()
+{
+    emit operationStarted("download", this);
+    QThread::sleep(5);
+    emit operationFinished("download", this, true);
+}
+
+void TextsPatch::install()
+{
+    emit operationStarted("install", this);
+    QThread::sleep(5);
+    emit operationFinished("install", this, true);
+}
+
+void TextsPatch::activate()
+{
+    emit operationStarted("activate", this);
+    QThread::sleep(5);
+    emit operationFinished("activate", this, true);
+}

+ 43 - 0
src/Legacy/models/patch/textspatch.h

@@ -0,0 +1,43 @@
+#ifndef TEXTPATCH_H
+#define TEXTPATCH_H
+
+#include <QObject>
+
+#include "models/patch/patch.h"
+
+class TextsPatch : public Patch
+{
+    Q_OBJECT
+
+public:
+    TextsPatch(LotroDatManager* mgr, QObject* parent = nullptr);
+
+public slots:
+    virtual void checkForUpdates() override;
+    virtual void download() override;
+    virtual void install() override;
+    virtual void activate() override;
+
+private slots:
+//    void onDownloaderProgressChanged(Downloader* ptr, Downloader::Status status);
+//    void onDownloaderFinished(Downloader* ptr);
+//    void onLotroDatManagerOperationFinished(QString operation_name, QVector<QVariant> args, bool successful);
+//    void onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args);
+//    void onLotroDatManagerStatusChanged(LotroDatManager::Status status);
+
+private:
+    const QStringList databases_names = {
+        "image",
+        "texture",
+        "loadscreen",
+    };
+
+//    void installLoadscreens();
+//    void enableLoadscreens();
+//    void disableLoadscreens();
+
+//    quint8 elapsed_patches_to_download_ = 0; // for download process
+//    quint8 elapsed_databases_to_install_ = 0; // for install process
+//    quint8 elapsed_categories_to_activate_ = 0; // for activate/deactivate process
+};
+#endif // TEXTPATCH_H

+ 40 - 0
src/Legacy/models/patch/videospatch.cpp

@@ -0,0 +1,40 @@
+#include "videospatch.h"
+#include "LotroDat/LotroDat.h"
+#include "LotroDat/Database.h"
+#include "models/lotrodatmanagerobserver.h"
+
+#include <QUrlQuery>
+#include <QSet>
+#include <QThread>
+
+VideosPatch::VideosPatch(LotroDatManager *mgr, QObject *parent) : Patch("VideosPatch", mgr, parent)
+{
+}
+
+void VideosPatch::checkForUpdates()
+{
+    emit operationStarted("checkForUpdates", this);
+    QThread::sleep(1);
+    emit operationFinished("checkForUpdates",  this, true);
+}
+
+void VideosPatch::download()
+{
+    emit operationStarted("download", this);
+    QThread::sleep(5);
+    emit operationFinished("download", this, true);
+}
+
+void VideosPatch::install()
+{
+    emit operationStarted("install", this);
+    QThread::sleep(5);
+    emit operationFinished("install", this, true);
+}
+
+void VideosPatch::activate()
+{
+    emit operationStarted("activate", this);
+    QThread::sleep(5);
+    emit operationFinished("activate", this, true);
+}

+ 44 - 0
src/Legacy/models/patch/videospatch.h

@@ -0,0 +1,44 @@
+#ifndef VIDEOSPATCH_H
+#define VIDEOSPATCH_H
+
+#include <QObject>
+
+#include "models/patch/patch.h"
+
+class VideosPatch : public Patch
+{
+    Q_OBJECT
+
+public:
+    VideosPatch(LotroDatManager* mgr, QObject* parent = nullptr);
+
+public slots:
+    virtual void checkForUpdates() override;
+    virtual void download() override;
+    virtual void install() override;
+    virtual void activate() override;
+
+private slots:
+//    void onDownloaderProgressChanged(Downloader* ptr, Downloader::Status status);
+//    void onDownloaderFinished(Downloader* ptr);
+//    void onLotroDatManagerOperationFinished(QString operation_name, QVector<QVariant> args, bool successful);
+//    void onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args);
+//    void onLotroDatManagerStatusChanged(LotroDatManager::Status status);
+
+private:
+    const QStringList databases_names = {
+        "image",
+        "texture",
+        "loadscreen",
+    };
+
+//    void installLoadscreens();
+//    void enableLoadscreens();
+//    void disableLoadscreens();
+
+//    quint8 elapsed_patches_to_download_ = 0; // for download process
+//    quint8 elapsed_databases_to_install_ = 0; // for install process
+//    quint8 elapsed_categories_to_activate_ = 0; // for activate/deactivate process
+};
+
+#endif // VIDEOSPATCH_H

+ 0 - 299
src/Legacy/models/patchdownloader.cpp

@@ -1,299 +0,0 @@
-#include "patchdownloader.h"
-#include "models/filesystem.h"
-#include "models/settings.h"
-#include <QApplication>
-#include <QDir>
-#include <QStringList>
-#include <QUrlQuery>
-#include <QVariant>
-#include <QDebug>
-
-Q_DECLARE_METATYPE(QList<PatchDownloadData>)
-
-PatchDownloader::PatchDownloader(QObject *parent) : QObject(parent), patch_download_dir(QApplication::applicationDirPath() + "/data")
-{
-    qRegisterMetaType<QList<PatchDownloadData>>();
-    active_downloads_number = 0;
-
-    connect(&update_check_timer, &QTimer::timeout, this, &PatchDownloader::checkForUpdates);
-    update_check_timer.setInterval(1000 * 60 * 5); // 5 minutes
-    update_check_timer.start();
-}
-
-PatchDownloader::~PatchDownloader()
-{
-    foreach (Downloader* downloader, downloads_list) {
-        downloader->waitForDownloaded();
-        downloader->deleteLater();
-    }
-}
-
-QString PatchDownloader::getPredictedDownloadSizeFormatted()
-{
-    double mbytes = 0;
-
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 650;
-    }
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 80;
-    }
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 120;
-    }
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 3;
-    }
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 4;
-    }
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 1;
-    }
-    if (Settings::getValue("DatabaseDownload/sound").toString() == "Enabled") {
-        mbytes += 2100;
-    }
-
-    QString unit = "Мб";
-    if (mbytes > 1024) {
-        mbytes /= 1024;
-        unit = "Гб";
-    }
-
-    return QString::number(mbytes, 'f', 1) + " " + unit;
-}
-
-QString PatchDownloader::getDatabasePathByPatchName(QString name)
-{
-    return patch_download_dir.absolutePath() + "/" + patch_data[name].url.fileName();
-}
-
-void PatchDownloader::checkForUpdates()
-{
-    foreach (QString patch_name, all_patch_names) {
-        if (downloads_list.contains(patch_name))
-            continue;
-
-        downloads_list[patch_name] = new Downloader();
-        connect(downloads_list[patch_name], &Downloader::progressChanged, this, &PatchDownloader::onDownloaderProgressChanged);
-        connect(downloads_list[patch_name], &Downloader::downloadFinished, this, &PatchDownloader::onDownloaderCompleted);
-    }
-
-    if (active_downloads_number > 0) {
-        qDebug() << "PatchDownloader: downloads are not ready yet, passing checkForUpdates";
-        return;
-    }
-
-    emit checkForUpdatesStarted();
-    if (!updatePatchList()) {
-        emit checkForUpdatesFinished();
-        return;
-    }
-    removeOldPatchesFromDirecrory();
-    DownloadMissingPatches();
-    qDebug() << "Finished checking for updates!";
-    emit checkForUpdatesFinished();
-}
-
-void PatchDownloader::onDownloaderCompleted(Downloader *downloader_ptr)
-{
-    if (downloader_ptr->targetFile) {
-        downloader_ptr->targetFile->close();
-        downloader_ptr->targetFile->deleteLater();
-    }
-
-    QString patch_finished_download_name = "none";
-
-    foreach (QString patch_name, downloads_list.keys()) {
-        if (downloads_list[patch_name] == downloader_ptr)
-            patch_finished_download_name = patch_name;
-    }
-
-    if (patch_finished_download_name != "none") {
-        QString patch_filepath = patch_download_dir.absolutePath() + "/" + patch_data[patch_finished_download_name].url.fileName();
-        Settings::setValue("DatabaseDownloadDate/" + patch_data[patch_finished_download_name].name, QDate::currentDate().toString("dd.MM.yyyy"));
-        Settings::setValue("DatabaseApplied/" + patch_data[patch_finished_download_name].name, "False");
-        Settings::setValue("DatabasePath/" + patch_data[patch_finished_download_name].name, patch_filepath);
-
-        emit changePatchStatus(patch_finished_download_name, "Загрузка завершена");
-    }
-
-    active_downloads_number--;
-
-    if (active_downloads_number == 0) {
-        emit downloadCompleted();
-    }
-}
-
-void PatchDownloader::onDownloaderProgressChanged(Downloader*)
-{
-
-    quint64 totalSize = 0;
-    quint64 downloadedSize = 0;
-    quint64 summary_speed = 0;
-    quint64 time_elapsed = 0;
-
-    foreach (Downloader* downloader, downloads_list) {
-        totalSize += downloader->getBytesTotal();
-        downloadedSize += downloader->getBytesDownloaded();
-
-        if (downloader->getBytesTotal() != downloader->getBytesDownloaded()) {
-            summary_speed += downloader->getSpeed();
-        }
-    }
-
-    time_elapsed = (totalSize - downloadedSize) / qMax(quint64(1), summary_speed);
-
-    QList<PatchDownloadData> download_data;
-    download_data << PatchDownloadData({"general", downloadedSize, totalSize, Downloader::getSpeedFormatted(summary_speed), Downloader::getElapsedTimeFormatted(time_elapsed)});
-
-    foreach (QString patch_name, downloads_list.keys()) {
-        Downloader* patch_download = downloads_list[patch_name];
-        if (patch_download->isStarted()) {
-            download_data << PatchDownloadData({patch_name, patch_download->getBytesDownloaded(), patch_download->getBytesTotal(),
-                             Downloader::getSpeedFormatted(patch_download->getSpeed()),
-                             Downloader::getElapsedTimeFormatted(patch_download->getElapsedTime())});
-        }
-    }
-
-    emit progressChanged(download_data);
-}
-
-int PatchDownloader::versionFromPatchFilename(QString filename)
-{
-    int version = 0;
-    for (int i = filename.indexOf("_v") + 2; i < filename.indexOf("_v") + 7; i += 2) {
-        version = version * 10 + (filename.at(i).toLatin1() - '0');
-    }
-    return version;
-}
-
-bool PatchDownloader::updatePatchList()
-{
-    QUrlQuery query; // query for building GET-request aka patch-version
-
-    foreach (QString patch_name, all_patch_names) {
-        query.addQueryItem(patch_name, "100");
-    }
-
-    QUrl target_url;
-    target_url.setUrl("http://translate.lotros.ru/groupware/check_updates");
-    target_url.setQuery(query);
-
-    QByteArray target_array;
-    Downloader downloader;
-    downloader.setUrl(target_url);
-    downloader.targetBytearray = &target_array;
-    downloader.start();
-    downloader.waitForDownloaded();
-
-    if (target_array.isEmpty()) {
-        qDebug() << __FUNCTION__ << "Cannot download, target_array is empty!";
-        emit getPatchListError();
-        return false;
-    }
-
-    QStringList entry_list = QString(target_array).split('|');
-
-    if (entry_list.size() != all_patch_names.size()) {
-        qDebug() << __FUNCTION__ << "Entry list size is not equal to patch names size!" << QString(target_array);
-        emit getPatchListError();
-        return false;
-    }
-
-    for (int i = 0; i < entry_list.size(); ++i) {
-        QStringList current_patch_data = entry_list[i].split(":::");
-        if (current_patch_data.size() != 3) {
-            qDebug() << __FUNCTION__ << "Incorrect patch entry size! Entry: " << entry_list[i];
-            emit getPatchListError();
-            return false;
-        }
-        patch_data[all_patch_names[i]] = {current_patch_data[0], current_patch_data[1], current_patch_data[2], all_patch_names[i]};
-    }
-    return true;
-}
-
-bool PatchDownloader::removeOldPatchesFromDirecrory()
-{
-    QStringList actual_hash_list;
-    foreach (Patch patch, patch_data) {
-        actual_hash_list.append(patch.md5_hash);
-    }
-
-    qDebug() << "Removing old patches. Current hash list " << actual_hash_list;
-
-    QStringList paths = patch_download_dir.entryList(QDir::Files);
-
-    foreach (QString filename, paths) {
-        QString hash = FileSystem::fileHash(patch_download_dir.absolutePath() + "/" + filename, QCryptographicHash::Md5);
-        if (!actual_hash_list.contains(hash)) {
-            qDebug() << "File " << filename << " with hash " << hash << "seems outdated, deleting!";
-            if (!QFile::remove(patch_download_dir.absolutePath() + "/" +filename)) {
-                qDebug() << __FUNCTION__ << "Unable to remove file " << filename;
-                emit removeFileError(patch_download_dir.absolutePath() + "/" + filename);
-            }
-        }
-    }
-    return true;
-}
-
-bool PatchDownloader::DownloadMissingPatches()
-{
-    QDir dir(patch_download_dir);
-    if (!dir.exists())
-        QDir().mkdir(patch_download_dir.absolutePath());
-
-    bool download_started = false;
-
-    foreach (Patch patch, patch_data) {
-        QString patch_filepath = patch_download_dir.absolutePath() + "/" + patch.url.fileName();
-
-        qDebug() << "Patch" << patch.name << "is marked as" << Settings::getValue("DatabaseDownload/" + patch.name).toString();
-
-        if (Settings::getValue("DatabaseDownload/" + patch.name).toString() != "Enabled") {
-            emit changePatchStatus(patch.name, "Не выбраны для установки");
-            continue;
-        }
-
-        if (FileSystem::fileExists(patch_filepath)) {
-            if (FileSystem::fileHash(patch_filepath, QCryptographicHash::Md5) == patch.md5_hash) {
-                Settings::setValue("DatabasePath/" + patch.name, patch_filepath);
-                QString download_date = Settings::getValue("DatabaseDownloadDate/" + patch.name).toString();
-                emit changePatchStatus(patch.name, "Актуальная версия (" + download_date + ")");
-                continue;
-            }
-
-            Settings::setValue("DatabasePath/" + patch.name, "none");
-
-            if (!QFile::remove(patch_filepath)) {
-                qDebug() << __FUNCTION__ << "Unable to remove file " << patch_filepath;
-                emit changePatchStatus(patch.name, "Ошибка обновления 0x1");
-                emit removeFileError(patch_filepath);
-                continue;
-            }
-        }
-
-        emit changePatchStatus(patch.name, "Ожидает скачивания");
-
-        if (!download_started) {
-            download_started = true;
-            qDebug() << "Started downloads of PatchDownloader!";
-            emit downloadStarted();
-        }
-
-        qDebug() << "Starting download of file " << patch_filepath << " from url " << patch.url;
-
-        downloads_list[patch.name]->setUrl(patch.url);
-        downloads_list[patch.name]->targetFile = new QFile(patch_filepath, downloads_list[patch.name]);
-        downloads_list[patch.name]->targetFile->open(QIODevice::ReadWrite);
-        downloads_list[patch.name]->start();
-        active_downloads_number++;
-    }
-
-    foreach (Patch patch, patch_data) {
-        downloads_list[patch.name]->waitForDownloaded();
-    }
-
-    qDebug() << "Finished downloading patches!";
-    return true;
-}

+ 0 - 79
src/Legacy/models/patchdownloader.h

@@ -1,79 +0,0 @@
-#ifndef PATCHDOWNLOADER_H
-#define PATCHDOWNLOADER_H
-
-#include <QObject>
-#include <QTimer>
-#include <QDate>
-#include <QDir>
-#include <QSettings>
-#include <QMap>
-#include "models/downloader.h"
-
-struct Patch {
-    QUrl url;
-    QString md5_hash;
-    QString datetime;
-    QString name;
-};
-
-struct PatchDownloadData {
-    QString patch_name;
-    quint64 bytesDownloaded;
-    quint64 bytesTotal;
-    QString download_speed_formatted;
-    QString elapsed_time_formatted;
-};
-
-class PatchDownloader : public QObject
-{
-    Q_OBJECT
-public:
-    explicit PatchDownloader(QObject *parent = nullptr);
-    ~PatchDownloader();
-    void enableAutoUpdate();
-    void disableAutoUpdate();
-    void stopAllDownloads();
-    void startAllDownloads();
-    QString getPredictedDownloadSizeFormatted();
-    QString getDatabasePathByPatchName(QString name);
-
-public slots:
-    void checkForUpdates();
-
-private slots:
-    void onDownloaderCompleted(Downloader* downloader_ptr);
-    void onDownloaderProgressChanged(Downloader* downloader_ptr);
-
-signals:
-    void checkForUpdatesStarted();
-    void checkForUpdatesFinished();
-    void getPatchListError();
-    void removeFileError(QString filename);
-    void downloadNewFilesError();
-
-    void downloadCompleted();
-    void downloadStarted();
-    void progressChanged(QList<PatchDownloadData>);
-
-    void changePatchStatus(QString patch_name, QString status);
-    void patchDateChanged(QString patch_name, QDate patch_date);
-
-private:
-    int versionFromPatchFilename(QString filename);
-    bool updatePatchList();
-    bool removeOldPatchesFromDirecrory();
-    bool DownloadMissingPatches();
-
-private:
-    quint8 active_downloads_number = 0;
-
-    const QDir patch_download_dir;
-    const QStringList all_patch_names = {"sound", "text", "image", "loadscreen", "texture", "font", "video"};
-
-    QTimer update_check_timer;
-
-    QMap<QString, Downloader*> downloads_list;
-    QMap<QString, Patch> patch_data;
-};
-
-#endif // PATCHDOWNLOADER_H

+ 87 - 0
src/Legacy/models/patchlist.cpp

@@ -0,0 +1,87 @@
+#include "patchlist.h"
+
+#include <QDebug>
+
+PatchList::PatchList(LotroDatManager *mgr, QObject *parent)
+{
+    texts_patch_ = new TextsPatch(mgr);
+    graphics_patch_ = new GraphicsPatch(mgr);
+    sounds_patch_ = new SoundsPatch(mgr);
+    videos_patch_ = new VideosPatch(mgr);
+
+    texts_patch_thread_ = new QThread(this);
+    graphics_patch_thread_ = new QThread(this);
+    sounds_patch_thread_ = new QThread(this);
+    videos_patch_thread_ = new QThread(this);
+
+    connect(texts_patch_thread_, &QThread::finished, texts_patch_, &TextsPatch::deleteLater);
+    connect(graphics_patch_thread_, &QThread::finished, graphics_patch_, &GraphicsPatch::deleteLater);
+    connect(sounds_patch_thread_, &QThread::finished, sounds_patch_, &SoundsPatch::deleteLater);
+    connect(videos_patch_thread_, &QThread::finished, videos_patch_, &VideosPatch::deleteLater);
+
+    texts_patch_->moveToThread(texts_patch_thread_);
+    graphics_patch_->moveToThread(graphics_patch_thread_);
+    sounds_patch_->moveToThread(sounds_patch_thread_);
+    videos_patch_->moveToThread(videos_patch_thread_);
+
+    texts_patch_thread_->start();
+    graphics_patch_thread_->start();
+    sounds_patch_thread_->start();
+    videos_patch_thread_->start();
+
+    patch_update_timer.setInterval(10 * 60 * 1000); // 10 minutes
+    connect(&patch_update_timer, &QTimer::timeout, this, &PatchList::onUpdateTimerTimeout);
+}
+
+const TextsPatch *PatchList::getTextsPatch()
+{
+    return texts_patch_;
+}
+
+const GraphicsPatch *PatchList::getGraphicsPatch()
+{
+    return graphics_patch_;
+}
+
+const SoundsPatch *PatchList::getSoundsPatch()
+{
+    return sounds_patch_;
+}
+
+const VideosPatch *PatchList::getVideosPatch()
+{
+    return videos_patch_;
+}
+
+void PatchList::onPatchOperationStarted(QString operation_name, Patch *patch)
+{
+    qDebug() << "Operation " << operation_name << " started of patchset " << patch->getPatchName();
+}
+
+void PatchList::onPatchOperationFinished(QString operation_name, Patch *patch, bool result)
+{
+    qDebug() << "Operation " << operation_name << " finished of patchset " << patch->getPatchName() << ", result = " << result;
+    if (!result) {
+        return; // Do not continue operations chain, if error occured
+    }
+
+    if (operation_name == "checkForUpdates") {
+        QMetaObject::invokeMethod(patch, &Patch::download, Qt::QueuedConnection);
+    }
+
+    if (operation_name == "download") {
+        QMetaObject::invokeMethod(patch, &Patch::install, Qt::QueuedConnection);
+    }
+
+    if (operation_name == "install") {
+        QMetaObject::invokeMethod(patch, &Patch::activate, Qt::QueuedConnection);
+    }
+}
+
+void PatchList::onUpdateTimerTimeout()
+{
+    QMetaObject::invokeMethod(texts_patch_, &TextsPatch::checkForUpdates, Qt::QueuedConnection);
+    QMetaObject::invokeMethod(graphics_patch_, &GraphicsPatch::checkForUpdates, Qt::QueuedConnection);
+    QMetaObject::invokeMethod(sounds_patch_, &SoundsPatch::checkForUpdates, Qt::QueuedConnection);
+    QMetaObject::invokeMethod(videos_patch_, &VideosPatch::checkForUpdates, Qt::QueuedConnection);
+}

+ 51 - 0
src/Legacy/models/patchlist.h

@@ -0,0 +1,51 @@
+#ifndef PATCHLIST_H
+#define PATCHLIST_H
+
+#include <QObject>
+#include <QTimer>
+#include <QThread>
+
+#include "models/patch/patch.h"
+#include "models/patch/textspatch.h"
+#include "models/patch/graphicspatch.h"
+#include "models/patch/soundspatch.h"
+#include "models/patch/videospatch.h"
+
+class PatchList : public QObject
+{
+    Q_OBJECT
+public:
+    explicit PatchList(LotroDatManager* mgr, QObject *parent = nullptr);
+
+    const TextsPatch *getTextsPatch();
+
+    const GraphicsPatch *getGraphicsPatch();
+
+    const SoundsPatch *getSoundsPatch();
+
+    const VideosPatch *getVideosPatch();
+
+
+public slots:
+    void onPatchOperationStarted(QString operation_name, Patch* patch);
+
+    void onPatchOperationFinished(QString operation_name, Patch* patch, bool result);
+
+    void onUpdateTimerTimeout();
+
+private:
+    TextsPatch *texts_patch_;
+    GraphicsPatch *graphics_patch_;
+    SoundsPatch *sounds_patch_;
+    VideosPatch *videos_patch_;
+
+    QThread *texts_patch_thread_;
+    QThread *graphics_patch_thread_;
+    QThread *sounds_patch_thread_;
+    QThread *videos_patch_thread_;
+
+private:
+    QTimer patch_update_timer;
+};
+
+#endif // PATCHLIST_H

+ 28 - 16
src/Legacy/models/settings.h

@@ -10,7 +10,7 @@ static QMap<QString, QVariant> defaults = {
     // General info
     {"General/UI_scale", "100"},
     {"General/CurrentInitStage", "0"},
-    {"General/MicroUpdates", "Disabled"},
+    {"General/MicroUpdates", false},
     {"General/PatchDownloadDir", "data"},
 
     // Lotro Manager
@@ -20,23 +20,35 @@ static QMap<QString, QVariant> defaults = {
     {"Lotro/no_splash_screen", "True"},
 
     // Databases download settings
-    {"DatabaseDownload/sound", "Disabled"},
-    {"DatabaseDownload/text", "Disabled"},
-    {"DatabaseDownload/image", "Disabled"},
-    {"DatabaseDownload/loadscreen", "Disabled"},
-    {"DatabaseDownload/texture", "Disabled"},
-    {"DatabaseDownload/font", "Disabled"},
-    {"DatabaseDownload/video", "Disabled"},
+
+    {"DatabaseDownload/text", false},          // TextsPatch
+    {"DatabaseDownload/font", false},          // TextsPatch
+    {"DatabaseDownload/image", false},         // GraphicsPatch
+    {"DatabaseDownload/loadscreen", false},    // GraphicsPatch
+    {"DatabaseDownload/texture", false},       // GraphicsPatch
+    {"DatabaseDownload/sound", false},         // SoundsPatch
+    {"DatabaseDownload/video", false},         // VideosPatch
+
+    // Flags, meaning that database is fresh and needs to be installed
+
+    {"DatabaseUpdated/text", false},           // TextsPatch
+    {"DatabaseUpdated/font", false},           // TextsPatch
+    {"DatabaseUpdated/image", false},          // GraphicsPatch
+    {"DatabaseUpdated/loadscreen", false},     // GraphicsPatch
+    {"DatabaseUpdated/texture", false},        // GraphicsPatch
+    {"DatabaseUpdated/sound", false},          // SoundsPatch
+    {"DatabaseUpdated/video", false},          // VideosPatch
 
     // Localisation components
-    {"Components/fonts", "Disabled"},
-    {"Components/texts_main", "Disabled"},
-    {"Components/texts_items", "Disabled"},
-    {"Components/texts_emotes", "Disabled"},
-    {"Components/maps", "Disabled"},
-    {"Components/loadscreens", "Disabled"},
-    {"Components/sounds", "Disabled"},
-    {"Components/videos", "Disabled"},
+    {"Components/fonts", false},               // TextsPatch
+    {"Components/texts_main", false},          // TextsPatch
+    {"Components/texts_items", false},         // TextsPatch
+    {"Components/texts_emotes", false},        // TextsPatch
+    {"Components/maps", false},                // ImagesPatch
+    {"Components/loadscreens", false},         // ImagesPatch
+    {"Components/textures", false},            // ImagesPatch
+    {"Components/sounds", false},              // SoundsPatch
+    {"Components/videos", false},              // VideosPatch
 
     // Network
     {"Network/site_url", "http://translate.lotros.ru/"},

+ 15 - 4
src/Legacy/object_script.Legacy.Debug

@@ -4,9 +4,7 @@ INPUT(
 ./..\..\build\debug\Legacy\obj\main.o
 ./..\..\build\debug\Legacy\obj\downloader.o
 ./..\..\build\debug\Legacy\obj\lotrodatmanager.o
-./..\..\build\debug\Legacy\obj\patchdownloader.o
 ./..\..\build\debug\Legacy\obj\selfupdater.o
-./..\..\build\debug\Legacy\obj\internallogicmanager.o
 ./..\..\build\debug\Legacy\obj\helpwidget.o
 ./..\..\build\debug\Legacy\obj\mainwindow.o
 ./..\..\build\debug\Legacy\obj\menuentry.o
@@ -21,12 +19,18 @@ INPUT(
 ./..\..\build\debug\Legacy\obj\dialogwindow.o
 ./..\..\build\debug\Legacy\obj\qsmoothscrollarea.o
 ./..\..\build\debug\Legacy\obj\fonts.o
+./..\..\build\debug\Legacy\obj\patch.o
+./..\..\build\debug\Legacy\obj\soundspatch.o
+./..\..\build\debug\Legacy\obj\videospatch.o
+./..\..\build\debug\Legacy\obj\textspatch.o
+./..\..\build\debug\Legacy\obj\graphicspatch.o
+./..\..\build\debug\Legacy\obj\lotrodatmanagerobserver.o
+./..\..\build\debug\Legacy\obj\patchlist.o
+./..\..\build\debug\Legacy\obj\legacyapplication.o
 ./..\..\build\debug\Legacy\obj\legacy_plugin_import.o
 ./..\..\build\debug\Legacy\obj\moc_downloader.o
 ./..\..\build\debug\Legacy\obj\moc_lotrodatmanager.o
-./..\..\build\debug\Legacy\obj\moc_patchdownloader.o
 ./..\..\build\debug\Legacy\obj\moc_selfupdater.o
-./..\..\build\debug\Legacy\obj\moc_internallogicmanager.o
 ./..\..\build\debug\Legacy\obj\moc_helpwidget.o
 ./..\..\build\debug\Legacy\obj\moc_mainwindow.o
 ./..\..\build\debug\Legacy\obj\moc_menuentry.o
@@ -40,4 +44,11 @@ INPUT(
 ./..\..\build\debug\Legacy\obj\moc_weeklycodewidget.o
 ./..\..\build\debug\Legacy\obj\moc_dialogwindow.o
 ./..\..\build\debug\Legacy\obj\moc_qsmoothscrollarea.o
+./..\..\build\debug\Legacy\obj\moc_patch.o
+./..\..\build\debug\Legacy\obj\moc_soundspatch.o
+./..\..\build\debug\Legacy\obj\moc_videospatch.o
+./..\..\build\debug\Legacy\obj\moc_textspatch.o
+./..\..\build\debug\Legacy\obj\moc_graphicspatch.o
+./..\..\build\debug\Legacy\obj\moc_lotrodatmanagerobserver.o
+./..\..\build\debug\Legacy\obj\moc_patchlist.o
 );

+ 15 - 4
src/Legacy/object_script.Legacy.Release

@@ -2,9 +2,7 @@ INPUT(
 ./..\..\build\release\Legacy\obj\main.o
 ./..\..\build\release\Legacy\obj\downloader.o
 ./..\..\build\release\Legacy\obj\lotrodatmanager.o
-./..\..\build\release\Legacy\obj\patchdownloader.o
 ./..\..\build\release\Legacy\obj\selfupdater.o
-./..\..\build\release\Legacy\obj\internallogicmanager.o
 ./..\..\build\release\Legacy\obj\helpwidget.o
 ./..\..\build\release\Legacy\obj\mainwindow.o
 ./..\..\build\release\Legacy\obj\menuentry.o
@@ -19,12 +17,18 @@ INPUT(
 ./..\..\build\release\Legacy\obj\dialogwindow.o
 ./..\..\build\release\Legacy\obj\qsmoothscrollarea.o
 ./..\..\build\release\Legacy\obj\fonts.o
+./..\..\build\release\Legacy\obj\patch.o
+./..\..\build\release\Legacy\obj\soundspatch.o
+./..\..\build\release\Legacy\obj\videospatch.o
+./..\..\build\release\Legacy\obj\textspatch.o
+./..\..\build\release\Legacy\obj\graphicspatch.o
+./..\..\build\release\Legacy\obj\lotrodatmanagerobserver.o
+./..\..\build\release\Legacy\obj\patchlist.o
+./..\..\build\release\Legacy\obj\legacyapplication.o
 ./..\..\build\release\Legacy\obj\legacy_plugin_import.o
 ./..\..\build\release\Legacy\obj\moc_downloader.o
 ./..\..\build\release\Legacy\obj\moc_lotrodatmanager.o
-./..\..\build\release\Legacy\obj\moc_patchdownloader.o
 ./..\..\build\release\Legacy\obj\moc_selfupdater.o
-./..\..\build\release\Legacy\obj\moc_internallogicmanager.o
 ./..\..\build\release\Legacy\obj\moc_helpwidget.o
 ./..\..\build\release\Legacy\obj\moc_mainwindow.o
 ./..\..\build\release\Legacy\obj\moc_menuentry.o
@@ -38,4 +42,11 @@ INPUT(
 ./..\..\build\release\Legacy\obj\moc_weeklycodewidget.o
 ./..\..\build\release\Legacy\obj\moc_dialogwindow.o
 ./..\..\build\release\Legacy\obj\moc_qsmoothscrollarea.o
+./..\..\build\release\Legacy\obj\moc_patch.o
+./..\..\build\release\Legacy\obj\moc_soundspatch.o
+./..\..\build\release\Legacy\obj\moc_videospatch.o
+./..\..\build\release\Legacy\obj\moc_textspatch.o
+./..\..\build\release\Legacy\obj\moc_graphicspatch.o
+./..\..\build\release\Legacy\obj\moc_lotrodatmanagerobserver.o
+./..\..\build\release\Legacy\obj\moc_patchlist.o
 );

+ 9 - 11
src/Legacy/widgets/aboutwidget.cpp

@@ -1,19 +1,17 @@
-#include "widgets/aboutwidget.h"
 #include "ui_aboutwidget.h"
-#include "models/filesystem.h"
-#include "models/lotrodatmanager.h"
-#include "widgets/mainwindow.h"
-#include "constants.h"
+
+#include "models/patchlist.h"
 #include "models/settings.h"
+#include "constants.h"
+
+#include "widgets/aboutwidget.h"
 
-#include <QDebug>
-#include <QFileDialog>
-#include <QMessageBox>
 #include <QDesktopServices>
 
-AboutWidget::AboutWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent) :
-    QWidget(parent), lotro_manager(lotro_dat_manager),
-    ui(new Ui::AboutWidget)
+AboutWidget::AboutWidget(PatchList *legacy_patches, QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::AboutWidget)
+    , legacy_patches_(legacy_patches)
 {
     ui->setupUi(this);
 }

+ 4 - 8
src/Legacy/widgets/aboutwidget.h

@@ -2,22 +2,19 @@
 #define AboutWidget_H
 
 #include <QWidget>
-#include <QTimer>
-#include <QSettings>
 
 namespace Ui {
 class AboutWidget;
 }
 
-class PatchDownloader;
-class LotroDatManager;
+class PatchList;
 
 class AboutWidget : public QWidget
 {
     Q_OBJECT
 
 public:
-    explicit AboutWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent = 0);
+    explicit AboutWidget(PatchList* legacy_patches, QWidget *parent = 0);
     ~AboutWidget();
 
 public slots:
@@ -36,10 +33,9 @@ private slots:
     void on_goto_donate_clicked();
 
 private:
-    PatchDownloader* patch_updater;
-    LotroDatManager* lotro_manager;
-
     Ui::AboutWidget *ui;
+
+    PatchList *legacy_patches_;
 };
 
 #endif // AboutWidget_H

+ 4 - 7
src/Legacy/widgets/chooseversiondialog.cpp

@@ -1,21 +1,18 @@
 #include "chooseversiondialog.h"
 #include "ui_chooseversiondialog.h"
 
-#include "models/lotrodatmanager.h"
-#include "models/patchdownloader.h"
 #include "models/settings.h"
 #include "widgets/mainwindow.h"
 #include "constants.h"
 
-ChooseVersionDialog::ChooseVersionDialog(PatchDownloader *patch_downloader, LotroDatManager *lotro_dat_manager, QWidget *parent) :
-    QWidget(parent), lotro_manager(lotro_dat_manager),
+ChooseVersionDialog::ChooseVersionDialog(QWidget *parent) :
+    QWidget(parent),
     ui(new Ui::ChooseVersionDialog)
 {
 //    setWindowModality(Qt::WindowModal);
     ui->setupUi(this);
     ui->wait_widget->hide();
     ui->cancel_widget->show();
-
 }
 
 ChooseVersionDialog::~ChooseVersionDialog()
@@ -44,14 +41,14 @@ void ChooseVersionDialog::on_start_patched_clicked()
 {
     ui->wait_widget->show();
     ui->cancel_widget->hide();
-    QMetaObject::invokeMethod(lotro_manager, "StartGame", Qt::QueuedConnection, Q_ARG(LOTRO_DAT::DatLocaleManager::LOCALE, LOTRO_DAT::DatLocaleManager::PATCHED));
+//    QMetaObject::invokeMethod(lotro_manager, "StartGame", Qt::QueuedConnection, Q_ARG(LOTRO_DAT::DatLocaleManager::LOCALE, LOTRO_DAT::DatLocaleManager::PATCHED));
 }
 
 void ChooseVersionDialog::on_start_original_clicked()
 {
     ui->wait_widget->show();
     ui->cancel_widget->hide();
-    QMetaObject::invokeMethod(lotro_manager, "StartGame", Qt::QueuedConnection, Q_ARG(LOTRO_DAT::DatLocaleManager::LOCALE, LOTRO_DAT::DatLocaleManager::ORIGINAL));
+//    QMetaObject::invokeMethod(lotro_manager, "StartGame", Qt::QueuedConnection, Q_ARG(LOTRO_DAT::DatLocaleManager::LOCALE, LOTRO_DAT::DatLocaleManager::ORIGINAL));
 }
 
 void ChooseVersionDialog::on_cancel_clicked()

+ 1 - 4
src/Legacy/widgets/chooseversiondialog.h

@@ -17,7 +17,7 @@ class ChooseVersionDialog : public QWidget
     Q_OBJECT
 
 public:
-    explicit ChooseVersionDialog(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent = 0);
+    explicit ChooseVersionDialog(QWidget *parent = 0);
     ~ChooseVersionDialog();
 
 public slots:
@@ -41,9 +41,6 @@ signals:
     void cancelled();
 
 private:
-    PatchDownloader* patch_updater;
-    LotroDatManager* lotro_manager;
-
     Ui::ChooseVersionDialog *ui;
     QPoint dragPosition;
 };

+ 9 - 4
src/Legacy/widgets/helpwidget.cpp

@@ -1,11 +1,16 @@
-#include "widgets/HelpWidget.h"
 #include "ui_HelpWidget.h"
+
+#include "models/patchlist.h"
+
+#include "widgets/helpwidget.h"
+
 #include <QDebug>
 #include <QScrollBar>
 
-HelpWidget::HelpWidget(PatchDownloader*, LotroDatManager*, QWidget *parent) :
-    QWidget(parent),
-    ui(new Ui::HelpWidget)
+HelpWidget::HelpWidget(PatchList* legacy_patches, QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::HelpWidget)
+    , legacy_patches_(legacy_patches)
 {
     ui->setupUi(this);
     currently_active_entry = ui->menuentry_1;

+ 5 - 6
src/Legacy/widgets/helpwidget.h

@@ -11,15 +11,14 @@ namespace Ui {
 class HelpWidget;
 }
 
-class PatchDownloader;
-class LotroDatManager;
+class PatchList;
 
 class HelpWidget : public QWidget
 {
     Q_OBJECT
 
 public:
-    explicit HelpWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent = 0);
+    explicit HelpWidget(PatchList *legacy_patches, QWidget *parent = 0);
 
     ~HelpWidget();
 
@@ -48,14 +47,14 @@ private slots:
     void on_menuentry_5_clicked();
 
 private:
-    PatchDownloader* patch_updater;
-    LotroDatManager* lotro_manager;
+    Ui::HelpWidget *ui;
+
+    PatchList *legacy_patches_;
 
     QPushButton* currently_active_entry = nullptr;
     QPropertyAnimation* menuHoverWidgetAnimation = nullptr;
     QPropertyAnimation* scrollAreaContentsAnimation = nullptr;
 
-    Ui::HelpWidget *ui;
 };
 
 #endif // HelpWidget_H

+ 101 - 155
src/Legacy/widgets/mainwindow.cpp

@@ -2,9 +2,6 @@
 #include "ui_mainwindow.h"
 #include "constants.h"
 
-#include "models/patchdownloader.h"
-#include "models/lotrodatmanager.h"
-
 #include "widgets/chooseversiondialog.h"
 #include "widgets/dialogwindow.h"
 
@@ -23,91 +20,84 @@
 #include <QNetworkAccessManager>
 
 #include <ui_statuswidget.h>
+
 namespace Ui {
 class StatusWidget;
 }
 
-
-MainWindow::MainWindow(QWidget *parent) :
-    QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint),
-    ui(new Ui::MainWindow), menuHoverWidget(nullptr), menuHoverWidgetAnimation(nullptr)
+MainWindow::MainWindow(PatchList *legacy_patches, QWidget *parent)
+    : QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint)
+    , legacy_patches_(legacy_patches)
+    , ui(new Ui::MainWindow)
+    , current_active_entry_(nullptr)
+    , current_hovered_entry_(nullptr)
+    , status_widget_(nullptr)
+    , settings_widget_(nullptr)
+    , help_widget_(nullptr)
+    , about_widget_(nullptr)
+    , choose_locale_dialog_(nullptr)
+    , dialog_window_(nullptr)
+    , menu_hover_widget_(nullptr)
+    , menu_hover_widget_animation_(nullptr)
 {
     constructFonts();
     ui->setupUi(this);
 
-    currently_active_entry = ui->menuentry_1;
-    currently_hover_entry = nullptr;
-
-    qDebug() << "Creating patch downloader instance & thread";
-    lotro_functions_thread = new QThread();
-    patch_updater = new PatchDownloader();
-    lotro_manager = new LotroDatManager();
-
-//    connect(patch_updater, &PatchDownloader::checkForUpdatesStarted, this, &MainWindow::onPatchDownloaderStarted, Qt::BlockingQueuedConnection);
-//    connect(patch_updater, &PatchDownloader::checkForUpdatesFinished, this, &MainWindow::onPatchDownloaderFinished, Qt::BlockingQueuedConnection);
-//    connect(lotro_manager, &LotroDatManager::processStarted, this, &MainWindow::onLotroManagerStarted, Qt::BlockingQueuedConnection);
-//    connect(lotro_manager, &LotroDatManager::processFinished, this, &MainWindow::onLotroManagerFinished, Qt::BlockingQueuedConnection);
-//    connect(lotro_manager, &LotroDatManager::caughtError, this, &MainWindow::onLotroManagerErrorOccured, Qt::BlockingQueuedConnection);
+    current_active_entry_ = ui->menuentry_1;
+    current_hovered_entry_ = nullptr;
 
-    connect(lotro_functions_thread, &QThread::finished, patch_updater, &QObject::deleteLater, Qt::QueuedConnection);
-    connect(lotro_functions_thread, &QThread::finished, lotro_manager, &QObject::deleteLater, Qt::QueuedConnection);
-    patch_updater->moveToThread(lotro_functions_thread);
-    lotro_manager->moveToThread(lotro_functions_thread);
-    lotro_functions_thread->start();
+    qDebug() << __FUNCTION__ << "Initialising main frame...";
+    status_widget_ = new StatusWidget(legacy_patches_, this);
+    settings_widget_ = new SettingsWidget(legacy_patches_, this);
+    help_widget_ = new HelpWidget(legacy_patches_, this);
+    about_widget_ = new AboutWidget(legacy_patches_, this);
 
-    qDebug() << "Initialising lotro manager...";
-    QMetaObject::invokeMethod(lotro_manager, "InitialiseManager", Qt::QueuedConnection);
+    ui->content_layout->addWidget(status_widget_);
+    ui->content_layout->addWidget(settings_widget_);
+    ui->content_layout->addWidget(help_widget_);
+    ui->content_layout->addWidget(about_widget_);
 
-    status_widget = new StatusWidget(patch_updater, lotro_manager, this);
-    settings_widget = new SettingsWidget(patch_updater, lotro_manager, this);
-    help_widget = new HelpWidget(patch_updater, lotro_manager, this);
-    about_widget = new AboutWidget(patch_updater, lotro_manager, this);
-
-    choose_locale_dialog = new ChooseVersionDialog(patch_updater, lotro_manager, this);
-    choose_locale_dialog->resize(size());
-    choose_locale_dialog->hide();
-    connect(choose_locale_dialog, &ChooseVersionDialog::cancelled, this, &MainWindow::hideChooseVersionDialog);
+    hideAllContentWidgets();
+    status_widget_->show();
 
-    dialog_window = new DialogWindow(this);
-    dialog_window->resize(size());
+    qDebug() << __FUNCTION__ << "Initialising additional frames...";
 
-    ui->content_layout->addWidget(status_widget);
-    ui->content_layout->addWidget(settings_widget);
-    ui->content_layout->addWidget(help_widget);
-    ui->content_layout->addWidget(about_widget);
+    choose_locale_dialog_ = new ChooseVersionDialog(this);
+    choose_locale_dialog_->resize(size());
+    choose_locale_dialog_->hide();
+    connect(choose_locale_dialog_, &ChooseVersionDialog::cancelled, choose_locale_dialog_, &ChooseVersionDialog::hide);
 
-    hideAllContentWidgets();
-    status_widget->show();
+    dialog_window_ = new DialogWindow(this);
+    dialog_window_->resize(size());
 
-    qDebug() << "Making background";
+    qDebug() << __FUNCTION__ << "Making background";
 
     qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
-    current_bg_id = qrand() % MAX_PIXMAP_ID + 1;
-    QPixmap background(":/backgrounds/bg" + QString::number(current_bg_id) + ".png");
+    current_bg_id_ = qrand() % MAX_PIXMAP_ID + 1;
+    QPixmap background(":/backgrounds/bg" + QString::number(current_bg_id_) + ".png");
     setupWindowBackgroundAndMask(background);
 
     setupMenuHoverWidget();
 
-    qDebug() << "Initialising background updates";
-    background_update_timer.setInterval(30 * 1000);
-    connect(&background_update_timer, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
-    background_update_timer.start();
+    qDebug() << __FUNCTION__ << "Initialising background updates";
+    background_update_timer_.setInterval(30 * 1000);
+    connect(&background_update_timer_, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
+    background_update_timer_.start();
 
-    qDebug() << "Initialising main window connections";
+    qDebug() << __FUNCTION__ << "Initialising main window connections";
     makeConnections();
 
-    qDebug() << "Installing event filters to clickable objects";
+    qDebug() << __FUNCTION__ << "Installing event filters to clickable objects";
     setEventFilterRecursive(this);
 
-    qDebug() << "Finishing main frame initialisation";
+    qDebug() << __FUNCTION__ << "Finished main frame initialisation";
     show();
-    QMetaObject::invokeMethod(patch_updater, "checkForUpdates");
 }
 
 void MainWindow::mousePressEvent(QMouseEvent *event)
 {
     if (event->button() == Qt::LeftButton) {
-        dragPosition = event->globalPos() - frameGeometry().topLeft();
+        drag_position_ = event->globalPos() - frameGeometry().topLeft();
         event->accept();
     }
 }
@@ -115,7 +105,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
 void MainWindow::mouseMoveEvent(QMouseEvent *event)
 {
     if (event->buttons() & Qt::LeftButton) {
-        move(event->globalPos() - dragPosition);
+        move(event->globalPos() - drag_position_);
         event->accept();
     }
 }
@@ -139,17 +129,17 @@ void MainWindow::resizeEvent(QResizeEvent * event)
 
     ui->content_area->move(0, height * 110 / default_window_height);
     ui->content_area->resize(width * 1000 / default_window_width, height * 538 / default_window_height);
-    setupWindowBackgroundAndMask(current_bg);
-    choose_locale_dialog->resize(event->size());
+    setupWindowBackgroundAndMask(current_bg_);
+    choose_locale_dialog_->resize(event->size());
 
     ui->closeButton->setMinimumSize(width * 20 / default_window_width, height * 20 / default_window_height);
     ui->minimizeButton->setMinimumSize(width * 20 / default_window_width, height * 20 / default_window_height);
 
-    choose_locale_dialog->move({0, 0});
-    choose_locale_dialog->resize(event->size());
+    choose_locale_dialog_->move({0, 0});
+    choose_locale_dialog_->resize(event->size());
 
-    dialog_window->move({0, 0});
-    dialog_window->resize(size());
+    dialog_window_->move({0, 0});
+    dialog_window_->resize(size());
     updateFontSizes();
 }
 
@@ -158,18 +148,17 @@ void MainWindow::randomChangeBackground()
     if (!qApp)
         return;
 
-    qDebug() << "Starting background update";
-
+    qDebug() << __FUNCTION__ << "Starting background update";
 
     int next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
-    while (next_pixmap_id == current_bg_id) {
+    while (next_pixmap_id == current_bg_id_) {
         next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
     }
-    qDebug() << "Next background id = " << next_pixmap_id;
+    qDebug() << __FUNCTION__ << "Next background id = " << next_pixmap_id;
 
-    QPixmap *cur_bg = new QPixmap(current_bg);
+    QPixmap *cur_bg = new QPixmap(current_bg_);
     QPixmap *new_bg= new QPixmap(":/backgrounds/bg" + QString::number(next_pixmap_id) + ".png");
-    current_bg_id = next_pixmap_id;
+    current_bg_id_ = next_pixmap_id;
 
     QtConcurrent::run([cur_bg, new_bg, this](){
         const int iterations_num = 50;
@@ -189,7 +178,7 @@ void MainWindow::randomChangeBackground()
         }
         delete cur_bg;
         delete new_bg;
-        qDebug() << "Background update finished";
+        qDebug() << __FUNCTION__ << "Background update finished";
     });
 }
 
@@ -198,80 +187,53 @@ MainWindow::~MainWindow()
     delete ui;
 }
 
+void MainWindow::showMessageDialog(QString title, QString message, QString ok_button_text, QString cancel_button_text)
+{
+
+}
+
 void MainWindow::on_menuentry_1_clicked()
 {
-    currently_active_entry = ui->menuentry_1;
+    current_active_entry_ = ui->menuentry_1;
     hideAllContentWidgets();
-    status_widget->show();
+    status_widget_->show();
 }
 
 void MainWindow::on_menuentry_2_clicked()
 {
-    currently_active_entry = ui->menuentry_2;
+    current_active_entry_ = ui->menuentry_2;
     hideAllContentWidgets();
-    settings_widget->show();
+    settings_widget_->show();
 }
 
 void MainWindow::on_menuentry_3_clicked()
 {
-    currently_active_entry = ui->menuentry_3;
+    current_active_entry_ = ui->menuentry_3;
     hideAllContentWidgets();
-    help_widget->show();
+    help_widget_->show();
 }
 
 void MainWindow::on_menuentry_4_clicked()
 {
-    currently_active_entry = ui->menuentry_4;
+    current_active_entry_ = ui->menuentry_4;
     hideAllContentWidgets();
-    about_widget->show();
+    about_widget_->show();
 }
 
 void MainWindow::onHoverMenuentry(MenuEntry *hovered_entry)
 {
-    if (currently_hover_entry != hovered_entry) {
-        currently_hover_entry = hovered_entry;
+    if (current_hovered_entry_ != hovered_entry) {
+        current_hovered_entry_ = hovered_entry;
         moveMenuHoverWidget(hovered_entry);
     }
 }
 
-
-void MainWindow::onPatchDownloaderStarted() {
-    qDebug() << "Patch downloader started!";
-}
-
-void MainWindow::onPatchDownloaderFinished() {
-    qDebug() << "Patch downloader finished!";
-
-//    if (lotro_manager->Initialised()) {
-//        QMetaObject::invokeMethod(lotro_manager, "InstallUpdates", Qt::QueuedConnection);
-//    }
-    return;
-}
-
-void MainWindow::onLotroManagerStarted(QString operation, QVector<QVariant> data) {
-    qDebug() << "LotroManager: Started operation " << operation << " with parameters " << data;
-    return;
-}
-
-void MainWindow::onLotroManagerFinished(QString operation, QVector<QVariant> data) {
-    qDebug() << "LotroManager: Finished operation " << operation << " with parameters " << data;
-//    if (operation == "")
-    return;
-}
-
-void MainWindow::onLotroManagerErrorOccured(QString, QVector<QVariant>) {
-
-}
-
-
 void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
 {
-    if (!qApp)
-        return;
-    current_bg = background;
-    QPixmap scaled_bg = current_bg.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-    current_mask = scaled_bg.mask();
-    setMask(current_mask);
+    current_bg_ = background;
+    QPixmap scaled_bg = current_bg_.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+    current_mask_ = scaled_bg.mask();
+    setMask(current_mask_);
 
     QPalette palette;
     palette.setBrush(QPalette::Window, scaled_bg);
@@ -284,36 +246,36 @@ void MainWindow::makeConnections()
 
 void MainWindow::setupMenuHoverWidget()
 {
-    menuHoverWidget = new QWidget(ui->menu_widget);
-    menuHoverWidget->setStyleSheet("background-color: rgba(55, 37, 31, 230);");
-    menuHoverWidget->resize(0, 0);
+    menu_hover_widget_ = new QWidget(ui->menu_widget);
+    menu_hover_widget_->setStyleSheet("background-color: rgba(55, 37, 31, 230);");
+    menu_hover_widget_->resize(0, 0);
 
     connect(ui->menuentry_1, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
     connect(ui->menuentry_2, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
     connect(ui->menuentry_3, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
     connect(ui->menuentry_4, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
 
-    currently_active_entry = ui->menuentry_1;
-    menu_hover_checker_timer.setInterval(500);
-    connect(&menu_hover_checker_timer, &QTimer::timeout, this, &MainWindow::checkMenuIsHovered);
-    menu_hover_checker_timer.start();
+    current_active_entry_ = ui->menuentry_1;
+    menu_hover_checker_timer_.setInterval(500);
+    connect(&menu_hover_checker_timer_, &QTimer::timeout, this, &MainWindow::checkMenuIsHovered);
+    menu_hover_checker_timer_.start();
 }
 
 void MainWindow::moveMenuHoverWidget(MenuEntry *target)
 {
-    if (menuHoverWidget->size() == QSize(0, 0)) {
-        menuHoverWidget->resize(target->size() + QSize(10, 0));
-        menuHoverWidget->move(target->pos() + QPoint(-5, 0));
+    if (menu_hover_widget_->size() == QSize(0, 0)) {
+        menu_hover_widget_->resize(target->size() + QSize(10, 0));
+        menu_hover_widget_->move(target->pos() + QPoint(-5, 0));
     } else {
-        if (menuHoverWidgetAnimation == nullptr)
-            menuHoverWidgetAnimation = new QPropertyAnimation(menuHoverWidget, "geometry");
+        if (menu_hover_widget_animation_ == nullptr)
+            menu_hover_widget_animation_ = new QPropertyAnimation(menu_hover_widget_, "geometry");
         else
-            menuHoverWidgetAnimation->stop();
+            menu_hover_widget_animation_->stop();
 
-        menuHoverWidgetAnimation->setDuration(200);
-        menuHoverWidgetAnimation->setStartValue(QRect(menuHoverWidget->pos(), menuHoverWidget->size()));
-        menuHoverWidgetAnimation->setEndValue(QRect(target->pos() + QPoint(-5, 0), target->size() + QSize(10, 0)));
-        menuHoverWidgetAnimation->start();
+        menu_hover_widget_animation_->setDuration(200);
+        menu_hover_widget_animation_->setStartValue(QRect(menu_hover_widget_->pos(), menu_hover_widget_->size()));
+        menu_hover_widget_animation_->setEndValue(QRect(target->pos() + QPoint(-5, 0), target->size() + QSize(10, 0)));
+        menu_hover_widget_animation_->start();
     }
 
     ui->menuentry_1->raise();
@@ -328,32 +290,17 @@ void MainWindow::checkMenuIsHovered()
     QWidget *hovered = qApp->widgetAt(pos);
     if (!hovered || hovered->objectName().size() < 4 ||
             (hovered->objectName().left(9) != "menuentry" && hovered->objectName() != "menu_widget")) {
-        moveMenuHoverWidget(currently_active_entry);
-        currently_hover_entry = nullptr;
+        moveMenuHoverWidget(current_active_entry_);
+        current_hovered_entry_ = nullptr;
     }
 }
 
 void MainWindow::hideAllContentWidgets()
 {
-    status_widget->hide();
-    settings_widget->hide();
-    help_widget->hide();
-    about_widget->hide();
-}
-
-void MainWindow::showChooseVersionDialog()
-{
-//    QGraphicsBlurEffect *effect = new QGraphicsBlurEffect();
-//    effect->setBlurRadius(10);
-//    effect->setBlurHints(QGraphicsBlurEffect::QualityHint);
-//    ui->content_area->setGraphicsEffect(effect);
-    choose_locale_dialog->show();
-}
-
-void MainWindow::hideChooseVersionDialog()
-{
-//    ui->content_area->setGraphicsEffect(nullptr);
-    choose_locale_dialog->hide();
+    status_widget_->hide();
+    settings_widget_->hide();
+    help_widget_->hide();
+    about_widget_->hide();
 }
 
 void MainWindow::updateFontSizes()
@@ -366,7 +313,6 @@ void MainWindow::updateFontSizes()
 
 void MainWindow::on_closeButton_clicked()
 {
-    hide();
     qApp->quit();
 }
 

+ 30 - 28
src/Legacy/widgets/mainwindow.h

@@ -8,6 +8,8 @@
 #include <QBitmap>
 #include <QGraphicsBlurEffect>
 #include <QFont>
+#include <QMutex>
+#include <QMutexLocker>
 
 #include "statuswidget.h"
 #include "settingswidget.h"
@@ -21,20 +23,24 @@ class MainWindow;
 
 class MenuEntry;
 class DialogWindow;
+class PatchList;
 
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
 
 public:
-    explicit MainWindow(QWidget *parent = 0);
+    explicit MainWindow(PatchList *legacy_patches, QWidget *parent = 0);
     ~MainWindow();
+    int getLastDialogResult();
 
 public slots:
-    void showChooseVersionDialog();
-    void hideChooseVersionDialog();
+    void showMessageDialog(QString title, QString message, QString ok_button_text = "Ок", QString cancel_button_text = "Отмена");
     void updateFontSizes();
 
+signals:
+    void messageDialogFinished();
+
 protected:
     void mouseMoveEvent(QMouseEvent *event) override;
     void mousePressEvent(QMouseEvent *event) override;
@@ -60,15 +66,8 @@ private slots:
 
     void setupWindowBackgroundAndMask(QPixmap background);
 
-    void onPatchDownloaderStarted();
-    void onPatchDownloaderFinished();
-
-    void onLotroManagerStarted(QString, QVector<QVariant>);
-    void onLotroManagerFinished(QString, QVector<QVariant>);
-    void onLotroManagerErrorOccured(QString, QVector<QVariant>);
-
 private:
-    void makeConnections();
+    void makeConnections(); // TODO
 
     void setupMenuHoverWidget();
 
@@ -81,30 +80,33 @@ private:
     bool buttonsMouseMoveEventFilter(QObject *obj, QEvent *event);
 
     void setEventFilterRecursive(QObject* widget);
-private:    
-    MenuEntry* currently_active_entry;
-    MenuEntry* currently_hover_entry;
+
+private:
+    PatchList *legacy_patches_;
 
     Ui::MainWindow *ui;
 
-    StatusWidget *status_widget;
-    SettingsWidget *settings_widget;
-    HelpWidget *help_widget;
-    AboutWidget *about_widget;
+    MenuEntry* current_active_entry_;
+    MenuEntry* current_hovered_entry_;
+
+    StatusWidget *status_widget_;
+    SettingsWidget *settings_widget_;
+    HelpWidget *help_widget_;
+    AboutWidget *about_widget_;
 
-    ChooseVersionDialog *choose_locale_dialog;
-    DialogWindow *dialog_window;
+    ChooseVersionDialog *choose_locale_dialog_;
+    DialogWindow *dialog_window_;
 
-    QWidget* menuHoverWidget;
-    QPropertyAnimation* menuHoverWidgetAnimation;
-    QTimer menu_hover_checker_timer;
+    QWidget* menu_hover_widget_;
+    QPropertyAnimation* menu_hover_widget_animation_;
+    QTimer menu_hover_checker_timer_;
 
-    QPoint dragPosition;
+    QPoint drag_position_;
 
-    int current_bg_id;
-    QPixmap current_bg;
-    QBitmap current_mask;
-    QTimer background_update_timer;
+    int current_bg_id_;
+    QPixmap current_bg_;
+    QBitmap current_mask_;
+    QTimer background_update_timer_;
 
     const int MAX_PIXMAP_ID = 21;
 };

+ 10 - 34
src/Legacy/widgets/settingswidget.cpp

@@ -1,10 +1,11 @@
-#include "widgets/settingswidget.h"
-#include "widgets/mainwindow.h"
 #include "ui_settingswidget.h"
-#include "models/filesystem.h"
-#include "models/lotrodatmanager.h"
-#include "models/patchdownloader.h"
+
 #include "models/settings.h"
+#include "models/patchlist.h"
+
+#include "widgets/settingswidget.h"
+#include "widgets/mainwindow.h"
+
 #include "constants.h"
 
 #include <QDebug>
@@ -12,9 +13,10 @@
 #include <QFileDialog>
 #include <QMetaObject>
 
-SettingsWidget::SettingsWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent) :
-    QWidget(parent), patch_updater(patch_downloader), lotro_manager(lotro_dat_manager),
-    ui(new Ui::SettingsWidget)
+SettingsWidget::SettingsWidget(PatchList *legacy_patches, QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::SettingsWidget)
+    , legacy_patches_(legacy_patches)
 {
     ui->setupUi(this);
     for (int i = 1; i <= 4; ++i)
@@ -32,11 +34,6 @@ SettingsWidget::SettingsWidget(PatchDownloader* patch_downloader, LotroDatManage
     ui->lotro_base_language_combobox->installEventFilter(combobox_scrolling_disabler);
     ui->interface_scale_combobox->installEventFilter(combobox_scrolling_disabler);
 //    ui->content_scroll_area->verticalScrollBar()->installEventFilter(scroller);
-
-    connect(patch_downloader, &PatchDownloader::checkForUpdatesStarted, this, &SettingsWidget::handleCheckForUpdatesStarted, Qt::QueuedConnection);
-    connect(patch_downloader, &PatchDownloader::checkForUpdatesFinished, this, &SettingsWidget::handleCheckForUpdatesFinished, Qt::QueuedConnection);
-    connect(lotro_manager, &LotroDatManager::processStarted, this, &SettingsWidget::handleLotroManagerStarted);
-    connect(lotro_manager, &LotroDatManager::processFinished, this, &SettingsWidget::handleLotroManagerFinished);
 }
 
 SettingsWidget::~SettingsWidget()
@@ -144,25 +141,6 @@ void SettingsWidget::resizeEvent(QResizeEvent *event)
     ui->apply_button_entry_2->setMinimumHeight(double(55) * coefficient);
 }
 
-void SettingsWidget::handleLotroManagerStarted(QString process_name, QVector<QVariant> data)
-{
-}
-
-void SettingsWidget::handleLotroManagerFinished(QString process_name, QVector<QVariant> data)
-{
-//    if (process_name == "")
-}
-
-void SettingsWidget::handleCheckForUpdatesStarted()
-{
-
-}
-
-void SettingsWidget::handleCheckForUpdatesFinished()
-{
-
-}
-
 void SettingsWidget::on_interface_scale_combobox_currentIndexChanged(const QString &arg1)
 {
     MainWindow* window = qobject_cast<MainWindow*>(qApp->activeWindow());
@@ -196,7 +174,6 @@ void SettingsWidget::on_change_folder_button_clicked()
 
     Settings::setValue("Lotro/game_path", game_folder);
     ui->game_folder_path->setText(game_folder);
-    QMetaObject::invokeMethod(lotro_manager, "InitialiseManager", Qt::QueuedConnection);
 }
 
 void SettingsWidget::on_lotro_base_language_combobox_currentIndexChanged(int index)
@@ -214,5 +191,4 @@ void SettingsWidget::on_lotro_base_language_combobox_currentIndexChanged(int ind
         return;
 
     Settings::setValue("Lotro/original_locale", value);
-    QMetaObject::invokeMethod(lotro_manager, "InitialiseManager", Qt::QueuedConnection);
 }

+ 5 - 15
src/Legacy/widgets/settingswidget.h

@@ -16,8 +16,7 @@ namespace Ui {
 class SettingsWidget;
 }
 
-class PatchDownloader;
-class LotroDatManager;
+class PatchList;
 
 namespace SettingsWidgetPrivate {
 
@@ -102,7 +101,7 @@ class SettingsWidget : public QWidget
 
 public:
 
-    explicit SettingsWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent = 0);
+    explicit SettingsWidget(PatchList *legacy_patches, QWidget *parent = 0);
 
     ~SettingsWidget();
 
@@ -121,15 +120,6 @@ protected:
     void resizeEvent(QResizeEvent *event) override;
 
 private slots:
-
-    void handleLotroManagerStarted(QString, QVector<QVariant>);
-
-    void handleLotroManagerFinished(QString, QVector<QVariant>);
-
-    void handleCheckForUpdatesStarted();
-
-    void handleCheckForUpdatesFinished();
-
     void on_interface_scale_combobox_currentIndexChanged(const QString &arg1);
 
     void on_change_folder_button_clicked();
@@ -137,10 +127,10 @@ private slots:
     void on_lotro_base_language_combobox_currentIndexChanged(int index);
 
 private:
-    PatchDownloader* patch_updater;
-    LotroDatManager* lotro_manager;
-
     Ui::SettingsWidget *ui;
+
+    PatchList *legacy_patches_;
+
     SettingsWidgetPrivate::ComboboxScrollingDisabler* combobox_scrolling_disabler;
     SettingsWidgetPrivate::SettingsTabsScroller* scroller;
 };

+ 8 - 63
src/Legacy/widgets/statuswidget.cpp

@@ -1,8 +1,10 @@
 #include "statuswidget.h"
 #include "ui_statuswidget.h"
+
+#include "models/patchlist.h"
+
 #include "widgets/mainwindow.h"
-#include "models/patchdownloader.h"
-#include "models/lotrodatmanager.h"
+
 #include "constants.h"
 
 #include <QDesktopServices>
@@ -10,19 +12,15 @@
 #include <QDebug>
 #include <QMessageBox>
 
-StatusWidget::StatusWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent) :
-    QWidget(parent), patch_updater(patch_downloader), lotro_manager(lotro_dat_manager),
-    ui(new Ui::StatusWidget)
+StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::StatusWidget)
+    , legacy_patches_(legacy_patches)
 {
 
     ui->setupUi(this);
     last_progress_update_time.start();
 
-    connect(patch_updater, &PatchDownloader::checkForUpdatesStarted, this, &StatusWidget::onPatchDownloaderStarted, Qt::QueuedConnection);
-    connect(patch_updater, &PatchDownloader::progressChanged, this, &StatusWidget::onPatchDownloaderProgressChanged, Qt::QueuedConnection);
-    connect(patch_updater, &PatchDownloader::checkForUpdatesFinished, this, &StatusWidget::onPatchDownloaderFinished, Qt::QueuedConnection);
-    connect(patch_updater, &PatchDownloader::changePatchStatus, this, &StatusWidget::updatePatchStatus);
-
     connect(ui->weekly_code_widget, &WeeklyCodeWidget::showCompletedTooltip, this, &StatusWidget::setToolTipToWeeklyCodeComplete);
     connect(ui->weekly_code_widget, &WeeklyCodeWidget::showHelpTooltip, this, &StatusWidget::setToolTipToWeeklyCodeHelp);
     connect(ui->weekly_code_widget, &WeeklyCodeWidget::showNoTooltip, this, &StatusWidget::resetToolTip);
@@ -137,58 +135,6 @@ void StatusWidget::resizeEvent(QResizeEvent *event)
     updateFontsSizes();
 }
 
-void StatusWidget::onPatchDownloaderStarted()
-{
-    qDebug() << "Status widget received DownloadStarted signal!";
-    ui->game_button->setDisabled(true);
-    ui->progress_label->setText("Проверка обновлений...");
-    ui->progressBar->setValue(0);
-}
-
-void StatusWidget::onPatchDownloaderFinished()
-{
-    ui->progress_label->setText("Все патчи загружены!");
-    ui->progressBar->setValue(100);
-    ui->game_button->setDisabled(false);
-}
-
-void StatusWidget::onPatchDownloaderProgressChanged(QList<PatchDownloadData> patches_data)
-{
-    if (last_progress_update_time.elapsed() < 200) {
-        return;
-    } else {
-        last_progress_update_time.restart();
-    }
-
-    foreach (PatchDownloadData data, patches_data) {
-        if (data.patch_name == "general") {
-            ui->progress_label->setText("Скачивание переводов " + data.download_speed_formatted + ".\nЗагружено "
-                                       + Downloader::getSizeFormatted(data.bytesDownloaded) + " из " + Downloader::getSizeFormatted(data.bytesTotal)
-                                       + " (" + QString::number(double(data.bytesDownloaded) * 100.0 / double(data.bytesTotal), 'f', 1) + "%) "
-                                       + "\nОставшееся время: " + data.elapsed_time_formatted);
-            ui->progressBar->setValue(data.bytesDownloaded * 100 / data.bytesTotal);
-        } else {
-            updatePatchStatus(data.patch_name, "Скачивание " + QString::number(double(data.bytesDownloaded) * 100.0 / double(data.bytesTotal), 'f', 1) + "% (" + data.download_speed_formatted + ")");
-        }
-    }
-}
-
-void StatusWidget::updatePatchStatus(QString patch_name, QString status)
-{
-    QString status_label_name = patch_name + "s_status";
-    QLabel* status_label = findChild<QLabel*>(status_label_name);
-    if (!status_label)
-        return;
-
-    status_label->setText(status);
-}
-
-void StatusWidget::on_game_button_clicked()
-{
-    MainWindow* window = qobject_cast<MainWindow*>(parentWidget()->parentWidget()->parentWidget());
-    window->showChooseVersionDialog();
-}
-
 void StatusWidget::setToolTipToWeeklyCodeHelp()
 {
     fadeBetweenToolTips(ui->weekly_code_tooltip_1);
@@ -231,6 +177,5 @@ void StatusWidget::fadeBetweenToolTips(QWidget* next_tooltip)
     if (next_active_tooltip_anim->state() == QAbstractAnimation::Stopped)
         next_active_tooltip_anim->start();
 
-
     active_tooltip = next_tooltip;
 }

+ 5 - 17
src/Legacy/widgets/statuswidget.h

@@ -3,24 +3,23 @@
 
 #include <QWidget>
 #include <QSettings>
-#include <QPropertyAnimation>
+#include <QTime>
 #include <QMap>
+#include <QPropertyAnimation>
 #include <QGraphicsOpacityEffect>
 
-#include "models/patchdownloader.h"
-
 namespace Ui {
 class StatusWidget;
 }
 
-class LotroDatManager;
+class PatchList;
 
 class StatusWidget : public QWidget
 {
     Q_OBJECT
 
 public:
-    explicit StatusWidget(PatchDownloader* patch_downloader, LotroDatManager* lotro_dat_manager, QWidget *parent = 0);
+    explicit StatusWidget(PatchList *legacy_patches, QWidget *parent = 0);
     ~StatusWidget();
 
 public slots:
@@ -30,14 +29,6 @@ protected:
     void resizeEvent(QResizeEvent *event) override;
 
 private slots:
-    void onPatchDownloaderStarted();
-    void onPatchDownloaderFinished();
-    void onPatchDownloaderProgressChanged(QList<PatchDownloadData>);
-
-    void updatePatchStatus(QString patch_name, QString status);
-
-    void on_game_button_clicked();
-
     void setToolTipToWeeklyCodeHelp();
     void setToolTipToWeeklyCodeComplete();
     void setToolTipToNewsHelp();
@@ -46,13 +37,10 @@ private slots:
 
     void fadeBetweenToolTips(QWidget* next_tooltip);
 
-
-
 private:
     Ui::StatusWidget *ui;
 
-    PatchDownloader* patch_updater;
-    LotroDatManager* lotro_manager;
+    PatchList *legacy_patches_;
 
     QMap<QString, QGraphicsOpacityEffect*> tooltip_effects;
     QMap<QString, QPropertyAnimation*> tooltip_animations;