Commit ce3a105d authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Emit propertiesChanged signal when portal list changes

parent e124698b
......@@ -10,6 +10,7 @@ Controller::Controller(QObject *parent) : QObject(parent), connection(QDBusConne
port->dbusPath.setPath("/fake/test0");
connection.registerObject(port->dbusPath.path(), port);
ports.append(port);
notifyPropertyChanged("PortList");
}
QStringList Controller::PortList() const
......@@ -37,9 +38,10 @@ void Controller::CreateFilePort(QString)
void Controller::Autodetect()
{
qDebug() << "Autodetect";
bool changed = false;
// Remove nonexistent
for(Port *port : ports) {
port->Exists();
if(!port->Exists()) changed = true;
}
// Detect new
......@@ -54,6 +56,7 @@ void Controller::Autodetect()
}
if(!isInList) {
changed = true;
Port *port = new Port(info.systemLocation());
new PortAdaptor(port);
port->dbusPath.setPath("/autodetected"+info.systemLocation());
......@@ -63,6 +66,7 @@ void Controller::Autodetect()
ports.append(port);
}
}
if(changed) notifyPropertyChanged("PortList");
qDebug() << "Autodetect done";
}
......@@ -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
public:
QDBusConnection connection;
private:
void notifyPropertyChanged( const char *propertyName );
};
#endif // CONTROLLER_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment