mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-15 06:52:34 +02:00
Add automatic project export to zip
This commit is contained in:
parent
5d4cc8d4fc
commit
0e05ec1188
@ -210,6 +210,9 @@ public slots:
|
||||
emit isConnectedChanged(m_isConnected);
|
||||
}
|
||||
|
||||
private:
|
||||
bool exportGodotProject(const QString& absolutePath, int timeoutMilliseconds = 30000);
|
||||
|
||||
private:
|
||||
const std::shared_ptr<GlobalVariables> m_globalVariables;
|
||||
std::unique_ptr<SDKConnection> m_connection;
|
||||
|
@ -52,7 +52,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
|
||||
if (auto obj = ScreenPlayUtil::openJsonFileToObject(absolutePath + "/project.json")) {
|
||||
if (obj->contains("properties"))
|
||||
projectSettingsListModelProperties = obj->value("properties").toObject();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
projectSettingsListModelProperties = properties;
|
||||
}
|
||||
@ -92,6 +92,9 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
|
||||
if (m_type != InstalledType::InstalledType::GodotWallpaper) {
|
||||
m_appArgumentsList.append(" --disable-features=HardwareMediaKeyHandling");
|
||||
}
|
||||
if (m_type == InstalledType::InstalledType::GodotWallpaper) {
|
||||
exportGodotProject(m_absolutePath);
|
||||
}
|
||||
}
|
||||
|
||||
bool ScreenPlayWallpaper::start()
|
||||
@ -108,6 +111,7 @@ bool ScreenPlayWallpaper::start()
|
||||
// to display the original wallpaper.
|
||||
const bool success = m_process.startDetached();
|
||||
qInfo() << "Starting ScreenPlayWallpaper detached: " << (success ? "success" : "failed!") << m_process.program();
|
||||
qInfo() << m_appArgumentsList;
|
||||
if (!success) {
|
||||
qInfo() << m_process.program() << m_appArgumentsList;
|
||||
emit error(QString("Could not start Wallpaper: " + m_process.errorString()));
|
||||
@ -289,6 +293,63 @@ bool ScreenPlayWallpaper::replace(
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ScreenPlayWallpaper::exportGodotProject(const QString& absolutePath, int timeoutMilliseconds)
|
||||
{
|
||||
// Prepare the Godot export command
|
||||
const QList<QString> godotCmd = { "--export-pack", "--headless", "Windows Desktop", "project.zip" };
|
||||
|
||||
// Create QProcess instance to run the command
|
||||
QProcess process;
|
||||
|
||||
// Set the working directory to the given absolute path
|
||||
process.setWorkingDirectory(absolutePath);
|
||||
process.setProgram(m_globalVariables->godotEditorExecutablePath().toString());
|
||||
// Start the Godot export process
|
||||
process.setArguments(godotCmd);
|
||||
if (!process.startDetached()) {
|
||||
qCritical() << "Godot failed to start.";
|
||||
return false;
|
||||
}
|
||||
// Wait for the process to finish or timeout
|
||||
if (!process.waitForFinished(timeoutMilliseconds)) {
|
||||
qCritical() << "Godot export process timed out or failed to start.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Capture the standard output and error
|
||||
QString stdoutString = process.readAllStandardOutput();
|
||||
QString stderrString = process.readAllStandardError();
|
||||
|
||||
// If you want to print the output to the console:
|
||||
if (!stdoutString.isEmpty())
|
||||
qDebug() << "Output:" << stdoutString;
|
||||
if (!stderrString.isEmpty())
|
||||
qDebug() << "Error:" << stderrString;
|
||||
|
||||
// Check for errors
|
||||
if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) {
|
||||
qCritical() << "Failed to export Godot project. Error:" << process.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the project.zip file was created
|
||||
QString zipPath = QDir(absolutePath).filePath("project.zip");
|
||||
if (!QFile::exists(zipPath)) {
|
||||
qCritical() << "Expected export file (project.zip) was not created.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Optional: Verify if the .zip file is valid
|
||||
// (A complete verification would involve extracting the file and checking its contents,
|
||||
// but for simplicity, we're just checking its size here)
|
||||
QFileInfo zipInfo(zipPath);
|
||||
if (zipInfo.size() <= 0) {
|
||||
qCritical() << "The exported project.zip file seems to be invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_screenplaywallpaper.cpp"
|
||||
|
@ -161,8 +161,8 @@ void Settings::setupWidgetAndWindowPaths()
|
||||
m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableBinEnding()));
|
||||
m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableBinEnding()));
|
||||
m_globalVariables->setGodotWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaperGodot" + ScreenPlayUtil::executableBinEnding()));
|
||||
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/Godot" + ScreenPlayUtil::executableBinEnding()));
|
||||
|
||||
const auto godotEditorName = "Godot_" + godotVersion + "-stable_win64.exe";
|
||||
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/" + godotEditorName));
|
||||
} else if (osType == "osx") {
|
||||
// ScreenPlayTest is not bundled in an .app so the working directory
|
||||
// the the same as the executable.
|
||||
@ -175,22 +175,32 @@ void Settings::setupWidgetAndWindowPaths()
|
||||
m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + basePath + "ScreenPlayWidget").toLocalFile());
|
||||
m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + basePath + "ScreenPlayWallpaper").toLocalFile());
|
||||
m_globalVariables->setGodotWallpaperExecutablePath(QUrl(workingDir.path() + basePath + "ScreenPlayWallpaperGodot").toLocalFile());
|
||||
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + basePath + "Godot").toLocalFile());
|
||||
const auto godotEditorName = "Godot_" + godotVersion + "-stable_osx.universal";
|
||||
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/" + godotEditorName));
|
||||
} else if (osType == "linux") {
|
||||
m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget"));
|
||||
m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper"));
|
||||
m_globalVariables->setGodotWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaperGodot"));
|
||||
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/Godot"));
|
||||
const auto godotEditorName = "Godot_" + godotVersion + "-stable_x11.64";
|
||||
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/" + godotEditorName));
|
||||
} else {
|
||||
qFatal("OS not supported.");
|
||||
}
|
||||
|
||||
if (!QFileInfo::exists(m_globalVariables->godotWallpaperExecutablePath().toString())) {
|
||||
qInfo() << "godotWallpaperExecutablePath:" << m_globalVariables->godotWallpaperExecutablePath();
|
||||
qCritical("Godot Wallpaper not found");
|
||||
}
|
||||
if (!QFileInfo::exists(m_globalVariables->godotEditorExecutablePath().toString())) {
|
||||
qInfo() << "godotEditorExecutablePath :" << m_globalVariables->godotEditorExecutablePath();
|
||||
qCritical("Godot Editor not found");
|
||||
}
|
||||
if (!QFileInfo::exists(m_globalVariables->widgetExecutablePath().toString())) {
|
||||
qInfo() << "widgetExecutablePath:" << m_globalVariables->widgetExecutablePath().toString();
|
||||
qInfo() << "widgetExecutablePath:" << m_globalVariables->widgetExecutablePath();
|
||||
qCritical("widget executable not found!");
|
||||
}
|
||||
if (!QFileInfo::exists(m_globalVariables->wallpaperExecutablePath().toString())) {
|
||||
qInfo() << "wallpaperExecutablePath:" << m_globalVariables->wallpaperExecutablePath().toString();
|
||||
qInfo() << "wallpaperExecutablePath:" << m_globalVariables->wallpaperExecutablePath();
|
||||
qCritical("wallpaper executable not found!");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user