mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 19:42:45 +01: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:
parent
1fe1fb2c4b
commit
045cefae56
@ -100,5 +100,6 @@
|
|||||||
<file>legal/Qt LGPLv3.txt</file>
|
<file>legal/Qt LGPLv3.txt</file>
|
||||||
<file>legal/gpl-3.0.txt</file>
|
<file>legal/gpl-3.0.txt</file>
|
||||||
<file>legal/lgpl-2.1.txt</file>
|
<file>legal/lgpl-2.1.txt</file>
|
||||||
|
<file>assets/icons/icon_delete.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
1
ScreenPlay/assets/icons/icon_delete.svg
Normal file
1
ScreenPlay/assets/icons/icon_delete.svg
Normal 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 |
@ -1,6 +1,6 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
import ScreenPlay 1.0
|
import ScreenPlay 1.0
|
||||||
import ScreenPlay.Enums.InstalledType 1.0
|
import ScreenPlay.Enums.InstalledType 1.0
|
||||||
@ -219,14 +219,9 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
ScreenPlay.util.setSidebarItem(
|
ScreenPlay.util.setSidebarItem(screenPlayItem.screenId,
|
||||||
screenPlayItem.screenId,
|
|
||||||
screenPlayItem.type)
|
screenPlayItem.type)
|
||||||
} else if (mouse.button === Qt.RightButton) {
|
} else if (mouse.button === Qt.RightButton) {
|
||||||
if (workshopID != 0) {
|
|
||||||
miWorkshop.enabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMenu.popup()
|
contextMenu.popup()
|
||||||
hasMenuOpen = true
|
hasMenuOpen = true
|
||||||
}
|
}
|
||||||
@ -238,21 +233,41 @@ Item {
|
|||||||
onClosed: hasMenuOpen = false
|
onClosed: hasMenuOpen = false
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Open containing folder")
|
text: qsTr("Open containing folder")
|
||||||
|
icon.source: "qrc:/assets/icons/icon_folder_open.svg"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
ScreenPlay.util.openFolderInExplorer(absoluteStoragePath)
|
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 {
|
MenuItem {
|
||||||
id: miWorkshop
|
id: miWorkshop
|
||||||
text: qsTr("Open workshop Page")
|
text: qsTr("Open workshop Page")
|
||||||
enabled: false
|
enabled: screenPlayItem.workshopID !== 0
|
||||||
|
icon.source: "qrc:/assets/icons/icon_steam.svg"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally(
|
Qt.openUrlExternally(
|
||||||
"steam://url/CommunityFilePage/" + workshopID)
|
"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: [
|
states: [
|
||||||
|
@ -46,6 +46,27 @@ void InstalledListModel::init()
|
|||||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadLambda);
|
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.
|
\brief Returns the length of the installed items.
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
#include <QHash>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@ -100,6 +101,7 @@ public slots:
|
|||||||
void reset();
|
void reset();
|
||||||
void init();
|
void init();
|
||||||
QVariantMap get(QString folderId) const;
|
QVariantMap get(QString folderId) const;
|
||||||
|
bool deinstallItemAt(const int index);
|
||||||
|
|
||||||
void setCount(int count)
|
void setCount(int count)
|
||||||
{
|
{
|
||||||
@ -109,7 +111,6 @@ public slots:
|
|||||||
m_count = count;
|
m_count = count;
|
||||||
emit countChanged(m_count);
|
emit countChanged(m_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void setScreenVisible(bool visible);
|
void setScreenVisible(bool visible);
|
||||||
void setScreenToVideo(QString absolutePath);
|
void setScreenToVideo(QString absolutePath);
|
||||||
|
Loading…
Reference in New Issue
Block a user