ill-implemented new backend

This commit is contained in:
Yuri Kozyrev 2022-07-19 14:51:11 +04:00
parent f874d764db
commit 5c3499b865
6 changed files with 40 additions and 7 deletions

View File

@ -22,7 +22,8 @@ public:
signals: signals:
void move(QString windowId, QString targetUrl); void move(QString windowId, QString targetUrl);
void ifaceReq( QString senderId, QString service, QString path void ifaceReq( QString senderId, QString shortName
, QString service, QString path
, QString interface, QDBusConnection connection ); , QString interface, QDBusConnection connection );
public slots: public slots:
@ -38,7 +39,7 @@ private:
void open(QString targetUrl); void open(QString targetUrl);
void justMove(QString senderId, QString targetUrl); void justMove(QString senderId, QString targetUrl);
void collectIfaces(QObject *window); void collectIfaces(QObject *window, QString targetId);
QHash<QString, QVector<QString>> past; QHash<QString, QVector<QString>> past;
QHash<QString, QVector<QString>> future; QHash<QString, QVector<QString>> future;

View File

@ -10,11 +10,12 @@
namespace Alterator{ namespace Alterator{
class DBusConnector: public QObject class DBusConnector: public QObject
{ {
Q_OBJECT
public: public:
DBusConnector(QObject *parent = nullptr); DBusConnector(QObject *parent = nullptr);
signals: signals:
void pushInLogs(QString targetId, QList<QString> logs); //void pushInLogs(QString targetId, QList<QString> logs);
void giveInterface(QString targetId, DBusInterface *iface); void giveInterface(QString targetId, DBusInterface *iface);
public slots: public slots:

View File

@ -14,6 +14,9 @@ class DBusInterface: public QObject{
public: public:
DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri, DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri,
QString iname, QString sname, QObject *parent = 0 ); QString iname, QString sname, QObject *parent = 0 );
QString getShortName();
DBusPropertyMap *getProperties();
public slots: public slots:
void propertyUpdatedFromDBus( void propertyUpdatedFromDBus(
QDBusArgument ifaceName QDBusArgument ifaceName

View File

@ -23,6 +23,9 @@ Loader::Loader(QObject *p):QObject(p)
open(startingPage); open(startingPage);
connect(dbus, SIGNAL(giveInterface(QString, DBusInterface *)) connect(dbus, SIGNAL(giveInterface(QString, DBusInterface *))
, this, SLOT(getIface(QString, DBusInterface *))); , this, SLOT(getIface(QString, DBusInterface *)));
connect(this, SIGNAL(ifaceReq( QString, QString, QString, QString, QString, QDBusConnection))
, dbus, SLOT(ifaceReq( QString, QString, QString, QString, QString, QDBusConnection)));
} }
void Loader::open(QString targetUrl){ void Loader::open(QString targetUrl){
@ -31,6 +34,7 @@ void Loader::open(QString targetUrl){
QObject *window = engine->rootObjects().last(); QObject *window = engine->rootObjects().last();
window->setProperty("url", targetUrl); window->setProperty("url", targetUrl);
window->setProperty("windowId", windowId); window->setProperty("windowId", windowId);
collectIfaces(window, windowId);
past.insert(windowId, QVector<QString>() << targetUrl); past.insert(windowId, QVector<QString>() << targetUrl);
future.insert(windowId, QVector<QString>()); future.insert(windowId, QVector<QString>());
widgets.insert(windowId, window); widgets.insert(windowId, window);
@ -89,10 +93,26 @@ void Loader::forvard(QString senderId){
} }
void Loader::getIface(QString targetId, DBusInterface *iface){ void Loader::getIface(QString targetId, DBusInterface *iface){
qDebug() << engine->rootContext()->children(); QQmlContext *pageContext = new QQmlContext(engine->rootContext());
widgets[targetId]->findChild<QQmlComponent *>(
"currentPageN", Qt::FindChildrenRecursively)->create(pageContext);
pageContext->setContextProperty(iface->getShortName(), iface);
QQmlContext *ifaceContext = new QQmlContext(pageContext);
widgets[targetId]->findChild<QQmlComponent *>(
"currentPageN", Qt::FindChildrenRecursively)->create(ifaceContext);
ifaceContext->setContextProperty("properties", iface->getProperties());
} }
void Loader::collectIfaces(QObject *window){ void Loader::collectIfaces(QObject *window, QString targetId){
QList<QVariant> window->property("requiredInterfaces"); QList<QVariant> raw = window->property("requiredInterfaces").toList();
QVariant i;
foreach(i, raw){
QHash<QString, QVariant> t = i.toHash();
emit(ifaceReq(targetId, t["shortName"].toString()
, t["service"].toString(), t["path"].toString()
, t["interface"].toString()
, t["isSessionBus"].toBool() ? QDBusConnection::sessionBus()
: QDBusConnection::systemBus()));
}
} }
} }

View File

@ -9,6 +9,14 @@ DBusInterface::DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri
ifaceName = iname; ifaceName = iname;
connect(introspection, SIGNAL(updateDBus()), this, SLOT(updateDBus())); connect(introspection, SIGNAL(updateDBus()), this, SLOT(updateDBus()));
} }
QString DBusInterface::getShortName(){
return shortName;
}
DBusPropertyMap * DBusInterface::getProperties(){
return properties;
}
void DBusInterface::propertyUpdatedFromDBus( void DBusInterface::propertyUpdatedFromDBus(
QDBusArgument ifaceName QDBusArgument ifaceName
, QDBusArgument changedProperties , QDBusArgument changedProperties

View File

@ -10,7 +10,7 @@ import shared 1.0
ScrollView { ScrollView {
id: view id: view
property var RequiredInterfaces: property var requiredInterfaces:
[ {shortname : "hostname" [ {shortname : "hostname"
, service : "org.freedesktop.hostname1" , service : "org.freedesktop.hostname1"
, path : "/org/freedesktop/hostname1" , path : "/org/freedesktop/hostname1"