summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/aglextras/hmi/aglapplication.cpp4
-rw-r--r--src/aglextras/hmi/aglapplication.h13
-rw-r--r--src/aglextras/hmi/aglapplication_p.h2
-rw-r--r--src/aglextras/hmi/aglwmclient.cpp18
-rw-r--r--src/aglextras/hmi/aglwmclient.h1
-rw-r--r--src/aglextras/hmi/aglwmclient_p.h1
6 files changed, 38 insertions, 1 deletions
diff --git a/src/aglextras/hmi/aglapplication.cpp b/src/aglextras/hmi/aglapplication.cpp
index 82e49bf..320aa17 100644
--- a/src/aglextras/hmi/aglapplication.cpp
+++ b/src/aglextras/hmi/aglapplication.cpp
@@ -31,7 +31,6 @@ QT_BEGIN_NAMESPACE
AGLApplicationPrivate::AGLApplicationPrivate (AGLApplication *app)
: binding_address(new QUrl)
, engine(new QQmlApplicationEngine(app))
-
{
;
}
@@ -108,6 +107,9 @@ AGLApplication::exec (void)
void AGLApplication::setupApplicationRole (const QString &role)
{
d_ptr->wmclient = new AGLWmClient(role, d_ptr->port, d_ptr->secret);
+ d_ptr->screen_info = new AGLScreenInfo(this, d_ptr->wmclient->get_scale_factor());
+ d_ptr->engine->rootContext()->setContextProperty(QStringLiteral("screenInfo"),
+ d_ptr->screen_info);
}
QT_END_NAMESPACE
diff --git a/src/aglextras/hmi/aglapplication.h b/src/aglextras/hmi/aglapplication.h
index df68979..f9d17a0 100644
--- a/src/aglextras/hmi/aglapplication.h
+++ b/src/aglextras/hmi/aglapplication.h
@@ -43,6 +43,19 @@ private:
friend class AGLApplicationPrivate;
QSharedPointer<AGLApplicationPrivate> d_ptr;
};
+
+class AGLScreenInfo : public QObject
+{
+ Q_OBJECT
+
+public:
+ AGLScreenInfo(QObject* parent = 0, double scale = 1.0) : QObject(parent), _scale_factor(scale) {};
+
+ Q_INVOKABLE double scale_factor() const { return _scale_factor; };
+
+private:
+ double _scale_factor;
+};
QT_END_NAMESPACE
#endif // AGLAPPLICATION_H
diff --git a/src/aglextras/hmi/aglapplication_p.h b/src/aglextras/hmi/aglapplication_p.h
index 93e5976..6cc1880 100644
--- a/src/aglextras/hmi/aglapplication_p.h
+++ b/src/aglextras/hmi/aglapplication_p.h
@@ -23,6 +23,7 @@ class QUrl;
class QQmlApplicationEngine;
class AGLWmClient;
class AGLApplication;
+class AGLScreenInfo;
class AGLApplicationPrivate
{
public:
@@ -35,6 +36,7 @@ class AGLApplicationPrivate
QUrl* binding_address;
QQmlApplicationEngine *engine;
AGLWmClient* wmclient;
+ AGLScreenInfo* screen_info;
friend class AGLApplication;
};
QT_END_NAMESPACE
diff --git a/src/aglextras/hmi/aglwmclient.cpp b/src/aglextras/hmi/aglwmclient.cpp
index cb80e17..3baf6c7 100644
--- a/src/aglextras/hmi/aglwmclient.cpp
+++ b/src/aglextras/hmi/aglwmclient.cpp
@@ -63,6 +63,11 @@ void AGLWmClient::disconnect_frame_swapped (void)
#endif // USE_AGL_HMI_LOWLEVEL_API
}
+double AGLWmClient::get_scale_factor (void)
+{
+ return d_ptr->scale_factor;
+}
+
#ifdef USE_AGL_HMI_LOWLEVEL_API
void AGLWmClient::attach (QQmlApplicationEngine* engine)
{
@@ -104,6 +109,19 @@ AGLWmClient::AGLWmClient (const QString&, int port, QString)
return;
}
+ // Get information of screen
+ {
+ json_object *obj = json_object_new_object();
+ int ret = w_ptr->getDisplayInfo(obj);
+ if (!ret) {
+ json_object *j_val;
+ if (json_object_object_get_ex(obj, "scale", &j_val)) {
+ d_ptr->scale_factor = json_object_get_double(j_val);
+ }
+ }
+ json_object_put(obj);
+ }
+
d_ptr->binding = true;
d_ptr->layout = layout;
diff --git a/src/aglextras/hmi/aglwmclient.h b/src/aglextras/hmi/aglwmclient.h
index 4603610..d6132aa 100644
--- a/src/aglextras/hmi/aglwmclient.h
+++ b/src/aglextras/hmi/aglwmclient.h
@@ -33,6 +33,7 @@ class AGLEXTRAS_EXPORT AGLWmClient : public QObject
public:
AGLWmClient (const QString& layout, int port, QString secret);
void attach (QQmlApplicationEngine* engine);
+ double get_scale_factor (void);
private slots:
void disconnect_frame_swapped (void);
diff --git a/src/aglextras/hmi/aglwmclient_p.h b/src/aglextras/hmi/aglwmclient_p.h
index 239a4ae..ff5cd1f 100644
--- a/src/aglextras/hmi/aglwmclient_p.h
+++ b/src/aglextras/hmi/aglwmclient_p.h
@@ -29,6 +29,7 @@ class AGLWmClientPrivate
QString layout; // id of layaout which is managed by AGL WM
QMetaObject::Connection loading;
bool binding = false;
+ double scale_factor = 1.0;
friend class AGLWmClient;
};
QT_END_NAMESPACE