Add uninstall option

pull/16/head
kateleet 5 years ago
parent aa5f787ac7
commit c12a23f0a5

@ -26,6 +26,7 @@ set(SRCS
src/listmodelmanager.cpp src/listmodelmanager.cpp
src/iconitem.cpp src/iconitem.cpp
src/processprovider.cpp src/processprovider.cpp
src/appmanager.cpp
) )
set(RESOURCES set(RESOURCES

@ -21,6 +21,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Window 2.12 import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import FishUI 1.0 as FishUI import FishUI 1.0 as FishUI
import Cutefish.Launcher 1.0 import Cutefish.Launcher 1.0
@ -134,6 +135,16 @@ Item {
onTriggered: launcherModel.removeFromDock(model.appId) onTriggered: launcherModel.removeFromDock(model.appId)
} }
MenuItem {
id: uninstallItem
text: qsTr("Uninstall")
onTriggered: {
root.uninstallDialog.desktopPath = model.appId
root.uninstallDialog.appName = model.name
root.uninstallDialog.visible = true
}
}
// MenuItem { // MenuItem {
// text: qsTr("Uninstall") // text: qsTr("Uninstall")
// onTriggered: {} // onTriggered: {}
@ -155,6 +166,7 @@ Item {
if (mouse.button == Qt.LeftButton) if (mouse.button == Qt.LeftButton)
launcherModel.launch(model.appId) launcherModel.launch(model.appId)
else if (mouse.button == Qt.RightButton) { else if (mouse.button == Qt.RightButton) {
uninstallItem.visible = appManager.isCutefishOS()
_itemMenu.updateActions() _itemMenu.updateActions()
_itemMenu.popup() _itemMenu.popup()
} }

@ -39,6 +39,69 @@ Item {
property bool showed: launcher.showed property bool showed: launcher.showed
property int iconSize: root.height < 960 ? 96 : 128 property int iconSize: root.height < 960 ? 96 : 128
property alias uninstallDialog: _uninstallDialog
AppManager {
id: appManager
}
Dialog {
id: _uninstallDialog
property var desktopPath: ""
property var appName: ""
width: _uninstallDialogLayout.implicitWidth + FishUI.Units.largeSpacing * 2
height: _uninstallDialogLayout.implicitHeight + FishUI.Units.largeSpacing * 2
modal: true
x: (root.width - width) / 2
y: (root.height - height) / 2
ColumnLayout {
id: _uninstallDialogLayout
anchors.centerIn: parent
anchors.margins: FishUI.Units.largeSpacing
spacing: FishUI.Units.largeSpacing * 1.5
Label {
text: qsTr("Are you sure you want to uninstall %1 ?").arg(_uninstallDialog.appName)
wrapMode: Text.WordWrap
}
RowLayout {
spacing: FishUI.Units.largeSpacing
Button {
text: qsTr("Cancel")
onClicked: _uninstallDialog.close()
Layout.fillWidth: true
}
Button {
flat: true
text: qsTr("Uninstall")
Layout.fillWidth: true
onClicked: {
_uninstallDialog.close()
appManager.uninstall(_uninstallDialog.desktopPath)
}
}
}
}
}
Connections {
target: launcher
function onVisibleChanged(visible) {
if (!visible) {
_uninstallDialog.close()
}
}
}
// onShowedChanged: { // onShowedChanged: {
// appViewOpacityAni.restart() // appViewOpacityAni.restart()
// blurAnimation.restart() // blurAnimation.restart()

@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 CutefishOS.
*
* Author: Kate Leet <kate@cutefishos.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "appmanager.h"
#include <QFile>
AppManager::AppManager(QObject *parent)
: QObject(parent)
, m_iface("com.cutefish.Daemon",
"/AppManager",
"com.cutefish.AppManager", QDBusConnection::sessionBus())
{
}
void AppManager::uninstall(const QString &desktopFile)
{
if (m_iface.isValid()) {
m_iface.asyncCall("uninstall", desktopFile);
}
}
bool AppManager::isCutefishOS()
{
return QFile::exists("/etc/cutefishos");
}

@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 CutefishOS.
*
* Author: Kate Leet <kate@cutefishos.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef APPMANAGER_H
#define APPMANAGER_H
#include <QObject>
#include <QDBusInterface>
#include <QDBusPendingCall>
class AppManager : public QObject
{
Q_OBJECT
public:
explicit AppManager(QObject *parent = nullptr);
Q_INVOKABLE void uninstall(const QString &desktopFile);
Q_INVOKABLE bool isCutefishOS();
private:
QDBusInterface m_iface;
};
#endif // APPMANAGER_H

@ -28,6 +28,7 @@
#include "launchermodel.h" #include "launchermodel.h"
#include "pagemodel.h" #include "pagemodel.h"
#include "iconitem.h" #include "iconitem.h"
#include "appmanager.h"
#include <QDebug> #include <QDebug>
#include <QTranslator> #include <QTranslator>
@ -45,6 +46,7 @@ int main(int argc, char *argv[])
qmlRegisterType<LauncherModel>(uri, 1, 0, "LauncherModel"); qmlRegisterType<LauncherModel>(uri, 1, 0, "LauncherModel");
qmlRegisterType<PageModel>(uri, 1, 0, "PageModel"); qmlRegisterType<PageModel>(uri, 1, 0, "PageModel");
qmlRegisterType<IconItem>(uri, 1, 0, "IconItem"); qmlRegisterType<IconItem>(uri, 1, 0, "IconItem");
qmlRegisterType<AppManager>(uri, 1, 0, "AppManager");
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
qmlRegisterType<QAbstractItemModel>(); qmlRegisterType<QAbstractItemModel>();

@ -4,25 +4,30 @@
<context> <context>
<name>GridItemDelegate</name> <name>GridItemDelegate</name>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="115"/> <location filename="../qml/GridItemDelegate.qml" line="116"/>
<source>Open</source> <source>Open</source>
<translation type="unfinished">Open</translation> <translation type="unfinished">Open</translation>
</message> </message>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="121"/> <location filename="../qml/GridItemDelegate.qml" line="122"/>
<source>Send to dock</source> <source>Send to dock</source>
<translation>Send to dock</translation> <translation>Send to dock</translation>
</message> </message>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="127"/> <location filename="../qml/GridItemDelegate.qml" line="128"/>
<source>Send to desktop</source> <source>Send to desktop</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="133"/> <location filename="../qml/GridItemDelegate.qml" line="134"/>
<source>Remove from dock</source> <source>Remove from dock</source>
<translation>Remove from dock</translation> <translation>Remove from dock</translation>
</message> </message>
<message>
<location filename="../qml/GridItemDelegate.qml" line="140"/>
<source>Uninstall</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Launcher</name> <name>Launcher</name>
@ -35,12 +40,27 @@
<context> <context>
<name>main</name> <name>main</name>
<message> <message>
<location filename="../qml/main.qml" line="213"/> <location filename="../qml/main.qml" line="69"/>
<source>Are you sure you want to uninstall %1 ?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/main.qml" line="77"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/main.qml" line="84"/>
<source>Uninstall</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/main.qml" line="276"/>
<source>Search</source> <source>Search</source>
<translation>Search</translation> <translation>Search</translation>
</message> </message>
<message> <message>
<location filename="../qml/main.qml" line="288"/> <location filename="../qml/main.qml" line="351"/>
<source>Not found</source> <source>Not found</source>
<translation>Not found</translation> <translation>Not found</translation>
</message> </message>

@ -4,25 +4,30 @@
<context> <context>
<name>GridItemDelegate</name> <name>GridItemDelegate</name>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="115"/> <location filename="../qml/GridItemDelegate.qml" line="116"/>
<source>Open</source> <source>Open</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="121"/> <location filename="../qml/GridItemDelegate.qml" line="122"/>
<source>Send to dock</source> <source>Send to dock</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="127"/> <location filename="../qml/GridItemDelegate.qml" line="128"/>
<source>Send to desktop</source> <source>Send to desktop</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../qml/GridItemDelegate.qml" line="133"/> <location filename="../qml/GridItemDelegate.qml" line="134"/>
<source>Remove from dock</source> <source>Remove from dock</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<location filename="../qml/GridItemDelegate.qml" line="140"/>
<source>Uninstall</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>Launcher</name> <name>Launcher</name>
@ -35,12 +40,27 @@
<context> <context>
<name>main</name> <name>main</name>
<message> <message>
<location filename="../qml/main.qml" line="213"/> <location filename="../qml/main.qml" line="69"/>
<source>Are you sure you want to uninstall %1 ?</source>
<translation> %1 ?</translation>
</message>
<message>
<location filename="../qml/main.qml" line="77"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../qml/main.qml" line="84"/>
<source>Uninstall</source>
<translation></translation>
</message>
<message>
<location filename="../qml/main.qml" line="276"/>
<source>Search</source> <source>Search</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../qml/main.qml" line="288"/> <location filename="../qml/main.qml" line="351"/>
<source>Not found</source> <source>Not found</source>
<translation></translation> <translation></translation>
</message> </message>

Loading…
Cancel
Save