|
@@ -1,19 +1,11 @@
|
|
|
#include "app.h"
|
|
|
+#include "filesystem.h"
|
|
|
|
|
|
Helper::Helper()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
-QString Helper::fileHash(const QString &fileName, QCryptographicHash::Algorithm hashAlgorithm){
|
|
|
- QFile file(fileName);
|
|
|
- if (file.open(QIODevice::ReadOnly)) {
|
|
|
- QByteArray fileData = file.readAll();
|
|
|
- QByteArray hashData = QCryptographicHash::hash(fileData, hashAlgorithm);
|
|
|
- return hashData.toHex();
|
|
|
- }
|
|
|
- return QByteArray();
|
|
|
-}
|
|
|
|
|
|
int Helper::getVersion(QString string) {
|
|
|
std::string str(string.toLatin1().data());
|
|
@@ -182,13 +174,7 @@ QString Helper::getSkinName() {
|
|
|
return skin;
|
|
|
}
|
|
|
|
|
|
-bool Helper::fileExists(QString path) {
|
|
|
- App *app = &App::getInstance();
|
|
|
- QFileInfo check_file(path);
|
|
|
- bool exists = check_file.exists() && check_file.isFile();
|
|
|
- if(exists == false) qWarning("%s:%i: %s%s", __FILE__, __LINE__, "Файл не найден: ", app->helper->stringToChar(path));
|
|
|
- return exists;
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
void Helper::applyShadow(QWidget * obj, QString color, int blur, int offset_x, int offset_y){
|
|
|
QGraphicsDropShadowEffect *pLabelTextShadowEffect = new QGraphicsDropShadowEffect(obj);
|
|
@@ -228,7 +214,7 @@ void Helper::myDialogBox(QString text, QString info, QString okText, QString can
|
|
|
|
|
|
QString skin = app->helper->getSkinName();
|
|
|
QString iconpath = "";
|
|
|
- iconpath = app->helper->fileExists("styles/" + skin + "/" + image) ? "styles/" + skin + "/" + image : ":/res/styles/" + skin + "/" + image;
|
|
|
+ iconpath = FileSystem::fileExists("styles/" + skin + "/" + image) ? "styles/" + skin + "/" + image : ":/res/styles/" + skin + "/" + image;
|
|
|
QPixmap icon(iconpath);
|
|
|
|
|
|
app->window->ui->dialogImage->setPixmap(icon.scaled(app->window->ui->dialogImage->width(), app->window->ui->dialogImage->height()));
|
|
@@ -332,7 +318,7 @@ void Helper::installMicroPatch(){
|
|
|
app->helper->prepareMicroPatch();
|
|
|
app->helper->applyMicroPatch();
|
|
|
QDir dir("/data/micro");
|
|
|
- app->helper->clearFolder(dir);
|
|
|
+ FileSystem::clearFolder(dir);
|
|
|
});
|
|
|
app->window->ui->hintLabel->setText("Установка завершена");
|
|
|
app->window->ui->exthintLabel->setText("Обновления успешно установлены");
|
|
@@ -361,7 +347,7 @@ void Helper::prepareMicroPatch(){
|
|
|
|
|
|
qInfo("%s:%i: %s", __FILE__, __LINE__, "Опция активна. Начинаем загрузку обновлений");
|
|
|
app->network->micropatch = QApplication::applicationDirPath() + "/data/micro/" + QString::number(timestamp) + ".db";
|
|
|
- if(!app->helper->fileExists(app->network->micropatch)){
|
|
|
+ if(!FileSystem::fileExists(app->network->micropatch)){
|
|
|
qInfo("%s:%i: %s%s", __FILE__, __LINE__, "Файл патча: ", app->helper->stringToChar(app->network->micropatch));
|
|
|
app->network->micropatch = app->network->getMicroPath(timestamp);
|
|
|
}
|
|
@@ -463,7 +449,7 @@ void Helper::saveLocale(int locale, QPushButton * button){
|
|
|
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(app->helper->fileExists(app->config->getValue("Local", "folder") + "/" + file)){
|
|
|
+ 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);
|
|
@@ -519,7 +505,7 @@ void Helper::startGame(){
|
|
|
|
|
|
QFile f(app->config->getValue("Local", "folder") + "/TurbineLauncher.exe");
|
|
|
QProcess process;
|
|
|
- if(fileExists(f.fileName())){
|
|
|
+ if(FileSystem::fileExists(f.fileName())){
|
|
|
if(f.fileName().contains(" ")) f.setFileName("\"" + f.fileName() + "\"");
|
|
|
process.startDetached(f.fileName(), args);
|
|
|
process.waitForFinished(-1);
|
|
@@ -679,7 +665,7 @@ bool Helper::isDatReady(){
|
|
|
QString file = app->config->getValue("Local", "file");
|
|
|
QFile fl(dir+"/" + file);
|
|
|
qDebug() << fl.fileName();
|
|
|
- if(app->helper->fileExists(fl.fileName())){
|
|
|
+ if(FileSystem::fileExists(fl.fileName())){
|
|
|
QDir game_dir(dir);
|
|
|
free = game_dir.rename(fl.fileName(), fl.fileName() + "99");
|
|
|
game_dir.rename(fl.fileName() + "99", fl.fileName());
|
|
@@ -767,16 +753,3 @@ int Helper::checkDatFile(){
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
-void Helper::clearFolder(QDir &dir){
|
|
|
-
|
|
|
- QStringList lstFiles = dir.entryList(QDir::Files);
|
|
|
-
|
|
|
-
|
|
|
- foreach (QString entry, lstFiles){
|
|
|
- QString entryAbsPath = dir.absolutePath() + "/" + entry;
|
|
|
-
|
|
|
- qDebug() << dir.absolutePath();
|
|
|
- QFile::remove(entryAbsPath);
|
|
|
- }
|
|
|
-}
|