1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Add gif and website wallpaper to Installed Type enum

Also document where to change code when changing
this enum
This commit is contained in:
Elias Steurer 2020-12-12 13:47:56 +01:00
parent a414a8ebeb
commit 6d65791976
6 changed files with 96 additions and 93 deletions

View File

@ -87,5 +87,6 @@
<file>qml/Create/WizardsFiles/HTMLWallpaperMain.html</file>
<file>qml/Create/WizardsFiles/HTMLWidgetMain.html</file>
<file>qml/Common/LicenseSelector.qml</file>
<file>qml/Common/Util.js</file>
</qresource>
</RCC>

View File

@ -0,0 +1,14 @@
function isWallpaper(type) {
return type === InstalledType.VideoWallpaper
|| type === InstalledType.HTMLWallpaper
|| type === InstalledType.QMLWallpaper
|| type === InstalledType.GifWallpaper
|| type === InstalledType.WebsiteWallpaper
|| type === InstalledType.GodotWallpaper
}
function isWidget(type) {
return type === InstalledType.HTMLWidget
|| type === InstalledType.QMLWidget
}

View File

@ -5,36 +5,27 @@ import QtQuick.Controls.Styles 1.4
import ScreenPlay 1.0
import ScreenPlay.Enums.InstalledType 1.0
import "../Common/Util.js" as JSUtil
Item {
id: root
width: 320
height: 180
property string customTitle: "name here"
property string customTitle
property string screenId
property url absoluteStoragePath
property var type
property var type: InstalledType.Unknown
property int workshopID: 0
property int itemIndex
property string screenId: ""
signal openContextMenu(point position)
onTypeChanged: {
switch (type) {
case InstalledType.Unknown:
return
case InstalledType.VideoWallpaper:
case InstalledType.QMLWallpaper:
case InstalledType.HTMLWallpaper:
case InstalledType.GodotWallpaper:
case InstalledType.GifWallpaper:
case InstalledType.WebsiteWallpaper:
if (JSUtil.isWallpaper()) {
icnType.source = "qrc:/assets/icons/icon_widgets.svg"
return
case InstalledType.QMLWidget:
case InstalledType.HTMLWidget:
} else {
icnType.source = "qrc:/assets/icons/icon_movie.svg"
return
}
}
@ -92,7 +83,6 @@ Item {
spread: 0.2
color: "black"
opacity: 0.4
cornerRadius: 15
}
@ -121,6 +111,7 @@ Item {
anchors.fill: parent
sourceImage: m_preview
sourceImageGIF: m_previewGIF
type: root.type
absoluteStoragePath: m_absoluteStoragePath
}

View File

@ -9,6 +9,7 @@ Item {
property string absoluteStoragePath
property string sourceImage
property string sourceImageGIF
property var type: InstalledType.Unknown
function enter() {
if (root.sourceImageGIF != "") {

View File

@ -12,6 +12,7 @@ import ScreenPlay.Enums.InstalledType 1.0
import "../Monitors"
import "../Common" as Common
import "../Common/Util.js" as JSUtil
Item {
id: root
@ -43,7 +44,8 @@ Item {
image.playing = true
}
if (isWidget() || (monitorSelection.activeMonitors.length > 0)) {
if (JSUtil.isWidget(root.type)
|| (monitorSelection.activeMonitors.length > 0)) {
btnSetWallpaper.enabled = true
return
}
@ -51,17 +53,6 @@ Item {
btnSetWallpaper.enabled = false
}
function isWallpaper() {
return type === InstalledType.VideoWallpaper
|| type === InstalledType.HTMLWallpaper
|| type === InstalledType.QMLWallpaper
}
function isWidget() {
return type === InstalledType.HTMLWidget
|| type === InstalledType.QMLWidget
}
function indexOfValue(model, value) {
for (var i = 0; i < model.length; i++) {
@ -87,7 +78,7 @@ Item {
root.contentFolderName = folderName
root.type = type
if (root.isWallpaper()) {
if (JSUtil.isWallpaper(root.type)) {
if (type === InstalledType.VideoWallpaper) {
root.state = "activeWallpaper"
} else {
@ -117,7 +108,6 @@ Item {
id: sidebarWrapper
anchors.fill: parent
Item {
id: navBackground
height: navHeight
@ -271,7 +261,7 @@ Item {
availableHeight: height
fontSize: 11
onActiveMonitorsChanged: {
if (isWidget()) {
if (JSUtil.isWidget(root.type)) {
btnSetWallpaper.enabled = true
return
}
@ -363,7 +353,7 @@ Item {
+ "/" + root.contentFolderName
const previewImage = ScreenPlay.installedListModel.get(
root.contentFolderName).m_preview
if (root.isWallpaper()) {
if (JSUtil.isWallpaper(root.type)) {
let activeMonitors = monitorSelection.getActiveMonitors(
)
@ -374,7 +364,8 @@ Item {
// We only have sliderVolume if it is a VideoWallpaper
let volume = 0.0
if (type === InstalledType.VideoWallpaper) {
volume = Math.round(sliderVolume.slider.value * 100) / 100
volume = Math.round(
sliderVolume.slider.value * 100) / 100
}
const screenFile = ScreenPlay.installedListModel.get(
@ -387,7 +378,7 @@ Item {
1.0, {}, true)
}
if (root.isWidget()) {
if (JSUtil.isWidget(root.type)) {
ScreenPlay.screenPlayManager.createWidget(
type, Qt.point(0, 0), absoluteStoragePath,
previewImage, {}, true)
@ -404,7 +395,6 @@ Item {
State {
name: "inactive"
PropertyChanges {
target: root
anchors.rightMargin: -root.width
@ -442,7 +432,6 @@ Item {
State {
name: "activeWallpaper"
PropertyChanges {
target: image
opacity: 1

View File

@ -52,40 +52,6 @@ namespace ScreenPlay {
*/
namespace InstalledType {
Q_NAMESPACE
enum class InstalledType {
Unknown,
VideoWallpaper,
QMLWallpaper,
HTMLWallpaper,
GodotWallpaper,
GifWallpaper,
WebsiteWallpaper,
QMLWidget,
HTMLWidget,
};
Q_ENUM_NS(InstalledType)
static bool isWallpaper(const InstalledType type)
{
return (type == InstalledType::VideoWallpaper
|| type == InstalledType::QMLWallpaper
|| type == InstalledType::HTMLWallpaper
|| type == InstalledType::GifWallpaper
|| type == InstalledType::WebsiteWallpaper
|| type == InstalledType::GodotWallpaper);
}
static bool isWidget(const InstalledType type)
{
return (type == InstalledType::QMLWidget || type == InstalledType::HTMLWidget);
}
}
namespace SearchType {
Q_NAMESPACE
@ -114,6 +80,45 @@ namespace FillMode {
}
namespace InstalledType {
Q_NAMESPACE
// When changing the enum, one also needs to change:
// GlobalVariables::getAvailableWallpaper
// GlobalVariables::getAvailableWidgets
// Common/Util.js isWallpaper() and isWidget()
// ScreenPlayWallpaper: BaseWindow::parseWallpaperType()
enum class InstalledType {
Unknown,
//Wallpaper
VideoWallpaper,
QMLWallpaper,
HTMLWallpaper,
GodotWallpaper,
GifWallpaper,
WebsiteWallpaper,
//Widgets
QMLWidget,
HTMLWidget,
};
Q_ENUM_NS(InstalledType)
static bool isWallpaper(const InstalledType type)
{
return (type == InstalledType::VideoWallpaper
|| type == InstalledType::QMLWallpaper
|| type == InstalledType::HTMLWallpaper
|| type == InstalledType::GifWallpaper
|| type == InstalledType::WebsiteWallpaper
|| type == InstalledType::GodotWallpaper);
}
static bool isWidget(const InstalledType type)
{
return (type == InstalledType::QMLWidget || type == InstalledType::HTMLWidget);
}
}
class GlobalVariables : public QObject {
Q_OBJECT
@ -126,6 +131,30 @@ class GlobalVariables : public QObject {
public:
explicit GlobalVariables(QObject* parent = nullptr);
static QStringList getAvailableWallpaper()
{
return {
"qmlWallpaper",
"htmlWallpaper",
"videoWallpaper",
"godotWallpaper",
"gifWallpaper",
"websiteWallpaper"
};
}
static QStringList getAvailableWidgets()
{
return {
"qmlWidget",
"htmlWidget",
};
}
static QStringList getAvailableTypes()
{
return { getAvailableWallpaper() + getAvailableWidgets() };
}
/*!
\property GlobalVariables::localStoragePath
\brief Returns the localStoragePath.
@ -167,28 +196,6 @@ public:
return m_version;
}
static QStringList getAvailableWallpaper()
{
return {
"qmlWallpaper",
"htmlWallpaper",
"videoWallpaper",
"godotWallpaper",
};
}
static QStringList getAvailableWidgets()
{
return {
"qmlWidget",
"htmlWidget",
};
}
static QStringList getAvailableTypes()
{
return { getAvailableWallpaper() + getAvailableWidgets() };
}
signals:
void localStoragePathChanged(QUrl localStoragePath);
void localSettingsPathChanged(QUrl localSettingsPath);