|
| 1 | +/* TombRaiderLinuxLauncher |
| 2 | + * Martin Bångens Copyright (C) 2024 |
| 3 | + * This program is free software: you can redistribute it and/or modify |
| 4 | + * it under the terms of the GNU General Public License as published by |
| 5 | + * the Free Software Foundation, either version 3 of the License, or |
| 6 | + * (at your option) any later version. |
| 7 | +
|
| 8 | + * This program is distributed in the hope that it will be useful, |
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | + * GNU General Public License for more details. |
| 12 | + */ |
| 13 | + |
| 14 | +#include "Runner.hpp" |
| 15 | + |
| 16 | +Runner::Runner() : m_env(QProcessEnvironment::systemEnvironment()) { |
| 17 | + m_status = 0; |
| 18 | + // You can modify the environment of the process if needed |
| 19 | + // m_env.insert("WINEPREFIX", "/path/to/wineprefix"); |
| 20 | + // m_process.setProcessEnvironment(m_env); |
| 21 | +} |
| 22 | + |
| 23 | +Runner::Runner(const QString& cmd) |
| 24 | + : m_env(QProcessEnvironment::systemEnvironment()) { |
| 25 | + m_env.insert("WINEDLLOVERRIDES", "winmm=n,b"); |
| 26 | + m_process.setProcessEnvironment(m_env); |
| 27 | + m_status = 0; |
| 28 | + m_command = cmd; |
| 29 | +} |
| 30 | + |
| 31 | +void Runner::run() { |
| 32 | + // Start Wine with the application as an argument |
| 33 | + m_process.setWorkingDirectory("/home/noisecode3/.local/share/TombRaiderLinuxLauncher/19.TRLE"); |
| 34 | + m_process.start(m_command, QStringList() << "SabatuTR2.exe"); |
| 35 | + QObject::connect(&m_process, &QProcess::readyReadStandardOutput, [&]() { |
| 36 | + // Read and print the output to standard output |
| 37 | + QTextStream(stdout) << m_process.readAllStandardOutput(); |
| 38 | + }); |
| 39 | + |
| 40 | + if (m_process.waitForStarted() == true) { |
| 41 | + m_process.waitForFinished(); |
| 42 | + m_status = 0; |
| 43 | + } else { |
| 44 | + m_status = 1; |
| 45 | + qWarning() << "Failed to start Wine process!"; |
| 46 | + } |
| 47 | +} |
0 commit comments