mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 08:22:33 +02:00
Add automatic qml plugin generation...
We still need a way to register the enums in the plugin
This commit is contained in:
parent
b1abd38b28
commit
fbb4d80817
@ -203,7 +203,8 @@ target_link_libraries(
|
|||||||
Qt6::WebSockets
|
Qt6::WebSockets
|
||||||
Qt6::Svg
|
Qt6::Svg
|
||||||
Qt6::WebEngineQuick
|
Qt6::WebEngineQuick
|
||||||
Qt6::WebEngineCore)
|
Qt6::WebEngineCore
|
||||||
|
SteamSDK)
|
||||||
|
|
||||||
if(${TESTS_ENABLED})
|
if(${TESTS_ENABLED})
|
||||||
add_executable(tst_ScreenPlay tests/tst_main.cpp)
|
add_executable(tst_ScreenPlay tests/tst_main.cpp)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
#include "steam/steam_qt_enums_generated.h"
|
||||||
|
|
||||||
namespace ScreenPlay {
|
namespace ScreenPlay {
|
||||||
/*!
|
/*!
|
||||||
\module ScreenPlay
|
\module ScreenPlay
|
||||||
@ -96,6 +98,16 @@ App::App()
|
|||||||
qRegisterMetaType<MonitorListModel*>();
|
qRegisterMetaType<MonitorListModel*>();
|
||||||
qRegisterMetaType<ProfileListModel*>();
|
qRegisterMetaType<ProfileListModel*>();
|
||||||
|
|
||||||
|
|
||||||
|
// 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.
|
// Registers the enums from globalvariables.
|
||||||
// Apparently this is the only way for qml to work
|
// Apparently this is the only way for qml to work
|
||||||
// https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/
|
// https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Qt5Compat.GraphicalEffects
|
import Qt5Compat.GraphicalEffects
|
||||||
import Workshop 1.0
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Material
|
|||||||
import Qt5Compat.GraphicalEffects
|
import Qt5Compat.GraphicalEffects
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Workshop 1.0
|
import Workshop 1.0
|
||||||
|
import WorkshopEnums 1.0
|
||||||
import ScreenPlay 1.0
|
import ScreenPlay 1.0
|
||||||
import "upload/"
|
import "upload/"
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls.Material
|
|||||||
import Qt5Compat.GraphicalEffects
|
import Qt5Compat.GraphicalEffects
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Workshop 1.0
|
import Workshop 1.0
|
||||||
|
import WorkshopEnums 1.0
|
||||||
import ScreenPlay 1.0
|
import ScreenPlay 1.0
|
||||||
import "upload/"
|
import "upload/"
|
||||||
import "../Common" as Common
|
import "../Common" as Common
|
||||||
|
@ -4,7 +4,8 @@ import Qt5Compat.GraphicalEffects
|
|||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls.Material.impl
|
import QtQuick.Controls.Material.impl
|
||||||
import Workshop
|
import Workshop 1.0
|
||||||
|
import WorkshopEnums 1.0
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
project(workshopplugin LANGUAGES CXX)
|
project(ScreenPlayWorkshop LANGUAGES CXX)
|
||||||
|
|
||||||
add_subdirectory(SteamSDK)
|
add_subdirectory(SteamSDK)
|
||||||
|
|
||||||
@ -16,7 +16,6 @@ set(SOURCES
|
|||||||
src/steamworkshopitem.cpp
|
src/steamworkshopitem.cpp
|
||||||
src/workshop.cpp
|
src/workshop.cpp
|
||||||
src/installedlistmodel.cpp
|
src/installedlistmodel.cpp
|
||||||
src/screenplayworkshop_plugin.cpp
|
|
||||||
src/steamworkshop.cpp
|
src/steamworkshop.cpp
|
||||||
src/steamworkshoplistmodel.cpp
|
src/steamworkshoplistmodel.cpp
|
||||||
src/steamaccount.cpp
|
src/steamaccount.cpp
|
||||||
@ -31,19 +30,22 @@ set(HEADER
|
|||||||
src/workshop.h
|
src/workshop.h
|
||||||
src/workshopitem.h
|
src/workshopitem.h
|
||||||
src/installedlistmodel.h
|
src/installedlistmodel.h
|
||||||
src/screenplayworkshop_plugin.h
|
|
||||||
src/steamworkshop.h
|
src/steamworkshop.h
|
||||||
src/steamaccount.h
|
src/steamaccount.h
|
||||||
src/steamqmlimageprovider.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})
|
# Needed by the automatic generated target missing includes
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR})
|
# https://github.com/qt/qtdeclarative/blob/7a7064e14f094e843e1ee832cc927e86f887621a/src/qml/Qt6QmlMacros.cmake#L2042
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR})
|
target_include_directories(${PROJECT_NAME} PUBLIC src/)
|
||||||
|
|
||||||
set(STEAM_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SteamSDK/redistributable_bin/")
|
set(STEAM_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SteamSDK/redistributable_bin/")
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
#include <QtQml>
|
||||||
|
|
||||||
#include "ScreenPlayUtil/projectfile.h"
|
#include "ScreenPlayUtil/projectfile.h"
|
||||||
#include "ScreenPlayUtil/util.h"
|
#include "ScreenPlayUtil/util.h"
|
||||||
@ -33,6 +34,7 @@ namespace ScreenPlayWorkshop {
|
|||||||
class InstalledListModel : public QAbstractListModel {
|
class InstalledListModel : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
QML_NAMED_ELEMENT(InstalledListModel)
|
||||||
Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged)
|
Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#include "screenplayworkshop_plugin.h"
|
|
||||||
|
|
||||||
void ScreenPlayWorkshopPlugin::registerTypes(const char* uri)
|
|
||||||
{
|
|
||||||
qRegisterMetaType<ScreenPlayWorkshop::SteamQMLImageProvider*>("SteamQMLImageProvider*");
|
|
||||||
qmlRegisterType<ScreenPlayWorkshop::SteamQMLImageProvider>("Workshop", 1, 0, "SteamImage");
|
|
||||||
|
|
||||||
qmlRegisterUncreatableMetaObject(ScreenPlayWorkshopSteamEnums::staticMetaObject,
|
|
||||||
"Workshop",
|
|
||||||
1, 0,
|
|
||||||
"SteamEnums",
|
|
||||||
"Error: only enums");
|
|
||||||
|
|
||||||
qRegisterMetaType<ScreenPlayWorkshop::SteamAccount*>("SteamAccount*");
|
|
||||||
qRegisterMetaType<ScreenPlayWorkshop::InstalledListModel*>("InstalledListModel*");
|
|
||||||
|
|
||||||
qmlRegisterType<ScreenPlayWorkshop::SteamWorkshop>("Workshop", 1, 0, "SteamWorkshop");
|
|
||||||
qmlRegisterType<ScreenPlayWorkshop::Workshop>("Workshop", 1, 0, "ScreenPlayWorkshop");
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QQmlContext>
|
|
||||||
#include <QQmlEngine>
|
|
||||||
#include <QQmlExtensionPlugin>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QtQml>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
};
|
|
@ -7,6 +7,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QtQml>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <steam/steam_api.h>
|
#include <steam/steam_api.h>
|
||||||
@ -15,7 +16,7 @@ namespace ScreenPlayWorkshop {
|
|||||||
|
|
||||||
class SteamAccount : public QObject {
|
class SteamAccount : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
QML_NAMED_ELEMENT(SteamAccount)
|
||||||
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
|
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
|
||||||
Q_PROPERTY(quint32 accountID READ accountID WRITE setAccountID NOTIFY accountIDChanged)
|
Q_PROPERTY(quint32 accountID READ accountID WRITE setAccountID NOTIFY accountIDChanged)
|
||||||
Q_PROPERTY(QImage avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
|
Q_PROPERTY(QImage avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
#include <QSGNode>
|
#include <QSGNode>
|
||||||
#include <QSGSimpleTextureNode>
|
#include <QSGSimpleTextureNode>
|
||||||
#include <QSGTexture>
|
#include <QSGTexture>
|
||||||
|
#include <QtQml>
|
||||||
|
|
||||||
namespace ScreenPlayWorkshop {
|
namespace ScreenPlayWorkshop {
|
||||||
class SteamQMLImageProvider : public QQuickItem {
|
class SteamQMLImageProvider : public QQuickItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
QML_NAMED_ELEMENT(SteamImage)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SteamQMLImageProvider(QQuickItem* parent);
|
SteamQMLImageProvider(QQuickItem* parent);
|
||||||
@ -28,7 +30,6 @@ public:
|
|||||||
node->setRect(boundingRect());
|
node->setRect(boundingRect());
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setImage(QImage image)
|
void setImage(QImage image)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
#include <QtQml>
|
||||||
|
|
||||||
// Steam
|
// Steam
|
||||||
#include "cstring"
|
#include "cstring"
|
||||||
@ -40,6 +41,7 @@ struct SteamItemUpdate {
|
|||||||
class SteamWorkshop : public QObject {
|
class SteamWorkshop : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
QML_NAMED_ELEMENT(SteamWorkshop)
|
||||||
Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged)
|
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 itemProcessed READ itemProcessed WRITE setItemProcessed NOTIFY itemProcessedChanged)
|
||||||
Q_PROPERTY(unsigned long long bytesTotal READ bytesTotal WRITE setBytesTotal NOTIFY bytesTotalChanged)
|
Q_PROPERTY(unsigned long long bytesTotal READ bytesTotal WRITE setBytesTotal NOTIFY bytesTotalChanged)
|
||||||
|
@ -14,7 +14,7 @@ namespace ScreenPlayWorkshop {
|
|||||||
|
|
||||||
class Workshop : public QQuickItem {
|
class Workshop : public QQuickItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
QML_NAMED_ELEMENT(ScreenPlayWorkshop)
|
||||||
Q_PROPERTY(InstalledListModel* installedListModel READ installedListModel NOTIFY installedListModelChanged)
|
Q_PROPERTY(InstalledListModel* installedListModel READ installedListModel NOTIFY installedListModelChanged)
|
||||||
Q_PROPERTY(SteamWorkshop* steamWorkshop READ steamWorkshop NOTIFY steamWorkshopChanged)
|
Q_PROPERTY(SteamWorkshop* steamWorkshop READ steamWorkshop NOTIFY steamWorkshopChanged)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user