107 lines
3.5 KiB
Diff
107 lines
3.5 KiB
Diff
From b8df82788c21c4e768b55e9a09f6d61f44febd5f Mon Sep 17 00:00:00 2001
|
|
From: peijiankang <peijiankang@kylinos.cn>
|
|
Date: Wed, 1 Feb 2023 12:44:20 +0800
|
|
Subject: [PATCH] fix uninstall failed issue
|
|
|
|
---
|
|
.../RightClickMenu/rightclickmenu.cpp | 50 +++++++++-
|
|
.../RightClickMenu/rightclickmenu.h | 6 ++
|
|
3 files changed, 51 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.cpp b/src/UserInterface/RightClickMenu/rightclickmenu.cpp
|
|
index 45f7b46..40d58e0 100755
|
|
--- a/src/UserInterface/RightClickMenu/rightclickmenu.cpp
|
|
+++ b/src/UserInterface/RightClickMenu/rightclickmenu.cpp
|
|
@@ -19,11 +19,15 @@
|
|
#include "rightclickmenu.h"
|
|
#include "src/UtilityFunction/utility.h"
|
|
#include <QDebug>
|
|
+#include <QMessageBox>
|
|
+#include <QKeyEvent>
|
|
|
|
RightClickMenu::RightClickMenu(QWidget *parent):
|
|
QWidget(parent)
|
|
{
|
|
m_cmdProc = new QProcess;
|
|
+ connect(m_cmdProc , &QProcess::readyReadStandardOutput, this , &RightClickMenu::onReadOutput);
|
|
+
|
|
m_whiteList.append("kylin-screenshot.desktop");
|
|
m_whiteList.append("ukui-notebook.desktop");
|
|
m_whiteList.append("ukui-clock.desktop");
|
|
@@ -141,14 +145,50 @@ void RightClickMenu::addToDesktopActionTriggerSlot()
|
|
|
|
void RightClickMenu::uninstallActionTriggerSlot()
|
|
{
|
|
- QString cmd = QString("kylin-uninstaller %1")
|
|
- .arg(m_desktopfp.toLocal8Bit().data());
|
|
- bool ret = QProcess::startDetached(cmd);
|
|
- myDebug() << "卸载:" << cmd << ret;
|
|
- myDebug() << "kylin-uninstaller";
|
|
+ QString cmd=QString("rpm -qf "+m_desktopfp);
|
|
+ m_cmdProc->setReadChannel(QProcess::StandardOutput);
|
|
+ m_cmdProc->start("sh",QStringList()<<"-c"<<cmd);
|
|
+ m_cmdProc->waitForFinished();
|
|
+ m_cmdProc->waitForReadyRead();
|
|
+ m_cmdProc->close();
|
|
m_actionNumber = 6;
|
|
}
|
|
|
|
+void RightClickMenu::onReadOutput()
|
|
+{
|
|
+ QString packagestr=QString::fromLocal8Bit(m_cmdProc->readAllStandardOutput().data());
|
|
+ QString packageName=packagestr.split(":").at(0);
|
|
+
|
|
+ packageName = packageName.trimmed();
|
|
+ QProcess tempProcess;
|
|
+ QString cmd = QString("pkexec rpm -e %1").arg(packageName);
|
|
+ tempProcess.start(cmd);
|
|
+ tempProcess.waitForFinished();
|
|
+
|
|
+ QString errorInfo1 = tempProcess.readAllStandardError().data();
|
|
+ QString result1 = tempProcess.readAllStandardOutput().data();
|
|
+ //check uninstall
|
|
+ cmd = QString("rpm -qa");
|
|
+ tempProcess.start(cmd);
|
|
+ tempProcess.waitForFinished();
|
|
+
|
|
+ QString errorInfo2 = tempProcess.readAllStandardError().data();
|
|
+ QString result2 = tempProcess.readAllStandardOutput().data();
|
|
+ bool bFail = false;
|
|
+ bFail= result2.contains(packageName);
|
|
+
|
|
+ if(!bFail)
|
|
+ {
|
|
+ QMessageBox::information(this,tr("infomation"),tr("Uninstall finished!"));
|
|
+ }
|
|
+ else {
|
|
+ QMessageBox::information(this,tr("error"), errorInfo1);
|
|
+ }
|
|
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Menu,Qt::NoModifier);
|
|
+ QCoreApplication::sendEvent(this->parent(),&event);
|
|
+}
|
|
+
|
|
+
|
|
void RightClickMenu::attributeActionTriggerSlot()
|
|
{
|
|
char command[100];
|
|
diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.h b/src/UserInterface/RightClickMenu/rightclickmenu.h
|
|
index a96c65d..bba9cf1 100755
|
|
--- a/src/UserInterface/RightClickMenu/rightclickmenu.h
|
|
+++ b/src/UserInterface/RightClickMenu/rightclickmenu.h
|
|
@@ -117,6 +117,12 @@ private Q_SLOTS:
|
|
* @brief Uninstall
|
|
*/
|
|
void uninstallActionTriggerSlot();
|
|
+
|
|
+ /**
|
|
+ * @brief Read command output
|
|
+ */
|
|
+ void onReadOutput();
|
|
+
|
|
/**
|
|
* @brief Attribute
|
|
*/
|
|
--
|
|
2.33.0
|
|
|