diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index fff6c751..ab4cdeca 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -90,11 +90,11 @@ App::App() // 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/ - qRegisterMetaType(); - qmlRegisterUncreatableMetaObject(ScreenPlay::Enums::staticMetaObject, - "ScreenPlayEnums", + qRegisterMetaType(); + qmlRegisterUncreatableMetaObject(ScreenPlay::FillMode::staticMetaObject, + "ScreenPlay.Enums.FillMode", 1, 0, - "ScreenPlayEnums", + "FillMode", "Error: only enums"); qRegisterMetaType(); @@ -104,6 +104,13 @@ App::App() "InstalledType", "Error: only enums"); + qRegisterMetaType(); + qmlRegisterUncreatableMetaObject(ScreenPlay::SearchType::staticMetaObject, + "ScreenPlay.Enums.SearchType", + 1, 0, + "SearchType", + "Error: only enums"); + qmlRegisterAnonymousType("ScreenPlay", 1); qmlRegisterAnonymousType("ScreenPlay", 1); diff --git a/ScreenPlay/qml/Installed/Installed.qml b/ScreenPlay/qml/Installed/Installed.qml index c6de2acc..5debfc05 100644 --- a/ScreenPlay/qml/Installed/Installed.qml +++ b/ScreenPlay/qml/Installed/Installed.qml @@ -5,6 +5,8 @@ import QtQuick.Controls.Styles 1.4 import QtGraphicalEffects 1.0 import ScreenPlay 1.0 +import ScreenPlay.Enums.InstalledType 1.0 +import ScreenPlay.Enums.SearchType 1.0 Item { id: pageInstalled @@ -18,7 +20,7 @@ Item { Component.onCompleted: { pageInstalled.state = "in" - ScreenPlay.installedListFilter.sortByRoleType("All") + ScreenPlay.installedListFilter.sortBySearchType(SearchType.All) checkIsContentInstalled() } @@ -248,7 +250,7 @@ Item { icon.source: "qrc:/assets/icons/icon_installed.svg" onClicked: { setSidebarActive(false) - ScreenPlay.installedListFilter.sortByRoleType("All") + ScreenPlay.installedListFilter.sortBySearchType(SearchType.All) } } TabButton { @@ -263,7 +265,7 @@ Item { icon.source: "qrc:/assets/icons/icon_code.svg" onClicked: { setSidebarActive(false) - ScreenPlay.installedListFilter.sortByRoleType("Scenes") + ScreenPlay.installedListFilter.sortBySearchType(SearchType.Scenes) } } TabButton { @@ -278,7 +280,7 @@ Item { icon.source: "qrc:/assets/icons/icon_movie.svg" onClicked: { setSidebarActive(false) - ScreenPlay.installedListFilter.sortByRoleType("Videos") + ScreenPlay.installedListFilter.sortBySearchType(SearchType.Wallpaper) } } TabButton { @@ -293,7 +295,7 @@ Item { icon.source: "qrc:/assets/icons/icon_widgets.svg" onClicked: { setSidebarActive(false) - ScreenPlay.installedListFilter.sortByRoleType("Widgets") + ScreenPlay.installedListFilter.sortBySearchType(SearchType.Widgets) } } } diff --git a/ScreenPlay/qml/Installed/Sidebar.qml b/ScreenPlay/qml/Installed/Sidebar.qml index b0828f5a..975517a2 100644 --- a/ScreenPlay/qml/Installed/Sidebar.qml +++ b/ScreenPlay/qml/Installed/Sidebar.qml @@ -6,7 +6,7 @@ import QtQuick.Layouts 1.12 import QtQuick.Controls.Material 2.12 import ScreenPlay 1.0 -import ScreenPlayEnums 1.0 +import ScreenPlay.Enums.FillMode 1.0 import ScreenPlay.Enums.InstalledType 1.0 import "../Monitors" @@ -311,19 +311,19 @@ Item { ScreenPlay.settings.videoFillMode) model: [{ - "value": ScreenPlayEnums.Stretch, + "value": InstalledType.Stretch, "text": qsTr("Stretch") }, { - "value": ScreenPlayEnums.Fill, + "value": InstalledType.Fill, "text": qsTr("Fill") }, { - "value": ScreenPlayEnums.Contain, + "value": InstalledType.Contain, "text": qsTr("Contain") }, { - "value": ScreenPlayEnums.Cover, + "value": InstalledType.Cover, "text": qsTr("Cover") }, { - "value": ScreenPlayEnums.Scale_Down, + "value": InstalledType.Scale_Down, "text": qsTr("Scale-Down") }] } diff --git a/ScreenPlay/qml/Monitors/DefaultVideoControls.qml b/ScreenPlay/qml/Monitors/DefaultVideoControls.qml index 8c8ab14d..cc8f86b3 100644 --- a/ScreenPlay/qml/Monitors/DefaultVideoControls.qml +++ b/ScreenPlay/qml/Monitors/DefaultVideoControls.qml @@ -5,7 +5,7 @@ import QtQuick.Controls.Material 2.2 import QtQuick.Layouts 1.3 import ScreenPlay 1.0 -import ScreenPlayEnums 1.0 +import ScreenPlay.Enums.FillMode 1.0 import "../Common/" as SP @@ -86,19 +86,19 @@ ColumnLayout { model: [{ - "value": ScreenPlayEnums.Stretch, + "value": FillMode.Stretch, "text": qsTr("Stretch") }, { - "value": ScreenPlayEnums.Fill, + "value": FillMode.Fill, "text": qsTr("Fill") }, { - "value": ScreenPlayEnums.Contain, + "value": FillMode.Contain, "text": qsTr("Contain") }, { - "value": ScreenPlayEnums.Cover, + "value": FillMode.Cover, "text": qsTr("Cover") }, { - "value": ScreenPlayEnums.Scale_Down, + "value": FillMode.Scale_Down, "text": qsTr("Scale-Down") }] } diff --git a/ScreenPlay/qml/Monitors/Monitors.qml b/ScreenPlay/qml/Monitors/Monitors.qml index 3ef1b2bb..f7cde45b 100644 --- a/ScreenPlay/qml/Monitors/Monitors.qml +++ b/ScreenPlay/qml/Monitors/Monitors.qml @@ -5,7 +5,7 @@ import QtQuick.Controls.Material 2.2 import QtQuick.Layouts 1.3 import ScreenPlay 1.0 -import ScreenPlayEnums 1.0 +import ScreenPlay.Enums.InstalledType 1.0 import "../Common/" as SP Item { @@ -107,7 +107,7 @@ Item { videoControlWrapper.state = "visible" customPropertiesGridView.model = listModel - if (type === ScreenPlayEnums.VideoWallpaper) { + if (type === InstalledType.VideoWallpaper) { customPropertiesGridView.state = "hidden" videoControlWrapper.state = "visible" } else { diff --git a/ScreenPlay/qml/Settings/Settings.qml b/ScreenPlay/qml/Settings/Settings.qml index 8387f0e6..68a29b62 100644 --- a/ScreenPlay/qml/Settings/Settings.qml +++ b/ScreenPlay/qml/Settings/Settings.qml @@ -7,7 +7,7 @@ import QtGraphicalEffects 1.0 import Qt.labs.platform 1.0 import ScreenPlay 1.0 -import ScreenPlayEnums 1.0 +import ScreenPlay.Enums.FillMode 1.0 import Settings 1.0 import "../Common" @@ -322,19 +322,19 @@ Item { cbVideoFillMode.comboBox.currentValue) model: [{ - "value": ScreenPlayEnums.Stretch, + "value": FillMode.Stretch, "text": qsTr("Stretch") }, { - "value": ScreenPlayEnums.Fill, + "value": FillMode.Fill, "text": qsTr("Fill") }, { - "value": ScreenPlayEnums.Contain, + "value": FillMode.Contain, "text": qsTr("Contain") }, { - "value": ScreenPlayEnums.Cover, + "value": FillMode.Cover, "text": qsTr("Cover") }, { - "value": ScreenPlayEnums.Scale_Down, + "value": FillMode.Scale_Down, "text": qsTr("Scale-Down") }] } diff --git a/ScreenPlay/src/globalvariables.h b/ScreenPlay/src/globalvariables.h index e032f250..faff2464 100644 --- a/ScreenPlay/src/globalvariables.h +++ b/ScreenPlay/src/globalvariables.h @@ -57,10 +57,12 @@ namespace InstalledType { enum class InstalledType { Unknown, + VideoWallpaper, QMLWallpaper, HTMLWallpaper, GodotWallpaper, + QMLWidget, HTMLWidget, }; @@ -68,7 +70,21 @@ namespace InstalledType { } -namespace Enums { +namespace SearchType { + Q_NAMESPACE + + enum class SearchType { + All, + Text, + Scenes, //QML, HTML, Godot wallpaper + Wallpaper, + Widget, + }; + Q_ENUM_NS(SearchType) + +} + +namespace FillMode { Q_NAMESPACE enum class FillMode { diff --git a/ScreenPlay/src/installedlistfilter.cpp b/ScreenPlay/src/installedlistfilter.cpp index e7e9759f..f19c1d33 100644 --- a/ScreenPlay/src/installedlistfilter.cpp +++ b/ScreenPlay/src/installedlistfilter.cpp @@ -20,42 +20,13 @@ InstalledListFilter::InstalledListFilter(const std::shared_ptr #include #include +#include "globalvariables.h" +#include "installedlistmodel.h" + namespace ScreenPlay { class InstalledListFilter : public QSortFilterProxyModel { @@ -48,11 +50,12 @@ public: InstalledListFilter(const std::shared_ptr& ilm); public slots: - void sortByRoleType(QString type); - void sortByName(QString name); + void sortBySearchType(const ScreenPlay::SearchType::SearchType searchType); + void sortByName(const QString& name); void resetFilter(); private: const std::shared_ptr m_ilm; + ScreenPlay::SearchType::SearchType m_searchType = ScreenPlay::SearchType::SearchType::All; }; } diff --git a/ScreenPlay/src/installedlistmodel.cpp b/ScreenPlay/src/installedlistmodel.cpp index 2868577f..8098dcfa 100644 --- a/ScreenPlay/src/installedlistmodel.cpp +++ b/ScreenPlay/src/installedlistmodel.cpp @@ -84,6 +84,8 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const return m_screenPlayFiles.at(row).m_workshopID; case TagsRole: return m_screenPlayFiles.at(row).m_tags; + case SearchTypeRole: + return QVariant::fromValue(m_screenPlayFiles.at(row).m_searchType); default: return QVariant(); } @@ -105,6 +107,7 @@ QHash InstalledListModel::roleNames() const { AbsoluteStoragePathRole, "screenAbsoluteStoragePath" }, { WorkshopIDRole, "screenWorkshopID" }, { TagsRole, "screenTags" }, + { SearchTypeRole, "screenSearchType" }, }; return roles; } @@ -153,7 +156,7 @@ void InstalledListModel::loadInstalledContent() }); } -QVariantMap InstalledListModel::get(QString folderId) +QVariantMap InstalledListModel::get(QString folderId) const { QVariantMap map; diff --git a/ScreenPlay/src/installedlistmodel.h b/ScreenPlay/src/installedlistmodel.h index e12c3a0f..bfecc4b8 100644 --- a/ScreenPlay/src/installedlistmodel.h +++ b/ScreenPlay/src/installedlistmodel.h @@ -85,6 +85,7 @@ public: AbsoluteStoragePathRole, WorkshopIDRole, TagsRole, + SearchTypeRole, }; Q_ENUM(InstalledRole) @@ -93,13 +94,12 @@ public: return m_count; } - public slots: void loadInstalledContent(); void append(const QJsonObject&, const QString&); void reset(); void init(); - QVariantMap get(QString folderId); + QVariantMap get(QString folderId) const; void setCount(int count) { diff --git a/ScreenPlay/src/projectfile.h b/ScreenPlay/src/projectfile.h index 5d63a86d..987e3fe5 100644 --- a/ScreenPlay/src/projectfile.h +++ b/ScreenPlay/src/projectfile.h @@ -102,9 +102,11 @@ struct ProjectFile { QString type = obj.value("type").toString(); if (type.endsWith("Wallpaper")) { if (type.startsWith("video")) { + m_searchType = SearchType::SearchType::Wallpaper; m_type = InstalledType::InstalledType::VideoWallpaper; return; } + m_searchType = SearchType::SearchType::Scenes; if (type.startsWith("qml")) { m_type = InstalledType::InstalledType::QMLWallpaper; return; @@ -120,6 +122,7 @@ struct ProjectFile { } if (type.endsWith("Widget")) { + m_searchType = SearchType::SearchType::Widget; if (type.startsWith("qml")) { m_type = InstalledType::InstalledType::QMLWidget; return; @@ -144,6 +147,7 @@ struct ProjectFile { QString m_folderId; QUrl m_absoluteStoragePath; InstalledType::InstalledType m_type = InstalledType::InstalledType::Unknown; + SearchType::SearchType m_searchType = SearchType::SearchType::All; int m_workshopID { 0 }; QVariantList m_tags; }; diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 77513226..a097944e 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -39,7 +39,7 @@ ScreenPlayManager::ScreenPlayManager( */ void ScreenPlayManager::createWallpaper( const InstalledType::InstalledType type, - const Enums::FillMode fillMode, + const FillMode::FillMode fillMode, const QString& absoluteStoragePath, const QString& previewImage, const QString& file, @@ -366,7 +366,7 @@ void ScreenPlayManager::loadProfiles() QString typeString = wallpaperObj.value("type").toString(); auto type = QStringToEnum(typeString, InstalledType::InstalledType::VideoWallpaper); - auto fillMode = QStringToEnum(fillModeString, Enums::FillMode::Cover); + auto fillMode = QStringToEnum(fillModeString, FillMode::FillMode::Cover); createWallpaper(type, fillMode, absolutePath, previewImage, file, monitors, volume, false); monitors.clear(); diff --git a/ScreenPlay/src/screenplaymanager.h b/ScreenPlay/src/screenplaymanager.h index 75e9511d..de9d83e5 100644 --- a/ScreenPlay/src/screenplaymanager.h +++ b/ScreenPlay/src/screenplaymanager.h @@ -94,7 +94,7 @@ public slots: // moc needs full enum namespace info see QTBUG-58454 void createWallpaper( const ScreenPlay::InstalledType::InstalledType type, - const ScreenPlay::Enums::FillMode fillMode, + const ScreenPlay::FillMode::FillMode fillMode, const QString& absoluteStoragePath, const QString& previewImage, const QString& file, diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index f6a75361..266aaae6 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -21,7 +21,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper( const QString& previewImage, const QString& file, const float volume, - const Enums::FillMode fillMode, + const FillMode::FillMode fillMode, const InstalledType::InstalledType type, const bool checkWallpaperVisible, QObject* parent) diff --git a/ScreenPlay/src/screenplaywallpaper.h b/ScreenPlay/src/screenplaywallpaper.h index c01d4419..dfeb2c22 100644 --- a/ScreenPlay/src/screenplaywallpaper.h +++ b/ScreenPlay/src/screenplaywallpaper.h @@ -60,7 +60,7 @@ class ScreenPlayWallpaper : public QObject { Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged) Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged) - Q_PROPERTY(Enums::FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) + Q_PROPERTY(FillMode::FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) Q_PROPERTY(InstalledType::InstalledType type READ type WRITE setType NOTIFY typeChanged) public: @@ -72,7 +72,7 @@ public: const QString& previewImage, const QString& file, const float volume, - const Enums::FillMode fillMode, + const FillMode::FillMode fillMode, const InstalledType::InstalledType type, const bool checkWallpaperVisible, QObject* parent = nullptr); @@ -104,7 +104,7 @@ public: return m_file; } - Enums::FillMode fillMode() const + FillMode::FillMode fillMode() const { return m_fillMode; } @@ -132,7 +132,7 @@ signals: void appIDChanged(QString appID); void typeChanged(InstalledType::InstalledType type); void fileChanged(QString file); - void fillModeChanged(Enums::FillMode fillMode); + void fillModeChanged(FillMode::FillMode fillMode); void absolutePathChanged(QString absolutePath); void profileJsonObjectChanged(QJsonObject profileJsonObject); void volumeChanged(float volume); @@ -187,7 +187,7 @@ public slots: emit fileChanged(m_file); } - void setFillMode(Enums::FillMode fillMode) + void setFillMode(FillMode::FillMode fillMode) { if (m_fillMode == fillMode) return; @@ -236,7 +236,7 @@ private: QString m_previewImage; InstalledType::InstalledType m_type; - Enums::FillMode m_fillMode; + FillMode::FillMode m_fillMode; QString m_appID; QString m_absolutePath; QString m_file; diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index b763141b..9d48b7f2 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -64,9 +64,9 @@ Settings::Settings(const std::shared_ptr& globalVariables, setHighPriorityStart(m_qSettings.value("ScreenPlayExecutable", false).toBool()); if (m_qSettings.contains("VideoFillMode")) { auto value = m_qSettings.value("VideoFillMode").toString(); - setVideoFillMode(QStringToEnum(value, Enums::FillMode::Cover)); + setVideoFillMode(QStringToEnum(value, FillMode::FillMode::Cover)); } else { - setVideoFillMode(Enums::FillMode::Cover); + setVideoFillMode(FillMode::FillMode::Cover); } if (m_qSettings.contains("Theme")) { diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 0bacd6a7..c01acedd 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -83,7 +83,7 @@ class Settings : public QObject { Q_PROPERTY(bool checkWallpaperVisible READ checkWallpaperVisible WRITE setCheckWallpaperVisible NOTIFY checkWallpaperVisibleChanged) Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY offlineModeChanged) - Q_PROPERTY(ScreenPlay::Enums::FillMode videoFillMode READ videoFillMode WRITE setVideoFillMode NOTIFY videoFillModeChanged) + Q_PROPERTY(ScreenPlay::FillMode::FillMode videoFillMode READ videoFillMode WRITE setVideoFillMode NOTIFY videoFillModeChanged) Q_PROPERTY(Language language READ language WRITE setLanguage NOTIFY languageChanged) Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged) @@ -159,7 +159,7 @@ public: return m_checkWallpaperVisible; } - ScreenPlay::Enums::FillMode videoFillMode() const + ScreenPlay::FillMode::FillMode videoFillMode() const { return m_videoFillMode; } @@ -196,7 +196,7 @@ signals: void silentStartChanged(bool silentStart); void anonymousTelemetryChanged(bool anonymousTelemetry); void checkWallpaperVisibleChanged(bool checkWallpaperVisible); - void videoFillModeChanged(ScreenPlay::Enums::FillMode videoFillMode); + void videoFillModeChanged(ScreenPlay::FillMode::FillMode videoFillMode); void languageChanged(Language language); void fontChanged(QString font); void themeChanged(Theme theme); @@ -314,7 +314,7 @@ public slots: emit checkWallpaperVisibleChanged(m_checkWallpaperVisible); } - void setVideoFillMode(ScreenPlay::Enums::FillMode videoFillMode) + void setVideoFillMode(ScreenPlay::FillMode::FillMode videoFillMode) { if (m_videoFillMode == videoFillMode) return; @@ -374,7 +374,7 @@ private: QString m_gitBuildHash; QString m_decoder; - ScreenPlay::Enums::FillMode m_videoFillMode { ScreenPlay::Enums::FillMode::Cover }; + ScreenPlay::FillMode::FillMode m_videoFillMode { ScreenPlay::FillMode::FillMode::Cover }; Language m_language { Language::En }; Theme m_theme { Theme::System }; QString m_font { "Roboto" };