From 41967b541ca3d071001ecf978544d07e62588368 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 23 Apr 2022 19:26:55 +0200 Subject: [PATCH] Fix none steam builds and installer Refactor Navigation to use Qt style navigation --- CMakeLists.txt | 5 +- ScreenPlay/CMakeLists.txt | 19 +- ScreenPlay/main.cpp | 3 +- ScreenPlay/main.qml | 2 +- ScreenPlay/qml/Installed/Navigation.qml | 8 - ScreenPlay/qml/Navigation/Navigation.qml | 97 ++++++---- ScreenPlay/qml/Navigation/NavigationItem.qml | 191 ------------------- ScreenPlay/src/settings.cpp | 5 +- ScreenPlay/tests/tst_main.cpp | 3 +- ScreenPlayShader/src/TestMain.qml | 87 +++------ ScreenPlayUtil/qml/Dialog.qml | 2 - ScreenPlayUtil/qml/Popup.qml | 2 +- ScreenPlayWorkshop/qml/PopupOffline.qml | 9 +- ScreenPlayWorkshop/src/TestMain.cpp | 3 +- Tools/build.py | 6 +- 15 files changed, 118 insertions(+), 324 deletions(-) delete mode 100644 ScreenPlay/qml/Navigation/NavigationItem.qml diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e6c9b92..2877f268 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ project( LANGUAGES CXX) # This sets cmake to compile all dlls into the main directory -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -70,7 +70,6 @@ execute_process( add_compile_definitions(COMPILE_INFO="Build Date: ${BUILD_DATE}. Git Hash: ${GIT_COMMIT_HASH}. ") add_compile_definitions(SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") -add_compile_definitions(SCREENPLAY_STEAM="${SCREENPLAY_STEAM}") if(UNIX AND NOT APPLE) # Fixes QWebEngine linker errors on Ubuntu 20.04 @@ -113,6 +112,6 @@ message(STATUS "[PROJECT] VCPKG_TARGET_TRIPLET = ${VCPKG_TARGET_TRIPLET}") message(STATUS "[PROJECT] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") message(STATUS "[PROJECT] CMAKE_VERSION = ${CMAKE_VERSION}") -if(${SCREENPLAY_CREATE_INSTALLER}) +if(${SCREENPLAY_INSTALLER}) include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CreateIFWInstaller.cmake) endif() diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 2398dbb8..b05075ce 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -84,7 +84,6 @@ set(QML qml/Monitors/MonitorsProjectSettingItem.qml qml/Monitors/SaveNotification.qml qml/Navigation/Navigation.qml - qml/Navigation/NavigationItem.qml qml/Navigation/WindowNavButton.qml qml/Navigation/WindowNavigation.qml qml/Settings/SettingBool.qml @@ -160,9 +159,16 @@ target_link_libraries( ScreenPlayQmlplugin ScreenPlayUtil ScreenPlayUtilplugin - ScreenPlayWorkshopplugin - ScreenPlayWorkshop SteamSDKQtEnums) + +if(${SCREENPLAY_STEAM}) + target_compile_definitions(ScreenPlayLib PRIVATE SCREENPLAY_STEAM=1) + target_link_libraries( + ScreenPlayLib + PUBLIC ScreenPlayWorkshopplugin + ScreenPlayWorkshop) +endif() + target_include_directories(ScreenPlayLib PUBLIC ) qt_add_executable(${PROJECT_NAME} main.cpp) @@ -171,6 +177,13 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlayLib) if(${SCREENPLAY_TESTS}) add_executable(tst_ScreenPlay tests/tst_main.cpp) target_link_libraries(tst_ScreenPlay PRIVATE ScreenPlayLib Qt6::Test) + if(${SCREENPLAY_STEAM}) + target_compile_definitions(tst_ScreenPlay PRIVATE SCREENPLAY_STEAM=1) + target_link_libraries( + tst_ScreenPlay + PUBLIC ScreenPlayWorkshopplugin + ScreenPlayWorkshop) + endif() endif() diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index 446dec22..2a5d888b 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -40,8 +40,9 @@ Q_IMPORT_QML_PLUGIN(ScreenPlayQmlPlugin) Q_IMPORT_QML_PLUGIN(ScreenPlayUtilPlugin) +#ifdef SCREENPLAY_STEAM Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin) - +#endif int main(int argc, char* argv[]) { Q_INIT_RESOURCE(Resources); diff --git a/ScreenPlay/main.qml b/ScreenPlay/main.qml index 28ec3a91..644773c1 100644 --- a/ScreenPlay/main.qml +++ b/ScreenPlay/main.qml @@ -83,7 +83,7 @@ ApplicationWindow { "sidebar": sidebar }) if (!ScreenPlay.settings.silentStart) - root.showNormal() + root.show() } Item { diff --git a/ScreenPlay/qml/Installed/Navigation.qml b/ScreenPlay/qml/Installed/Navigation.qml index 867ea501..57824b9b 100644 --- a/ScreenPlay/qml/Installed/Navigation.qml +++ b/ScreenPlay/qml/Installed/Navigation.qml @@ -56,12 +56,10 @@ Item { TabButton { text: qsTr("All") - font.family: ScreenPlay.settings.font icon.height: 16 icon.width: 16 height: parent.height width: implicitWidth - font.weight: Font.Thin icon.source: "qrc:/assets/icons/icon_installed.svg" onClicked: { setSidebarActive(false) @@ -76,10 +74,8 @@ Item { text: qsTr("Scenes") icon.height: 16 icon.width: 16 - font.family: ScreenPlay.settings.font width: implicitWidth height: parent.height - font.weight: Font.Thin icon.source: "qrc:/assets/icons/icon_code.svg" onClicked: { setSidebarActive(false) @@ -94,10 +90,8 @@ Item { text: qsTr("Videos") icon.height: 16 icon.width: 16 - font.family: ScreenPlay.settings.font height: parent.height width: implicitWidth - font.weight: Font.Thin icon.source: "qrc:/assets/icons/icon_movie.svg" onClicked: { setSidebarActive(false) @@ -112,10 +106,8 @@ Item { text: qsTr("Widgets") icon.height: 16 icon.width: 16 - font.family: ScreenPlay.settings.font height: parent.height width: implicitWidth - font.weight: Font.Thin icon.source: "qrc:/assets/icons/icon_widgets.svg" onClicked: { setSidebarActive(false) diff --git a/ScreenPlay/qml/Navigation/Navigation.qml b/ScreenPlay/qml/Navigation/Navigation.qml index 3ae0dcae..c455d157 100644 --- a/ScreenPlay/qml/Navigation/Navigation.qml +++ b/ScreenPlay/qml/Navigation/Navigation.qml @@ -69,83 +69,98 @@ Rectangle { target: ScreenPlay.util } - Row { + TabBar { id: row - height: 60 + height: 50 + currentIndex: 2 anchors { - top: parent.top - right: parent.right + bottom: parent.bottom left: parent.left leftMargin: 20 } spacing: 0 - NavigationItem { + TabButton { id: navCreate - - state: "inactive" - name: "Create" text: qsTr("Create") - iconSource: "qrc:/assets/icons/icon_plus.svg" - onPageClicked: function (name) { - root.onPageChanged(name) + icon.height: 16 + icon.width: 16 + font.pointSize: 12 + height: parent.height + width: implicitWidth + icon.source: "qrc:/assets/icons/icon_plus.svg" + onClicked: { + root.onPageChanged("Create") } objectName: "createTab" + background: Item {} } - NavigationItem { + TabButton { id: navWorkshop - - state: "inactive" - name: "Workshop" + enabled: ScreenPlay.settings.steamVersion text: qsTr("Workshop") - iconSource: "qrc:/assets/icons/icon_steam.svg" - onPageClicked: function (name) { - root.onPageChanged(name) + icon.height: 16 + icon.width: 16 + font.pointSize: 12 + height: parent.height + width: implicitWidth + icon.source: "qrc:/assets/icons/icon_steam.svg" + onClicked: { + root.onPageChanged("Workshop") } objectName: "workshopTab" + background: Item {} } - NavigationItem { + TabButton { id: navInstalled - - state: "active" - name: "Installed" - text: qsTr("Installed") - amount: ScreenPlay.installedListModel.count - iconSource: "qrc:/assets/icons/icon_installed.svg" - onPageClicked: function (name) { - root.onPageChanged(name) + text: qsTr("Installed") + " " + ScreenPlay.installedListModel.count + icon.height: 16 + icon.width: 16 + font.pointSize: 12 + height: parent.height + width: implicitWidth + icon.source: "qrc:/assets/icons/icon_installed.svg" + onClicked: { + root.onPageChanged("Installed") } objectName: "installedTab" + background: Item {} } - NavigationItem { + TabButton { id: navCommunity - - state: "inactive" - name: "Community" text: qsTr("Community") - iconSource: "qrc:/assets/icons/icon_community.svg" - onPageClicked: function (name) { - root.onPageChanged(name) + icon.height: 16 + icon.width: 16 + font.pointSize: 12 + height: parent.height + width: implicitWidth + icon.source: "qrc:/assets/icons/icon_community.svg" + onClicked: { + root.onPageChanged("Community") } objectName: "communityTab" + background: Item {} } - NavigationItem { + TabButton { id: navSettings - - state: "inactive" - name: "Settings" text: qsTr("Settings") - iconSource: "qrc:/assets/icons/icon_settings.svg" - onPageClicked: function (name) { - root.onPageChanged(name) + icon.height: 16 + icon.width: 16 + font.pointSize: 12 + height: parent.height + width: implicitWidth + icon.source: "qrc:/assets/icons/icon_settings.svg" + onClicked: { + root.onPageChanged("Settings") } objectName: "settingsTab" + background: Item {} } } diff --git a/ScreenPlay/qml/Navigation/NavigationItem.qml b/ScreenPlay/qml/Navigation/NavigationItem.qml deleted file mode 100644 index 70e20388..00000000 --- a/ScreenPlay/qml/Navigation/NavigationItem.qml +++ /dev/null @@ -1,191 +0,0 @@ -import QtQuick -import Qt5Compat.GraphicalEffects -import QtQuick.Controls.Material -import ScreenPlay 1.0 - -Item { - id: navigationItem - - property string iconSource: "qrc:/assets/icons/icon_installed.svg" - property string name - property alias text: txt.text - property alias amount: txtAmount.text - property bool enabled: true - - signal pageClicked(string name) - - function setActive(isActive) { - if (isActive) - navigationItem.state = "active"; - else - navigationItem.state = "inactive"; - } - - width: txtAmount.paintedWidth + txt.paintedWidth + icon.paintedWidth + 40 - height: 60 - state: "inactive" - onEnabledChanged: { - if (!enabled) { - navigationItem.width = 0; - navigationItem.opacity = 0; - } - } - - MouseArea { - id: mouseArea - - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - navigationItem.pageClicked(navigationItem.name); - } - - Image { - id: icon - - source: iconSource - width: 16 - height: 16 - sourceSize.height: 16 - sourceSize.width: 16 - fillMode: Image.PreserveAspectFit - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.verticalCenter: parent.verticalCenter - } - - Text { - id: txtAmount - - anchors.left: icon.right - anchors.leftMargin: 10 - font.pointSize: 14 - color: Material.primaryTextColor - anchors.verticalCenter: parent.verticalCenter - font.family: ScreenPlay.settings.font - font.weight: Font.Normal - text: "" - } - - Text { - id: txt - - anchors.left: txtAmount.right - anchors.leftMargin: navigationItem.amount == "" ? 0 : 5 - text: "name" - font.pointSize: 12 - color: Material.primaryTextColor - anchors.verticalCenter: parent.verticalCenter - font.family: ScreenPlay.settings.font - font.weight: Font.Normal - } - - ColorOverlay { - id: iconColorOverlay - - anchors.fill: icon - source: icon - color: Material.accentColor - } - - Rectangle { - id: navIndicator - - y: 83 - height: 3 - color: Material.accent - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - } - - } - - Behavior on width { - PropertyAnimation { - duration: 50 - } - - } - - states: [ - State { - name: "active" - - PropertyChanges { - target: navIndicator - anchors.bottomMargin: 0 - } - - PropertyChanges { - target: iconColorOverlay - color: Material.accent - } - - }, - State { - name: "disabled" - - PropertyChanges { - target: navIndicator - anchors.bottomMargin: -3 - } - - PropertyChanges { - target: iconColorOverlay - color: "#00000000" - } - - }, - State { - name: "inactive" - - PropertyChanges { - target: navIndicator - anchors.bottomMargin: -3 - } - - PropertyChanges { - target: iconColorOverlay - color: "#00000000" - } - - } - ] - transitions: [ - Transition { - from: "*" - to: "active" - - NumberAnimation { - properties: "anchors.bottomMargin" - duration: 200 - easing.type: Easing.OutQuart - } - - }, - Transition { - from: "*" - to: "disabled" - - NumberAnimation { - properties: "anchors.bottomMargin" - duration: 200 - easing.type: Easing.OutQuart - } - - }, - Transition { - from: "*" - to: "inactive" - - NumberAnimation { - properties: "anchors.bottomMargin" - duration: 100 - easing.type: Easing.OutQuart - } - - } - ] -} diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 21867f50..b829c980 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -42,8 +42,9 @@ Settings::Settings(const std::shared_ptr& globalVariables, { const QString qtVersion = QString("Qt Version: %1.%2.%3").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH); setGitBuildHash(COMPILE_INFO + qtVersion); - setSteamVersion(!(QString(SCREENPLAY_STEAM).compare("OFF", Qt::CaseInsensitive) ? false : true)); - +#ifdef SCREENPLAY_STEAM + setSteamVersion(true); +#endif #ifdef Q_OS_WIN setDesktopEnvironment(DesktopEnvironment::Windows); #endif diff --git a/ScreenPlay/tests/tst_main.cpp b/ScreenPlay/tests/tst_main.cpp index fe38f746..f22a290a 100644 --- a/ScreenPlay/tests/tst_main.cpp +++ b/ScreenPlay/tests/tst_main.cpp @@ -45,8 +45,9 @@ Q_IMPORT_QML_PLUGIN(ScreenPlayQmlPlugin) Q_IMPORT_QML_PLUGIN(ScreenPlayUtilPlugin) +#ifdef SCREENPLAY_STEAM Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin) - +#endif class ScreenPlayTest : public QObject { Q_OBJECT diff --git a/ScreenPlayShader/src/TestMain.qml b/ScreenPlayShader/src/TestMain.qml index 439006f4..3afd779f 100644 --- a/ScreenPlayShader/src/TestMain.qml +++ b/ScreenPlayShader/src/TestMain.qml @@ -10,67 +10,34 @@ Window { visible: true title: qsTr("ScreenPlayShader") - Image { - id: img - anchors.fill: parent - fillMode: Image.PreserveAspectCrop - source: "qrc:/ScreenPlayShader/assets/test_image_andras-vas-Bd7gNnWJBkU-unsplash.jpg" -// layer.enabled: true -// layer.effect: ShaderEffect { -// property real amplitude: 0.04 * .1 -// property real frequency: 2 -// property real time: 0 -// property real framerate: 60 -// property real updateInterval: Math.round( -// (1000 / framerate) * 10) / 10 + Image { + id: img + anchors.fill: parent + fillMode: Image.PreserveAspectCrop + source: "qrc:/ScreenPlayShader/assets/test_image_andras-vas-Bd7gNnWJBkU-unsplash.jpg" + layer.enabled: true + layer.effect: ShaderEffect { + property real amplitude: 0.04 * .1 + property real frequency: 2 + property real time: 0 + property real framerate: 60 + property real updateInterval: Math.round( + (1000 / framerate) * 10) / 10 -// Timer { -// interval: updateInterval -// onIntervalChanged: print(updateInterval) -// running: true -// repeat: true -// onTriggered: { -// if (parent.time > 600) { -// parent.time = 0 -// } -// parent.time += 1 -// } -// } + Timer { + interval: updateInterval + onIntervalChanged: print(updateInterval) + running: true + repeat: true + onTriggered: { + if (parent.time > 600) { + parent.time = 0 + } + parent.time += 1 + } + } -// fragmentShader: "/shaders/water.frag.qsb" -// } + fragmentShader: "/shaders/wobble.frag.qsb" } -// Image { -// id: img -// anchors.fill: parent -// fillMode: Image.PreserveAspectCrop - -// layer.enabled: true -// layer.effect: ShaderEffect { -// property real amplitude: 0.04 * .1 -// property real frequency: 2 -// property real time: 0 -// property real framerate: 60 -// property size resolution: Qt.size(1920,1080) -// property real updateInterval: Math.round( -// (1000 / framerate) * 10) / 10 - -// Timer { -// interval: updateInterval -// onIntervalChanged: print(updateInterval) -// running: true -// repeat: true -// onTriggered: { -// if (parent.time > 600) { -// parent.time = 0 -// } -// parent.time += 1 -// } -// } - -// // fragmentShader: "/shaders/lightning.frag.qsb" -// vertexShader: "/shaders/lightning.vert.qsb" -// } -// source: "qrc:/ScreenPlayWorkshop/assets/mask_01.png" -// } + } } diff --git a/ScreenPlayUtil/qml/Dialog.qml b/ScreenPlayUtil/qml/Dialog.qml index a92cf335..0e322078 100644 --- a/ScreenPlayUtil/qml/Dialog.qml +++ b/ScreenPlayUtil/qml/Dialog.qml @@ -14,8 +14,6 @@ Dialog { modal: true focus: true - - Overlay.modal: ModalBackgroundBlur { id: blurBg sourceItem: root.modalSource diff --git a/ScreenPlayUtil/qml/Popup.qml b/ScreenPlayUtil/qml/Popup.qml index 19f07188..7f74c35a 100644 --- a/ScreenPlayUtil/qml/Popup.qml +++ b/ScreenPlayUtil/qml/Popup.qml @@ -3,7 +3,7 @@ import QtQuick.Controls import Qt5Compat.GraphicalEffects import QtQuick.Controls.Material import QtQuick.Layouts - +import ScreenPlayUtil 1.0 Popup { id: root diff --git a/ScreenPlayWorkshop/qml/PopupOffline.qml b/ScreenPlayWorkshop/qml/PopupOffline.qml index 75ca4428..26a4ef59 100644 --- a/ScreenPlayWorkshop/qml/PopupOffline.qml +++ b/ScreenPlayWorkshop/qml/PopupOffline.qml @@ -4,7 +4,7 @@ import QtQuick.Layouts import QtQuick.Controls.Material import Qt5Compat.GraphicalEffects import ScreenPlayWorkshop 1.0 - +import ScreenPlayUtil 1.0 Popup { id: popupOffline @@ -22,9 +22,9 @@ Popup { required property ScreenPlayWorkshop workshop required property SteamWorkshop steam required property Item modalSource -// Overlay.modal: ModalBackgroundBlur { -// sourceItem: root.modalSource -// } + Overlay.modal: ModalBackgroundBlur { + sourceItem: root.modalSource + } ColumnLayout { anchors.fill: parent @@ -63,7 +63,6 @@ Popup { text: qsTr("Back") Layout.alignment: Qt.AlignHCenter onClicked: { - ScreenPlay.util.setNavigation("Installed") popupOffline.close() } } diff --git a/ScreenPlayWorkshop/src/TestMain.cpp b/ScreenPlayWorkshop/src/TestMain.cpp index 71d0ce3f..d9c93740 100644 --- a/ScreenPlayWorkshop/src/TestMain.cpp +++ b/ScreenPlayWorkshop/src/TestMain.cpp @@ -1,7 +1,7 @@ +#include "steam/steam_qt_enums_generated.h" #include #include #include -#include "steam/steam_qt_enums_generated.h" Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin) @@ -18,7 +18,6 @@ int main(int argc, char* argv[]) "SteamEnums", "Error: only enums"); - QQmlApplicationEngine engine; // The first subfolder is the libraryName followed by the regular // folder strucutre: LibararyName/Subfolder diff --git a/Tools/build.py b/Tools/build.py index 6dbddbd3..d87707d6 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -144,11 +144,11 @@ if __name__ == "__main__": print("Starting build with type %s. Qt Version: %s. Root path: %s" % (args.build_type, qt_version, root_path)) if args.build_steam: - build_steam = "OFF" + build_steam = "ON" if args.build_tests: - build_tests = "OFF" + build_tests = "ON" if args.build_installer: - build_installer = "OFF" + build_installer = "ON" cmake_configure_command = f'cmake ../ \ -DCMAKE_PREFIX_PATH={qt_path} \