mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
Fix legacy builds
This commit is contained in:
parent
eacb94de41
commit
51b3694661
3 changed files with 21 additions and 8 deletions
|
@ -26,23 +26,23 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= 0x060000
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||||
#endif
|
#endif
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
#if QT_VERSION >= 0x050400
|
||||||
if (QSysInfo::windowsVersion() >= 0x0080)
|
if (QSysInfo::windowsVersion() >= 0x0080) {
|
||||||
{
|
|
||||||
a.setFont(QApplication::font("QMenu"));
|
a.setFont(QApplication::font("QMenu"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantList arguments;
|
QVariantList arguments;
|
||||||
for (const QString &argument : a.arguments()) {
|
const QStringList appArgs = a.arguments();
|
||||||
|
for (const QString &argument : appArgs) {
|
||||||
arguments << QVariant::fromValue(argument);
|
arguments << QVariant::fromValue(argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,11 @@ int main(int argc, char *argv[])
|
||||||
QVariant scriptPath = arguments.first();
|
QVariant scriptPath = arguments.first();
|
||||||
QFile luaScript(scriptPath.toString());
|
QFile luaScript(scriptPath.toString());
|
||||||
if (!luaScript.open(QIODevice::ReadOnly)) {
|
if (!luaScript.open(QIODevice::ReadOnly)) {
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
QTextStream(stderr) << "Error: Failed to open \"" << arguments.first().toString() << "\"." << Qt::endl;
|
QTextStream(stderr) << "Error: Failed to open \"" << arguments.first().toString() << "\"." << Qt::endl;
|
||||||
|
#else
|
||||||
|
QTextStream(stderr) << "Error: Failed to open \"" << arguments.first().toString() << "\"." << endl;
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ int main(int argc, char *argv[])
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
QVariantList arguments;
|
QVariantList arguments;
|
||||||
for (const QString &argument : a.arguments()) {
|
const QStringList appArgs = a.arguments();
|
||||||
|
for (const QString &argument : appArgs) {
|
||||||
arguments << QVariant::fromValue(argument);
|
arguments << QVariant::fromValue(argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,11 @@ int main(int argc, char *argv[])
|
||||||
QVariant scriptPath = arguments.first();
|
QVariant scriptPath = arguments.first();
|
||||||
QFile luaScript(scriptPath.toString());
|
QFile luaScript(scriptPath.toString());
|
||||||
if (!luaScript.open(QIODevice::ReadOnly)) {
|
if (!luaScript.open(QIODevice::ReadOnly)) {
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
QTextStream(stderr) << "Error: Failed to open \"" << arguments.first().toString() << "\"." << Qt::endl;
|
QTextStream(stderr) << "Error: Failed to open \"" << arguments.first().toString() << "\"." << Qt::endl;
|
||||||
|
#else
|
||||||
|
QTextStream(stderr) << "Error: Failed to open \"" << arguments.first().toString() << "\"." << endl;
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +64,14 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (luaEngine.executeLuaFunction("main", arguments, true)) {
|
if (luaEngine.executeLuaFunction("main", arguments, true)) {
|
||||||
QVariant variant = luaEngine.returnVariant();
|
QVariant variant = luaEngine.returnVariant();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= 0x060000
|
||||||
if (variant.typeId() == QMetaType::Int || variant.typeId() == QMetaType::LongLong) {
|
if (variant.typeId() == QMetaType::Int || variant.typeId() == QMetaType::LongLong) {
|
||||||
#else
|
#else
|
||||||
if (variant.type() == QVariant::Int || variant.type() == QVariant::LongLong) {
|
if (variant.type() == QVariant::Int || variant.type() == QVariant::LongLong) {
|
||||||
#endif
|
#endif
|
||||||
return variant.toInt();
|
return variant.toInt();
|
||||||
}
|
}
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= 0x060000
|
||||||
else if (variant.typeId() == QMetaType::QString) {
|
else if (variant.typeId() == QMetaType::QString) {
|
||||||
#else
|
#else
|
||||||
else if (variant.type() == QVariant::String) {
|
else if (variant.type() == QVariant::String) {
|
||||||
|
|
|
@ -71,7 +71,11 @@ int LuaEngineOS::executeProcess(lua_State *L_p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if QT_VERSION >= 0x050F00
|
||||||
|
processReturn = system(getVariant(L_p, 1).toString().toUtf8().constData());
|
||||||
|
#else
|
||||||
processReturn = QProcess::execute(getVariant(L_p, 1).toString());
|
processReturn = QProcess::execute(getVariant(L_p, 1).toString());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (runInBackground && !processSuccessed) {
|
if (runInBackground && !processSuccessed) {
|
||||||
processReturn = -2;
|
processReturn = -2;
|
||||||
|
|
Loading…
Reference in a new issue