通知设置排除/etc/xdg/autostart目录下的desktop文件;
增加desktop文件名转全路径的接口。 Signed-off-by: iaom <zhangpengfei@kylinos.cn>
This commit is contained in:
parent
188a895ca9
commit
c2b047fdc9
|
@ -159,7 +159,9 @@ void SettingsManagerPrivate::updateSettingsFile()
|
|||
|
||||
QStringList SettingsManagerPrivate::getAppInfo()
|
||||
{
|
||||
return m_applicationInfo->getInfo(UkuiSearch::ApplicationProperties{}).keys();
|
||||
|
||||
return m_applicationInfo->getInfo(UkuiSearch::ApplicationProperties{},
|
||||
UkuiSearch::ApplicationPropertyMap{{UkuiSearch::ApplicationProperty::AutoStart, 0}}).keys();
|
||||
}
|
||||
|
||||
void SettingsManagerPrivate::initSettingsData(QJsonObject &data)
|
||||
|
@ -185,9 +187,17 @@ void SettingsManagerPrivate::initSettingsData(QJsonObject &data)
|
|||
void SettingsManagerPrivate::desktopFileAdd(const QStringList &data)
|
||||
{
|
||||
QJsonObject applicationsSettings = m_settingsData.value(QStringLiteral("Applications")).toObject();
|
||||
bool needUpdate = false;
|
||||
for (const QString &desktopPath : data) {
|
||||
applicationsSettings.insert(desktopPath, m_applicationDefaultSettings);
|
||||
if(m_applicationInfo->getInfo(desktopPath, UkuiSearch::ApplicationProperty::AutoStart).toInt() == 0) {
|
||||
applicationsSettings.insert(desktopPath, m_applicationDefaultSettings);
|
||||
needUpdate = true;
|
||||
}
|
||||
}
|
||||
if(!needUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_settingsData.insert(QStringLiteral("Applications"), applicationsSettings);
|
||||
|
||||
QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock"));
|
||||
|
|
|
@ -23,14 +23,16 @@
|
|||
#include <KWindowSystem>
|
||||
#include <application-info.h>
|
||||
using namespace UkuiNotification;
|
||||
static UkuiSearch::ApplicationInfo s_applicationInfo;
|
||||
QString Utils::desktopEntryFromPid(uint pid)
|
||||
{
|
||||
QString desktop;
|
||||
if(UkuiSearch::ApplicationInfo().tranPidToDesktopFp(pid, desktop)) {
|
||||
if(s_applicationInfo.tranPidToDesktopFp(pid, desktop)) {
|
||||
return desktop;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QString Utils::displayFromPid(uint pid)
|
||||
{
|
||||
QFile environFile(QStringLiteral("/proc/%1/environ").arg(QString::number(pid)));
|
||||
|
@ -50,4 +52,11 @@ QString Utils::displayFromPid(uint pid)
|
|||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QString Utils::desktopEntryFromName(const QString& desktopFileName)
|
||||
{
|
||||
QString desktopFilePathName;
|
||||
s_applicationInfo.desktopFilePathFromName(desktopFileName, desktopFilePathName);
|
||||
return desktopFilePathName;
|
||||
}
|
|
@ -24,6 +24,7 @@ namespace UkuiNotification {
|
|||
namespace Utils {
|
||||
QString desktopEntryFromPid(uint pid);
|
||||
QString displayFromPid(uint pid);
|
||||
QString desktopEntryFromName(const QString& desktopFileName);
|
||||
}
|
||||
}
|
||||
#endif //UKUI_NOTIFICATION_UTILS_H
|
||||
|
|
|
@ -34,7 +34,7 @@ NotificationServerApplication::NotificationServerApplication(int &argc, char **a
|
|||
});
|
||||
Server::self().init();
|
||||
}
|
||||
parseCmd(this->arguments().join(" ").toUtf8(), !isRunning());
|
||||
parseCmd(arguments().join(" ").toUtf8(), !isRunning());
|
||||
}
|
||||
|
||||
NotificationServerApplication::~NotificationServerApplication()
|
||||
|
|
|
@ -67,10 +67,15 @@ uint ServerPrivate::Notify(const QString &app_name, uint replaces_id, const QStr
|
|||
if(newHints.value(QStringLiteral("x-ukui-display")).toString().isEmpty() && pid > 0) {
|
||||
newHints.insert(QStringLiteral("x-ukui-display"), UkuiNotification::Utils::displayFromPid(pid));
|
||||
}
|
||||
//todo 如果desktop-entry只有文件名,需要获取全路径
|
||||
if(newHints.value(QStringLiteral("desktop-entry")).toString().isEmpty() && pid > 0) {
|
||||
newHints.insert(QStringLiteral("desktop-entry"), UkuiNotification::Utils::desktopEntryFromPid(pid));
|
||||
//如果desktop-entry只有文件名,需要获取全路径
|
||||
QString desktopEntry = newHints.value(QStringLiteral("desktop-entry")).toString();
|
||||
if(!desktopEntry.isEmpty()) {
|
||||
desktopEntry = UkuiNotification::Utils::desktopEntryFromName(desktopEntry);
|
||||
}
|
||||
if(desktopEntry.isEmpty() && pid > 0) {
|
||||
desktopEntry = UkuiNotification::Utils::desktopEntryFromPid(pid);
|
||||
}
|
||||
newHints.insert(QStringLiteral("desktop-entry"), desktopEntry);
|
||||
|
||||
qDebug() << "New message received:" << app_name << id << app_icon << summary << body
|
||||
<< actions << hints << timeout << "new hints" << newHints;
|
||||
|
|
Loading…
Reference in New Issue