diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 8c35f42a..b5604ccc 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -203,7 +203,8 @@ target_link_libraries( Qt6::WebSockets Qt6::Svg Qt6::WebEngineQuick - Qt6::WebEngineCore) + Qt6::WebEngineCore + SteamSDK) if(${TESTS_ENABLED}) add_executable(tst_ScreenPlay tests/tst_main.cpp) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 4da64d96..d73ded68 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -1,5 +1,7 @@ #include "app.h" +#include "steam/steam_qt_enums_generated.h" + namespace ScreenPlay { /*! \module ScreenPlay @@ -96,6 +98,16 @@ App::App() qRegisterMetaType(); qRegisterMetaType(); + + // TODO: This is a workaround because I don't know how to + // init this in the ScreenPlayWorkshop plugin. + // Move to workshop plugin. + qmlRegisterUncreatableMetaObject(ScreenPlayWorkshopSteamEnums::staticMetaObject, + "WorkshopEnums", + 1, 0, + "SteamEnums", + "Error: only enums"); + // Registers the enums from globalvariables. // Apparently this is the only way for qml to work // https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/ diff --git a/ScreenPlay/qml/Workshop/Background.qml b/ScreenPlay/qml/Workshop/Background.qml index 4a4c51a6..de0632c1 100644 --- a/ScreenPlay/qml/Workshop/Background.qml +++ b/ScreenPlay/qml/Workshop/Background.qml @@ -1,6 +1,5 @@ import QtQuick import Qt5Compat.GraphicalEffects -import Workshop 1.0 Rectangle { id: root diff --git a/ScreenPlay/qml/Workshop/SteamWorkshop.qml b/ScreenPlay/qml/Workshop/SteamWorkshop.qml index 7e9a40bd..d5a89ccf 100644 --- a/ScreenPlay/qml/Workshop/SteamWorkshop.qml +++ b/ScreenPlay/qml/Workshop/SteamWorkshop.qml @@ -4,6 +4,7 @@ import QtQuick.Controls.Material import Qt5Compat.GraphicalEffects import QtQuick.Layouts import Workshop 1.0 +import WorkshopEnums 1.0 import ScreenPlay 1.0 import "upload/" diff --git a/ScreenPlay/qml/Workshop/SteamWorkshopStartPage.qml b/ScreenPlay/qml/Workshop/SteamWorkshopStartPage.qml index 5505b247..d9cf62f0 100644 --- a/ScreenPlay/qml/Workshop/SteamWorkshopStartPage.qml +++ b/ScreenPlay/qml/Workshop/SteamWorkshopStartPage.qml @@ -4,6 +4,7 @@ import QtQuick.Controls.Material import Qt5Compat.GraphicalEffects import QtQuick.Layouts import Workshop 1.0 +import WorkshopEnums 1.0 import ScreenPlay 1.0 import "upload/" import "../Common" as Common diff --git a/ScreenPlay/qml/Workshop/upload/UploadProjectItem.qml b/ScreenPlay/qml/Workshop/upload/UploadProjectItem.qml index 1361a092..de5d7906 100644 --- a/ScreenPlay/qml/Workshop/upload/UploadProjectItem.qml +++ b/ScreenPlay/qml/Workshop/upload/UploadProjectItem.qml @@ -4,7 +4,8 @@ import Qt5Compat.GraphicalEffects import QtQuick.Controls.Material import QtQuick.Layouts import QtQuick.Controls.Material.impl -import Workshop +import Workshop 1.0 +import WorkshopEnums 1.0 Page { diff --git a/ScreenPlayWorkshop/CMakeLists.txt b/ScreenPlayWorkshop/CMakeLists.txt index 547c7113..0c9006c2 100644 --- a/ScreenPlayWorkshop/CMakeLists.txt +++ b/ScreenPlayWorkshop/CMakeLists.txt @@ -1,4 +1,4 @@ -project(workshopplugin LANGUAGES CXX) +project(ScreenPlayWorkshop LANGUAGES CXX) add_subdirectory(SteamSDK) @@ -16,7 +16,6 @@ set(SOURCES src/steamworkshopitem.cpp src/workshop.cpp src/installedlistmodel.cpp - src/screenplayworkshop_plugin.cpp src/steamworkshop.cpp src/steamworkshoplistmodel.cpp src/steamaccount.cpp @@ -31,19 +30,22 @@ set(HEADER src/workshop.h src/workshopitem.h src/installedlistmodel.h - src/screenplayworkshop_plugin.h src/steamworkshop.h src/steamaccount.h src/steamqmlimageprovider.h) -add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADER}) +qt_add_qml_module( + ${PROJECT_NAME} + OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/Workshop + URI "Workshop" + SOURCES ${SOURCES} ${HEADER} + VERSION + 1.0) -set(WORKSHOP_PLUGIN_DIR ${CMAKE_BINARY_DIR}/bin/workshop) -file(MAKE_DIRECTORY ${WORKSHOP_PLUGIN_DIR}) -set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR}) -set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR}) -set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR}) +# Needed by the automatic generated target missing includes +# https://github.com/qt/qtdeclarative/blob/7a7064e14f094e843e1ee832cc927e86f887621a/src/qml/Qt6QmlMacros.cmake#L2042 +target_include_directories(${PROJECT_NAME} PUBLIC src/) set(STEAM_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SteamSDK/redistributable_bin/") diff --git a/ScreenPlayWorkshop/src/installedlistmodel.h b/ScreenPlayWorkshop/src/installedlistmodel.h index 2f051491..90cb1712 100644 --- a/ScreenPlayWorkshop/src/installedlistmodel.h +++ b/ScreenPlayWorkshop/src/installedlistmodel.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "ScreenPlayUtil/projectfile.h" #include "ScreenPlayUtil/util.h" @@ -33,6 +34,7 @@ namespace ScreenPlayWorkshop { class InstalledListModel : public QAbstractListModel { Q_OBJECT + QML_NAMED_ELEMENT(InstalledListModel) Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged) public: diff --git a/ScreenPlayWorkshop/src/screenplayworkshop_plugin.cpp b/ScreenPlayWorkshop/src/screenplayworkshop_plugin.cpp deleted file mode 100644 index 003d5910..00000000 --- a/ScreenPlayWorkshop/src/screenplayworkshop_plugin.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "screenplayworkshop_plugin.h" - -void ScreenPlayWorkshopPlugin::registerTypes(const char* uri) -{ - qRegisterMetaType("SteamQMLImageProvider*"); - qmlRegisterType("Workshop", 1, 0, "SteamImage"); - - qmlRegisterUncreatableMetaObject(ScreenPlayWorkshopSteamEnums::staticMetaObject, - "Workshop", - 1, 0, - "SteamEnums", - "Error: only enums"); - - qRegisterMetaType("SteamAccount*"); - qRegisterMetaType("InstalledListModel*"); - - qmlRegisterType("Workshop", 1, 0, "SteamWorkshop"); - qmlRegisterType("Workshop", 1, 0, "ScreenPlayWorkshop"); -} diff --git a/ScreenPlayWorkshop/src/screenplayworkshop_plugin.h b/ScreenPlayWorkshop/src/screenplayworkshop_plugin.h deleted file mode 100644 index 446f30b3..00000000 --- a/ScreenPlayWorkshop/src/screenplayworkshop_plugin.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "steam/steam_qt_enums_generated.h" -#include "workshop.h" - -#include "steamqmlimageprovider.h" - -class ScreenPlayWorkshopPlugin : public QQmlExtensionPlugin { - Q_OBJECT - - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - void registerTypes(const char* uri) override; -}; diff --git a/ScreenPlayWorkshop/src/steamaccount.h b/ScreenPlayWorkshop/src/steamaccount.h index c288ba9b..f32cfdd9 100644 --- a/ScreenPlayWorkshop/src/steamaccount.h +++ b/ScreenPlayWorkshop/src/steamaccount.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -15,7 +16,7 @@ namespace ScreenPlayWorkshop { class SteamAccount : public QObject { Q_OBJECT - + QML_NAMED_ELEMENT(SteamAccount) Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) Q_PROPERTY(quint32 accountID READ accountID WRITE setAccountID NOTIFY accountIDChanged) Q_PROPERTY(QImage avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) diff --git a/ScreenPlayWorkshop/src/steamqmlimageprovider.h b/ScreenPlayWorkshop/src/steamqmlimageprovider.h index 6eb0df5f..5b5e2261 100644 --- a/ScreenPlayWorkshop/src/steamqmlimageprovider.h +++ b/ScreenPlayWorkshop/src/steamqmlimageprovider.h @@ -5,10 +5,12 @@ #include #include #include +#include namespace ScreenPlayWorkshop { class SteamQMLImageProvider : public QQuickItem { Q_OBJECT + QML_NAMED_ELEMENT(SteamImage) public: SteamQMLImageProvider(QQuickItem* parent); @@ -28,7 +30,6 @@ public: node->setRect(boundingRect()); return node; } - public slots: void setImage(QImage image) { diff --git a/ScreenPlayWorkshop/src/steamworkshop.h b/ScreenPlayWorkshop/src/steamworkshop.h index d451521b..40a20348 100644 --- a/ScreenPlayWorkshop/src/steamworkshop.h +++ b/ScreenPlayWorkshop/src/steamworkshop.h @@ -13,6 +13,7 @@ #include #include #include +#include // Steam #include "cstring" @@ -40,6 +41,7 @@ struct SteamItemUpdate { class SteamWorkshop : public QObject { Q_OBJECT + QML_NAMED_ELEMENT(SteamWorkshop) Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged) Q_PROPERTY(unsigned long long itemProcessed READ itemProcessed WRITE setItemProcessed NOTIFY itemProcessedChanged) Q_PROPERTY(unsigned long long bytesTotal READ bytesTotal WRITE setBytesTotal NOTIFY bytesTotalChanged) diff --git a/ScreenPlayWorkshop/src/workshop.h b/ScreenPlayWorkshop/src/workshop.h index fde0432b..574921ef 100644 --- a/ScreenPlayWorkshop/src/workshop.h +++ b/ScreenPlayWorkshop/src/workshop.h @@ -14,7 +14,7 @@ namespace ScreenPlayWorkshop { class Workshop : public QQuickItem { Q_OBJECT - + QML_NAMED_ELEMENT(ScreenPlayWorkshop) Q_PROPERTY(InstalledListModel* installedListModel READ installedListModel NOTIFY installedListModelChanged) Q_PROPERTY(SteamWorkshop* steamWorkshop READ steamWorkshop NOTIFY steamWorkshopChanged)