From e53f75b59bc07fde913f3e759736ba7a30f317d5 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 25 Aug 2023 13:29:47 +0200 Subject: [PATCH] Add switch between x11 and wayland Add missing dependencies --- .vscode/extensions.json | 4 ++- ScreenPlayWallpaper/main.cpp | 53 ++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 7643df70..d94eeef8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,8 @@ "delgan.qml-format", "ms-vscode.cpptools-extension-pack", "ms-vscode.cmake-tools", - "seanwu.vscode-qt-for-python" + "seanwu.vscode-qt-for-python", + "mhutchie.git-graph", + "vadimcn.vscode-lldb" ] } \ No newline at end of file diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index aaab1bbe..32f9ddf3 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -36,14 +36,19 @@ int main(int argc, char* argv[]) #endif QGuiApplication app(argc, argv); + std::unique_ptr window; + const auto platformName = QGuiApplication::platformName(); #if defined(Q_OS_WIN) - WinWindow window; + window = std::make_unique(); #elif defined(Q_OS_LINUX) - //LinuxX11Window window; - LinuxWaylandWindow window; + if(platformName == "xcb"){ + window = std::make_unique(); + } else if(platformName == "wayland"){ + window = std::make_unique(); + } #elif defined(Q_OS_OSX) - MacWindow window; + window = std::make_unique(); #endif // If we start with only one argument (app path) @@ -61,17 +66,17 @@ int main(int argc, char* argv[]) "/wallpaper_video_astronaut_vp9", // 4 "/wallpaper_video_nebula_h264" // 5 }; - const int index = 5; + const int index = 1; QString projectPath = exampleContentPath + contentFolder.at(index); - window.setActiveScreensList({ 0 }); - window.setProjectPath(projectPath); - window.setAppID("test"); - window.setVolume(1); - window.setFillMode("cover"); - window.setType(ScreenPlay::InstalledType::InstalledType::VideoWallpaper); - window.setCheckWallpaperVisible(true); - window.setDebugMode(false); + window->setActiveScreensList({ 0 }); + window->setProjectPath(projectPath); + window->setAppID("test"); + window->setVolume(1); + window->setFillMode("cover"); + window->setType(ScreenPlay::InstalledType::InstalledType::VideoWallpaper); + window->setCheckWallpaperVisible(true); + window->setDebugMode(false); } else { // 8 parameter + 1 OS working directory as the first default paramter if (argumentList.length() != 9) { @@ -113,24 +118,24 @@ int main(int argc, char* argv[]) } appID = appID.remove("appID="); - window.setActiveScreensList(activeScreensList.value()); - window.setProjectPath(argumentList.at(2)); - window.setAppID(appID); - window.setVolume(volume); - window.setFillMode(argumentList.at(5)); - window.setType(installedType); - window.setCheckWallpaperVisible(checkWallpaperVisible); - window.setDebugMode(false); + window->setActiveScreensList(activeScreensList.value()); + window->setProjectPath(argumentList.at(2)); + window->setAppID(appID); + window->setVolume(volume); + window->setFillMode(argumentList.at(5)); + window->setType(installedType); + window->setCheckWallpaperVisible(checkWallpaperVisible); + window->setDebugMode(false); } - const auto setupStatus = window.setup(); + const auto setupStatus = window->setup(); if (setupStatus != ScreenPlay::WallpaperExitCode::Ok) { return static_cast(setupStatus); } - const auto startStatus = window.start(); + const auto startStatus = window->start(); if (startStatus != ScreenPlay::WallpaperExitCode::Ok) { return static_cast(startStatus); } - emit window.qmlStart(); + emit window->qmlStart(); return app.exec(); }