diff --git a/ScreenPlay/Resources.qrc b/ScreenPlay/Resources.qrc
index a7be202c..2461a0f8 100644
--- a/ScreenPlay/Resources.qrc
+++ b/ScreenPlay/Resources.qrc
@@ -100,5 +100,6 @@
legal/Qt LGPLv3.txt
legal/gpl-3.0.txt
legal/lgpl-2.1.txt
+ assets/icons/icon_delete.svg
diff --git a/ScreenPlay/assets/icons/icon_delete.svg b/ScreenPlay/assets/icons/icon_delete.svg
new file mode 100644
index 00000000..3acec0ad
--- /dev/null
+++ b/ScreenPlay/assets/icons/icon_delete.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/ScreenPlay/qml/Installed/ScreenPlayItem.qml b/ScreenPlay/qml/Installed/ScreenPlayItem.qml
index 852cf4f9..ff9fb4a6 100644
--- a/ScreenPlay/qml/Installed/ScreenPlayItem.qml
+++ b/ScreenPlay/qml/Installed/ScreenPlayItem.qml
@@ -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: [
diff --git a/ScreenPlay/src/installedlistmodel.cpp b/ScreenPlay/src/installedlistmodel.cpp
index 21b58b96..7264f655 100644
--- a/ScreenPlay/src/installedlistmodel.cpp
+++ b/ScreenPlay/src/installedlistmodel.cpp
@@ -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.
*/
diff --git a/ScreenPlay/src/installedlistmodel.h b/ScreenPlay/src/installedlistmodel.h
index bfecc4b8..730e5df0 100644
--- a/ScreenPlay/src/installedlistmodel.h
+++ b/ScreenPlay/src/installedlistmodel.h
@@ -43,6 +43,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -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);