summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp87
1 files changed, 36 insertions, 51 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 3c460d5..44a2892 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -32,10 +32,11 @@
#include <QDebug>
#include <QScreen>
-#include <signalcomposer.h>
#include <wayland-client.h>
#include "agl-shell-client-protocol.h"
+#include <vehiclesignals.h>
+
// Global indicating whether canned animation should run
bool runAnimation = true;
@@ -46,7 +47,7 @@ global_add(void *data, struct wl_registry *reg, uint32_t name,
struct agl_shell **shell = static_cast<struct agl_shell **>(data);
if (strcmp(interface, agl_shell_interface.name) == 0) {
*shell = static_cast<struct agl_shell *>(wl_registry_bind(reg,
- name, &agl_shell_interface, version)
+ name, &agl_shell_interface, 1)
);
}
}
@@ -141,10 +142,22 @@ create_component(QPlatformNativeInterface *native, QQmlComponent *comp,
return getWlSurface(native, win);
}
+static QScreen *find_screen(const char *screen_name)
+{
+ QList<QScreen *> screens = qApp->screens();
+ QString name(screen_name);
+
+ for (QScreen *screen : screens) {
+ if (name == screen->name())
+ return screen;
+ }
+
+ return nullptr;
+}
int main(int argc, char *argv[])
{
- QString myname = QString("cluster-gauges");
+ QString myname = QString("cluster-dashboard");
struct agl_shell *agl_shell;
struct wl_output *output;
@@ -162,63 +175,35 @@ int main(int argc, char *argv[])
std::shared_ptr<struct agl_shell> shell{agl_shell, agl_shell_destroy};
- screen = qApp->primaryScreen();
+ const char *screen_name = getenv("DASHBOARD_START_SCREEN");
+ if (screen_name)
+ screen = find_screen(screen_name);
+ else
+ screen = qApp->primaryScreen();
output = getWlOutput(native, screen);
- QCommandLineParser parser;
- parser.addPositionalArgument("port", app.translate("main", "port for binding"));
- parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
- parser.addHelpOption();
- parser.addVersionOption();
- parser.process(app);
-
- QStringList positionalArguments = parser.positionalArguments();
+ read_config();
QQmlApplicationEngine engine;
QQmlContext *context = engine.rootContext();
+ context->setContextProperty("runAnimation", runAnimation);
- if (positionalArguments.length() == 2) {
- int port = positionalArguments.takeFirst().toInt();
- QString secret = positionalArguments.takeFirst();
-
- QUrl bindingAddress;
- QUrlQuery query;
+ VehicleSignalsConfig vsConfig(myname);
+ context->setContextProperty("VehicleSignals", new VehicleSignals(vsConfig));
- struct wl_surface *bg;
+ QQmlComponent bg_comp(&engine, QUrl("qrc:/cluster-gauges.qml"));
+ qDebug() << bg_comp.errors();
+ struct wl_surface *bg = create_component(native, &bg_comp, screen, &qobj_bg);
- bindingAddress.setScheme(QStringLiteral("ws"));
- bindingAddress.setHost(QStringLiteral("localhost"));
- bindingAddress.setPort(port);
- bindingAddress.setPath(QStringLiteral("/api"));
+ // set the surface as the background
+ agl_shell_set_background(agl_shell, bg, output);
- query.addQueryItem(QStringLiteral("token"), secret);
- bindingAddress.setQuery(query);
-
- read_config();
-
- context->setContextProperty(QStringLiteral("bindingAddress"),
- bindingAddress);
-
- context->setContextProperty("SignalComposer",
- new SignalComposer(bindingAddress,
- context));
- context->setContextProperty("runAnimation", runAnimation);
-
- QQmlComponent bg_comp(&engine, QUrl("qrc:/cluster-gauges.qml"));
- qDebug() << bg_comp.errors();
-
- bg = create_component(native, &bg_comp, screen, &qobj_bg);
-
- // set the surface as the background
- agl_shell_set_background(agl_shell, bg, output);
-
- // instruct the compositor it can display after Qt has a chance
- // to load everything
- QTimer::singleShot(500, [agl_shell](){
- qDebug() << "agl_shell ready!";
- agl_shell_ready(agl_shell);
- });
- }
+ // instruct the compositor it can display after Qt has a chance
+ // to load everything
+ QTimer::singleShot(500, [agl_shell](){
+ qDebug() << "agl_shell ready!";
+ agl_shell_ready(agl_shell);
+ });
return app.exec();
}