fix(src): 【需求25776】【开始菜单】最新安装应用的右键菜单缺失“从列表中删除”

This commit is contained in:
youdiansaodongxi 2024-04-30 15:18:06 +08:00 committed by He Sir
parent c296e07e21
commit c9be7becd7
11 changed files with 64 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QFileInfo> #include <QFileInfo>
#include <QProcess> #include <QProcess>
#include <QDateTime>
namespace UkuiMenu { namespace UkuiMenu {
@ -43,6 +44,7 @@ private:
static void addToPanelAction(QObject *parent, const QString &appId, QList<QAction *> &list); static void addToPanelAction(QObject *parent, const QString &appId, QList<QAction *> &list);
static void addToDesktopAction(QObject *parent, const QString &appId, QList<QAction *> &list); static void addToDesktopAction(QObject *parent, const QString &appId, QList<QAction *> &list);
static void addUninstall(QObject *parent, const QString &appId, QList<QAction *> &list); static void addUninstall(QObject *parent, const QString &appId, QList<QAction *> &list);
static void addRemoveFromList(QObject *parent, const QString &appId, const int &appLaunched, const QString &appInsertTime, QList<QAction *> &list);
}; };
int AppContentMenu::index() const int AppContentMenu::index() const
@ -60,6 +62,8 @@ QList<QAction *> AppContentMenu::actions(const DataEntity &data, QMenu *parent,
QList<QAction *> list; QList<QAction *> list;
QString appId = data.id(); QString appId = data.id();
int appTop = data.top(); int appTop = data.top();
int appLaunched = data.launched();
QString appInsertTime = data.insertTime();
switch (location) { switch (location) {
case MenuInfo::AppList: { case MenuInfo::AppList: {
@ -78,6 +82,8 @@ QList<QAction *> AppContentMenu::actions(const DataEntity &data, QMenu *parent,
addUninstall(parent, appId, list); addUninstall(parent, appId, list);
//添加到桌面快捷方式 //添加到桌面快捷方式
addToDesktopAction(parent, appId, list); addToDesktopAction(parent, appId, list);
//添加从当前列表移除
addRemoveFromList(parent, appId, appLaunched, appInsertTime, list);
break; break;
default: default:
break; break;
@ -173,6 +179,23 @@ void AppContentMenu::addUninstall(QObject *parent, const QString &appId, QList<Q
} }
} }
void AppContentMenu::addRemoveFromList(QObject *parent, const QString &appId, const int &appLaunched, const QString &appInsertTime, QList<QAction *> &list)
{
if (appLaunched == 1) return;
QDateTime installDate = QDateTime::fromString(appInsertTime, "yyyy-MM-dd hh:mm:ss");
if (!installDate.isValid()) return;
QDateTime currentDateTime = QDateTime::currentDateTime();
qint64 xt = currentDateTime.toSecsSinceEpoch() - installDate.toSecsSinceEpoch();
if ((xt >= 0) && (xt <= 30 * 24 * 3600)) {
list << new QAction(QObject::tr("Remove from List"), parent);
QObject::connect(list.last(), &QAction::triggered, parent, [appId] {
BasicAppModel::instance()->databaseInterface()->updateApLaunchedState(appId, true);
});
}
}
// ====== AppMenuPlugin ====== // // ====== AppMenuPlugin ====== //
QString AppMenuPlugin::id() QString AppMenuPlugin::id()
{ {

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation>Erstellen einer Anwendungsgruppe</translation> <translation>Erstellen einer Anwendungsgruppe</translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation>Aus Liste entfernen</translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation>Creación de un grupo de aplicaciones</translation> <translation>Creación de un grupo de aplicaciones</translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation>Quitar de la lista</translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation>Créer un groupe dapplications</translation> <translation>Créer un groupe dapplications</translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation>Retirer de la liste</translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation>Бағдарлама тобын жасау</translation> <translation>Бағдарлама тобын жасау</translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation>Тізімнен жою</translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation>Тиркеме тобун түзүү</translation> <translation>Тиркеме тобун түзүү</translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation>Тизмеден чыгаруу</translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation> </translation> <translation> </translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation> </translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation>يېڭىدىن قوللىنىش گۇرۇپپىسى قۇرما</translation> <translation>يېڭىدىن قوللىنىش گۇرۇپپىسى قۇرما</translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation>تىزىملىكتىن چىقىرىۋەتمەك</translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -107,6 +107,10 @@
<source>Create a new folder</source> <source>Create a new folder</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Remove from List</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>SearchInputBar</name> <name>SearchInputBar</name>

View File

@ -105,7 +105,11 @@
</message> </message>
<message> <message>
<source>Create a new folder</source> <source>Create a new folder</source>
<translation></translation> <translation></translation>
</message>
<message>
<source>Remove from List</source>
<translation></translation>
</message> </message>
</context> </context>
<context> <context>