diff --git a/CMakeLists.txt b/CMakeLists.txt index 3596db19..b2c99d3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE) add_compile_definitions(COMPILE_INFO="${BUILD_DATE} + ${GIT_COMMIT_HASH}") +add_compile_definitions(SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") if(UNIX AND NOT APPLE) # Fixes QWebEngine linker errors on Ubuntu 20.04 @@ -83,6 +84,7 @@ if(WIN32) add_subdirectory(ScreenPlaySysInfo) endif() +message(STATUS "[DEFINE] SOURCE_DIR = ${SOURCE_DIR}") message(STATUS "[DEFINE] BUILD_DATE = ${BUILD_DATE}") message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}") message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index d2e568dc..6e4115a9 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -172,6 +172,21 @@ if(APPLE) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/) + # tst_ScreenPlay needs ffmpeg in the base path + if(${TESTS_ENABLED}) + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg + ${CMAKE_BINARY_DIR}/bin/) + + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe + ${CMAKE_BINARY_DIR}/bin/) + endif() + add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD diff --git a/ScreenPlay/assets/tests/video_import.mp4 b/ScreenPlay/assets/tests/video_import.mp4 new file mode 100644 index 00000000..6a2ac6d2 Binary files /dev/null and b/ScreenPlay/assets/tests/video_import.mp4 differ diff --git a/ScreenPlay/qml/Workshop/PopupOffline.qml b/ScreenPlay/qml/Workshop/PopupOffline.qml index f6c0167c..be4cbf15 100644 --- a/ScreenPlay/qml/Workshop/PopupOffline.qml +++ b/ScreenPlay/qml/Workshop/PopupOffline.qml @@ -15,6 +15,9 @@ Popup { anchors.centerIn: Overlay.overlay dim: true + property ScreenPlayWorkshop workshop + property SteamWorkshop steam + Text { id: txtOffline @@ -22,7 +25,7 @@ Popup { font.family: ScreenPlay.settings.font font.pointSize: 21 color: Material.foreground - text: qsTr("You need to run Steam for this :)") + text: qsTr("You need to run Steam for this. steamErrorRestart: %1 - steamErrorAPIInit: %2").arg(steam.steamErrorRestart).arg(steam.steamErrorAPIInit) } Button { diff --git a/ScreenPlay/qml/Workshop/Workshop.qml b/ScreenPlay/qml/Workshop/Workshop.qml index 7204d304..ac828a5a 100644 --- a/ScreenPlay/qml/Workshop/Workshop.qml +++ b/ScreenPlay/qml/Workshop/Workshop.qml @@ -10,14 +10,14 @@ Item { id: root ScreenPlayWorkshop { - id: workshop + id: ws Component.onCompleted: { - const success = workshop.init(); + const success = ws.init(); if(success){ stackView.push("qrc:/qml/Workshop/SteamWorkshop.qml", { - "workshop": workshop, - "steam": workshop.steamWorkshop + "workshop": ws, + "steam": ws.steamWorkshop }) } else { popupOffline.open() @@ -27,6 +27,8 @@ Item { PopupOffline { id: popupOffline + workshop: ws + steam: ws.steamWorkshop } StackView { @@ -39,8 +41,8 @@ Item { ignoreUnknownSignals: true function onOpenSteamProfile(){ stackView.push("qrc:/qml/Workshop/SteamProfile.qml", { - "workshop": workshop, - "steam": workshop.steamWorkshop + "workshop": ws, + "steam": ws.steamWorkshop }) } function onRequestWorkshopMainPage(){ diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 93d9021c..07fcf238 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -153,9 +153,13 @@ void Settings::setupWidgetAndWindowPaths() #ifdef Q_OS_OSX - workingDir.cdUp(); - workingDir.cdUp(); - workingDir.cdUp(); + // ScreenPlayTest is not bundled in an .app so the working directory + // the the same as the executable. + if (QFileInfo(QCoreApplication::applicationFilePath()).fileName() != "tst_ScreenPlay") { + workingDir.cdUp(); + workingDir.cdUp(); + workingDir.cdUp(); + } m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); @@ -164,11 +168,11 @@ void Settings::setupWidgetAndWindowPaths() if (!QFileInfo::exists(m_globalVariables->widgetExecutablePath().toString())) { qInfo() << "widgetExecutablePath:" << m_globalVariables->widgetExecutablePath().toString(); - qFatal("widget executable not found!"); + qCritical("widget executable not found!"); } if (!QFileInfo::exists(m_globalVariables->wallpaperExecutablePath().toString())) { qInfo() << "wallpaperExecutablePath:" << m_globalVariables->wallpaperExecutablePath().toString(); - qFatal("wallpaper executable not found!"); + qCritical("wallpaper executable not found!"); } } diff --git a/ScreenPlay/tests/tst_main.cpp b/ScreenPlay/tests/tst_main.cpp index bc340588..89798510 100644 --- a/ScreenPlay/tests/tst_main.cpp +++ b/ScreenPlay/tests/tst_main.cpp @@ -55,6 +55,7 @@ private slots: Q_INIT_RESOURCE(ScreenPlayQML); Q_INIT_RESOURCE(ScreenPlayAssets); + app.init(); m_window = qobject_cast(app.mainWindowEngine()->rootObjects().first()); QVERIFY(m_window); @@ -130,10 +131,13 @@ void ScreenPlayTest::import_convert_video() auto* createWallpaperInit = m_window->findChild("createWallpaperInit"); QVERIFY(createWallpaperInit); + const QString originalVideoPath = QString(SOURCE_DIR) + "/ScreenPlay/assets/tests/video_import.mp4"; + qInfo() << originalVideoPath; + QVERIFY(QMetaObject::invokeMethod(createWallpaperInit, QString("startConvert").toLatin1().constData(), Qt::ConnectionType::AutoConnection, - Q_ARG(QVariant, "file:///D:/Video Loop/bbb.mp4"), + Q_ARG(QVariant, originalVideoPath), Q_ARG(QVariant, 1))); // VideoCodec::VP9 QTest::qWait(1000); diff --git a/ScreenPlay/translations/ScreenPlay_de.qm b/ScreenPlay/translations/ScreenPlay_de.qm index c701fce1..0abb7302 100644 Binary files a/ScreenPlay/translations/ScreenPlay_de.qm and b/ScreenPlay/translations/ScreenPlay_de.qm differ diff --git a/ScreenPlay/translations/ScreenPlay_zh_cn.qm b/ScreenPlay/translations/ScreenPlay_zh_cn.qm index 5a629558..01e91b80 100644 Binary files a/ScreenPlay/translations/ScreenPlay_zh_cn.qm and b/ScreenPlay/translations/ScreenPlay_zh_cn.qm differ diff --git a/ScreenPlayWallpaper/src/basewindow.h b/ScreenPlayWallpaper/src/basewindow.h index a96b57fd..8c1534cf 100644 --- a/ScreenPlayWallpaper/src/basewindow.h +++ b/ScreenPlayWallpaper/src/basewindow.h @@ -150,6 +150,7 @@ public slots: virtual void destroyThis() { } virtual void setVisible(bool show) { Q_UNUSED(show) } virtual void messageReceived(QString key, QString value) final; + virtual void clearComponentCache() {} virtual void replaceWallpaper( const QString absolutePath, const QString file, diff --git a/ScreenPlayWallpaper/src/macwindow.cpp b/ScreenPlayWallpaper/src/macwindow.cpp index 6f2d9873..08f621e8 100644 --- a/ScreenPlayWallpaper/src/macwindow.cpp +++ b/ScreenPlayWallpaper/src/macwindow.cpp @@ -63,3 +63,8 @@ void MacWindow::destroyThis() { QCoreApplication::quit(); } + +void MacWindow::clearComponentCache() +{ + m_window.engine()->clearComponentCache(); +} diff --git a/ScreenPlayWallpaper/src/macwindow.h b/ScreenPlayWallpaper/src/macwindow.h index d47591fe..56470d25 100644 --- a/ScreenPlayWallpaper/src/macwindow.h +++ b/ScreenPlayWallpaper/src/macwindow.h @@ -65,6 +65,7 @@ signals: public slots: void setVisible(bool show) override; void destroyThis() override; + void clearComponentCache() override; private: QQuickView m_window; diff --git a/ScreenPlayWallpaper/src/winwindow.h b/ScreenPlayWallpaper/src/winwindow.h index abb808f2..32454c1e 100644 --- a/ScreenPlayWallpaper/src/winwindow.h +++ b/ScreenPlayWallpaper/src/winwindow.h @@ -73,7 +73,7 @@ public slots: void setVisible(bool show) override; void destroyThis() override; void terminate(); - void clearComponentCache(); + void clearComponentCache() override; void setWindowsDesktopProperties(WindowsDesktopProperties* windowsDesktopProperties) { diff --git a/ScreenPlayWidget/qml/Widget.qml b/ScreenPlayWidget/qml/Widget.qml index 51e2dd68..b3ad6fdd 100644 --- a/ScreenPlayWidget/qml/Widget.qml +++ b/ScreenPlayWidget/qml/Widget.qml @@ -11,7 +11,9 @@ Item { Connections { function onQmlExit() { - Widget.setWindowBlur(0); + if(Qt.platform.os === "windows") + Widget.setWindowBlur(0); + animFadeOut.start(); } @@ -136,7 +138,8 @@ Item { onEntered: imgClose.opacity = 1 onExited: imgClose.opacity = 0.15 onClicked: { - Widget.setWindowBlur(0); + if(Qt.platform.os === "windows") + Widget.setWindowBlur(0); animFadeOut.start(); } diff --git a/ScreenPlayWorkshop/src/steamapiwrapper.cpp b/ScreenPlayWorkshop/src/steamapiwrapper.cpp index 104972e6..c0ef87aa 100644 --- a/ScreenPlayWorkshop/src/steamapiwrapper.cpp +++ b/ScreenPlayWorkshop/src/steamapiwrapper.cpp @@ -1,4 +1,3 @@ -#pragma once #include #include #include diff --git a/ScreenPlayWorkshop/src/steamworkshop.cpp b/ScreenPlayWorkshop/src/steamworkshop.cpp index c16f9b14..f57e598a 100644 --- a/ScreenPlayWorkshop/src/steamworkshop.cpp +++ b/ScreenPlayWorkshop/src/steamworkshop.cpp @@ -121,6 +121,42 @@ void SteamWorkshop::onRequestItemDetailReturned(SteamUGCQueryCompleted_t* pCallb } } +bool SteamWorkshop::steamErrorAPIInit() const +{ + return m_steamErrorAPIInit; +} + +void SteamWorkshop::setSteamErrorAPIInit(bool newSteamErrorAPIInit) +{ + if (m_steamErrorAPIInit == newSteamErrorAPIInit) + return; + m_steamErrorAPIInit = newSteamErrorAPIInit; + emit steamErrorAPIInitChanged(); +} + +void SteamWorkshop::resetSteamErrorAPIInit() +{ + setSteamErrorAPIInit({}); // TODO: Adapt to use your actual default value +} + +bool SteamWorkshop::steamErrorRestart() const +{ + return m_steamErrorRestart; +} + +void SteamWorkshop::setSteamErrorRestart(bool newSteamErrorRestart) +{ + if (m_steamErrorRestart == newSteamErrorRestart) + return; + m_steamErrorRestart = newSteamErrorRestart; + emit steamErrorRestartChanged(); +} + +void SteamWorkshop::resetSteamErrorRestart() +{ + setSteamErrorRestart({}); // TODO: Adapt to use your actual default value +} + void SteamWorkshop::requestUserItems() { if (!checkOnline()) diff --git a/ScreenPlayWorkshop/src/steamworkshop.h b/ScreenPlayWorkshop/src/steamworkshop.h index 54e7d3f9..d451521b 100644 --- a/ScreenPlayWorkshop/src/steamworkshop.h +++ b/ScreenPlayWorkshop/src/steamworkshop.h @@ -48,6 +48,8 @@ class SteamWorkshop : public QObject { Q_PROPERTY(SteamWorkshopListModel* workshopProfileListModel READ workshopProfileListModel WRITE setWorkshopProfileListModel NOTIFY workshopProfileListModelChanged) Q_PROPERTY(UploadListModel* uploadListModel READ uploadListModel NOTIFY uploadListModelChanged) Q_PROPERTY(SteamAccount* steamAccount READ steamAccount WRITE setSteamAccount NOTIFY steamAccountChanged) + Q_PROPERTY(bool steamErrorRestart READ steamErrorRestart WRITE setSteamErrorRestart RESET resetSteamErrorRestart NOTIFY steamErrorRestartChanged) + Q_PROPERTY(bool steamErrorAPIInit READ steamErrorAPIInit WRITE setSteamErrorAPIInit RESET resetSteamErrorAPIInit NOTIFY steamErrorAPIInitChanged) public: SteamWorkshop() @@ -72,6 +74,14 @@ public: SteamWorkshopListModel* workshopListModel() const { return m_workshopListModel.get(); } SteamWorkshopListModel* workshopProfileListModel() const { return m_workshopProfileListModel.get(); } + bool steamErrorRestart() const; + void setSteamErrorRestart(bool newSteamErrorRestart); + void resetSteamErrorRestart(); + + bool steamErrorAPIInit() const; + void setSteamErrorAPIInit(bool newSteamErrorAPIInit); + void resetSteamErrorAPIInit(); + public slots: bool checkOnline(); void bulkUploadToWorkshop(QStringList absoluteStoragePaths); @@ -175,6 +185,10 @@ signals: void workshopProfileListModelChanged(SteamWorkshopListModel*); + void steamErrorRestartChanged(); + + void steamErrorAPIInitChanged(); + private: void onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool bIOFailure); bool queryWorkshopItemFromHandle(SteamWorkshopListModel* listModel, SteamUGCQueryCompleted_t* pCallback); diff --git a/ScreenPlayWorkshop/src/workshop.cpp b/ScreenPlayWorkshop/src/workshop.cpp index bb86c8b5..dcf03130 100644 --- a/ScreenPlayWorkshop/src/workshop.cpp +++ b/ScreenPlayWorkshop/src/workshop.cpp @@ -7,7 +7,6 @@ Workshop::Workshop(QQuickItem* parent) m_installedListModel = std::make_unique(); m_steamWorkshop = std::make_unique(672870); m_installedListModel->init(); - qInfo() << "Workshop init"; } } diff --git a/Tools/Readme.md b/Tools/Readme.md index a9afdecd..00038458 100644 --- a/Tools/Readme.md +++ b/Tools/Readme.md @@ -1,15 +1,27 @@ ## Tools -This folder contains serveral python tools to help with development: +This folder contains serveral python tools to help with development. Depending on your os you have to change the python command to ```python```, ```python3``` or ```python3.9``` + #### setup.py -- Installs third party dependencies for all platforms +- Installs third party c++ dependencies for all platforms + - ```python3 setup.py -u=xxx -p=xxx``` #### build.py - Build ScreenPlay locally + - ```python3 build.py -t=release``` #### clang_format.py - Invokers clang-format for all .cpp and .h files -#### qdoc.py -- Builds documentation for all projects into Docs/html -#### download_ffmpeg.py -- Donwload ffmpeg for macos only for now + - ```python3 clang_format.py ``` #### qml_format.py - Calls qmlformat for all qml files + - ```python3 qml_format.py``` +#### qdoc.py +- Builds documentation for all projects into Docs/html + - ```python3 qdoc.py``` +#### download_ffmpeg.py +- Donwload ffmpeg for macos only for now + - ```python3 download_ffmpeg.py``` + +#### steam_publish.py +- Upload to steam. This is needed to add some much needed output like git commit to the steam ui for selecting branches + - ```python3 steam_publish.py -u xxx -p xxx``` + diff --git a/Tools/build.py b/Tools/build.py index 62ede846..65e8cdd1 100644 --- a/Tools/build.py +++ b/Tools/build.py @@ -60,7 +60,7 @@ if platform == "win32": cmake_target_triplet = "x64-windows" elif platform == "darwin": cmake_prefix_path = "~/Qt/" + qt_version + "/clang_64" - deploy_command = "{prefix_path}/bin/macdeployqt {app}.app -qmldir=../../{app}/qml " + deploy_command = "{prefix_path}/bin/macdeployqt {app}.app -qmldir=../../{app}/qml -executable={app}.app/Contents/MacOS/{app}" cmake_target_triplet = "x64-osx" elif platform == "linux": deploy_command = "cqtdeployer -qmldir ../../{app}/qml -bin {app}" @@ -75,21 +75,22 @@ cmake_toolchain_file = ( "'{root_path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake'").format(root_path=root_path) print("cmake_toolchain_file: %s " % cmake_toolchain_file) -build_folder = "build-" + cmake_target_triplet + "-" + args.build_type +build_folder = root_path + "/build-" + cmake_target_triplet + "-" + args.build_type if os.path.isdir(build_folder): - print("Remove previous build folder") + print("Remove previous build folder: " + build_folder) shutil.rmtree(build_folder) os.mkdir(build_folder) -os.chdir(root_path + "/" + build_folder) +os.chdir(build_folder) cmake_configure_command = """cmake ../ -DCMAKE_PREFIX_PATH={prefix_path} -DCMAKE_BUILD_TYPE={type} -DCMAKE_TOOLCHAIN_FILE={toolchain} -DVCPKG_TARGET_TRIPLET={triplet} + -DTESTS_ENABLED=OFF -DSCREENPLAY_STEAM_DEPLOY=ON -DSCREENPLAY_STEAM=ON -G "CodeBlocks - Ninja" @@ -123,13 +124,16 @@ execute(deploy_command.format( executable_file_ending=executable_file_ending)) if platform == "darwin" and args.sign_build: - execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --options \"runtime\" --entitlements \"../../ScreenPlay/entitlements.plist\" \"ScreenPlay.app/\"") - execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --options \"runtime\" \"ScreenPlayWallpaper.app/\"") - execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --options \"runtime\" \"ScreenPlayWidget.app/\"") + print("Remove workshop build folder (macos only).") + shutil.rmtree(build_folder + "/bin/workshop") - execute("codesign --verify --verbose \"ScreenPlay.app/\"") - execute("codesign --verify --verbose \"ScreenPlayWallpaper.app/\"") - execute("codesign --verify --verbose \"ScreenPlayWidget.app/\"") + execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --entitlements \"../../ScreenPlay/entitlements.plist\" --deep \"ScreenPlay.app/\"") + execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWallpaper.app/\"") + execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWidget.app/\"") + + execute("codesign --verify --verbose=4 \"ScreenPlay.app/\"") + execute("codesign --verify --verbose=4 \"ScreenPlayWallpaper.app/\"") + execute("codesign --verify --verbose=4 \"ScreenPlayWidget.app/\"") execute("xcnotary notarize ScreenPlay.app -d kelteseth@gmail.com -k ScreenPlay") execute("xcnotary notarize ScreenPlayWallpaper.app -d kelteseth@gmail.com -k ScreenPlay")