Skip to content
Snippets Groups Projects
Commit ce3a105d authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Emit propertiesChanged signal when portal list changes

parent e124698b
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ Controller::Controller(QObject *parent) : QObject(parent), connection(QDBusConne ...@@ -10,6 +10,7 @@ Controller::Controller(QObject *parent) : QObject(parent), connection(QDBusConne
port->dbusPath.setPath("/fake/test0"); port->dbusPath.setPath("/fake/test0");
connection.registerObject(port->dbusPath.path(), port); connection.registerObject(port->dbusPath.path(), port);
ports.append(port); ports.append(port);
notifyPropertyChanged("PortList");
} }
QStringList Controller::PortList() const QStringList Controller::PortList() const
...@@ -37,9 +38,10 @@ void Controller::CreateFilePort(QString) ...@@ -37,9 +38,10 @@ void Controller::CreateFilePort(QString)
void Controller::Autodetect() void Controller::Autodetect()
{ {
qDebug() << "Autodetect"; qDebug() << "Autodetect";
bool changed = false;
// Remove nonexistent // Remove nonexistent
for(Port *port : ports) { for(Port *port : ports) {
port->Exists(); if(!port->Exists()) changed = true;
} }
// Detect new // Detect new
...@@ -54,6 +56,7 @@ void Controller::Autodetect() ...@@ -54,6 +56,7 @@ void Controller::Autodetect()
} }
if(!isInList) { if(!isInList) {
changed = true;
Port *port = new Port(info.systemLocation()); Port *port = new Port(info.systemLocation());
new PortAdaptor(port); new PortAdaptor(port);
port->dbusPath.setPath("/autodetected"+info.systemLocation()); port->dbusPath.setPath("/autodetected"+info.systemLocation());
...@@ -63,6 +66,7 @@ void Controller::Autodetect() ...@@ -63,6 +66,7 @@ void Controller::Autodetect()
ports.append(port); ports.append(port);
} }
} }
if(changed) notifyPropertyChanged("PortList");
qDebug() << "Autodetect done"; qDebug() << "Autodetect done";
} }
...@@ -85,3 +89,17 @@ void Controller::removePort(QDBusObjectPath id) ...@@ -85,3 +89,17 @@ void Controller::removePort(QDBusObjectPath id)
} }
} }
} }
void Controller::notifyPropertyChanged( const char *propertyName )
{
QDBusMessage signal = QDBusMessage::createSignal(
"/controller",
"org.freedesktop.DBus.Properties",
"PropertiesChanged");
signal << QString("info.skorepa.DSerial.controller");
QVariantMap changedProps;
changedProps.insert(propertyName, property(propertyName));
signal << changedProps;
signal << QStringList();
QDBusConnection::sessionBus().send(signal);
}
...@@ -33,6 +33,9 @@ class Controller : public QObject ...@@ -33,6 +33,9 @@ class Controller : public QObject
public: public:
QDBusConnection connection; QDBusConnection connection;
private:
void notifyPropertyChanged( const char *propertyName );
}; };
#endif // CONTROLLER_H #endif // CONTROLLER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment