aboutsummaryrefslogtreecommitdiffstats
path: root/HomeScreen/src
diff options
context:
space:
mode:
authorBocklage, Jens <Jens_Bocklage@mentor.com>2016-06-24 16:19:10 +0200
committerBocklage, Jens <Jens_Bocklage@mentor.com>2016-06-24 16:19:10 +0200
commitca3605ea664834acdf712e691be8f0358b1c6b6f (patch)
tree58b60fe19816136209a4a7302ed6d44e733fcc37 /HomeScreen/src
parentff25a2a06428ffb0d6d8aeddb5faaa301b4201fe (diff)
v0.1.0
06/24/2016 - reworked status bar - reviewed D-Bus interfaces, now using signals instead of methods for day/night mode - created new home screen simulator app - license changed to Apache 2.0 - put D-Bus introspections in one central place - disabled "only one instance allowed" for development
Diffstat (limited to 'HomeScreen/src')
-rw-r--r--HomeScreen/src/controlbarwidget.cpp92
-rw-r--r--HomeScreen/src/controlbarwidget.h56
-rw-r--r--HomeScreen/src/main.cpp54
-rw-r--r--HomeScreen/src/mainwindow.cpp104
-rw-r--r--HomeScreen/src/mainwindow.h63
-rw-r--r--HomeScreen/src/popupwidget.cpp103
-rw-r--r--HomeScreen/src/popupwidget.h58
-rw-r--r--HomeScreen/src/settingswidget.cpp127
-rw-r--r--HomeScreen/src/settingswidget.h58
-rw-r--r--HomeScreen/src/statusbarwidget.cpp205
-rw-r--r--HomeScreen/src/statusbarwidget.h60
11 files changed, 980 insertions, 0 deletions
diff --git a/HomeScreen/src/controlbarwidget.cpp b/HomeScreen/src/controlbarwidget.cpp
new file mode 100644
index 0000000..e01fe26
--- /dev/null
+++ b/HomeScreen/src/controlbarwidget.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2016 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 "controlbarwidget.h"
+#include "ui_controlbarwidget.h"
+
+ControlBarWidget::ControlBarWidget(QWidget *parent) :
+ QWidget(parent),
+ mp_ui(new Ui::ControlBarWidget),
+ mp_settingsWidget(0),
+ m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
+ mp_dayNightModeProxy(0)
+{
+ // this has to be adopted to the system setup
+ mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
+ "/",
+ QDBusConnection::sessionBus(),
+ 0);
+ QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
+
+ mp_ui->setupUi(this);
+}
+
+ControlBarWidget::~ControlBarWidget()
+{
+ delete mp_dayNightModeProxy;
+ if (0 != mp_settingsWidget)
+ {
+ delete mp_settingsWidget;
+ }
+ delete mp_ui;
+}
+
+void ControlBarWidget::dayNightModeSlot(int mode)
+{
+ QIcon icon;
+ switch (mode)
+ {
+ case SystemDayNight::DAYNIGHTMODE_DAY:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
+ mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_green_day.png)"));
+
+ icon.addFile(QStringLiteral(":/icons/home_day.png"), QSize(), QIcon::Normal, QIcon::Off);
+ mp_ui->pushButton_Home->setIcon(icon);
+ icon.addFile(QStringLiteral(":/icons/settings_day.png"), QSize(), QIcon::Normal, QIcon::Off);
+ mp_ui->pushButton_Settings->setIcon(icon);
+ break;
+ case SystemDayNight::DAYNIGHTMODE_NIGHT:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
+ mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_green_night.png)"));
+
+ icon.addFile(QStringLiteral(":/icons/home_night.png"), QSize(), QIcon::Normal, QIcon::Off);
+ mp_ui->pushButton_Home->setIcon(icon);
+ icon.addFile(QStringLiteral(":/icons/settings_night.png"), QSize(), QIcon::Normal, QIcon::Off);
+ mp_ui->pushButton_Settings->setIcon(icon);
+ break;
+ default:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
+ }
+}
+
+void ControlBarWidget::on_pushButton_Settings_clicked()
+{
+ if (0 == mp_settingsWidget)
+ {
+ mp_settingsWidget = new SettingsWidget((QWidget*)parent());
+ }
+
+ mp_settingsWidget->move(0, 60);
+ mp_settingsWidget->show();
+}
+
+void ControlBarWidget::on_pushButton_Home_clicked()
+{
+ if (0 != mp_settingsWidget)
+ {
+ mp_settingsWidget->hide();
+ }
+}
diff --git a/HomeScreen/src/controlbarwidget.h b/HomeScreen/src/controlbarwidget.h
new file mode 100644
index 0000000..618fa35
--- /dev/null
+++ b/HomeScreen/src/controlbarwidget.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 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 CONTROLBARWIDGET_H
+#define CONTROLBARWIDGET_H
+
+#include <QWidget>
+#include "../interfaces/daynightmode.h"
+#include "daynightmode_proxy.h"
+#include "settingswidget.h"
+
+namespace Ui {
+class ControlBarWidget;
+}
+
+class ControlBarWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit ControlBarWidget(QWidget *parent = 0);
+ ~ControlBarWidget();
+
+// day/night mode
+public Q_SLOTS:
+ void dayNightModeSlot(int mode);
+
+private slots:
+ void on_pushButton_Settings_clicked();
+
+ void on_pushButton_Home_clicked();
+
+private:
+ Ui::ControlBarWidget *mp_ui;
+ SettingsWidget *mp_settingsWidget;
+ org::agl::daynightmode *mp_dBusDayNightMode_SettingsWidget;
+
+ // D-Bus day/night
+ SystemDayNight::eDayNightMode m_dayNightMode;
+ org::agl::daynightmode *mp_dayNightModeProxy;
+};
+
+#endif // CONTROLBARWIDGET_H
diff --git a/HomeScreen/src/main.cpp b/HomeScreen/src/main.cpp
new file mode 100644
index 0000000..9108c35
--- /dev/null
+++ b/HomeScreen/src/main.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 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 <QApplication>
+#include <QSysInfo>
+#include <QSharedMemory>
+
+int main(int argc, char *argv[])
+{
+ // allow only one instance of this application
+ /*QSharedMemory appInstance;
+ appInstance.setKey("HomeScreen");
+ if (!appInstance.create(1))
+ {
+ qDebug("Only one instance of the Home Screen App allowed!");
+ exit(-1);
+ }*/
+
+ QApplication a(argc, argv);
+
+ // used for application settings (QSettings)
+ QCoreApplication::setOrganizationDomain("LinuxFoundation");
+ QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
+ QCoreApplication::setApplicationName("HomeScreen");
+ QCoreApplication::setApplicationVersion("0.1.0");
+
+ MainWindow w;
+ w.move(0, 0);
+ w.show();
+
+
+#ifdef __arm__
+ qDebug("Running on ARM architecture");
+#endif
+#ifdef __i386__
+ qDebug("Running on x86 architecture");
+#endif
+
+ return a.exec();
+}
diff --git a/HomeScreen/src/mainwindow.cpp b/HomeScreen/src/mainwindow.cpp
new file mode 100644
index 0000000..e2b55a9
--- /dev/null
+++ b/HomeScreen/src/mainwindow.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2016 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"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ mp_ui(new Ui::MainWindow),
+ mp_statusBarWidget(0),
+ mp_controlBarWidget(0),
+ m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
+ mp_dayNightModeProxy(0),
+ mp_popupWidget(0)
+{
+ // this has to be adopted to the system setup
+ mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
+ "/",
+ QDBusConnection::sessionBus(),
+ 0);
+ QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
+
+ // dbus setup
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+
+ dbus.registerObject("/MainWindow", 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_popupWidget = new PopupWidget(this);
+ mp_controlBarWidget->raise();
+ // apply layout
+ mp_popupWidget->move(0, 0);
+
+ setWindowIcon(QIcon(":/icons/home_day.png"));
+}
+
+MainWindow::~MainWindow()
+{
+ delete mp_popupWidget;
+ delete mp_dayNightModeProxy;
+ delete mp_statusBarWidget;
+ delete mp_ui;
+}
+
+void MainWindow::dayNightModeSlot(int mode)
+{
+ switch (mode)
+ {
+ case SystemDayNight::DAYNIGHTMODE_DAY:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
+ mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_blue_day.png)"));
+ // home icon
+ mp_ui->widget_Home_Icon->setStyleSheet(QString("border-image: url(:/icons/home_day.png) 0 0 0 0 stretch stretch;"));
+
+ break;
+ case SystemDayNight::DAYNIGHTMODE_NIGHT:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
+ mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_blue_night.png)"));
+ // home icon
+ mp_ui->widget_Home_Icon->setStyleSheet(QString("border-image: url(:/icons/home_night.png) 0 0 0 0 stretch stretch;"));
+
+ break;
+ default:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
+ }
+}
+
+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
new file mode 100644
index 0000000..af725fd
--- /dev/null
+++ b/HomeScreen/src/mainwindow.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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 "../interfaces/daynightmode.h"
+#include "daynightmode_proxy.h"
+
+#include "popupwidget.h"
+
+#include "statusbarwidget.h"
+#include "controlbarwidget.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);
+
+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;
+
+ SystemDayNight::eDayNightMode m_dayNightMode;
+ org::agl::daynightmode *mp_dayNightModeProxy;
+
+ PopupWidget *mp_popupWidget;
+};
+
+#endif // MAINWINDOW_H
diff --git a/HomeScreen/src/popupwidget.cpp b/HomeScreen/src/popupwidget.cpp
new file mode 100644
index 0000000..81ffdf7
--- /dev/null
+++ b/HomeScreen/src/popupwidget.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2016 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"
+
+PopupWidget::PopupWidget(QWidget *parent) :
+ QWidget(parent),
+ mp_ui(new Ui::PopupWidget),
+ m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
+ mp_dayNightModeProxy(0),
+ mp_popupAdaptor(0)
+{
+ // this has to be adopted to the system setup
+ mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
+ "/",
+ QDBusConnection::sessionBus(),
+ 0);
+ QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
+
+ // publish dbus popup interface
+ mp_popupAdaptor = new PopupAdaptor((QObject*)this);
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+ dbus.registerObject("/Popup", this);
+ dbus.registerService("org.agl.homescreen");
+
+ mp_ui->setupUi(this);
+ this->close();
+}
+
+PopupWidget::~PopupWidget()
+{
+ delete mp_dayNightModeProxy;
+ delete mp_popupAdaptor;
+ delete mp_ui;
+}
+
+void PopupWidget::dayNightModeSlot(int mode)
+{
+ switch (mode)
+ {
+ case SystemDayNight::DAYNIGHTMODE_DAY:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
+ mp_ui->widget_Popup->setStyleSheet(QString("QWidget { \
+ border: 1px solid #D3D3D3; \
+ border-radius: 8px; \
+ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(242, 242, 249, 255), stop:1 rgba(255, 255, 255, 255)); \
+ color: #333; \
+ padding: 0px; \
+ } \
+ QWidget:on { \
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
+ }"));
+ mp_ui->label_Text->setStyleSheet(QString("background-color: rgba(109, 109, 109, 0); \
+ background-image: url(:/images/transparency.png); \
+ border-image: url(:/images/transparency.png);"));
+ break;
+ case SystemDayNight::DAYNIGHTMODE_NIGHT:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
+ mp_ui->widget_Popup->setStyleSheet(QString("QWidget { \
+ border: 1px solid #D3D3D3; \
+ border-radius: 8px; \
+ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(147, 147, 151, 255), stop:1 rgba(255, 255, 255, 255)); \
+ color: #333; \
+ padding: 0px; \
+ } \
+ QWidget:on { \
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
+ }"));
+ mp_ui->label_Text->setStyleSheet(QString("background-color: rgba(109, 109, 109, 0); \
+ background-image: url(:/images/transparency.png); \
+ border-image: url(:/images/transparency.png);"));
+ break;
+ default:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
+ }
+}
+
+void PopupWidget::showPopup(int type, const QString &text)
+{
+ this->show();
+ this->raise();
+ qDebug("PopupWidget::showPopup: type %d, text %s", type, text.toStdString().c_str());
+ mp_ui->label_Text->setText(text);
+}
+
+void PopupWidget::on_pushButton_OK_clicked()
+{
+ this->close();
+}
diff --git a/HomeScreen/src/popupwidget.h b/HomeScreen/src/popupwidget.h
new file mode 100644
index 0000000..a876576
--- /dev/null
+++ b/HomeScreen/src/popupwidget.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2016 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 "../interfaces/popup.h"
+#include "popup_adapter.h"
+#include "../interfaces/daynightmode.h"
+#include "daynightmode_proxy.h"
+
+
+namespace Ui {
+class PopupWidget;
+}
+
+class PopupWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit PopupWidget(QWidget *parent = 0);
+ ~PopupWidget();
+
+// day/night mode
+public Q_SLOTS:
+ void dayNightModeSlot(int mode);
+
+ // from popup_adapter.h
+public Q_SLOTS: // METHODS
+ void showPopup(int type, const QString &text);
+
+private slots:
+ void on_pushButton_OK_clicked();
+
+private:
+ Ui::PopupWidget *mp_ui;
+
+ SystemDayNight::eDayNightMode m_dayNightMode;
+ org::agl::daynightmode *mp_dayNightModeProxy;
+ PopupAdaptor *mp_popupAdaptor;
+};
+
+#endif // POPUPWIDGET_H
diff --git a/HomeScreen/src/settingswidget.cpp b/HomeScreen/src/settingswidget.cpp
new file mode 100644
index 0000000..039b99f
--- /dev/null
+++ b/HomeScreen/src/settingswidget.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2016 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>
+
+SettingsWidget::SettingsWidget(QWidget *parent) :
+ QWidget(parent),
+ mp_ui(new Ui::SettingsWidget),
+ m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
+ mp_dayNightModeProxy(0),
+ mp_translator(0)
+{
+ // this has to be adopted to the system setup
+ mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
+ "/",
+ QDBusConnection::sessionBus(),
+ 0);
+ QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
+
+ // 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->comboBoxLanguage->addItem(QString("English"), QVariant("homescreen_en_US.qm")); // TODO: make this configurable?
+ mp_ui->comboBoxLanguage->addItem(QString("Deutsch"), QVariant("homescreen_de_DE.qm"));
+ mp_ui->comboBoxLanguage->addItem(QString("日本語"), QVariant("homescreen_ja_JP.qm"));
+
+ QSettings settings;
+ mp_ui->comboBoxLanguage->setCurrentIndex(settings.value("systemsettings/language", 0).toInt());
+}
+
+SettingsWidget::~SettingsWidget()
+{
+ delete mp_translator;
+ delete mp_dayNightModeProxy;
+
+ QSettings settings;
+ settings.setValue("systemsettings/language", mp_ui->comboBoxLanguage->currentIndex());
+ delete mp_ui;
+}
+
+void SettingsWidget::dayNightModeSlot(int mode)
+{
+ switch (mode)
+ {
+ case SystemDayNight::DAYNIGHTMODE_DAY:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
+ mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_blue_day.png);"));
+ mp_ui->comboBoxLanguage->setStyleSheet(QString("QComboBox { \
+ border: 1px solid #D3D3D3; \
+ border-radius: 8px; \
+ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(242, 242, 249, 255), stop:1 rgba(255, 255, 255, 255)); \
+ color: #333; \
+ padding: 0px; \
+ } \
+ QComboBox:on { \
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
+ } \
+ QComboBox::drop-down { \
+ border: 0px solid; \
+ border-radius: 0px; \
+ } \
+ QComboBox::down-arrow:on { \
+ }"));
+ // settings icon
+ mp_ui->widget_Settings_Icon->setStyleSheet(QString("border-image: url(:/icons/settings_day.png) 0 0 0 0 stretch stretch;"));
+ break;
+ case SystemDayNight::DAYNIGHTMODE_NIGHT:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
+ mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_blue_night.png);"));
+ mp_ui->comboBoxLanguage->setStyleSheet(QString("QComboBox { \
+ border: 1px solid #D3D3D3; \
+ border-radius: 8px; \
+ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(147, 147, 151, 255), stop:1 rgba(255, 255, 255, 255)); \
+ color: #333; \
+ padding: 0px; \
+ } \
+ QComboBox:on { \
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
+ } \
+ QComboBox::drop-down { \
+ border: 0px solid; \
+ border-radius: 0px; \
+ } \
+ QComboBox::down-arrow:on { \
+ }"));
+ // settings icon
+ mp_ui->widget_Settings_Icon->setStyleSheet(QString("border-image: url(:/icons/settings_night.png) 0 0 0 0 stretch stretch;"));
+ break;
+ default:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
+ }
+}
+
+void SettingsWidget::changeEvent(QEvent* event)
+{
+ if (QEvent::LanguageChange == event->type())
+ {
+ mp_ui->retranslateUi(this);
+ }
+
+ QWidget::changeEvent(event);
+}
+
+void SettingsWidget::on_comboBoxLanguage_currentIndexChanged(const QString &)
+{
+ if (0 != mp_translator)
+ mp_translator->load(mp_ui->comboBoxLanguage->currentData().toString(), ":/translations");
+}
diff --git a/HomeScreen/src/settingswidget.h b/HomeScreen/src/settingswidget.h
new file mode 100644
index 0000000..15b24bd
--- /dev/null
+++ b/HomeScreen/src/settingswidget.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2016 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>
+#include "../interfaces/daynightmode.h"
+#include "daynightmode_proxy.h"
+
+
+namespace Ui {
+class SettingsWidget;
+}
+
+class SettingsWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit SettingsWidget(QWidget *parent = 0);
+ ~SettingsWidget();
+
+// day/night mode
+public Q_SLOTS:
+ void dayNightModeSlot(int mode);
+
+protected:
+ // called when the translator loaded a new language set
+ void changeEvent(QEvent* event);
+
+private slots:
+ void on_comboBoxLanguage_currentIndexChanged(const QString &);
+
+private:
+ Ui::SettingsWidget *mp_ui;
+
+ SystemDayNight::eDayNightMode m_dayNightMode;
+ org::agl::daynightmode *mp_dayNightModeProxy;
+
+ QTranslator *mp_translator;
+};
+
+#endif // SETTINGSWIDGET_H
diff --git a/HomeScreen/src/statusbarwidget.cpp b/HomeScreen/src/statusbarwidget.cpp
new file mode 100644
index 0000000..af144c5
--- /dev/null
+++ b/HomeScreen/src/statusbarwidget.cpp
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2016 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 "statusbarwidget.h"
+#include "ui_statusbarwidget.h"
+
+StatusBarWidget::StatusBarWidget(QWidget *parent) :
+ QWidget(parent),
+ mp_ui(new Ui::StatusBarWidget),
+ m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
+ mp_dayNightModeProxy(0),
+ mp_statusbarAdaptor(0),
+ mp_statusbarIconURIs(new QMap<int, QString>)
+{
+ // this has to be adopted to the system setup
+ mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
+ "/",
+ QDBusConnection::sessionBus(),
+ 0);
+ QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
+
+ // publish statusbar interface
+ mp_statusbarAdaptor = new StatusbarAdaptor((QObject*)this);
+
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+ dbus.registerObject("/StatusBar", this);
+ dbus.registerService("org.agl.homescreen");
+
+ mp_ui->setupUi(this);
+}
+
+StatusBarWidget::~StatusBarWidget()
+{
+ delete mp_statusbarAdaptor;
+ delete mp_dayNightModeProxy;
+ delete mp_ui;
+}
+
+void StatusBarWidget::dayNightModeSlot(int mode)
+{
+ switch (mode)
+ {
+ case SystemDayNight::DAYNIGHTMODE_DAY:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
+ mp_ui->widget->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_stripes_day.png)"));
+ mp_ui->label_1->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(1) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_2->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(2) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_3->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(3) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_4->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(4) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_5->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(5) + QString("); background-repeat: no-repeat;"));
+ break;
+ case SystemDayNight::DAYNIGHTMODE_NIGHT:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
+ mp_ui->widget->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_stripes_night.png)"));
+ mp_ui->label_1->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(1) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_2->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(2) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_3->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(3) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_4->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(4) + QString("); background-repeat: no-repeat;"));
+ mp_ui->label_5->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(5) + QString("); background-repeat: no-repeat;"));
+ break;
+ default:
+ m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
+ }
+}
+
+QList<int> StatusBarWidget::getAvailablePlaceholders()
+{
+ QList<int> result;
+
+ // for now, all are available
+ result.append(1);
+ result.append(2);
+ result.append(3);
+ result.append(4);
+ result.append(5);
+
+ return result;
+}
+
+QString StatusBarWidget::getStatusIcon(int placeholderIndex)
+{
+ return mp_statusbarIconURIs->value(placeholderIndex);
+}
+
+QString StatusBarWidget::getStatusText(int placeholderIndex)
+{
+ QString result = "";
+
+ switch (placeholderIndex)
+ {
+ case 1:
+ result = mp_ui->label_1->text();
+ break;
+ case 2:
+ result = mp_ui->label_2->text();
+ break;
+ case 3:
+ result = mp_ui->label_3->text();
+ break;
+ case 4:
+ result = mp_ui->label_4->text();
+ break;
+ case 5:
+ result = mp_ui->label_5->text();
+ break;
+ default:
+ break;
+ }
+
+ return result;
+}
+
+void StatusBarWidget::setStatusIcon(int placeholderIndex, const QString &iconURI)
+{
+ mp_statusbarIconURIs->insert(placeholderIndex, iconURI);
+
+ switch (m_dayNightMode)
+ {
+ case SystemDayNight::DAYNIGHTMODE_DAY:
+ switch (placeholderIndex)
+ {
+ case 1:
+ mp_ui->label_1->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 2:
+ mp_ui->label_2->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 3:
+ mp_ui->label_3->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 4:
+ mp_ui->label_4->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 5:
+ mp_ui->label_5->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ default:
+ break;
+ }
+ break;
+ case SystemDayNight::DAYNIGHTMODE_NIGHT:
+ switch (placeholderIndex)
+ {
+ case 1:
+ mp_ui->label_1->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 2:
+ mp_ui->label_2->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 3:
+ mp_ui->label_3->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 4:
+ mp_ui->label_4->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ case 5:
+ mp_ui->label_5->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void StatusBarWidget::setStatusText(int placeholderIndex, const QString &text)
+{
+ switch (placeholderIndex)
+ {
+ case 1:
+ mp_ui->label_1->setText(text);
+ break;
+ case 2:
+ mp_ui->label_2->setText(text);
+ break;
+ case 3:
+ mp_ui->label_3->setText(text);
+ break;
+ case 4:
+ mp_ui->label_4->setText(text);
+ break;
+ case 5:
+ mp_ui->label_5->setText(text);
+ break;
+ default:
+ break;
+ }
+}
+
+
diff --git a/HomeScreen/src/statusbarwidget.h b/HomeScreen/src/statusbarwidget.h
new file mode 100644
index 0000000..e17f13e
--- /dev/null
+++ b/HomeScreen/src/statusbarwidget.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 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 STATUSBARWIDGET_H
+#define STATUSBARWIDGET_H
+
+#include <QWidget>
+#include "../interfaces/daynightmode.h"
+#include "daynightmode_proxy.h"
+
+#include "statusbar_adapter.h"
+
+namespace Ui {
+class StatusBarWidget;
+}
+
+class StatusBarWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit StatusBarWidget(QWidget *parent = 0);
+ ~StatusBarWidget();
+
+// day/night mode
+public Q_SLOTS:
+ void dayNightModeSlot(int mode);
+
+// from statusbar_adapter.h
+public Q_SLOTS: // METHODS
+ QList<int> getAvailablePlaceholders();
+ QString getStatusIcon(int placeholderIndex);
+ QString getStatusText(int placeholderIndex);
+ void setStatusIcon(int placeholderIndex, const QString &iconURI);
+ void setStatusText(int placeholderIndex, const QString &text);
+
+private:
+ Ui::StatusBarWidget *mp_ui;
+
+ SystemDayNight::eDayNightMode m_dayNightMode;
+ org::agl::daynightmode *mp_dayNightModeProxy;
+ StatusbarAdaptor *mp_statusbarAdaptor;
+
+ QMap<int, QString> *mp_statusbarIconURIs;
+};
+
+#endif // STATUSBARWIDGET_H