0

I am preparing pure qml plasmoid for my new panel appereance in KDE Plasma 4 and I have to use at most Qt 4.7 library and Qt.Quick 1.1 for that. Is it possible to pick up current user's fullname? Is there any plasma API related to that like PlasmaCore or KSM etc. or any PlasmaCore datasource engine like the following:

#import org.kde.PlasmaCore 0.1 PlasmaCore
{
  Item{
      PlasmaCore.DataSource{
          engine  : "SystemInformation"
          connection : "get_user_fullname"
      }
  }
}

Or should I build a service like this? What are your suggestions, and thoughts?

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
oksidez
  • 71
  • 1
  • 1
  • 7

2 Answers2

1

I figured out ! I did create custom Data Engine that provides user's info over qdbus bridge you can learn basics of it from here : https://techbase.kde.org/Development/Tutorials/Plasma4/DataEngines @douyw basically misunderstood the question and i do not know who minused the question. Anyway , its an important issue for new generation of qml developing , making Data Engines is simply making API.

oksidez
  • 71
  • 1
  • 1
  • 7
0

Anything can be exported into qml context via a cpp wrapper. The following sample code snippets are copied from official doc(Qt4.8).

1) Write a wrapper class:

In this example, it exports current datetime. You can export your stuff in a similar way.

class ApplicationData : public QObject
{
    Q_OBJECT
public:
    Q_INVOKABLE QDateTime getCurrentDateTime() const {
        return QDateTime::currentDateTime();
    }
};

2) Export the wrapper class via qml context:

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    QDeclarativeView view;

    ApplicationData data;
    view.rootContext()->setContextProperty("applicationData", &data);

    view.setSource(QUrl::fromLocalFile("MyItem.qml"));
    view.show();

    return app.exec();
}

3) Use it in qml file(MyItem.qml):

import QtQuick 1.0

Text { text: applicationData.getCurrentDateTime() }

That's it!

douyw
  • 4,034
  • 1
  • 30
  • 28
  • Of course i know this process i already got the user info with the help of kuser.h library easly -,- , im making pure qml plasmoid , what i mean is i can only use js, or xml code plugins other wise with cpp i have to prepare a build based plasmoid. it has to be pure that plasmapkg can install it easly. – oksidez May 10 '15 at 00:54