完成了OTA功能,为游戏增加了图标
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
|
||||
#include "ElaApplication.h"
|
||||
#include "ElaTheme.h"
|
||||
@@ -6,10 +11,50 @@
|
||||
#include "CardData.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "SoundManager.h"
|
||||
#include "UpdateChecker.h"
|
||||
|
||||
static QFile* g_logFile = nullptr;
|
||||
static QMutex g_logMutex;
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& ctx, const QString& msg) {
|
||||
Q_UNUSED(ctx)
|
||||
QMutexLocker lock(&g_logMutex);
|
||||
QString level;
|
||||
switch (type) {
|
||||
case QtDebugMsg: level = "DEBUG"; break;
|
||||
case QtInfoMsg: level = "INFO"; break;
|
||||
case QtWarningMsg: level = "WARN"; break;
|
||||
case QtCriticalMsg: level = "ERROR"; break;
|
||||
case QtFatalMsg: level = "FATAL"; break;
|
||||
}
|
||||
QString line = QStringLiteral("[%1] [%2] %3\n")
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"), level, msg);
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
fprintf(stderr, "%s", line.toLocal8Bit().constData());
|
||||
#endif
|
||||
if (g_logFile && g_logFile->isOpen())
|
||||
g_logFile->write(line.toUtf8());
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
a.setApplicationVersion(APP_VERSION);
|
||||
|
||||
QString logDir = QCoreApplication::applicationDirPath() + "/logs";
|
||||
QDir().mkpath(logDir);
|
||||
QString logPath = logDir + "/" + QDateTime::currentDateTime().toString("yyyy-MM-dd_HHmmss") + ".log";
|
||||
g_logFile = new QFile(logPath);
|
||||
g_logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
QDir logClean(logDir);
|
||||
for (const auto& f : logClean.entryList({"*.log"}, QDir::Files)) {
|
||||
QFileInfo fi(logDir + "/" + f);
|
||||
if (fi.lastModified().daysTo(QDateTime::currentDateTime()) > 7)
|
||||
QFile::remove(fi.absoluteFilePath());
|
||||
}
|
||||
|
||||
eApp->init();
|
||||
eTheme->setThemeMode(ElaThemeType::Dark);
|
||||
|
||||
@@ -22,5 +67,11 @@ int main(int argc, char* argv[])
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
QTimer::singleShot(2000, [&]() {
|
||||
auto server = SettingsManager::instance().getString("network", "server_address");
|
||||
if (!server.isEmpty())
|
||||
UpdateChecker::instance().checkForUpdate(server, true);
|
||||
});
|
||||
|
||||
return QApplication::exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user