1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Cleanup and small fixes

This commit is contained in:
Elias Steurer 2023-06-02 10:19:12 +02:00
parent 38f6262f8e
commit 11905a6370
19 changed files with 135 additions and 167 deletions

View File

@ -14,7 +14,7 @@ Item {
property Item modalSource
Component.onCompleted: {
StackView.onActivated: {
wizardContentWrapper.state = "in";
stackView.push("qrc:/qml/ScreenPlayApp/qml/Create/StartInfo.qml");
}

View File

@ -39,7 +39,7 @@ Item {
}
}
Component.onCompleted: {
StackView.onActivated: {
navWrapper.state = "in";
App.installedListFilter.sortBySearchType(SearchType.All);
checkIsContentInstalled();

View File

@ -76,19 +76,6 @@ Item {
SettingsHorizontalSeperator {
}
SettingBool {
headline: qsTr("High priority Autostart")
available: false
description: qsTr("This options grants ScreenPlay a higher autostart priority than other apps.")
isChecked: App.settings.highPriorityStart
onCheckboxChanged: {
App.settings.setHighPriorityStart(checked);
}
}
SettingsHorizontalSeperator {
}
SettingBool {
height: 70
headline: qsTr("Send anonymous crash reports and statistics")
@ -240,7 +227,7 @@ Item {
header: SettingsHeader {
id: headerPerformance
text: qsTr("Performance")
text: qsTr("Wallpaper and Widgets")
image: "qrc:/qml/ScreenPlayApp/assets/icons/icon_build.svg"
}
@ -249,22 +236,10 @@ Item {
anchors.margins: 20
spacing: 20
SettingBool {
headline: qsTr("Pause wallpaper video rendering while another app is in the foreground")
description: qsTr("We disable the video rendering (not the audio!) for the best performance. If you have problem you can disable this behaviour here. Wallpaper restart required!")
isChecked: App.settings.checkWallpaperVisible
onCheckboxChanged: function (checked) {
App.settings.setCheckWallpaperVisible(checked);
}
}
SettingsHorizontalSeperator {
}
SettingsComboBox {
id: cbVideoFillMode
headline: qsTr("Default Fill Mode")
headline: qsTr("Default Wallpaper Fill Mode")
description: qsTr("Set this property to define how the video is scaled to fit the target area.")
Component.onCompleted: {
cbVideoFillMode.comboBox.currentIndex = root.indexOfValue(cbVideoFillMode.comboBox.model, App.settings.videoFillMode);

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
#pragma once
#include <qobjectdefs.h>
#include <QtCore/qmetatype.h>
#include <QObject>
namespace ScreenPlay {
/*!
\namespace ScreenPlay::SearchType

View File

@ -20,7 +20,7 @@ ScreenPlay::WallpaperExitCode MacWindow::start()
// OSX Development workaround:
// This folder needs then to be copied into the .app/Contents/MacOS/
// for the deploy version.
m_window.engine()->addImportPath(QGuiApplication::instance()->applicationDirPath()+ "/qml");
m_window.engine()->addImportPath(QGuiApplication::instance()->applicationDirPath() + "/qml");
// WARNING: Setting Window flags must be called *here*!
Qt::WindowFlags flags = m_window.flags();

View File

@ -33,7 +33,7 @@ int main(int argc, char* argv[])
// If we start with only one argument (path, appID, type),
// it means we want to test a single widget
if (argumentList.length() == 1) {
//WidgetWindow spwmw("test", "appid", "qmlWidget", { 100, 100 }, true);
// WidgetWindow spwmw("test", "appid", "qmlWidget", { 100, 100 }, true);
QString exampleContentPath = QString(SCREENPLAY_SOURCE_DIR) + "/Content";
QStringList contentFolder = {

View File

@ -5,8 +5,6 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import ScreenPlayWorkshop
import ScreenPlayUtil
import ScreenPlayApp
import ScreenPlay
Popup {
id: root

View File

@ -8,12 +8,12 @@ import "upload/"
Item {
id: root
objectName: "WorkshopProfilePage"
property ScreenPlayWorkshop screenPlayWorkshop
property SteamWorkshop steamWorkshop
signal requestBack
Component.onCompleted: steamWorkshop.requestUserItems()
property StackView stackView
StackView.onActivated: steamWorkshop.requestUserItems()
Flickable {
id: scrollView
@ -39,28 +39,11 @@ Item {
verticalCenter: parent.verticalCenter
}
spacing: 20
SteamImage {
SteamProfilePicture {
id: avatar
width: 70
height: 70
Component.onCompleted: {
root.steamWorkshop.steamAccount.loadAvatar();
}
Connections {
function onAvatarChanged(_avatar) {
avatar.setImage(_avatar);
avatarPlaceholder.opacity = 0;
}
target: root.steamWorkshop.steamAccount
}
Image {
id: avatarPlaceholder
anchors.fill: parent
source: "qrc:/qml/ScreenPlayWorkshop/assets/images/steam_default_avatar.png"
}
}
Text {
@ -71,7 +54,9 @@ Item {
Button {
text: qsTr("Back")
onClicked: root.requestBack()
onClicked: {
stackView.pop();
}
}
}
}

View File

@ -44,15 +44,6 @@ Item {
StackView {
id: stackView
property int duration: 300
Connections {
target: stackView.currentItem
ignoreUnknownSignals: true
function onRequestBack() {
stackView.pop();
}
}
anchors.fill: parent
replaceEnter: Transition {
OpacityAnimator {

View File

@ -15,7 +15,7 @@ Item {
property SteamWorkshop steamWorkshop
property Background background
Component.onCompleted: {
StackView.onActivated: {
root.state = "searching";
root.steamWorkshop.searchWorkshopByText("");
}
@ -239,6 +239,7 @@ Item {
Button {
id: btnSteamProfile
objectName: "btnSteamProfile"
anchors {
verticalCenter: parent.verticalCenter
@ -251,7 +252,8 @@ Item {
onClicked: {
stackView.push("qrc:/qml/ScreenPlayWorkshop/qml/SteamProfile.qml", {
"screenPlayWorkshop": root.screenPlayWorkshop,
"steamWorkshop": root.steamWorkshop
"steamWorkshop": root.steamWorkshop,
"stackView": root.stackView
});
}
}
@ -270,7 +272,8 @@ Item {
onClicked: {
stackView.push("qrc:/qml/ScreenPlayWorkshop/qml/upload/UploadProject.qml", {
"screenPlayWorkshop": root.screenPlayWorkshop,
"steamWorkshop": root.steamWorkshop
"steamWorkshop": root.steamWorkshop,
"stackView": root.stackView
});
}
}
@ -287,43 +290,44 @@ Item {
leftMargin: 20
verticalCenter: parent.verticalCenter
}
ToolButton {
icon.source: "qrc:/qml/ScreenPlayWorkshop/assets/icons/icon_search.svg"
onClicked: {
root.state = "searching";
root.steamWorkshop.searchWorkshopByText(tiSearch.text);
}
icon.width: 20
icon.height: 20
anchors {
left: parent.left
leftMargin: -3
bottom: parent.bottom
bottomMargin: 3
}
}
TextField {
id: tiSearch
placeholderTextColor: Material.secondaryTextColor
placeholderText: qsTr("Search for Wallpaper and Widgets...")
// WORKAROUND:
// onEditingFinished causes internal qml layout crash in Qt 6.4
Keys.onReturnPressed: event => {
event.accepted = true;
tiSearch.searchWorkshop();
}
// WORKAROUND:
// onEditingFinished causes internal qml layout crash in Qt 6.4
Timer {
id: timer
interval: 300
repeat: false
onTriggered: tiSearch.searchWorkshop()
}
onTextEdited: timer.restart()
function searchWorkshop() {
if (root.state === "searching") {
print("SEARCHING");
return;
}
root.state = "searching";
print("EDITING FINISHED", root.state);
if (tiSearch.text === "")
return root.steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend);
if (tiSearch.text === "") {
Qt.callLater(function () {
root.steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend);
});
return;
}
Qt.callLater(function () {
root.steamWorkshop.searchWorkshopByText(tiSearch.text);
});
}
leftInset: -20
leftPadding: 20
anchors {
top: parent.top
right: parent.right
@ -333,20 +337,29 @@ Item {
}
}
ToolButton {
icon.source: "qrc:/qml/ScreenPlayWorkshop/assets/icons/icon_close.svg"
property bool hasContent: tiSearch.text.length > 0
icon.source: hasContent ? "qrc:/qml/ScreenPlayWorkshop/assets/icons/icon_close.svg" : "qrc:/qml/ScreenPlayWorkshop/assets/icons/icon_search.svg"
onClicked: {
if (hasContent) {
root.state = "searching";
tiSearch.text = "";
tiSearch.clear();
Qt.callLater(function () {
root.steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend);
});
return;
}
root.state = "searching";
Qt.callLater(function () {
root.steamWorkshop.searchWorkshopByText(tiSearch.text);
});
}
enabled: tiSearch.text !== ""
icon.width: 20
icon.height: 20
anchors {
right: parent.right
rightMargin: -3
rightMargin: 0
bottom: parent.bottom
bottomMargin: 3
bottomMargin: 0
}
}
}

View File

@ -9,8 +9,7 @@ Item {
property ScreenPlayWorkshop screenPlayWorkshop
property SteamWorkshop steamWorkshop
signal requestBack
property StackView stackView
Item {
id: headerWrapper
@ -109,7 +108,7 @@ Item {
text: qsTr("Abort")
onClicked: {
root.requestBack();
stackView.pop();
}
anchors {

View File

@ -14,6 +14,9 @@ SteamAccount::SteamAccount(QObject* parent)
void SteamAccount::loadAvatar()
{
if (!m_avatar.isNull()) {
return;
}
int largeFriendAvatarHandle = SteamFriends()->GetLargeFriendAvatar(m_steamID);
// Returns 0 if no avatar is set for the user.
@ -43,40 +46,33 @@ void SteamAccount::loadAmountSubscribedItems()
void SteamAccount::onAvatarImageLoaded(AvatarImageLoaded_t* avatarImage)
{
// If called from another steam app
if (m_avatarLoaded)
return;
const int largeFriendAvatarHandle = SteamFriends()->GetLargeFriendAvatar(m_steamID);
if (largeFriendAvatarHandle <= 0) {
qWarning() << "onAvatarImageLoaded: getLargeFriendAvatarResult retunred: " << largeFriendAvatarHandle;
qWarning() << "onAvatarImageLoaded: GetLargeFriendAvatar returned: " << largeFriendAvatarHandle;
return;
}
uint32 width = 0;
uint32 height = 0;
if (!SteamUtils()->GetImageSize(avatarImage->m_iImage, &width, &height)) {
qWarning() << "Failed GetImageSize";
const bool sizeRetrieved = SteamUtils()->GetImageSize(avatarImage->m_iImage, &width, &height);
if (!sizeRetrieved) {
qWarning() << "onAvatarImageLoaded: Failed to get image size";
return;
}
const int size = width * height * 4;
QVector<uint8> imageData;
imageData.resize(size);
if (!SteamUtils()->GetImageRGBA(avatarImage->m_iImage, imageData.data(), size)) {
qWarning() << "Failed to load image buffer from callback";
const int imageSize = width * height * 4;
QVector<uint8> imageData(imageSize);
const bool imageRetrieved = SteamUtils()->GetImageRGBA(avatarImage->m_iImage, imageData.data(), imageSize);
if (!imageRetrieved) {
qWarning() << "onAvatarImageLoaded: Failed to load image buffer from callback";
return;
}
QImage avatar {
imageData.data(),
static_cast<int>(width),
static_cast<int>(height),
QImage::Format_RGBA8888
};
const QImage avatar { imageData.data(), static_cast<int>(width), static_cast<int>(height), QImage::Format_RGBA8888 };
setAvatar(avatar);
m_avatarLoaded = true;
}

View File

@ -11,17 +11,16 @@
#include "steamapiwrapper.h"
namespace SteamApiWrapper {
bool setItemTags(const QVariant& updateHandle, const QStringList tags)
bool setItemTags(const QVariant& updateHandle, const QStringList& tags)
{
SteamParamStringArray_t* pTags = new SteamParamStringArray_t();
const uint32 strCount = tags.size();
pTags->m_ppStrings = new const char*[strCount];
pTags->m_nNumStrings = strCount;
for (uint32 i = 0; i < strCount; i++) {
pTags->m_ppStrings[i] = tags.at(i).toUtf8().data();
auto pTags = std::make_unique<SteamParamStringArray_t>();
const uint32_t numTags = tags.size();
pTags->m_nNumStrings = numTags;
auto tagStrings = std::make_unique<const char*[]>(numTags);
for (uint32_t i = 0; i < numTags; ++i) {
tagStrings[i] = tags.at(i).toUtf8().constData();
}
return SteamUGC()->SetItemTags(updateHandle.toULongLong(), pTags);
pTags->m_ppStrings = tagStrings.get();
return SteamUGC()->SetItemTags(updateHandle.toULongLong(), pTags.get());
}
}

View File

@ -37,9 +37,14 @@ void SteamWorkshopItem::checkUploadProgress()
if (progress > 0.0f && progress < 1.0f)
setUploadProgress((progress * 100));
}
void SteamWorkshopItem::uploadItemToWorkshop(CreateItemResult_t* pCallback, bool bIOFailure)
{
if (!pCallback) {
qWarning() << "Invalid CreateItemResult_t pointer";
emit removeThis(this);
return;
}
if (pCallback->m_bUserNeedsToAcceptWorkshopLegalAgreement) {
emit userNeedsToAcceptWorkshopLegalAgreement();
}
@ -87,7 +92,7 @@ void SteamWorkshopItem::uploadItemToWorkshop(CreateItemResult_t* pCallback, bool
QString youtube;
if (jsonObject.contains("youtube")) {
language = jsonObject.value("youtube").toString();
youtube = jsonObject.value("youtube").toString();
}
if (!youtube.isEmpty()) {
@ -132,21 +137,21 @@ void SteamWorkshopItem::uploadItemToWorkshop(CreateItemResult_t* pCallback, bool
m_UGCUpdateHandle = SteamUGC()->StartItemUpdate(m_appID, pCallback->m_nPublishedFileId);
QVector<QByteArray> tagByteArray;
QVector<const char*> tagCharArray;
for (const auto& tag : tags) {
if (tag.length() > 255) {
qInfo() << "Skip to long tag (max 255) " << tag << " with length:" << tag.length();
qInfo() << "Skip too long tag (max 255):" << tag;
continue;
}
tagByteArray.append(tag.toUtf8());
pTags->m_ppStrings[i] = tagByteArray.at(i).data();
qInfo() << tag.toStdString().c_str() << pTags->m_ppStrings[i];
i++;
tagCharArray.append(tag.toUtf8());
}
pTags->m_nNumStrings = count;
bool success = SteamUGC()->SetItemTags(m_UGCUpdateHandle, pTags);
qInfo() << "SetItemTags" << success;
pTags->m_nNumStrings = tagCharArray.count();
pTags->m_ppStrings = tagCharArray.data();
bool success = SteamUGC()->SetItemTags(m_UGCUpdateHandle, pTags);
if (!success) {
qWarning() << "Failed to set item tags";
}
SteamUGC()->AddItemPreviewFile(m_UGCUpdateHandle, QByteArray(preview.toUtf8()).data(), EItemPreviewType::k_EItemPreviewType_Image);
SteamUGC()->SetItemTitle(m_UGCUpdateHandle, QByteArray(title.toUtf8().data()));
SteamUGC()->SetItemDescription(m_UGCUpdateHandle, QByteArray(description.toUtf8()).data());
@ -159,6 +164,11 @@ void SteamWorkshopItem::uploadItemToWorkshop(CreateItemResult_t* pCallback, bool
saveWorkshopID();
SteamAPICall_t apicall = SteamUGC()->SubmitItemUpdate(m_UGCUpdateHandle, nullptr);
if (apicall == k_uAPICallInvalid) {
qWarning() << "Failed to submit item update";
return;
}
m_submitItemUpdateResultResult.Set(apicall, this, &SteamWorkshopItem::submitItemUpdateStatus);
m_updateTimer.start(m_updateTimerInterval);
}

View File

@ -94,37 +94,39 @@ public slots:
m_uploadListModelItems.clear();
endResetModel();
}
void append(const QString& name, const QString& path, const quint64 appID)
{
auto item = std::make_unique<SteamWorkshopItem>(name, path, appID);
const auto roles = QVector<int> {
static_cast<int>(UploadListModelRole::UploadProgressRole),
static_cast<int>(UploadListModelRole::NameRole),
static_cast<int>(UploadListModelRole::AbsolutePreviewImagePath),
static_cast<int>(UploadListModelRole::Status)
};
const auto onDataChanged = [&]() {
emit this->dataChanged(index(0, 0), index(rowCount() - 1, 0), roles);
};
QObject::connect(item.get(), &SteamWorkshopItem::userNeedsToAcceptWorkshopLegalAgreement, this, &UploadListModel::userNeedsToAcceptWorkshopLegalAgreement);
QObject::connect(item.get(), &SteamWorkshopItem::uploadProgressChanged, this, onDataChanged);
QObject::connect(item.get(), &SteamWorkshopItem::nameChanged, this, onDataChanged);
QObject::connect(item.get(), &SteamWorkshopItem::absolutePreviewImagePathChanged, this, onDataChanged);
QObject::connect(item.get(), &SteamWorkshopItem::uploadComplete, this, [=](bool successful) {
onDataChanged();
});
QObject::connect(item.get(), &SteamWorkshopItem::statusChanged, this, [=](ScreenPlayWorkshopSteamEnums::EResult status) {
onDataChanged();
QObject::connect(item.get(), &SteamWorkshopItem::uploadProgressChanged, this, [this]() {
emit this->dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int> { static_cast<int>(UploadListModelRole::UploadProgressRole) });
bool allItemsUploaded = std::all_of(m_uploadListModelItems.cbegin(), m_uploadListModelItems.cend(), [](const auto& item) {
const auto status = item->status();
return status == ScreenPlayWorkshopSteamEnums::EResult::K_EResultOK || status == ScreenPlayWorkshopSteamEnums::EResult::K_EResultFail;
});
QObject::connect(item.get(), &SteamWorkshopItem::nameChanged, this, [this]() {
emit this->dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int> { static_cast<int>(UploadListModelRole::NameRole) });
});
QObject::connect(item.get(), &SteamWorkshopItem::absolutePreviewImagePathChanged, this, [this]() {
emit this->dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int> { static_cast<int>(UploadListModelRole::AbsolutePreviewImagePath) });
});
QObject::connect(item.get(), &SteamWorkshopItem::uploadComplete, this, [this](bool successful) {
emit this->dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int> { static_cast<int>(UploadListModelRole::AbsolutePreviewImagePath) });
});
QObject::connect(item.get(), &SteamWorkshopItem::statusChanged, this, [this](ScreenPlayWorkshopSteamEnums::EResult status) {
emit this->dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int> { static_cast<int>(UploadListModelRole::Status) });
// Check if all items are
for (const auto& item : m_uploadListModelItems) {
qDebug() << "item->status() " << item->status();
if (!(item->status() != ScreenPlayWorkshopSteamEnums::EResult::K_EResultOK
|| item->status() != ScreenPlayWorkshopSteamEnums::EResult::K_EResultFail)) {
return;
}
}
if (allItemsUploaded) {
emit this->uploadCompleted();
}
});
beginInsertRows(QModelIndex(), rowCount(), rowCount());

View File

@ -7,7 +7,7 @@ choco pack
Install the generated nupkg:
```
choco install screenplay.0.15.0-RC5.nupkg -dv -s .
choco install screenplay.0.15.0-RC6.nupkg -dv -s .
```
Set api key from [https://community.chocolatey.org/account](https://community.chocolatey.org/account):
@ -17,5 +17,5 @@ choco apikey --key AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAA --source https://push.chocol
Psuh:
```
choco push screenplay.0.15.0-RC5.nupkg --source https://push.chocolatey.org/
choco push screenplay.0.15.0-RC6.nupkg --source https://push.chocolatey.org/
```

View File

@ -26,7 +26,7 @@ This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Refe
<!-- version should MATCH as closely as possible with the underlying software -->
<!-- Is the version a prerelease of a version? https://docs.nuget.org/create/versioning#creating-prerelease-packages -->
<!-- Note that unstable versions like 0.0.1 can be considered a released version, but it's possible that one can release a 0.0.1-beta before you release a 0.0.1 version. If the version number is final, that is considered a released version and not a prerelease. -->
<version>0.15.0-RC5</version>
<version>0.15.0-RC6</version>
<packageSourceUrl>https://gitlab.com/kelteseth/ScreenPlay/-/tree/master/Tools/chocolatey/ScreenPlay</packageSourceUrl>
<!-- owners is a poor name for maintainers of the package. It sticks around by this name for compatibility reasons. It basically means you. -->
<owners>Elias Steurer</owners>

View File

@ -2,7 +2,7 @@
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = ''
$url64 = 'https://kelteseth.com/releases/0.15.0-RC5/ScreenPlay-0.15.0-RC5-x64-windows-release.zip'
$url64 = 'https://kelteseth.com/releases/0.15.0-RC6/ScreenPlay-0.15.0-RC6-x64-windows-release.zip'
$packageArgs = @{
packageName = $env:ChocolateyPackageName