mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 03:45:32 +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[])
|
||||
{
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
|
||||
#if QT_VERSION >= 0x060000
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
#endif
|
||||
QApplication a(argc, argv);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
if (QSysInfo::windowsVersion() >= 0x0080)
|
||||
{
|
||||
#if QT_VERSION >= 0x050400
|
||||
if (QSysInfo::windowsVersion() >= 0x0080) {
|
||||
a.setFont(QApplication::font("QMenu"));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QVariantList arguments;
|
||||
for (const QString &argument : a.arguments()) {
|
||||
const QStringList appArgs = a.arguments();
|
||||
for (const QString &argument : appArgs) {
|
||||
arguments << QVariant::fromValue(argument);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,11 @@ int main(int argc, char *argv[])
|
|||
QVariant scriptPath = arguments.first();
|
||||
QFile luaScript(scriptPath.toString());
|
||||
if (!luaScript.open(QIODevice::ReadOnly)) {
|
||||
#if QT_VERSION >= 0x050F00
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ int main(int argc, char *argv[])
|
|||
QCoreApplication a(argc, argv);
|
||||
|
||||
QVariantList arguments;
|
||||
for (const QString &argument : a.arguments()) {
|
||||
const QStringList appArgs = a.arguments();
|
||||
for (const QString &argument : appArgs) {
|
||||
arguments << QVariant::fromValue(argument);
|
||||
}
|
||||
|
||||
|
@ -37,7 +38,11 @@ int main(int argc, char *argv[])
|
|||
QVariant scriptPath = arguments.first();
|
||||
QFile luaScript(scriptPath.toString());
|
||||
if (!luaScript.open(QIODevice::ReadOnly)) {
|
||||
#if QT_VERSION >= 0x050F00
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -59,14 +64,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (luaEngine.executeLuaFunction("main", arguments, true)) {
|
||||
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) {
|
||||
#else
|
||||
if (variant.type() == QVariant::Int || variant.type() == QVariant::LongLong) {
|
||||
#endif
|
||||
return variant.toInt();
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#if QT_VERSION >= 0x060000
|
||||
else if (variant.typeId() == QMetaType::QString) {
|
||||
#else
|
||||
else if (variant.type() == QVariant::String) {
|
||||
|
|
|
@ -71,7 +71,11 @@ int LuaEngineOS::executeProcess(lua_State *L_p)
|
|||
}
|
||||
}
|
||||
else {
|
||||
#if QT_VERSION >= 0x050F00
|
||||
processReturn = system(getVariant(L_p, 1).toString().toUtf8().constData());
|
||||
#else
|
||||
processReturn = QProcess::execute(getVariant(L_p, 1).toString());
|
||||
#endif
|
||||
}
|
||||
if (runInBackground && !processSuccessed) {
|
||||
processReturn = -2;
|
||||
|
|
Loading…
Reference in a new issue