aboutsummaryrefslogtreecommitdiffstats
path: root/homescreen/src
diff options
context:
space:
mode:
Diffstat (limited to 'homescreen/src')
-rw-r--r--homescreen/src/appinfo.cpp176
-rw-r--r--homescreen/src/appinfo.h68
-rw-r--r--homescreen/src/applicationlauncher.cpp37
-rw-r--r--homescreen/src/applicationlauncher.h11
-rw-r--r--homescreen/src/applicationmodel.cpp144
-rw-r--r--homescreen/src/applicationmodel.h41
-rw-r--r--homescreen/src/hmi-debug.h70
-rw-r--r--homescreen/src/homescreencontrolinterface.cpp86
-rw-r--r--homescreen/src/homescreencontrolinterface.h52
-rw-r--r--homescreen/src/homescreenhandler.cpp88
-rw-r--r--homescreen/src/homescreenhandler.h47
-rw-r--r--homescreen/src/layouthandler.cpp279
-rw-r--r--homescreen/src/layouthandler.h65
-rw-r--r--homescreen/src/main.cpp107
-rw-r--r--homescreen/src/mainwindow.cpp186
-rw-r--r--homescreen/src/mainwindow.h83
-rw-r--r--homescreen/src/mastervolume.cpp2
-rw-r--r--homescreen/src/mastervolume.h1
-rw-r--r--homescreen/src/paclient.cpp240
-rw-r--r--homescreen/src/paclient.h64
-rw-r--r--homescreen/src/popupwidget.cpp92
-rw-r--r--homescreen/src/popupwidget.h58
-rw-r--r--homescreen/src/settingswidget.cpp103
-rw-r--r--homescreen/src/settingswidget.h53
24 files changed, 315 insertions, 1838 deletions
diff --git a/homescreen/src/appinfo.cpp b/homescreen/src/appinfo.cpp
deleted file mode 100644
index fd9a585..0000000
--- a/homescreen/src/appinfo.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- * Copyright (C) 2016 The Qt Company Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "appinfo.h"
-
-#include <QtCore/QJsonObject>
-
-class AppInfo::Private : public QSharedData
-{
-public:
- Private();
- Private(const Private &other);
-
- QString id;
- QString version;
- int width;
- int height;
- QString name;
- QString description;
- QString shortname;
- QString author;
- QString iconPath;
-};
-
-AppInfo::Private::Private()
- : width(-1)
- , height(-1)
-{
-}
-
-AppInfo::Private::Private(const Private &other)
- : QSharedData(other)
- , id(other.id)
- , version(other.version)
- , width(other.width)
- , height(other.height)
- , name(other.name)
- , description(other.description)
- , shortname(other.shortname)
- , author(other.author)
- , iconPath(other.iconPath)
-{
-}
-
-AppInfo::AppInfo()
- : d(new Private)
-{
-}
-
-AppInfo::AppInfo(const QString &icon, const QString &name, const QString &id)
- : d(new Private)
-{
- d->iconPath = icon;
- d->name = name;
- d->id = id;
-}
-
-AppInfo::AppInfo(const AppInfo &other)
- : d(other.d)
-{
-}
-
-AppInfo::~AppInfo()
-{
-}
-
-AppInfo &AppInfo::operator =(const AppInfo &other)
-{
- d = other.d;
- return *this;
-}
-
-QString AppInfo::id() const
-{
- return d->id;
-}
-
-QString AppInfo::version() const
-{
- return d->version;
-}
-
-int AppInfo::width() const
-{
- return d->width;
-}
-
-int AppInfo::height() const
-{
- return d->height;
-}
-
-QString AppInfo::name() const
-{
- return d->name;
-}
-
-QString AppInfo::description() const
-{
- return d->description;
-}
-
-QString AppInfo::shortname() const
-{
- return d->shortname;
-}
-
-QString AppInfo::author() const
-{
- return d->author;
-}
-
-QString AppInfo::iconPath() const
-{
- return d->iconPath;
-}
-
-void AppInfo::read(const QJsonObject &json)
-{
- d->id = json["id"].toString();
- d->version = json["version"].toString();
- d->width = json["width"].toInt();
- d->height = json["height"].toInt();
- d->name = json["name"].toString();
- d->description = json["description"].toString();
- d->shortname = json["shortname"].toString();
- d->author = json["author"].toString();
- d->iconPath = json["iconPath"].toString();
-}
-
-QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &appInfo)
-{
- argument.beginStructure();
- argument << appInfo.d->id;
- argument << appInfo.d->version;
- argument << appInfo.d->width;
- argument << appInfo.d->height;
- argument << appInfo.d->name;
- argument << appInfo.d->description;
- argument << appInfo.d->shortname;
- argument << appInfo.d->author;
- argument << appInfo.d->iconPath;
- argument.endStructure();
-
- return argument;
-}
-
-const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &appInfo)
-{
- argument.beginStructure();
- argument >> appInfo.d->id;
- argument >> appInfo.d->version;
- argument >> appInfo.d->width;
- argument >> appInfo.d->height;
- argument >> appInfo.d->name;
- argument >> appInfo.d->description;
- argument >> appInfo.d->shortname;
- argument >> appInfo.d->author;
- argument >> appInfo.d->iconPath;
- argument.endStructure();
- return argument;
-}
diff --git a/homescreen/src/appinfo.h b/homescreen/src/appinfo.h
deleted file mode 100644
index 0d98b10..0000000
--- a/homescreen/src/appinfo.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- * Copyright (C) 2016 The Qt Company Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef APPINFO_H
-#define APPINFO_H
-
-#include <QtCore/QSharedDataPointer>
-#include <QtDBus/QDBusArgument>
-
-class AppInfo
-{
- Q_GADGET
- Q_PROPERTY(QString id READ id)
- Q_PROPERTY(QString version READ version)
- Q_PROPERTY(int width READ width)
- Q_PROPERTY(int height READ height)
- Q_PROPERTY(QString name READ name)
- Q_PROPERTY(QString description READ description)
- Q_PROPERTY(QString shortname READ shortname)
- Q_PROPERTY(QString author READ author)
- Q_PROPERTY(QString iconPath READ iconPath)
-public:
- AppInfo();
- AppInfo(const QString &icon, const QString &name, const QString &id);
- AppInfo(const AppInfo &other);
- virtual ~AppInfo();
- AppInfo &operator =(const AppInfo &other);
- void swap(AppInfo &other) { qSwap(d, other.d); }
-
- QString id() const;
- QString version() const;
- int width() const;
- int height() const;
- QString name() const;
- QString description() const;
- QString shortname() const;
- QString author() const;
- QString iconPath() const;
-
- void read(const QJsonObject &json);
-
- friend QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &appInfo);
- friend const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &appInfo);
-
-private:
- class Private;
- QSharedDataPointer<Private> d;
-};
-
-Q_DECLARE_SHARED(AppInfo)
-Q_DECLARE_METATYPE(AppInfo)
-Q_DECLARE_METATYPE(QList<AppInfo>)
-
-#endif // APPINFO_H
diff --git a/homescreen/src/applicationlauncher.cpp b/homescreen/src/applicationlauncher.cpp
index 559a93c..5a1e2d6 100644
--- a/homescreen/src/applicationlauncher.cpp
+++ b/homescreen/src/applicationlauncher.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2016 The Qt Company Ltd.
* Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,30 +20,58 @@
#include "afm_user_daemon_proxy.h"
-#include <QtCore/QDebug>
+#include "hmi-debug.h"
extern org::AGL::afm::user *afm_user_daemon_proxy;
ApplicationLauncher::ApplicationLauncher(QObject *parent)
: QObject(parent)
+ , m_launching(false)
+ , m_timeout(new QTimer(this))
{
+ m_timeout->setInterval(3000);
+ m_timeout->setSingleShot(true);
+ connect(m_timeout, &QTimer::timeout, [&]() {
+ setLaunching(false);
+ });
+ connect(this, &ApplicationLauncher::launchingChanged, [&](bool launching) {
+ if (launching)
+ m_timeout->start();
+ else
+ m_timeout->stop();
+ });
+ connect(this, &ApplicationLauncher::currentChanged, [&]() {
+ setLaunching(false);
+ });
}
int ApplicationLauncher::launch(const QString &application)
{
int result = -1;
- qDebug() << "launch" << application;
+ HMI_DEBUG("HomeScreen","ApplicationLauncher launch %s.", application.toStdString().c_str());
result = afm_user_daemon_proxy->start(application).value().toInt();
- qDebug() << "pid:" << result;
+ HMI_DEBUG("HomeScreen","ApplicationLauncher pid: %d.", result);
if (result > 1) {
- setCurrent(application);
+ setLaunching(true);
}
return result;
}
+bool ApplicationLauncher::isLaunching() const
+{
+ return m_launching;
+}
+
+void ApplicationLauncher::setLaunching(bool launching)
+{
+ if (m_launching == launching) return;
+ m_launching = launching;
+ launchingChanged(launching);
+}
+
QString ApplicationLauncher::current() const
{
return m_current;
diff --git a/homescreen/src/applicationlauncher.h b/homescreen/src/applicationlauncher.h
index a31e663..dfa5846 100644
--- a/homescreen/src/applicationlauncher.h
+++ b/homescreen/src/applicationlauncher.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2016 The Qt Company Ltd.
* Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +21,22 @@
#include <QtCore/QObject>
+class QTimer;
+
class ApplicationLauncher : public QObject
{
Q_OBJECT
+ Q_PROPERTY(bool launching READ isLaunching NOTIFY launchingChanged)
Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged)
public:
explicit ApplicationLauncher(QObject *parent = NULL);
+ bool isLaunching() const;
QString current() const;
signals:
void newAppRequestsToBeVisible(int pid);
+ void launchingChanged(bool launching);
void currentChanged(const QString &current);
public slots:
@@ -38,7 +44,12 @@ public slots:
void setCurrent(const QString &current);
private:
+ void setLaunching(bool launching);
+
+private:
+ bool m_launching;
QString m_current;
+ QTimer *m_timeout;
};
#endif // APPLICATIONLAUNCHER_H
diff --git a/homescreen/src/applicationmodel.cpp b/homescreen/src/applicationmodel.cpp
deleted file mode 100644
index 417bc4c..0000000
--- a/homescreen/src/applicationmodel.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2016 The Qt Company Ltd.
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "applicationmodel.h"
-#include "appinfo.h"
-
-#include <QtCore/QDebug>
-
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusReply>
-
-#include "afm_user_daemon_proxy.h"
-
-extern org::AGL::afm::user *afm_user_daemon_proxy;
-
-class ApplicationModel::Private
-{
-public:
- Private();
-
- QList<AppInfo> data;
-};
-
-namespace {
- QString get_icon_name(QJsonObject const &i)
- {
- QString icon = i["id"].toString().split("@").front();
- if (icon == "hvac" || icon == "poi") {
- icon = icon.toUpper();
- } else if (icon == "mediaplayer") {
- icon = "Multimedia";
- } else {
- icon[0] = icon[0].toUpper();
- }
- return icon;
- }
-}
-
-ApplicationModel::Private::Private()
-{
- QString apps = afm_user_daemon_proxy->runnables(QStringLiteral(""));
- QJsonDocument japps = QJsonDocument::fromJson(apps.toUtf8());
- for (auto const &app : japps.array()) {
- QJsonObject const &jso = app.toObject();
- auto const name = jso["name"].toString();
- auto const id = jso["id"].toString();
- auto const icon = get_icon_name(jso);
- this->data.append(AppInfo(icon, name, id));
- qDebug() << "name:" << name << "icon:" << icon << "id:" << id;
- }
-}
-
-ApplicationModel::ApplicationModel(QObject *parent)
- : QAbstractListModel(parent)
- , d(new Private())
-{
-}
-
-ApplicationModel::~ApplicationModel()
-{
- delete this->d;
-}
-
-int ApplicationModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
-
- return this->d->data.count();
-}
-
-QVariant ApplicationModel::data(const QModelIndex &index, int role) const
-{
- QVariant ret;
- if (!index.isValid())
- return ret;
-
- switch (role) {
- case Qt::DecorationRole:
- ret = this->d->data[index.row()].iconPath();
- break;
- case Qt::DisplayRole:
- ret = this->d->data[index.row()].name();
- break;
- case Qt::UserRole:
- ret = this->d->data[index.row()].id();
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-QHash<int, QByteArray> ApplicationModel::roleNames() const
-{
- QHash<int, QByteArray> roles;
- roles[Qt::DecorationRole] = "icon";
- roles[Qt::DisplayRole] = "name";
- roles[Qt::UserRole] = "id";
- return roles;
-}
-
-QString ApplicationModel::id(int i) const
-{
- return data(index(i), Qt::UserRole).toString();
-}
-
-void ApplicationModel::move(int from, int to)
-{
- QModelIndex parent;
- if (to < 0 || to > rowCount()) return;
- if (from < to) {
- if (!beginMoveRows(parent, from, from, parent, to + 1)) {
- qDebug() << from << to << false;
- return;
- }
- d->data.move(from, to);
- endMoveRows();
- } else if (from > to) {
- if (!beginMoveRows(parent, from, from, parent, to)) {
- qDebug() << from << to << false;
- return;
- }
- d->data.move(from, to);
- endMoveRows();
- } else {
- qDebug() << from << to << false;
- }
-}
diff --git a/homescreen/src/applicationmodel.h b/homescreen/src/applicationmodel.h
deleted file mode 100644
index 2414b7e..0000000
--- a/homescreen/src/applicationmodel.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2016 The Qt Company Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef APPLICATIONMODEL_H
-#define APPLICATIONMODEL_H
-
-#include <QtCore/QAbstractListModel>
-
-class ApplicationModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit ApplicationModel(QObject *parent = nullptr);
- ~ApplicationModel();
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
- QHash<int, QByteArray> roleNames() const override;
- Q_INVOKABLE QString id(int index) const;
- Q_INVOKABLE void move(int from, int to);
-
-private:
- class Private;
- Private *d;
-};
-
-#endif // APPLICATIONMODEL_H
diff --git a/homescreen/src/hmi-debug.h b/homescreen/src/hmi-debug.h
new file mode 100644
index 0000000..28705f5
--- /dev/null
+++ b/homescreen/src/hmi-debug.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HMI_DEBUG_H__
+#define __HMI_DEBUG_H__
+
+#include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+
+enum LOG_LEVEL{
+ LOG_LEVEL_NONE = 0,
+ LOG_LEVEL_ERROR,
+ LOG_LEVEL_WARNING,
+ LOG_LEVEL_NOTICE,
+ LOG_LEVEL_INFO,
+ LOG_LEVEL_DEBUG,
+ LOG_LEVEL_MAX = LOG_LEVEL_DEBUG
+};
+
+#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+
+#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__)
+#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
+
+static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"};
+
+static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...)
+{
+ const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG"));
+ if(log_level < level)
+ {
+ return;
+ }
+
+ char *message;
+ struct timespec tp;
+ unsigned int time;
+
+ clock_gettime(CLOCK_REALTIME, &tp);
+ time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
+
+ va_list args;
+ va_start(args, log);
+ if (log == NULL || vasprintf(&message, log, args) < 0)
+ message = NULL;
+ fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message);
+ va_end(args);
+ free(message);
+}
+
+#endif //__HMI_DEBUG_H__
diff --git a/homescreen/src/homescreencontrolinterface.cpp b/homescreen/src/homescreencontrolinterface.cpp
deleted file mode 100644
index ecbe8e4..0000000
--- a/homescreen/src/homescreencontrolinterface.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "afm_user_daemon_proxy.h"
-#include "homescreencontrolinterface.h"
-
-extern org::AGL::afm::user *afm_user_daemon_proxy;
-
-HomeScreenControlInterface::HomeScreenControlInterface(QObject *parent) :
- QObject(parent),
- mp_homeScreenAdaptor(0)
-{
- // publish dbus homescreen interface
- mp_homeScreenAdaptor = new HomescreenAdaptor((QObject*)this);
-
- QDBusConnection dbus = QDBusConnection::sessionBus();
- dbus.registerObject("/HomeScreen", this);
- dbus.registerService("org.agl.homescreen");
-}
-
-QList<int> HomeScreenControlInterface::getAllSurfacesOfProcess(int pid)
-{
- qDebug("getAllSurfacesOfProcess %d", pid);
- return newRequestGetAllSurfacesOfProcess(pid);
-}
-
-int HomeScreenControlInterface::getSurfaceStatus(int surfaceId)
-{
- qDebug("getSurfaceStatus %d", surfaceId);
- return newRequestGetSurfaceStatus(surfaceId);
-}
-
-void HomeScreenControlInterface::hardKeyPressed(int key)
-{
- int pid = -1;
-
- switch (key)
- {
- case InputEvent::HARDKEY_NAV:
- qDebug("hardKeyPressed NAV key pressed!");
- pid = afm_user_daemon_proxy->start("navigation@0.1").value().toInt();
- qDebug("pid: %d", pid);
- emit newRequestsToBeVisibleApp(pid);
- break;
- case InputEvent::HARDKEY_MEDIA:
- qDebug("hardKeyPressed MEDIA key pressed!");
- pid = afm_user_daemon_proxy->start("media@0.1").value().toInt();
- qDebug("pid: %d", pid);
- emit newRequestsToBeVisibleApp(pid);
- break;
- default:
- qDebug("hardKeyPressed %d", key);
- break;
- }
-}
-
-void HomeScreenControlInterface::renderSurfaceToArea(int surfaceId, int layoutArea)
-{
- qDebug("renderSurfaceToArea %d %d", surfaceId, layoutArea);
- emit newRequestRenderSurfaceToArea(surfaceId, layoutArea);
-}
-
-bool HomeScreenControlInterface::renderAppToAreaAllowed(int appCategory, int layoutArea)
-{
- qDebug("renderAppToAreaAllowed %d %d", appCategory, layoutArea);
- return true; //TODO: ask policy manager
-}
-
-void HomeScreenControlInterface::requestSurfaceIdToFullScreen(int surfaceId)
-{
- qDebug("requestSurfaceIdToFullScreen %d", surfaceId);
- emit newRequestSurfaceIdToFullScreen(surfaceId);
-}
diff --git a/homescreen/src/homescreencontrolinterface.h b/homescreen/src/homescreencontrolinterface.h
deleted file mode 100644
index b68a2b2..0000000
--- a/homescreen/src/homescreencontrolinterface.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef HOMESCREENCONTROLINTERFACE_H
-#define HOMESCREENCONTROLINTERFACE_H
-
-#include <QObject>
-#include "include/homescreen.hpp"
-#include "homescreen_adaptor.h"
-
-class HomeScreenControlInterface : public QObject
-{
- Q_OBJECT
-public:
- explicit HomeScreenControlInterface(QObject *parent = 0);
-
-signals:
- void newRequestsToBeVisibleApp(int pid);
-
- QList<int> newRequestGetAllSurfacesOfProcess(int pid);
- int newRequestGetSurfaceStatus(int surfaceId);
- void newRequestRenderSurfaceToArea(int surfaceId, int layoutArea);
- bool newRequestRenderSurfaceToAreaAllowed(int surfaceId, int layoutArea);
- void newRequestSurfaceIdToFullScreen(int surfaceId);
-
-//from homescreen_adaptor.h
-public Q_SLOTS: // METHODS
- QList<int> getAllSurfacesOfProcess(int pid);
- int getSurfaceStatus(int surfaceId);
- void hardKeyPressed(int key);
- void renderSurfaceToArea(int surfaceId, int layoutArea);
- bool renderAppToAreaAllowed(int appCategory, int layoutArea);
- void requestSurfaceIdToFullScreen(int surfaceId);
-
-private:
- HomescreenAdaptor *mp_homeScreenAdaptor;
-};
-
-#endif // HOMESCREENCONTROLINTERFACE_H
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp
new file mode 100644
index 0000000..5da8b9e
--- /dev/null
+++ b/homescreen/src/homescreenhandler.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "homescreenhandler.h"
+#include <functional>
+#include "hmi-debug.h"
+
+void* HomescreenHandler::myThis = 0;
+
+HomescreenHandler::HomescreenHandler(QObject *parent) :
+ QObject(parent),
+ mp_hs(NULL)
+{
+
+}
+
+HomescreenHandler::~HomescreenHandler()
+{
+ if (mp_hs != NULL) {
+ delete mp_hs;
+ }
+}
+
+void HomescreenHandler::init(int port, const char *token)
+{
+ mp_hs = new LibHomeScreen();
+ mp_hs->init(port, token);
+
+ myThis = this;
+
+ mp_hs->registerCallback(nullptr, HomescreenHandler::onRep_static);
+
+ mp_hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [this](json_object *object){
+ const char *display_message = json_object_get_string(
+ json_object_object_get(object, "display_message"));
+ HMI_DEBUG("HomeScreen","set_event_handler Event_OnScreenMessage display_message = %s", display_message);
+ });
+
+}
+
+void HomescreenHandler::tapShortcut(QString application_name)
+{
+ HMI_DEBUG("HomeScreen","tapShortcut %s", application_name.toStdString().c_str());
+ mp_hs->tapShortcut(application_name.toStdString().c_str());
+}
+
+void HomescreenHandler::onRep_static(struct json_object* reply_contents)
+{
+ static_cast<HomescreenHandler*>(HomescreenHandler::myThis)->onRep(reply_contents);
+}
+
+void HomescreenHandler::onEv_static(const string& event, struct json_object* event_contents)
+{
+ static_cast<HomescreenHandler*>(HomescreenHandler::myThis)->onEv(event, event_contents);
+}
+
+void HomescreenHandler::onRep(struct json_object* reply_contents)
+{
+ const char* str = json_object_to_json_string(reply_contents);
+ HMI_DEBUG("HomeScreen","HomeScreen onReply %s", str);
+}
+
+void HomescreenHandler::onEv(const string& event, struct json_object* event_contents)
+{
+ const char* str = json_object_to_json_string(event_contents);
+ HMI_DEBUG("HomeScreen","HomeScreen onEv %s, contents: %s", event.c_str(), str);
+
+ if (event.compare("homescreen/on_screen_message") == 0) {
+ struct json_object *json_data = json_object_object_get(event_contents, "data");
+ struct json_object *json_display_message = json_object_object_get(json_data, "display_message");
+ const char* display_message = json_object_get_string(json_display_message);
+
+ HMI_DEBUG("HomeScreen","display_message = %s", display_message);
+ }
+}
diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h
new file mode 100644
index 0000000..c18d7a0
--- /dev/null
+++ b/homescreen/src/homescreenhandler.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HOMESCREENHANDLER_H
+#define HOMESCREENHANDLER_H
+
+#include <QObject>
+#include <libhomescreen.hpp>
+#include <string>
+
+using namespace std;
+
+class HomescreenHandler : public QObject
+{
+ Q_OBJECT
+public:
+ explicit HomescreenHandler(QObject *parent = 0);
+ ~HomescreenHandler();
+
+ void init(int port, const char* token);
+
+ Q_INVOKABLE void tapShortcut(QString application_name);
+
+ void onRep(struct json_object* reply_contents);
+ void onEv(const string& event, struct json_object* event_contents);
+
+ static void* myThis;
+ static void onRep_static(struct json_object* reply_contents);
+ static void onEv_static(const string& event, struct json_object* event_contents);
+private:
+ LibHomeScreen *mp_hs;
+};
+
+#endif // HOMESCREENHANDLER_H
diff --git a/homescreen/src/layouthandler.cpp b/homescreen/src/layouthandler.cpp
deleted file mode 100644
index 6f5ba01..0000000
--- a/homescreen/src/layouthandler.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "layouthandler.h"
-#include <QTimerEvent>
-
-LayoutHandler::LayoutHandler(QObject *parent) :
- QObject(parent),
- m_secondsTimerId(-1),
- mp_dBusWindowManagerProxy(0),
- mp_dBusPopupProxy(0),
- m_visibleSurfaces(),
- m_invisibleSurfaces(),
- m_requestsToBeVisibleSurfaces()
-{
- qDBusRegisterMetaType<SimplePoint>();
- qDBusRegisterMetaType<QList<SimplePoint> >();
- qDBusRegisterMetaType<LayoutArea>();
- qDBusRegisterMetaType<QList<LayoutArea> >();
- qDBusRegisterMetaType<Layout>();
- qDBusRegisterMetaType<QList<Layout> >();
-
- qDebug("D-Bus: connect to org.agl.windowmanager /windowmanager");
- mp_dBusWindowManagerProxy = new org::agl::windowmanager("org.agl.windowmanager",
- "/windowmanager",
- QDBusConnection::sessionBus(),
- 0);
- qDebug("D-Bus: connect to org.agl.homescreen /Popup");
- mp_dBusPopupProxy = new org::agl::popup("org.agl.homescreen",
- "/Popup",
- QDBusConnection::sessionBus(),
- 0);
-
- QDBusConnection::sessionBus().connect("org.agl.windowmanager",
- "/windowmanager",
- "org.agl.windowmanager",
- "surfaceVisibilityChanged",
- this,
- SIGNAL(surfaceVisibilityChanged(int,bool)));
-
- QList<LayoutArea> surfaceAreas;
- LayoutArea surfaceArea;
-
- const int SCREEN_WIDTH = 1080;
- const int SCREEN_HEIGHT = 1920;
-
- const int TOPAREA_HEIGHT = 218;
- const int TOPAREA_WIDTH = SCREEN_WIDTH;
- const int TOPAREA_X = 0;
- const int TOPAREA_Y = 0;
- const int MEDIAAREA_HEIGHT = 215;
- const int MEDIAAREA_WIDTH = SCREEN_WIDTH;
- const int MEDIAAREA_X = 0;
- const int MEDIAAREA_Y = SCREEN_HEIGHT - MEDIAAREA_HEIGHT;
-
-
- // only one Layout for CES2017 needed
- // layout 1:
- // one app surface, statusbar, control bar
- surfaceArea.x = 0;
- surfaceArea.y = TOPAREA_HEIGHT;
- surfaceArea.width = SCREEN_WIDTH;
- surfaceArea.height = SCREEN_HEIGHT - TOPAREA_HEIGHT - MEDIAAREA_HEIGHT;
-
- surfaceAreas.append(surfaceArea);
-
- mp_dBusWindowManagerProxy->addLayout(1, "one app", surfaceAreas);
-}
-
-LayoutHandler::~LayoutHandler()
-{
- delete mp_dBusPopupProxy;
- delete mp_dBusWindowManagerProxy;
-}
-
-void LayoutHandler::showAppLayer(const QString &app_id, int pid)
-{
- mp_dBusWindowManagerProxy->showAppLayer(app_id, pid);
-}
-
-void LayoutHandler::hideAppLayer()
-{
- // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3
- mp_dBusWindowManagerProxy->hideLayer(2); // TODO: enum
-}
-
-void LayoutHandler::makeMeVisible(int pid)
-{
- qDebug("makeMeVisible %d", pid);
-
-#if 0
- // if app does not request to be visible
- if (-1 == m_requestsToBeVisiblePids.indexOf(pid))
- {
- m_requestsToBeVisiblePids.append(pid);
-
- // callback every second
- if (-1 != m_secondsTimerId)
- {
- killTimer(m_secondsTimerId);
- m_secondsTimerId = -1;
- }
- m_secondsTimerId = startTimer(1000);
- }
- else
- {
- checkToDoQueue();
- }
-#endif
-}
-
-void LayoutHandler::checkToDoQueue()
-{
-#if 0
- if ((-1 != m_secondsTimerId) && (0 == m_requestsToBeVisiblePids.size()))
- {
- killTimer(m_secondsTimerId);
- m_secondsTimerId = -1;
- }
-
- if (0 != m_requestsToBeVisiblePids.size())
- {
- int pid = m_requestsToBeVisiblePids.at(0);
- qDebug("pid %d wants to be visible", pid);
-
- QList<int> allSurfaces;
- allSurfaces = mp_dBusWindowManagerProxy->getAllSurfacesOfProcess(pid);
- if (0 == allSurfaces.size())
- {
- qDebug("no surfaces for pid %d. retrying!", pid);
- }
- else
- {
- m_requestsToBeVisiblePids.removeAt(0);
- qSort(allSurfaces);
-
- if (0 != allSurfaces.size())
- {
- int firstSurface = allSurfaces.at(0);
-
- if (-1 != m_visibleSurfaces.indexOf(firstSurface))
- {
- qDebug("already visible");
- }
- else
- {
- if (-1 != m_invisibleSurfaces.indexOf(firstSurface))
- {
- m_invisibleSurfaces.removeAt(m_invisibleSurfaces.indexOf(firstSurface));
- }
- if (-1 == m_requestsToBeVisibleSurfaces.indexOf(firstSurface))
- {
- m_requestsToBeVisibleSurfaces.append(firstSurface);
- }
-
- qDebug("before");
- qDebug(" m_visibleSurfaces %d", m_visibleSurfaces.size());
- qDebug(" m_invisibleSurfaces %d", m_invisibleSurfaces.size());
- qDebug(" m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size());
-
- QList<int> availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(1); // one app only for CES2017
- if (1 == availableLayouts.size())
- {
- qDebug("active layout: %d", availableLayouts.at(0));
- m_invisibleSurfaces.append(m_visibleSurfaces);
- m_visibleSurfaces.clear();
- m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces);
- m_requestsToBeVisibleSurfaces.clear();
-
- mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0));
- for (int i = 0; i < m_visibleSurfaces.size(); ++i)
- {
- mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i);
- }
-
- qDebug("after");
- qDebug(" m_visibleSurfaces %d", m_visibleSurfaces.size());
- qDebug(" m_invisibleSurfaces %d", m_invisibleSurfaces.size());
- qDebug(" m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size());
- }
- else
- {
- qDebug("this should not happen!?");
- }
- }
- }
- }
- }
-#endif
-}
-
-#if 0
-QList<int> LayoutHandler::requestGetAllSurfacesOfProcess(int pid)
-{
- qDebug("requestGetAllSurfacesOfProcess %d", pid);
-
- return mp_dBusWindowManagerProxy->getAllSurfacesOfProcess(pid);
-}
-#endif
-
-int LayoutHandler::requestGetSurfaceStatus(int surfaceId)
-{
- int result = -1;
-
- if (-1 != m_visibleSurfaces.indexOf(surfaceId))
- {
- result = 0;
- }
- if (-1 != m_invisibleSurfaces.indexOf(surfaceId))
- {
- result = 1;
- }
- if (-1 != m_requestsToBeVisibleSurfaces.indexOf(surfaceId))
- {
- result = 1;
- }
-
- return result;
-}
-
-void LayoutHandler::requestRenderSurfaceToArea(int surfaceId, int layoutArea)
-{
- qDebug("requestRenderSurfaceToArea %d %d", surfaceId, layoutArea);
- mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(surfaceId, layoutArea);
-}
-
-bool LayoutHandler::requestRenderSurfaceToAreaAllowed(int surfaceId, int layoutArea)
-{
- qDebug("requestRenderSurfaceToAreaAllowed %d %d", surfaceId, layoutArea);
- bool result = true;
- return result;
-}
-
-void LayoutHandler::requestSurfaceIdToFullScreen(int surfaceId)
-{
- qDebug("requestSurfaceIdToFullScreen %d", surfaceId);
-}
-
-void LayoutHandler::setLayoutByName(QString layoutName)
-{
- // switch to new layout
- qDebug("setLayout: switch to new layout %s", layoutName.toStdString().c_str());
- m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces);
- m_requestsToBeVisibleSurfaces.clear();
-
- mp_dBusWindowManagerProxy->setLayoutByName(layoutName);
- for (int i = 0; i < m_visibleSurfaces.size(); ++i)
- {
- mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(i, i);
- }
-}
-
-void LayoutHandler::requestSurfaceVisibilityChanged(int surfaceId, bool visible)
-{
- qDebug("requestSurfaceVisibilityChanged %d %s", surfaceId, visible ? "true" : "false");
- emit surfaceVisibilityChanged(surfaceId, visible);
-}
-
-void LayoutHandler::timerEvent(QTimerEvent *e)
-{
- if (e->timerId() == m_secondsTimerId)
- {
- checkToDoQueue();
- }
-}
-
diff --git a/homescreen/src/layouthandler.h b/homescreen/src/layouthandler.h
deleted file mode 100644
index 007f1ad..0000000
--- a/homescreen/src/layouthandler.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LAYOUTHANDLER_H
-#define LAYOUTHANDLER_H
-
-#include <QObject>
-#include "windowmanager_proxy.h"
-#include "popup_proxy.h"
-
-class LayoutHandler : public QObject
-{
- Q_OBJECT
-public:
- explicit LayoutHandler(QObject *parent = 0);
- ~LayoutHandler();
-
-signals:
-
-public slots:
- void showAppLayer(const QString &app_id, int pid);
- void hideAppLayer();
- void makeMeVisible(int pid);
-private:
- void checkToDoQueue();
-public slots:
- int requestGetSurfaceStatus(int surfaceId);
- void requestRenderSurfaceToArea(int surfaceId, int layoutArea);
- bool requestRenderSurfaceToAreaAllowed(int surfaceId, int layoutArea);
- void requestSurfaceIdToFullScreen(int surfaceId);
- void setLayoutByName(QString layoutName);
-
- // this will receive the surfaceVisibilityChanged signal of the windowmanager
- void requestSurfaceVisibilityChanged(int surfaceId, bool visible);
-
-Q_SIGNALS: // SIGNALS
- void surfaceVisibilityChanged(int surfaceId, bool visible);
-
-protected:
- void timerEvent(QTimerEvent *e);
-private:
- int m_secondsTimerId;
- org::agl::windowmanager *mp_dBusWindowManagerProxy;
- org::agl::popup *mp_dBusPopupProxy;
-
- QList<int> m_requestsToBeVisiblePids;
- QList<int> m_visibleSurfaces;
- QList<int> m_invisibleSurfaces;
- QList<int> m_requestsToBeVisibleSurfaces;
-};
-
-#endif // LAYOUTHANDLER_H
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index 215e7c6..63edd54 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,16 +21,16 @@
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
#include <QtQml/qqml.h>
+#include <QQuickWindow>
-#include "layouthandler.h"
-#include "homescreencontrolinterface.h"
+#include <qlibwindowmanager.h>
+#include <weather.h>
#include "applicationlauncher.h"
#include "statusbarmodel.h"
-#include "applicationmodel.h"
-#include "appinfo.h"
#include "afm_user_daemon_proxy.h"
#include "mastervolume.h"
-#include "paclient.h"
+#include "homescreenhandler.h"
+#include "hmi-debug.h"
// XXX: We want this DBus connection to be shared across the different
// QML objects, is there another way to do this, a nice way, perhaps?
@@ -54,6 +55,7 @@ int main(int argc, char *argv[])
{
QGuiApplication a(argc, argv);
+ // use launch process
QScopedPointer<org::AGL::afm::user, Cleanup> afm_user_daemon_proxy(new org::AGL::afm::user("org.AGL.afm.user",
"/org/AGL/afm/user",
QDBusConnection::sessionBus(),
@@ -66,57 +68,80 @@ int main(int argc, char *argv[])
QCoreApplication::setApplicationVersion("0.7.0");
QCommandLineParser parser;
- parser.setApplicationDescription("AGL HomeScreen - see wwww... for more details");
+ parser.addPositionalArgument("port", a.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret", a.translate("main", "secret for binding"));
parser.addHelpOption();
parser.addVersionOption();
- QCommandLineOption quietOption(QStringList() << "q" << "quiet",
- QCoreApplication::translate("main", "Be quiet. No outputs."));
- parser.addOption(quietOption);
parser.process(a);
-
- if (parser.isSet(quietOption))
- {
- qInstallMessageHandler(noOutput);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ int port = 1700;
+ QString token = "wm";
+
+ if (positionalArguments.length() == 2) {
+ port = positionalArguments.takeFirst().toInt();
+ token = positionalArguments.takeFirst();
}
- // Fire up PA client QThread
- QThread* pat = new QThread;
- PaClient* client = new PaClient();
- client->moveToThread(pat);
- pat->start();
-
- qDBusRegisterMetaType<AppInfo>();
- qDBusRegisterMetaType<QList<AppInfo> >();
+ HMI_DEBUG("HomeScreen","port = %d, token = %s", port, token.toStdString().c_str());
- qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
- qmlRegisterType<ApplicationModel>("Home", 1, 0, "ApplicationModel");
+ // import C++ class to QML
+ // qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume");
- QQmlApplicationEngine engine;
-
- LayoutHandler* layoutHandler = new LayoutHandler();
-
- HomeScreenControlInterface* hsci = new HomeScreenControlInterface();
+ ApplicationLauncher *launcher = new ApplicationLauncher();
+ QLibWindowmanager* layoutHandler = new QLibWindowmanager();
+ if(layoutHandler->init(port,token) != 0){
+ exit(EXIT_FAILURE);
+ }
- QObject::connect(hsci, SIGNAL(newRequestGetSurfaceStatus(int)), layoutHandler, SLOT(requestGetSurfaceStatus(int)));
- QObject::connect(hsci, SIGNAL(newRequestsToBeVisibleApp(int)), layoutHandler, SLOT(makeMeVisible(int)));
- QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToArea(int, int)), layoutHandler, SLOT(requestRenderSurfaceToArea(int,int)));
- QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToAreaAllowed(int, int)), layoutHandler, SLOT(requestRenderSurfaceToAreaAllowed(int,int)));
- QObject::connect(hsci, SIGNAL(newRequestSurfaceIdToFullScreen(int)), layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
+ if (layoutHandler->requestSurface(QString("HomeScreen")) != 0) {
+ exit(EXIT_FAILURE);
+ }
+ layoutHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [layoutHandler](json_object *object) {
+ layoutHandler->endDraw(QString("HomeScreen"));
+ });
+
+ layoutHandler->set_event_handler(QLibWindowmanager::Event_ScreenUpdated, [layoutHandler, launcher](json_object *object) {
+ json_object *jarray = json_object_object_get(object, "ids");
+ int arrLen = json_object_array_length(jarray);
+ for( int idx = 0; idx < arrLen; idx++)
+ {
+ QString label = QString(json_object_get_string( json_object_array_get_idx(jarray, idx) ));
+ HMI_DEBUG("HomeScreen","Event_ScreenUpdated application: %s.", label.toStdString().c_str());
+ QMetaObject::invokeMethod(launcher, "setCurrent", Qt::QueuedConnection, Q_ARG(QString, label));
+ }
+ });
+
+ HomescreenHandler* homescreenHandler = new HomescreenHandler();
+ homescreenHandler->init(port, token.toStdString().c_str());
+
+ QUrl bindingAddress;
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), token);
+ bindingAddress.setQuery(query);
+
+ // mail.qml loading
+ QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
-
+ engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler);
+ engine.rootContext()->setContextProperty("launcher", launcher);
+ engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
- QList<QObject *> mobjs = engine.rootObjects();
- MasterVolume *mv = mobjs.first()->findChild<MasterVolume *>("mv");
- engine.rootContext()->setContextProperty("MasterVolume", mv);
- QObject::connect(mv, SIGNAL(sliderVolumeChanged(int)), client, SLOT(incDecVolume(int)));
- QObject::connect(client, SIGNAL(volumeExternallyChanged(int)), mv, SLOT(changeExternalVolume(int)));
+ QObject *root = engine.rootObjects().first();
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
+ QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface()));
- // Initalize PA client
- client->init();
+ // start homescreen appplications
+ launcher->launch("launcher@0.1"); //Launcher
return a.exec();
}
diff --git a/homescreen/src/mainwindow.cpp b/homescreen/src/mainwindow.cpp
deleted file mode 100644
index 7a0d743..0000000
--- a/homescreen/src/mainwindow.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-#include <include/daynightmode.hpp>
-
-MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- mp_ui(new Ui::MainWindow),
- mp_statusBarWidget(0),
- mp_controlBarWidget(0),
- mp_settingsWidget(0),
- //mp_applauncherwidget(0),
- mp_popupWidget(0),
- mp_layoutHandler(new LayoutHandler()),
- mp_dBusDayNightModeProxy(0),
- mp_proximityAdaptor(0),
- mp_homeScreenControlInterface(0)
-{
- // this has to be adopted to the system setup
- mp_dBusDayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
- "/",
- QDBusConnection::sessionBus(),
- 0);
- QObject::connect(mp_dBusDayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
-
- mp_proximityAdaptor = new ProximityAdaptor((QObject*)this);
-
- // dbus setup
- QDBusConnection dbus = QDBusConnection::sessionBus();
- dbus.registerObject("/Proximity", this);
- dbus.registerService("org.agl.homescreen");
-
- // no window decoration
- setWindowFlags(Qt::FramelessWindowHint);
-
- mp_ui->setupUi(this);
-
- mp_statusBarWidget = new StatusBarWidget(this);
- mp_statusBarWidget->raise();
- // apply layout
- mp_statusBarWidget->move(0, 0);
-
- mp_controlBarWidget = new ControlBarWidget(this);
- mp_controlBarWidget->raise();
- // apply layout
- mp_controlBarWidget->move(0, 1920-60);
-
- mp_settingsWidget = new SettingsWidget(this);
- mp_settingsWidget->raise();
- // apply layout
- mp_settingsWidget->move(0, 60);
- //mp_settingsWidget->hide();
-
- /*mp_applauncherwidget = new AppLauncherWidget(this);
- mp_applauncherwidget->raise();
- // apply layout
- mp_applauncherwidget->move(0, 60);*/
-
-
- mp_popupWidget = new PopupWidget();
- mp_controlBarWidget->raise();
- // apply layout
- mp_popupWidget->move(0, 0);
-
-
- QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), this, SLOT(updateColorScheme()));
- QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_statusBarWidget, SLOT(updateColorScheme()));
- QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_controlBarWidget, SLOT(updateColorScheme()));
- QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_settingsWidget, SLOT(updateColorScheme()));
- QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_popupWidget, SLOT(updateColorScheme()));
-
- QObject::connect(mp_controlBarWidget, SIGNAL(settingsButtonPressed()), mp_settingsWidget, SLOT(raise()));
- //QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_applauncherwidget, SLOT(raise()));
- QObject::connect(mp_controlBarWidget, SIGNAL(hideAppLayer()), mp_layoutHandler, SLOT(hideAppLayer()));
-
- //QObject::connect(mp_applauncherwidget, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int)));
- //QObject::connect(mp_applauncherwidget, SIGNAL(showAppLayer()), mp_layoutHandler, SLOT(showAppLayer()));
-
-
- // apply color scheme
- updateColorScheme();
-
- // this is only useful during development and will be removed later
- setWindowIcon(QIcon(":/icons/home_day.png"));
-
- // mp_applauncherwidget->populateAppList();
- //mp_layoutHandler->setUpLayouts();
-
- mp_homeScreenControlInterface = new HomeScreenControlInterface(this);
- // QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestGetAllSurfacesOfProcess(int)), mp_layoutHandler, SLOT(requestGetAllSurfacesOfProcess(int)));
- QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestGetSurfaceStatus(int)), mp_layoutHandler, SLOT(requestGetSurfaceStatus(int)));
- QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int)));
- QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestRenderSurfaceToArea(int, int)), mp_layoutHandler, SLOT(requestRenderSurfaceToArea(int,int)));
- QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestRenderSurfaceToAreaAllowed(int, int)), mp_layoutHandler, SLOT(requestRenderSurfaceToAreaAllowed(int,int)));
- QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestSurfaceIdToFullScreen(int)), mp_layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
-
- QObject::connect(mp_popupWidget, SIGNAL(comboBoxResult(QString)), mp_layoutHandler, SLOT(setLayoutByName(QString)));
-}
-
-MainWindow::~MainWindow()
-{
- delete mp_homeScreenControlInterface;
-
- delete mp_dBusDayNightModeProxy;
-
- delete mp_layoutHandler;
-
- delete mp_popupWidget;
- //delete mp_applauncherwidget;
- delete mp_settingsWidget;
- delete mp_controlBarWidget;
- delete mp_statusBarWidget;
- delete mp_proximityAdaptor;
- delete mp_ui;
-}
-
-void MainWindow::dayNightModeSlot(int mode)
-{
- QSettings settings;
- settings.setValue("systemsettings/daynightmode", mode);
- // make sure that everything is written to the settings file before continuing
- settings.sync();
-
- updateColorScheme();
-}
-
-void MainWindow::setObjectDetected(bool detected)
-{
- qDebug("setObjectDetected %s", detected ? "true" : "false");
- QSettings settings;
- settings.setValue("systemsettings/proximityobjectdetected", detected);
- // make sure that everything is written to the settings file before continuing
- settings.sync();
-
- updateColorScheme();
-}
-
-void MainWindow::updateColorScheme()
-{
- QSettings settings;
- QSettings settings_cs(QApplication::applicationDirPath() +
- "/colorschemes/" +
- settings.value("systemsettings/colorscheme", "default").toString() +
- "/" +
- QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
- "/" +
- QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
- ".ini",
- QSettings::IniFormat);
-
- mp_ui->widget_background->setStyleSheet(settings_cs.value("MainWindow/widget_background_css").toString());
- mp_ui->widget_homeIcon->setStyleSheet(settings_cs.value("MainWindow/widget_homeIcon_css").toString());
-
- // update children
- mp_statusBarWidget->updateColorScheme();
- mp_controlBarWidget->updateColorScheme();
- mp_settingsWidget->updateColorScheme();
- //mp_applauncherwidget->updateColorScheme();
- mp_popupWidget->updateColorScheme();
-}
-
-void MainWindow::changeEvent(QEvent* event)
-{
- if (QEvent::LanguageChange == event->type())
- {
- mp_ui->retranslateUi(this);
- }
-
- QMainWindow::changeEvent(event);
-}
-
diff --git a/homescreen/src/mainwindow.h b/homescreen/src/mainwindow.h
deleted file mode 100644
index ebcfea2..0000000
--- a/homescreen/src/mainwindow.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include "daynightmode_proxy.h"
-#include "proximity_adaptor.h"
-
-#include "homescreencontrolinterface.h"
-
-#include "statusbarwidget.h"
-#include "controlbarwidget.h"
-#include "settingswidget.h"
-//#include "applauncher.h"
-#include "popupwidget.h"
-
-#include "layouthandler.h"
-
-
-namespace Ui {
-class MainWindow;
-}
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
-// day/night mode
-public Q_SLOTS:
- void dayNightModeSlot(int mode);
-
-// from proximity_adaptor.h
-public Q_SLOTS:
- void setObjectDetected(bool detected);
-
-public slots:
- void updateColorScheme();
-
-protected:
- // called when the translator loaded a new language set
- void changeEvent(QEvent* event);
-
-
-private:
- Ui::MainWindow *mp_ui;
-
- StatusBarWidget *mp_statusBarWidget;
- org::agl::daynightmode *mp_dBusDayNightMode_StatusBarWidget;
- ControlBarWidget *mp_controlBarWidget;
- org::agl::daynightmode *mp_dBusDayNightMode_ControlBarWidget;
- SettingsWidget *mp_settingsWidget;
- //AppLauncherWidget *mp_applauncherwidget;
- PopupWidget *mp_popupWidget;
-
- LayoutHandler *mp_layoutHandler;
-
- org::agl::daynightmode *mp_dBusDayNightModeProxy;
-
- ProximityAdaptor *mp_proximityAdaptor;
-
- HomeScreenControlInterface *mp_homeScreenControlInterface;
-};
-
-#endif // MAINWINDOW_H
diff --git a/homescreen/src/mastervolume.cpp b/homescreen/src/mastervolume.cpp
index 46985ee..5e1e450 100644
--- a/homescreen/src/mastervolume.cpp
+++ b/homescreen/src/mastervolume.cpp
@@ -16,8 +16,6 @@
#include "mastervolume.h"
-#include <QtCore/QDebug>
-
void MasterVolume::setVolume(pa_volume_t volume)
{
int volume_delta = volume - m_volume;
diff --git a/homescreen/src/mastervolume.h b/homescreen/src/mastervolume.h
index edcdd8c..645968a 100644
--- a/homescreen/src/mastervolume.h
+++ b/homescreen/src/mastervolume.h
@@ -16,7 +16,6 @@
#include <QtCore/QObject>
#include <QQmlEngine>
-#include <QDebug>
#include <pulse/pulseaudio.h>
diff --git a/homescreen/src/paclient.cpp b/homescreen/src/paclient.cpp
deleted file mode 100644
index 59a3742..0000000
--- a/homescreen/src/paclient.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2016,2017 Konsulko Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "paclient.h"
-
-#include <QtCore/QDebug>
-
-PaClient::PaClient()
- : m_init(false), m_ml(nullptr), m_mlapi(nullptr), m_ctx(nullptr)
-{
-}
-
-PaClient::~PaClient()
-{
- if (m_init)
- close();
-}
-
-void PaClient::close()
-{
- if (!m_init) return;
- pa_threaded_mainloop_stop(m_ml);
- pa_threaded_mainloop_free(m_ml);
- m_init = false;
-}
-
-static void set_sink_volume_cb(pa_context *c, int success, void *data)
-{
- Q_UNUSED(data);
-
- if (!success)
- qWarning() << "PaClient: set sink volume: " <<
- pa_strerror(pa_context_errno(c));
-}
-
-void PaClient::incDecVolume(const int volume_delta)
-{
- pa_operation *o;
- pa_context *c = context();
- pa_sink_info *i = getDefaultSinkInfo();
-
- if (volume_delta > 0)
- pa_cvolume_inc_clamp(&i->volume, volume_delta, 65536);
- else
- pa_cvolume_dec(&i->volume, abs(volume_delta));
-
- o = pa_context_set_sink_volume_by_index(c, i->index, &i->volume, set_sink_volume_cb, NULL);
- if (!o) {
- qWarning() << "PaClient: set sink #" << i->index <<
- " volume: " << pa_strerror(pa_context_errno(c));
- return;
- }
- pa_operation_unref(o);
-}
-
-void get_sink_info_change_cb(pa_context *c,
- const pa_sink_info *i,
- int eol,
- void *data)
-{
- Q_UNUSED(c);
- Q_ASSERT(i);
- Q_ASSERT(data);
-
- if (eol) return;
-
- PaClient *self = reinterpret_cast<PaClient*>(data);
- pa_sink_info *si = self->getDefaultSinkInfo();
- if (i->index == si->index) {
- self->setDefaultSinkInfo(i);
- pa_cvolume *cvolume = &self->getDefaultSinkInfo()->volume;
- emit self->volumeExternallyChanged(pa_cvolume_avg(cvolume));
- }
-}
-
-void get_default_sink_info_cb(pa_context *c,
- const pa_sink_info *i,
- int eol,
- void *data)
-{
- Q_UNUSED(c);
- Q_ASSERT(i);
- Q_ASSERT(data);
-
- if (eol) return;
-
- PaClient *self = reinterpret_cast<PaClient*>(data);
- self->setDefaultSinkInfo(i);
-}
-
-pa_sink_info *PaClient::getDefaultSinkInfo(void)
-{
- return &m_default_sink_info;
-}
-
-void PaClient::setDefaultSinkInfo(const pa_sink_info *i)
-{
- m_default_sink_info.index = i->index;
- m_default_sink_info.channel_map.channels = i->channel_map.channels;
- pa_cvolume *cvolume = &m_default_sink_info.volume;
- cvolume->channels = i->volume.channels;
- for (int chan = 0; chan < i->channel_map.channels; chan++) {
- cvolume->values[chan] = i->volume.values[chan];
- }
-}
-
-void get_server_info_cb(pa_context *c,
- const pa_server_info *i,
- void *data)
-{
- pa_operation *o;
- o = pa_context_get_sink_info_by_name(c, i->default_sink_name, get_default_sink_info_cb, data);
- if (!o) {
- qWarning() << "PaClient: get sink info by name: " <<
- pa_strerror(pa_context_errno(c));
- return;
- }
-}
-
-void subscribe_cb(pa_context *c,
- pa_subscription_event_type_t type,
- uint32_t index,
- void *data)
-{
- pa_operation *o;
-
- if ((type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) != PA_SUBSCRIPTION_EVENT_CHANGE) {
- qWarning("PaClient: unhandled subscribe event operation");
- return;
- }
-
- switch (type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
- case PA_SUBSCRIPTION_EVENT_SINK:
- o = pa_context_get_sink_info_by_index(c, index, get_sink_info_change_cb, data);
- if (!o) {
- qWarning() << "PaClient: get sink info by index: " <<
- pa_strerror(pa_context_errno(c));
- return;
- }
- break;
- default:
- qWarning("PaClient: unhandled subscribe event facility");
- }
-}
-
-void context_state_cb(pa_context *c, void *data)
-{
- pa_operation *o;
- PaClient *self = reinterpret_cast<PaClient*>(data);
-
- switch (pa_context_get_state(c)) {
- case PA_CONTEXT_CONNECTING:
- case PA_CONTEXT_AUTHORIZING:
- case PA_CONTEXT_SETTING_NAME:
- break;
- case PA_CONTEXT_READY:
- o = pa_context_get_server_info(c, get_server_info_cb, data);
- if (!o) {
- qWarning() << "PaClient: get server info: " <<
- pa_strerror(pa_context_errno(c));
- return;
- }
- pa_operation_unref(o);
- pa_context_set_subscribe_callback(c, subscribe_cb, data);
- o = pa_context_subscribe(c, (pa_subscription_mask_t)(PA_SUBSCRIPTION_MASK_SINK), NULL, NULL);
- if (!o) {
- qWarning() << "PaClient: subscribe: " <<
- pa_strerror(pa_context_errno(c));
- return;
- }
- break;
- case PA_CONTEXT_TERMINATED:
- self->close();
- break;
-
- case PA_CONTEXT_FAILED:
- default:
- qCritical() << "PaClient: connection failed: " <<
- pa_strerror(pa_context_errno(c));
- self->close();
- break;
- }
-}
-
-void PaClient::init()
-{
- m_ml = pa_threaded_mainloop_new();
- if (!m_ml) {
- qCritical("PaClient: failed to create mainloop");
- return;
- }
-
- pa_threaded_mainloop_set_name(m_ml, "PaClient mainloop");
-
- m_mlapi = pa_threaded_mainloop_get_api(m_ml);
-
- lock();
-
- m_ctx = pa_context_new(m_mlapi, "HomeScreen");
- if (!m_ctx) {
- qCritical("PaClient: failed to create context");
- unlock();
- pa_threaded_mainloop_free(m_ml);
- return;
- }
- pa_context_set_state_callback(m_ctx, context_state_cb, this);
-
- if (pa_context_connect(m_ctx, 0, (pa_context_flags_t)0, 0) < 0) {
- qCritical("PaClient: failed to connect");
- pa_context_unref(m_ctx);
- unlock();
- pa_threaded_mainloop_free(m_ml);
- return;
- }
-
- if (pa_threaded_mainloop_start(m_ml) != 0) {
- qCritical("PaClient: failed to start mainloop");
- pa_context_unref(m_ctx);
- unlock();
- pa_threaded_mainloop_free(m_ml);
- return;
- }
-
- unlock();
-
- m_init = true;
-}
diff --git a/homescreen/src/paclient.h b/homescreen/src/paclient.h
deleted file mode 100644
index abf178b..0000000
--- a/homescreen/src/paclient.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2016,2017 Konsulko Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <pulse/pulseaudio.h>
-
-#include <QtCore/QHash>
-#include <QtCore/QObject>
-
-class PaClient : public QObject
-{
- Q_OBJECT
- public:
- PaClient();
- ~PaClient();
-
- void init();
- void close();
-
- inline pa_context *context() const
- {
- return m_ctx;
- }
-
- inline void lock()
- {
- pa_threaded_mainloop_lock(m_ml);
- }
-
- inline void unlock()
- {
- pa_threaded_mainloop_unlock(m_ml);
- }
-
- pa_sink_info * getDefaultSinkInfo(void);
- void setDefaultSinkInfo(const pa_sink_info *i);
- void setMasterVolume(const pa_cvolume *);
-
- public slots:
- void incDecVolume(const int volume_delta);
-
- signals:
- void volumeExternallyChanged(int volume);
-
- private:
- bool m_init;
- pa_threaded_mainloop *m_ml;
- pa_mainloop_api *m_mlapi;
- pa_context *m_ctx;
- pa_cvolume m_master_cvolume;
- pa_sink_info m_default_sink_info;
-};
diff --git a/homescreen/src/popupwidget.cpp b/homescreen/src/popupwidget.cpp
deleted file mode 100644
index 1f062f1..0000000
--- a/homescreen/src/popupwidget.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "popupwidget.h"
-#include "ui_popupwidget.h"
-#include <include/daynightmode.hpp>
-
-PopupWidget::PopupWidget(QWidget *parent) :
- QWidget(parent),
- mp_ui(new Ui::PopupWidget),
- mp_popupAdaptor(0),
- m_sendComboBoxChoice(false)
-{
- // publish dbus popup interface
- mp_popupAdaptor = new PopupAdaptor((QObject*)this);
- QDBusConnection dbus = QDBusConnection::sessionBus();
- dbus.registerObject("/Popup", this);
- dbus.registerService("org.agl.homescreen");
-
- // no window decoration
- setWindowFlags(Qt::FramelessWindowHint);
-
- mp_ui->setupUi(this);
-
- this->close();
-}
-
-PopupWidget::~PopupWidget()
-{
- delete mp_popupAdaptor;
- delete mp_ui;
-}
-
-void PopupWidget::updateColorScheme()
-{
- QSettings settings;
- QSettings settings_cs(QApplication::applicationDirPath() +
- "/colorschemes/" +
- settings.value("systemsettings/colorscheme", "default").toString() +
- "/" +
- QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
- "/" +
- QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
- ".ini",
- QSettings::IniFormat);
-
- mp_ui->widget_popup->setStyleSheet(settings_cs.value(QString("PopupWidget/widget_popup_css")).toString());
- mp_ui->label_text->setStyleSheet(settings_cs.value(QString("PopupWidget/label_text_css")).toString());
-}
-
-void PopupWidget::showPopup(int /*type*/, const QString &text)
-{
- m_sendComboBoxChoice = false;
- mp_ui->comboBox_choice->hide();
- this->show();
- this->raise();
- mp_ui->label_text->setText(text);
-}
-
-void PopupWidget::showPopupComboBox(const QString &text, const QStringList &choices)
-{
- mp_ui->comboBox_choice->clear();
- m_sendComboBoxChoice = true;
- mp_ui->comboBox_choice->addItems(choices);
- mp_ui->comboBox_choice->show();
- this->show();
- this->raise();
- mp_ui->label_text->setText(text);
-}
-
-void PopupWidget::on_pushButton_OK_clicked()
-{
- if (m_sendComboBoxChoice)
- {
- emit comboBoxResult(mp_ui->comboBox_choice->currentText());
- m_sendComboBoxChoice = false;
- }
- this->close();
-}
diff --git a/homescreen/src/popupwidget.h b/homescreen/src/popupwidget.h
deleted file mode 100644
index 7f3aaa8..0000000
--- a/homescreen/src/popupwidget.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef POPUPWIDGET_H
-#define POPUPWIDGET_H
-
-#include <QWidget>
-#include <include/popup.hpp>
-#include "popup_adaptor.h"
-
-namespace Ui {
-class PopupWidget;
-}
-
-class PopupWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit PopupWidget(QWidget *parent = 0);
- ~PopupWidget();
-public slots:
- void updateColorScheme();
-
- // from popup_adaptor.h
-public Q_SLOTS: // METHODS
- void showPopup(int /*type*/, const QString &text);
- void showPopupComboBox(const QString &text, const QStringList &choices);
-
-private slots:
- void on_pushButton_OK_clicked();
-
-signals:
- void comboBoxResult(QString choice);
-
-private:
- Ui::PopupWidget *mp_ui;
-
- PopupAdaptor *mp_popupAdaptor;
- bool m_sendComboBoxChoice;
- // for showPupupFor LayoutSelection
- //QList<QPushButton> m_pushButtons;
-};
-
-#endif // POPUPWIDGET_H
diff --git a/homescreen/src/settingswidget.cpp b/homescreen/src/settingswidget.cpp
deleted file mode 100644
index 1629bf0..0000000
--- a/homescreen/src/settingswidget.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "settingswidget.h"
-#include "ui_settingswidget.h"
-#include <QSettings>
-#include <include/daynightmode.hpp>
-
-SettingsWidget::SettingsWidget(QWidget *parent) :
- QWidget(parent),
- mp_ui(new Ui::SettingsWidget),
- mp_translator(0)
-{
- // no window decoration
- setWindowFlags(Qt::FramelessWindowHint);
-
- // multi-language support
- mp_translator = new QTranslator();
- mp_translator->load("homescreen_en_US.qm", ":/translations"); // TODO: read from system
- QApplication::instance()->installTranslator(mp_translator);
-
- mp_ui->setupUi(this);
-
- mp_ui->comboBox_language->addItem(QString("English"), QVariant("homescreen_en_US.qm")); // TODO: make this configurable
- mp_ui->comboBox_language->addItem(QString("Deutsch"), QVariant("homescreen_de_DE.qm"));
- mp_ui->comboBox_language->addItem(QString("日本語"), QVariant("homescreen_ja_JP.qm"));
-
- mp_ui->comboBox_colorScheme->addItem(QString("Default"), QVariant("default")); // TODO: make this configurable
- mp_ui->comboBox_colorScheme->addItem(QString("Demo 1"), QVariant("demo1"));
- mp_ui->comboBox_colorScheme->addItem(QString("Demo 2"), QVariant("demo2"));
-
- QSettings settings;
- mp_ui->comboBox_language->setCurrentIndex(settings.value("systemsettings/language", 0).toInt());
- mp_ui->comboBox_colorScheme->setCurrentIndex(settings.value("systemsettings/colorschemeindex", 0).toInt());
-}
-
-SettingsWidget::~SettingsWidget()
-{
- delete mp_translator;
- delete mp_ui;
-}
-
-void SettingsWidget::updateColorScheme()
-{
- QSettings settings;
- QSettings settings_cs(QApplication::applicationDirPath() +
- "/colorschemes/" +
- settings.value("systemsettings/colorscheme", "default").toString() +
- "/" +
- QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
- "/" +
- QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
- ".ini",
- QSettings::IniFormat);
-
- mp_ui->widget_background->setStyleSheet(settings_cs.value("SettingsWidget/widget_background_css").toString());
- mp_ui->comboBox_language->setStyleSheet(settings_cs.value("SettingsWidget/comboBox_language_css").toString());
- mp_ui->comboBox_colorScheme->setStyleSheet(settings_cs.value("SettingsWidget/comboBox_colorScheme_css").toString());
- mp_ui->widget_settingsIcon->setStyleSheet(settings_cs.value("SettingsWidget/widget_settingsIcon_css").toString());
-}
-
-void SettingsWidget::changeEvent(QEvent* event)
-{
- if (QEvent::LanguageChange == event->type())
- {
- mp_ui->retranslateUi(this);
- }
-
- QWidget::changeEvent(event);
-}
-
-void SettingsWidget::on_comboBox_language_currentIndexChanged(const QString &)
-{
- if (0 != mp_translator)
- mp_translator->load(mp_ui->comboBox_language->currentData().toString(), ":/translations");
-
- QSettings settings;
- settings.setValue("systemsettings/language", mp_ui->comboBox_language->currentIndex());
-}
-
-void SettingsWidget::on_comboBox_colorScheme_currentIndexChanged(const QString &)
-{
- QSettings settings;
- settings.setValue("systemsettings/colorscheme", mp_ui->comboBox_colorScheme->currentData().toString());
- settings.setValue("systemsettings/colorschemeindex", mp_ui->comboBox_colorScheme->currentIndex());
- // make sure that everything is written to the settings file before continuing
- settings.sync();
-
- emit colorSchemeChanged();
-}
diff --git a/homescreen/src/settingswidget.h b/homescreen/src/settingswidget.h
deleted file mode 100644
index 75bb383..0000000
--- a/homescreen/src/settingswidget.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SETTINGSWIDGET_H
-#define SETTINGSWIDGET_H
-
-#include <QWidget>
-#include <QTranslator>
-
-namespace Ui {
-class SettingsWidget;
-}
-
-class SettingsWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit SettingsWidget(QWidget *parent = 0);
- ~SettingsWidget();
-public slots:
- void updateColorScheme();
-
-protected:
- // called when the translator loaded a new language set
- void changeEvent(QEvent* event);
-
-private slots:
- void on_comboBox_language_currentIndexChanged(const QString &);
- void on_comboBox_colorScheme_currentIndexChanged(const QString &);
-
-signals:
- void colorSchemeChanged(void);
-
-private:
- Ui::SettingsWidget *mp_ui;
- QTranslator *mp_translator;
-};
-
-#endif // SETTINGSWIDGET_H