1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-06 10:39:53 +02:00

Add deletion of content if it is not a steam item

Deleting a steam subscription folder would be pointless
because Steam would just download it again. For now
this works only with none steam items, based if
their have a steamID in their project.json
This commit is contained in:
Elias Steurer 2020-08-11 20:30:28 +02:00
parent 1fe1fb2c4b
commit 045cefae56
5 changed files with 53 additions and 14 deletions

View File

@ -100,5 +100,6 @@
<file>legal/Qt LGPLv3.txt</file>
<file>legal/gpl-3.0.txt</file>
<file>legal/lgpl-2.1.txt</file>
<file>assets/icons/icon_delete.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>

After

Width:  |  Height:  |  Size: 215 B

View File

@ -1,6 +1,6 @@
import QtQuick 2.12
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls 2.12
import QtQuick.Controls.Styles 1.4
import ScreenPlay 1.0
import ScreenPlay.Enums.InstalledType 1.0
@ -219,14 +219,9 @@ Item {
onClicked: {
if (mouse.button === Qt.LeftButton) {
ScreenPlay.util.setSidebarItem(
screenPlayItem.screenId,
screenPlayItem.type)
ScreenPlay.util.setSidebarItem(screenPlayItem.screenId,
screenPlayItem.type)
} else if (mouse.button === Qt.RightButton) {
if (workshopID != 0) {
miWorkshop.enabled = true
}
contextMenu.popup()
hasMenuOpen = true
}
@ -238,21 +233,41 @@ Item {
onClosed: hasMenuOpen = false
MenuItem {
text: qsTr("Open containing folder")
icon.source: "qrc:/assets/icons/icon_folder_open.svg"
onClicked: {
ScreenPlay.util.openFolderInExplorer(absoluteStoragePath)
}
}
MenuItem {
text: qsTr("Deinstall Item")
icon.source: "qrc:/assets/icons/icon_delete.svg"
enabled: screenPlayItem.workshopID === 0
onClicked: {
deleteDialog.open()
}
}
MenuItem {
id: miWorkshop
text: qsTr("Open workshop Page")
enabled: false
enabled: screenPlayItem.workshopID !== 0
icon.source: "qrc:/assets/icons/icon_steam.svg"
onClicked: {
Qt.openUrlExternally(
"steam://url/CommunityFilePage/" + workshopID)
}
}
}
Dialog {
id: deleteDialog
title: "Are you sure you want to delete this item?"
standardButtons: Dialog.Ok | Dialog.Cancel
modal: true
dim: true
anchors.centerIn: Overlay.overlay
onAccepted: ScreenPlay.installedListModel.deinstallItemAt(
screenPlayItem.itemIndex)
}
}
states: [

View File

@ -36,9 +36,9 @@ void InstalledListModel::init()
loadInstalledContent();
auto reloadLambda = [this](){
QTimer::singleShot(500,[this](){
reset();
auto reloadLambda = [this]() {
QTimer::singleShot(500, [this]() {
reset();
});
};
@ -46,6 +46,27 @@ void InstalledListModel::init()
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadLambda);
}
bool InstalledListModel::deinstallItemAt(const int index)
{
if (index < 0 || index >= m_screenPlayFiles.count()) {
qWarning() << "remove folder error, invalid index " << index;
return false;
}
beginRemoveRows(QModelIndex(), index, index);
const QString path = QUrl::fromUserInput(m_screenPlayFiles.at(index).m_absoluteStoragePath.toString()).toLocalFile();
QDir dir(path);
const bool success = dir.removeRecursively();
if (!success)
qWarning() << "Could not remove folder: " << m_screenPlayFiles.at(index).m_absoluteStoragePath.toString();
m_screenPlayFiles.removeAt(index);
endRemoveRows();
return success;
}
/*!
\brief Returns the length of the installed items.
*/

View File

@ -43,6 +43,7 @@
#include <QFileSystemWatcher>
#include <QFuture>
#include <QFutureWatcher>
#include <QHash>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
@ -100,6 +101,7 @@ public slots:
void reset();
void init();
QVariantMap get(QString folderId) const;
bool deinstallItemAt(const int index);
void setCount(int count)
{
@ -109,7 +111,6 @@ public slots:
m_count = count;
emit countChanged(m_count);
}
signals:
void setScreenVisible(bool visible);
void setScreenToVideo(QString absolutePath);