1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

Merge branch '47-mark-new-wallpapers-with-a-banner' into 'master'

Resolve "Mark new wallpapers with a banner"

Closes #47

See merge request kelteseth/ScreenPlay!69
This commit is contained in:
Elias Steurer 2021-08-31 13:16:00 +00:00
commit 5b954e46d0
8 changed files with 74 additions and 41 deletions

View File

@ -130,5 +130,6 @@
<file>assets/icons/brand_reddit.svg</file>
<file>assets/icons/steam_default_avatar.png</file>
<file>assets/macos/app.screenplay.plist</file>
<file>assets/icons/item_banner_new.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 320 180" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(0.319516,0.319516,-0.498372,0.498372,302.434,-166.795)">
<path d="M350.406,189.405L226.597,189.405L189.603,213.123L387.4,213.123L350.406,189.405Z" style="fill:rgb(255,152,0);"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 672 B

View File

@ -207,6 +207,7 @@ Item {
focus: true
customTitle: m_title
type: m_type
isNew: m_isNew
screenId: m_folderId
absoluteStoragePath: m_absoluteStoragePath
publishedFileID: m_publishedFileID

View File

@ -17,6 +17,7 @@ Item {
property var publishedFileID: 0
property int itemIndex
property bool isScrolling: false
property bool isNew: false
signal openContextMenu(point position)
@ -24,16 +25,16 @@ Item {
height: 180
onTypeChanged: {
if (JSUtil.isWidget(type)) {
icnType.source = "qrc:/assets/icons/icon_widgets.svg";
return ;
icnType.source = "qrc:/assets/icons/icon_widgets.svg"
return
}
if (JSUtil.isScene(type)) {
icnType.source = "qrc:/assets/icons/icon_code.svg";
return ;
icnType.source = "qrc:/assets/icons/icon_code.svg"
return
}
if (JSUtil.isVideo(type)) {
icnType.source = "qrc:/assets/icons/icon_movie.svg";
return ;
icnType.source = "qrc:/assets/icons/icon_movie.svg"
return
}
}
@ -41,11 +42,11 @@ Item {
running: true
onTriggered: showAnim.start()
interval: {
var itemIndexMax = itemIndex;
var itemIndexMax = itemIndex
if (itemIndex > 30)
itemIndexMax = 3;
itemIndexMax = 3
5 * itemIndexMax * Math.random();
5 * itemIndexMax * Math.random()
}
}
@ -78,7 +79,6 @@ Item {
duration: 200
easing.type: Easing.OutCirc
}
}
OpacityAnimator {
@ -88,7 +88,6 @@ Item {
duration: 800
easing.type: Easing.OutCirc
}
}
RectangularGlow {
@ -107,7 +106,6 @@ Item {
top: parent.top
topMargin: 3
}
}
Item {
@ -174,22 +172,37 @@ Item {
left: parent.left
margins: 10
}
}
Rectangle {
color: "#AAffffff"
height: 30
visible: false
anchors {
right: parent.right
left: parent.left
bottom: parent.bottom
width: 120
height: 20
anchors{
top:parent.top
right:parent.right
rightMargin: -60
topMargin: -20
}
color: Material.color(Material.Orange)
transform: Rotation {
angle: 45
}
visible: root.isNew
Text {
font.family: ScreenPlay.settings.font
font.pointSize: 9
renderType: Text.QtRendering
color: "white"
text: qsTr("NEW")
smooth: true
antialiasing: true
visible: root.isNew
anchors.centerIn: parent
}
}
}
OpacityMask {
@ -203,25 +216,23 @@ Item {
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onEntered: {
root.state = "hover";
screenPlayItemImage.state = "hover";
screenPlayItemImage.enter();
root.state = "hover"
screenPlayItemImage.state = "hover"
screenPlayItemImage.enter()
}
onExited: {
root.state = "";
screenPlayItemImage.state = "loaded";
screenPlayItemImage.exit();
root.state = ""
screenPlayItemImage.state = "loaded"
screenPlayItemImage.exit()
}
onClicked: {
if (mouse.button === Qt.LeftButton)
ScreenPlay.util.setSidebarItem(root.screenId, root.type);
ScreenPlay.util.setSidebarItem(root.screenId, root.type)
else if (mouse.button === Qt.RightButton)
root.openContextMenu(Qt.point(mouseX, mouseY));
root.openContextMenu(Qt.point(mouseX, mouseY))
}
}
}
}
transitions: [
@ -256,7 +267,6 @@ Item {
from: 0.6
to: 1
}
},
Transition {
from: "hover"
@ -289,7 +299,6 @@ Item {
from: 1
to: 0.5
}
}
]
}

View File

@ -1,4 +1,5 @@
#include "installedlistmodel.h"
#include <QDebug>
namespace ScreenPlay {
@ -111,13 +112,15 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const
return m_screenPlayFiles.at(row).m_publishedFileID;
case static_cast<int>(ScreenPlayItem::Tags):
return m_screenPlayFiles.at(row).m_tags;
case static_cast<int>(ScreenPlayItem::IsNew):
return m_screenPlayFiles.at(row).m_isNew;
case static_cast<int>(ScreenPlayItem::LastModified):
return m_screenPlayFiles.at(row).m_lastModified;
case static_cast<int>(ScreenPlayItem::SearchType):
return QVariant::fromValue(m_screenPlayFiles.at(row).m_searchType);
default:
return QVariant();
}
qWarning() << "Unable to fetch value for row type:" << role;
return QVariant();
}
@ -137,17 +140,18 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
{ static_cast<int>(ScreenPlayItem::PublishedFileID), "m_publishedFileID" },
{ static_cast<int>(ScreenPlayItem::Tags), "m_tags" },
{ static_cast<int>(ScreenPlayItem::SearchType), "m_searchType" },
{ static_cast<int>(ScreenPlayItem::LastModified), "m_lastModified" },
{ static_cast<int>(ScreenPlayItem::IsNew), "m_isNew" },
{ static_cast<int>(ScreenPlayItem::LastModified), "m_lastModified" }
};
}
/*!
\brief Append an ProjectFile to the list.
*/
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const QDateTime& lastModified)
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const bool isNew, const QDateTime& lastModified)
{
beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size());
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), lastModified));
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), isNew, lastModified));
endInsertRows();
}
@ -166,6 +170,11 @@ void InstalledListModel::loadInstalledContent()
if (!QFile::exists(absoluteFilePath))
continue;
bool isNew = false;
if (item.birthTime().date() == QDateTime::currentDateTime().date())
isNew = true;
if (auto obj = ScreenPlayUtil::openJsonFileToObject(absoluteFilePath)) {
if (obj->isEmpty())
@ -176,7 +185,7 @@ void InstalledListModel::loadInstalledContent()
if (ScreenPlayUtil::getAvailableTypes().contains(obj->value("type").toString())) {
if (ScreenPlayUtil::getAvailableTypes().contains(obj->value("type").toString(), Qt::CaseInsensitive)) {
append(*obj, item.baseName(), item.lastModified());
append(*obj, item.baseName(), isNew, item.lastModified());
}
counter += 1;
@ -208,6 +217,7 @@ QVariantMap InstalledListModel::get(const QString& folderId) const
map.insert("m_type", QVariant::fromValue(m_screenPlayFiles[i].m_type));
map.insert("m_absoluteStoragePath", m_screenPlayFiles[i].m_absoluteStoragePath);
map.insert("m_publishedFileID", m_screenPlayFiles[i].m_publishedFileID);
map.insert("m_isNew", m_screenPlayFiles[i].m_isNew);
map.insert("m_lastModified", m_screenPlayFiles[i].m_lastModified);
return map;
}

View File

@ -89,6 +89,7 @@ public:
Tags,
SearchType,
LastModified,
IsNew,
};
Q_ENUM(ScreenPlayItem)
@ -101,7 +102,7 @@ public slots:
QVariantMap get(const QString& folderId) const;
void loadInstalledContent();
void append(const QJsonObject&, const QString&, const QDateTime& lastModified);
void append(const QJsonObject&, const QString&, const bool isNew, const QDateTime& lastModified);
void reset();
void init();
bool deinstallItemAt(const int index);

View File

@ -34,6 +34,7 @@
#pragma once
#include <QDateTime>
#include <QDebug>
#include <QJsonArray>
#include <QJsonObject>
@ -58,6 +59,7 @@ struct ProjectFile {
const QJsonObject& obj,
const QString& folderName,
const QUrl& absolutePath,
const bool isNew,
const QDateTime& lastModified)
{
@ -114,6 +116,7 @@ struct ProjectFile {
m_preview = m_previewGIF;
}
m_searchType = ScreenPlayUtil::getSearchTypeFromInstalledType(m_type);
m_isNew = isNew;
m_lastModified = lastModified;
}
@ -135,6 +138,7 @@ struct ProjectFile {
InstalledType::InstalledType m_type = InstalledType::InstalledType::Unknown;
SearchType::SearchType m_searchType = SearchType::SearchType::All;
bool m_isNew = false;
QDateTime m_lastModified;
};
}

View File

@ -82,7 +82,7 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const QDateTime& lastModified)
{
beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size());
m_screenPlayFiles.append(ScreenPlay::ProjectFile(obj, folderName, m_absoluteStoragePath, lastModified));
m_screenPlayFiles.append(ScreenPlay::ProjectFile(obj, folderName, m_absoluteStoragePath, false, lastModified));
endInsertRows();
}