Browse Source

LotroManager class partly reimpl

Ivan Arkhipov 6 years ago
parent
commit
a489894043
12 changed files with 203 additions and 73 deletions
  1. 9 9
      config.cpp
  2. 8 9
      downloadmanager.cpp
  3. 0 1
      filesystem.cpp
  4. 3 7
      helper.cpp
  5. 0 2
      helper.h
  6. 116 16
      lotromanager.cpp
  7. 31 5
      lotromanager.h
  8. 17 13
      main.cpp
  9. 1 1
      mainwindow.cpp
  10. 8 2
      mainwindow.ui
  11. 7 7
      network.cpp
  12. 3 1
      ui_mainwindow.h

+ 9 - 9
config.cpp

@@ -118,7 +118,7 @@ void AConfig::loadSkin(){
     qInfo("%s:%i: %s", __FILE__, __LINE__, "Начинаем настройку элементов");
 
     foreach (QString item, items){
-        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Устанавливаем настройки для ", app->helper->stringToChar(item));
+        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Устанавливаем настройки для ", item.toLocal8Bit().data());
         QWidget* obj = app->window->findChild<QWidget*>(item);
         if (obj != nullptr){
             obj->installEventFilter(app->window);
@@ -132,7 +132,7 @@ void AConfig::loadSkin(){
                 ));
             }
 
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ": настройка геометрии завершена");
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ": настройка геометрии завершена");
 
             if(settings.value("shadow") != k){
                 QString color = settings.value("shcolor") != k ? settings.value("shcolor").toString() : "#222";
@@ -141,7 +141,7 @@ void AConfig::loadSkin(){
                 int offset_y = settings.value("shy") != k ? settings.value("shy").toInt() : 1;
                 app->helper->applyShadow(obj, color, blur, offset_x, offset_y);
             }
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ":  настройка теней завершена");
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ":  настройка теней завершена");
 
             if(settings.value("text") != k){
                 QString text = settings.value("text").toString();
@@ -156,7 +156,7 @@ void AConfig::loadSkin(){
                    QLabel * l = dynamic_cast<QLabel* >(obj);
                    l->setText(settings.value("text").toString());
                 }
-                qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ": текст установлен");
+                qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ": текст установлен");
             }
 
             if(settings.value("align") != k){
@@ -165,13 +165,13 @@ void AConfig::loadSkin(){
                 if(settings.value("align") == "center") lab->setAlignment(Qt::AlignCenter);
                 if(settings.value("align") == "right") lab->setAlignment(Qt::AlignRight);
             }
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ": настройки позиционирования применены");
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ": настройки позиционирования применены");
 
             settings.endGroup();
         } else  {
             if(item == "mainWindow") {
                 settings.beginGroup(item);
-                qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ": обработка параметров главного окна");
+                qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ": обработка параметров главного окна");
                 int w = settings.value("width").toInt();
                 int h = settings.value("height").toInt();
 
@@ -185,7 +185,7 @@ void AConfig::loadSkin(){
                 app->window->move(center);
                 settings.endGroup();
             }
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ": закончен просчет геометрии");
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ": закончен просчет геометрии");
 
             if(item == "htmlColors") {
                 settings.beginGroup(item);
@@ -194,7 +194,7 @@ void AConfig::loadSkin(){
                 }
                 settings.endGroup();
             }
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, app->helper->stringToChar(item), ": загружены HTML-цвета");
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, item.toLocal8Bit().data(), ": загружены HTML-цвета");
         }
     }
     qInfo("%s:%i: %s", __FILE__, __LINE__, "Выполнено.");
@@ -267,6 +267,6 @@ const char * AConfig::getDatPath(int id){
     QStringList dats;
     dats << app->config->getValue("Local", "file") << "client_general.dat" << "client_sound.dat" << "client_surface.dat" << "client_highres.dat";
     //std::string file = (app->config->getValue("Local", "folder") + "/" + dats.at(id)).toStdString();
-    return app->helper->stringToChar(app->config->getValue("Local", "folder") + "/" + dats.at(id));
+    return (app->config->getValue("Local", "folder") + "/" + dats.at(id)).toLocal8Bit().data();
 }
 

+ 8 - 9
downloadmanager.cpp

@@ -24,8 +24,7 @@ void DownloadManager::append(const QStringList &urlList){
 }
 
 void DownloadManager::append(const QUrl &url){
-    App *app = &App::getInstance();
-    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Добавлен: ", app->helper->stringToChar(url.fileName()));
+    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Добавлен: ", url.fileName().toLocal8Bit().data());
     if (downloadQueue.isEmpty())
         QTimer::singleShot(0, this, SLOT(startNextDownload()));
 
@@ -48,7 +47,7 @@ void DownloadManager::startNextDownload()
     QUrl url = downloadQueue.dequeue();
     QString filename = QFileInfo(url.path()).fileName();
     output.setFileName(QApplication::applicationDirPath() + "/data/" + filename);
-    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Начата загрузка файла: ", app->helper->stringToChar(filename));
+    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Начата загрузка файла: ", filename.toLocal8Bit().data());
     // Проверяем целостность файла и игнорируем в случае если он цел
     QString hash = FileSystem::fileHash(QApplication::applicationDirPath() + "/data/" + filename, QCryptographicHash::Md5);
     QStringList pname = output.fileName().split("/");
@@ -57,19 +56,19 @@ void DownloadManager::startNextDownload()
     QString keyname = ptype.first();
     if(keyname == "loadscreens") keyname = "screens";
     if(hash == app->config->getValue("Hashes", ptype.first()) && app->config->getValue("Editor", keyname) == "true"){
-        qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Проверка хэша успешно завершена: ", app->helper->stringToChar(filename));
+        qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Проверка хэша успешно завершена: ", filename.toLocal8Bit().data());
         startNextDownload();
         return;
     }
 
-    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Хэш файла не совпал: ", app->helper->stringToChar(filename));
+    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Хэш файла не совпал: ", filename.toLocal8Bit().data());
     QStringList parsename = filename.split("_");
     QString name = parsename[0] + "Status";
     download_name = parsename[0];
     app->writtenLabel = app->window->ui->mainbox->findChild<QLabel *>(name);
 
     if (!output.open(QIODevice::WriteOnly)) {
-        qCritical("%s:%i: %s%s", __FILE__, __LINE__, "Произошла остановка скачивания ", app->helper->stringToChar(filename));
+        qCritical("%s:%i: %s%s", __FILE__, __LINE__, "Произошла остановка скачивания ", filename.toLocal8Bit().data());
         /*fprintf(stderr, "Problem opening save file '%s' for download '%s': %s\n",
                 qPrintable(filename), url.toEncoded().constData(),
                 qPrintable(output.errorString()));*/
@@ -78,7 +77,7 @@ void DownloadManager::startNextDownload()
         return;
     }
 
-    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем скачивание ", app->helper->stringToChar(url.fileName()));
+    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем скачивание ", url.fileName().toLocal8Bit().data());
 
     app->helper->setState("busy");// говорим что приложение занято
 
@@ -125,7 +124,7 @@ void DownloadManager::downloadFinished()
     app->helper->setState("free");// говорим что приложение освободилось
 
     if (currentDownload->error()) {
-         qWarning("%s:%i: %s%s", __FILE__, __LINE__, "Загрузка не удалась: ", app->helper->stringToChar(currentDownload->errorString()));
+         qWarning("%s:%i: %s%s", __FILE__, __LINE__, "Загрузка не удалась: ", currentDownload->errorString().toLocal8Bit().data());
         //fprintf(stderr, "Failed: %s\n", qPrintable(currentDownload->errorString()));
         if(app->writtenLabel != nullptr) app->writtenLabel->setText("Не удалась.");
     } else {       
@@ -149,7 +148,7 @@ void DownloadManager::abortDownload(QString name){
     if(download_name == name){
        if(app->state != "free" &&  currentDownload != NULL && currentDownload->isOpen()) {
             qDebug() << "Прерываем закачку " + download_name;
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Пользователь прервал закачку файла ", app->helper->stringToChar(download_name));
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Пользователь прервал закачку файла ", download_name.toLocal8Bit().data());
             if(app->writtenLabel != nullptr) app->writtenLabel->setText("Не выбран");
             currentDownload->abort();
 

+ 0 - 1
filesystem.cpp

@@ -33,4 +33,3 @@ void FileSystem::clearFolder(QDir &dir){
         QFile::remove(entryAbsPath);
     }
 }
-

+ 3 - 7
helper.cpp

@@ -44,10 +44,10 @@ void Helper::loadNews(){
         return;
     }
     QStringList data = response.split(":::");
-    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Получено новостей - ", app->helper->stringToChar(QString::number(data.count())));
+    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Получено новостей - ", QString::number(data.count()).toLocal8Bit().data());
     int counter = 1;
     foreach(QString news, data){
-        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем размещение новости №", app->helper->stringToChar(QString::number(counter)));
+        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем размещение новости №", QString::number(counter).toLocal8Bit().data());
         QStringList item = news.split("|");
         QLabel* image = app->window->ui->newsbox->findChild<QLabel*>("news" + QString::number(counter) + "Image");
         QLabel* title = app->window->ui->newsbox->findChild<QLabel*>("news" + QString::number(counter) + "Title");
@@ -174,7 +174,7 @@ QString Helper::getSkinName() {
     App *app = &App::getInstance();
     QString skin = app->config->getValue("Global", "current_theme");
     if(skin == "-1") skin = app->config->getValue("Global", "default_theme");
-    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Текущая тема оформления: ", app->helper->stringToChar(skin));
+    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Текущая тема оформления: ", skin.toLocal8Bit().data());
     return skin;
 }
 
@@ -318,10 +318,6 @@ void Helper::addComboItem(QComboBox* combo, QString itemName, QIcon* icon){
     combo->setItemIcon(0, *icon);
 }
 
-const char * Helper::stringToChar(QString val){
-    return val.toLocal8Bit().toStdString().c_str();
-}
-
 void Helper::replaceSkin(QString name){
     App *app = &App::getInstance();
     QString text = "Смена темы оформления";

+ 0 - 2
helper.h

@@ -33,8 +33,6 @@ class Helper:public QObject {
     int dateToTimestamp(QString customDateString, QString format);
     void addComboItem(QComboBox* combo, QString itemName, QIcon* icon);
 
-
-    const char *stringToChar(QString val);
     void replaceSkin(QString name);
 
     QString dialog_ok_answer;

+ 116 - 16
lotromanager.cpp

@@ -7,8 +7,113 @@
 LotroManager::LotroManager(QObject *parent) : QObject(parent)
 {
     dat_files_.resize(5);
+    operations_queue_.clear();
+    busy_ = false;
+
+    connect(this, SIGNAL(dat_operation_started()), this, SLOT(on_dat_operation_started()));
+}
+
+
+bool LotroManager::execute(QStringList operation) {
+    qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Вызываем execute() команды ", cmd[0].toLocal8Bit().data());
+
+    if (busy_ || cmd.size() == 0) {
+        qWarning("%s:%i: %s", __FILE__, __LINE__, "Ошибка! Уже выполняется другой процесс с данными!");
+        return false;
+    }
+
+    if (std::find(available_operations_.begin(), available_operations_.end(), cmd[0])
+            == available_operations_.end()) {
+
+        qWarning("%s:%i: %s%s%s", __FILE__, __LINE__, "Ошибка! Операция ", cmd[0].toLocal8Bit().data(), " не найдена в списке доступных!");
+        return false;
+    }
+
+    if (operation[0] == "StartGame") {
+        QtConcurrent::run([=]() {
+            emit dat_operation_started("StartGame");
+            startGame();
+            emit dat_operation_finished("StartGame");
+        });
+        return;
+    }
+
+    if (operation[0] == "SetLocale" && operation.size() == 2) {
+        QtConcurrent::run([=]() {
+            setGameLocale(operation[1]);
+            emit operation_finished("ApplyLoadScreens");
+        });
+        return;
+    }
+
+    if (operation[0] == "ChangeBaseLocale" && operation.size() == 2) {
+        QtConcurrent::run([=]() {
+            changeBaseLocale(operation[1]);
+            emit operation_finished("ApplyLoadScreens");
+        });
+        return;
+    }
+
+    if (operation[0] == "ApplyPatch" && operation.size() == 2) {
+        QtConcurrent::run([=]() {
+            applyPatch(operation[1]);
+            emit operation_finished("ApplyLoadScreens");
+        });
+        return;
+    }
+
+    if (operation[0] == "ApplyMicroPatch") {
+        QtConcurrent::run([=]() {
+            applyMicroPatch();
+            emit operation_finished("ApplyLoadScreens");
+        });
+        return;
+    }
+
+    if (operation[0] == "ApplyLoadScreens") {
+        QtConcurrent::run([=]() {
+            applyLoadscreens();
+            emit operation_finished("ApplyLoadScreens");
+        });
+
+        //applyLoadscreens();
+        return;
+    }
+
+    if (operation[0] == "ApplyGlobal") {
+        QtConcurrent::run([=]() {
+            applyPatch("fonts");
+            applyPatch("images");
+            applyPatch("texts");
+            applyPatch("sounds");
+            applyLoadscreens();
+            applyMicroPatch();
+            emit operation_finished("ApplyGlobal");
+        });
+        return;
+    }
+
+    if (operation[0] == "CheckDatFile") {
+        QtConcurrent::run(checkDatFile);
+        //checkDatFile();
+        return;
+    }
+
+    if (operation[0] == "SaveDatFiles") {
+        QtConcurrent::run(saveDatFiles);
+        //saveDatFiles();
+        return;
+    }
+
 }
 
+
+
+bool LotroManager::isBusy() {
+    return busy_;
+}
+
+
 void LotroManager::saveDatFiles() {
     for (auto dat_file : dat_files_)
         dat_file.CloseDatFile();
@@ -114,7 +219,7 @@ void LotroManager::applyPatch(QString name){
     App *app = &App::getInstance();
     app->window->ui->hintLabel->setText("Установка патчей");
     app->window->ui->exthintLabel->setText("Ожидайте. Идет установка выбранных патчей");
-    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем применение патча ", app->helper->stringToChar(name));
+    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Начинаем применение патча ", name.toLocal8Bit().data());
     QLabel* label = app->window->findChild<QLabel*>(name + "Status");
     QDir dir(QApplication::applicationDirPath() + "/data");
     if (!dir.exists()) {
@@ -124,9 +229,9 @@ void LotroManager::applyPatch(QString name){
     }
 
     QStringList paths = dir.entryList(QStringList(name + "*"));
-    qDebug() << app->helper->stringToChar("data/" + paths.first());
+    qDebug() << QString("data/" + paths.first()).toLocal8Bit().data();
     if(!paths.empty()){
-       database_.InitDatabase(app->helper->stringToChar("data/" + paths.first()));
+       database_.InitDatabase(QString("data/" + paths.first()).toLocal8Bit().data());
         int indb = database_.CountRows();
         qInfo("%s:%i: %s%d", __FILE__, __LINE__, "Файлов в обновлении: ", indb);
         for(int i = 0; i<=indb; i++){
@@ -257,7 +362,7 @@ void LotroManager::applyMicroPatch(){
     app->window->ui->hintLabel->setText("Установка последних обновлений");
     app->window->ui->exthintLabel->setText("Подождите пока закончится применение обновлений");
 
-    database_.InitDatabase(app->helper->stringToChar(app->network->micropatch));
+    database_.InitDatabase(app->network->micropatch.toLocal8Bit().data());
     int indb = database_.CountRows();
     qInfo("%s:%i: %s%d", __FILE__, __LINE__, "Файлов в обновлении: ", indb);
 
@@ -316,7 +421,7 @@ void LotroManager::applyLoadscreens(){
             subfile = database_.GetNextFile();
             qDebug() << i;
             if (!subfile.Empty()){
-                qInfo("%s:%i: %s", __FILE__, __LINE__, app->helper->stringToChar(folder + filenames[i]));
+                qInfo("%s:%i: %s", __FILE__, __LINE__, (folder + filenames[i]).toLocal8Bit().data());
                 QFile::remove(folder + filenames[i]);
                 subfile.binary_data.WriteToFile((folder + filenames[i]).toStdString());
             }
@@ -388,7 +493,7 @@ void LotroManager::prepareMicroPatch(){
     qInfo("%s:%i: %s", __FILE__, __LINE__, "Опция активна. Начинаем загрузку обновлений");
     app->network->micropatch = QApplication::applicationDirPath() + "/data/micro/" + QString::number(timestamp) + ".db";
     if(!FileSystem::fileExists(app->network->micropatch)){
-        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Файл патча: ", app->helper->stringToChar(app->network->micropatch));
+        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Файл патча: ", app->network->micropatch.toLocal8Bit().data());
         app->network->micropatch = app->network->getMicroPath(timestamp);
     }
     app->window->ui->hintLabel->setText("Загрузка завершена");
@@ -399,19 +504,15 @@ void LotroManager::prepareMicroPatch(){
     app->logSectionEnd();
 }
 
-void LotroManager::saveLocale(int locale, QPushButton * button){
+void LotroManager::changeBaseLocale(QString locale) {
     App *app = &App::getInstance();
     QString file;
 
-    if(locale == 0) file = "client_local_English.dat";
-    if(locale == 1) file = "client_local_DE.dat";
-    if(locale == 2) file = "client_local_FR.dat";
+    if(locale == "en") file = "client_local_English.dat";
+    if(locale == "de") file = "client_local_DE.dat";
+    if(locale == "fr") file = "client_local_FR.dat";
 
-    if(FileSystem::fileExists(app->config->getValue("Local", "folder") + "/" + file)){
-        app->window->ui->enButton->setEnabled(true);
-        app->window->ui->deButton->setEnabled(true);
-        app->window->ui->frButton->setEnabled(true);
-        button->setEnabled(false);
+    if (FileSystem::fileExists(app->config->getValue("Local", "folder") + "/" + file)) {
         app->config->setValue("Local", "file", file);
     } else {
         QString text = "Данная локализация отсутствует";
@@ -449,7 +550,6 @@ bool LotroManager::setGameLocale(QString locale){
     app->window->ui->goCancel->setEnabled(true);
     app->helper->setState("free");
     qDebug() << "Locale changed";
-
     return true;
 }
 

+ 31 - 5
lotromanager.h

@@ -21,6 +21,12 @@ public:
        return lotro_mgr_instance;
     }
 
+    bool execute(QStringList operation);
+
+    bool isBusy();
+
+private:
+
     void startGame();
 
     bool openDatFile(int id);
@@ -39,27 +45,47 @@ public:
 
     bool setGameLocale(QString locale);
 
-    void saveLocale(int locale, QPushButton *button);
+    void changeBaseLocale(QString locale);
 
     void saveDatFiles();
 
-public:
     void processFile();
 
     void installMicroPatch();
 
     void prepareMicroPatch();
 
-public:
+private:
+    bool busy_;
+
     LOTRO_DAT::LOCALE dat_locale_;
     std::vector<LOTRO_DAT::DatFile> dat_files_;
     LOTRO_DAT::Database database_;
 
+    std::deque<QStringList> operations_queue_;
+
+    const std::vector<QString> available_operations_ = {
+        "StartGame",
+        "SetLocale",
+        "ChangeBaseLocale",
+
+        "ApplyGlobal",
+        "ApplyPatch",
+        "ApplyMicroPatch",
+        "ApplyLoadScreens",
+
+        "CheckDatFile",
+        "SaveDatFiles"
+    };
+
 signals:
+    void dat_operation_started(QString operation);
+    void dat_operation_finished(QString operation, QString result = "");
+    void update_hint_label(QString head, QString content);
 
 private slots:
-    void handleFinisheddd();
-    //void processQueue();
+    void on_dat_operation_started(QString operation);
+    void on_dat_operation_finished(QString operation, QString result = "");
 };
 
 #endif // LOTROMANAGER_H

+ 17 - 13
main.cpp

@@ -38,10 +38,24 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &
 }
 
 int main(int argc, char *argv[]){
-    //if (argc <= 1 || (argc > 1 && std::string(argv[1]) != std::string("-S") && std::string(argv[1]) != "-prelaunched"))
-    //    return 0;
+    if (argc <= 1 || (argc > 1 && std::string(argv[1]) != "-prelaunched")) {
+        QApplication a(argc, argv);
+        QMessageBox msgBox;
+        msgBox.setIcon(QMessageBox::Warning);
+        msgBox.setText("Запуск Наследия невозможен без лаунчера. Используйте лаунчер Наследия для запуска приложения!");
+        msgBox.exec();
+        a.exit(0);
+        return 0;
+    }
+
+    freopen("log.txt", "w", stdout);
+    freopen("log.txt", "a", stderr);
 
-   // QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
+    setbuf(stdout, NULL);
+    setbuf(stderr, NULL);
+    setvbuf (stdout, NULL, _IONBF, BUFSIZ);
+    setvbuf (stderr, NULL, _IONBF, BUFSIZ);/**/
+    qInstallMessageHandler(myMessageOutput);// вывод логов в файл
 
     float scale_factor = 1;
 
@@ -81,18 +95,8 @@ int main(int argc, char *argv[]){
         scale_factor = dpi.toDouble();
         qDebug() << dpi;
         qputenv("QT_SCALE_FACTOR", dpi.toLatin1());
-        //qputenv("QT_SCREEN_SCALE_FACTORS", dpi.toLatin1());
     }
 
-    freopen("log.txt", "w", stdout);
-    freopen("log.txt", "a", stderr);
-
-    setbuf(stdout, NULL);
-    setbuf(stderr, NULL);
-    setvbuf (stdout, NULL, _IONBF, BUFSIZ);
-    setvbuf (stderr, NULL, _IONBF, BUFSIZ);/**/
-    qInstallMessageHandler(myMessageOutput);// вывод логов в файл
-
     QApplication a(argc, argv);
 
     QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));

+ 1 - 1
mainwindow.cpp

@@ -483,7 +483,7 @@ void MainWindow::on_okButton_clicked(){
         if(command == "loaddatfile"){
             app->config->deleteSection("Applied");
             QString filename = app->config->getDatPath(0);
-            qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Удаляем файл: ", app->helper->stringToChar(filename));
+            qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Удаляем файл: ", filename.toUtf8().data());
             LotroManager::getInstance().saveDatFiles();
             QFile::remove(filename);
             if (!FileSystem::fileExists(filename)) {

+ 8 - 2
mainwindow.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>427</width>
-    <height>310</height>
+    <width>848</width>
+    <height>387</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -1022,6 +1022,12 @@
        <height>221</height>
       </rect>
      </property>
+     <property name="openExternalLinks">
+      <bool>true</bool>
+     </property>
+     <property name="openLinks">
+      <bool>true</bool>
+     </property>
     </widget>
    </widget>
    <widget class="QGroupBox" name="aboutbox">

+ 7 - 7
network.cpp

@@ -62,7 +62,7 @@ QString ANetwork::getCoupon(){
     QString content = this->query(app->config->getValue("Network", "coupon") + ".txt");
     if (content != "error"){
         app->config->setValue("Values", "coupon", content);
-        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Ответ сервера: ", app->helper->stringToChar(content));
+        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Ответ сервера: ", content.toLocal8Bit().data());
         qInfo("%s:%i: %s", __FILE__, __LINE__, "Данные получены. Производим установку значений.");
     } else {
         qWarning("%s:%i: %s", __FILE__, __LINE__, "Не удалось получить информацию с сервера");
@@ -82,7 +82,7 @@ QString ANetwork::getFootMessage(){
     if (content != "error"){
         qInfo("%s:%i: %s", __FILE__, __LINE__, "Данные получены");
         app->config->setValue("Values", "foot", content);
-        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Ответ сервера: ", app->helper->stringToChar(content));
+        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Ответ сервера: ", content.toLocal8Bit().data());
     } else {
         qWarning("%s:%i: %s", __FILE__, __LINE__, "Не удалось получить информацию с сервера");
         content = app->config->getValue("Values", "foot");
@@ -114,7 +114,7 @@ QString ANetwork::getServers(){
     app->logSectionStart("Статусы серверов");
     QString content = this->query(app->config->getValue("Network", "servers") + ".txt");
     if (content != "error"){
-        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Ответ сервера: ", app->helper->stringToChar(content));
+        qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Ответ сервера: ", content.toLocal8Bit().data());
         qInfo("%s:%i: %s", __FILE__, __LINE__, "Данные получены. Производим установку значений.");
         app->config->setValue("Values", "servers", content);
         qDebug() << content;
@@ -192,7 +192,7 @@ void ANetwork::getPaths(){
                  version = QString::number(app->helper->getVersion(paths.first()));
                  QString hash = FileSystem::fileHash(datafolder + "/" + paths.first(), QCryptographicHash::Md5);
                  if(hash != app->config->getValue("Hashes", s + "s")){
-                     qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Эталон хэша отсутствует (удаляю файл): ", app->helper->stringToChar(paths.first()));
+                     qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Эталон хэша отсутствует (удаляю файл): ", paths.first().toLocal8Bit().data());
                      QFile base(datafolder + "/" + paths.first());
                      base.remove();
                      version="100";
@@ -210,7 +210,7 @@ void ANetwork::getPaths(){
                  }
 
             } else {
-                qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Патч отсутствует: ", s.toLocal8Bit().toStdString().c_str());
+                qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Патч отсутствует: ", s.toLocal8Bit().data());
                 version = "100";
                 QLabel* obj = app->window->ui->mainbox->findChild<QLabel*>(s + "sStatus");
                 if (obj != nullptr) {
@@ -223,7 +223,7 @@ void ANetwork::getPaths(){
     }
 
     url.setQuery(query.query());
-    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Запрашиваем информацию о патчах: ", url.fileName().toLocal8Bit().toStdString().c_str());
+    qDebug("%s:%i: %s%s", __FILE__, __LINE__, "Запрашиваем информацию о патчах: ", url.fileName().toLocal8Bit().data());
     QString content = this->query(url);
     if(content == "error"){
         qInfo("%s:%i: %s", __FILE__, __LINE__, "Отсутствует связь с сервером. Прервано.");
@@ -295,7 +295,7 @@ QString ANetwork::getMicroPath(int timestamp){
     qInfo("%s:%i: %s", __FILE__, __LINE__, "Загрузка микропатча завершена.");
 
 
-    LotroManager::getInstance().database_.InitDatabase(app->helper->stringToChar(filename));
+    LotroManager::getInstance().database_.InitDatabase(filename.toLocal8Bit().data());
     int indb = LotroManager::getInstance().database_.CountRows();
     qInfo("%s:%i: %s%i", __FILE__, __LINE__, "Патч содержит строк: ", indb);
     for(int i = 0; i<=indb; i++) LotroManager::getInstance().processFile();

+ 3 - 1
ui_mainwindow.h

@@ -151,7 +151,7 @@ public:
     {
         if (MainWindow->objectName().isEmpty())
             MainWindow->setObjectName(QStringLiteral("MainWindow"));
-        MainWindow->resize(427, 310);
+        MainWindow->resize(848, 387);
         MainWindow->setStyleSheet(QStringLiteral(""));
         centralWidget = new QWidget(MainWindow);
         centralWidget->setObjectName(QStringLiteral("centralWidget"));
@@ -398,6 +398,8 @@ public:
         textBrowser = new QTextBrowser(helpbox);
         textBrowser->setObjectName(QStringLiteral("textBrowser"));
         textBrowser->setGeometry(QRect(10, 0, 411, 221));
+        textBrowser->setOpenExternalLinks(true);
+        textBrowser->setOpenLinks(true);
         aboutbox = new QGroupBox(centralWidget);
         aboutbox->setObjectName(QStringLiteral("aboutbox"));
         aboutbox->setGeometry(QRect(430, 470, 441, 231));