feat: emit signal when AutoStart Changed
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "applicationservice.h"
|
||||
#include "dbus/AMobjectmanager1adaptor.h"
|
||||
#include "systemdsignaldispatcher.h"
|
||||
#include "propertiesForwarder.h"
|
||||
#include <QFile>
|
||||
#include <QDBusMessage>
|
||||
#include <unistd.h>
|
||||
@ -81,6 +82,10 @@ ApplicationManager1Service::ApplicationManager1Service(std::unique_ptr<Identifie
|
||||
}
|
||||
|
||||
scanAutoStart();
|
||||
|
||||
if (auto *ptr = new (std::nothrow) PropertiesForwarder{DDEApplicationManager1ObjectPath, this}; ptr == nullptr) {
|
||||
qCritical() << "new PropertiesForwarder of Application Manager failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationManager1Service::addInstanceToApplication(const QString &unitName, const QDBusObjectPath &systemdUnitPath)
|
||||
@ -240,6 +245,7 @@ bool ApplicationManager1Service::addApplication(DesktopFile desktopFileSource) n
|
||||
return false;
|
||||
}
|
||||
m_applicationList.insert(application->applicationPath(), application);
|
||||
emit listChanged();
|
||||
emit InterfacesAdded(application->applicationPath(), getChildInterfacesAndPropertiesFromObject(ptr));
|
||||
|
||||
return true;
|
||||
@ -251,6 +257,7 @@ void ApplicationManager1Service::removeOneApplication(const QDBusObjectPath &app
|
||||
emit InterfacesRemoved(application, getChildInterfacesFromObject(it->data()));
|
||||
unregisterObjectFromDBus(application.path());
|
||||
m_applicationList.remove(application);
|
||||
emit listChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
ApplicationManager1Service &operator=(const ApplicationManager1Service &) = delete;
|
||||
ApplicationManager1Service &operator=(ApplicationManager1Service &&) = delete;
|
||||
|
||||
Q_PROPERTY(QList<QDBusObjectPath> List READ list)
|
||||
Q_PROPERTY(QList<QDBusObjectPath> List READ list NOTIFY listChanged)
|
||||
[[nodiscard]] QList<QDBusObjectPath> list() const;
|
||||
|
||||
bool addApplication(DesktopFile desktopFileSource) noexcept;
|
||||
@ -48,6 +48,7 @@ public Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void InterfacesAdded(const QDBusObjectPath &object_path, const ObjectInterfaceMap &interfaces);
|
||||
void InterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
|
||||
void listChanged();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Identifier> m_identifier;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "APPobjectmanager1adaptor.h"
|
||||
#include "applicationchecker.h"
|
||||
#include "applicationmanager1service.h"
|
||||
#include "propertiesForwarder.h"
|
||||
#include "dbus/instanceadaptor.h"
|
||||
#include "launchoptions.h"
|
||||
#include <QUuid>
|
||||
@ -84,6 +85,11 @@ QSharedPointer<ApplicationService> ApplicationService::createApplicationService(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (auto *ptr = new (std::nothrow) PropertiesForwarder{app->m_applicationPath.path(), app.data()}; ptr == nullptr) {
|
||||
qCritical() << "new PropertiesForwarder of Application failed.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@ -402,12 +408,14 @@ bool ApplicationService::autostartCheck(const QString &linkPath) noexcept
|
||||
{
|
||||
QFileInfo info{linkPath};
|
||||
|
||||
if (!info.exists() or !info.isSymbolicLink()) {
|
||||
if (info.exists()) {
|
||||
if (info.isSymbolicLink()) {
|
||||
return true;
|
||||
}
|
||||
qWarning() << "same name desktop file exists:" << linkPath << "but this may not created by AM.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ApplicationService::isAutoStart() const noexcept
|
||||
@ -437,6 +445,8 @@ void ApplicationService::setAutoStart(bool autostart) noexcept
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit autostartChanged();
|
||||
}
|
||||
|
||||
QList<QDBusObjectPath> ApplicationService::instances() const noexcept
|
||||
|
@ -58,8 +58,7 @@ public:
|
||||
// FIXME:
|
||||
// This property should implement with fuse guarded $XDG_CONFIG_HOME/autostart/.
|
||||
// Current implementation has some problems,
|
||||
// such as it will not emit changed signal.
|
||||
Q_PROPERTY(bool AutoStart READ isAutoStart WRITE setAutoStart)
|
||||
Q_PROPERTY(bool AutoStart READ isAutoStart WRITE setAutoStart NOTIFY autostartChanged)
|
||||
[[nodiscard]] bool isAutoStart() const noexcept;
|
||||
void setAutoStart(bool autostart) noexcept;
|
||||
|
||||
@ -107,6 +106,7 @@ public Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void InterfacesAdded(const QDBusObjectPath &object_path, const ObjectInterfaceMap &interfaces);
|
||||
void InterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
|
||||
void autostartChanged();
|
||||
|
||||
private:
|
||||
friend class ApplicationManager1Service;
|
||||
|
Reference in New Issue
Block a user