diff options
Diffstat (limited to 'HomeScreen/src')
-rw-r--r-- | HomeScreen/src/applauncherwidget.cpp | 153 | ||||
-rw-r--r-- | HomeScreen/src/applauncherwidget.h | 51 | ||||
-rw-r--r-- | HomeScreen/src/controlbarwidget.cpp | 20 | ||||
-rw-r--r-- | HomeScreen/src/controlbarwidget.h | 3 | ||||
-rw-r--r-- | HomeScreen/src/homescreencontrolinterface.cpp | 42 | ||||
-rw-r--r-- | HomeScreen/src/homescreencontrolinterface.h | 30 | ||||
-rw-r--r-- | HomeScreen/src/main.cpp | 10 | ||||
-rw-r--r-- | HomeScreen/src/mainwindow.cpp | 44 | ||||
-rw-r--r-- | HomeScreen/src/mainwindow.h | 12 | ||||
-rw-r--r-- | HomeScreen/src/popupwidget.cpp | 6 | ||||
-rw-r--r-- | HomeScreen/src/popupwidget.h | 4 | ||||
-rw-r--r-- | HomeScreen/src/settingswidget.cpp | 2 | ||||
-rw-r--r-- | HomeScreen/src/statusbarwidget.cpp | 2 |
13 files changed, 360 insertions, 19 deletions
diff --git a/HomeScreen/src/applauncherwidget.cpp b/HomeScreen/src/applauncherwidget.cpp new file mode 100644 index 0000000..94dd357 --- /dev/null +++ b/HomeScreen/src/applauncherwidget.cpp @@ -0,0 +1,153 @@ +/* + * 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 "applauncherwidget.h" +#include "ui_applauncherwidget.h" +#include <include/daynightmode.hpp> +#include <QSettings> + +#define APP_LIST_COLUMN_COUNT 5 + +AppLauncherWidget::AppLauncherWidget(QWidget *parent) : + QWidget(parent), + mp_ui(new Ui::AppLauncherWidget), + mp_appList(new QList<AppInfo>()), + mp_appTable(0), + mp_dBusAppFrameworkProxy() +{ + mp_ui->setupUi(this); + + AppInfo ai; + for (int i = 0; i < 100; ++i) + { + ai.setName("test" + QString::number(i)); + mp_appList->append(ai); + } + + qDebug("D-Bus: connect to org.agl.homescreenappframeworkbindertizen /AppFramework"); + mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbindertizen", + "/AppFramework", + QDBusConnection::sessionBus(), + 0); + + populateAppList(); +} + +AppLauncherWidget::~AppLauncherWidget() +{ + delete mp_dBusAppFrameworkProxy; + if (0 != mp_appTable) + { + delete mp_appTable; + } + delete mp_appList; + delete mp_ui; +} + +void AppLauncherWidget::updateColorScheme() +{ + QSettings settings; + QSettings settings_cs(QApplication::applicationDirPath() + + "/colorschemes/" + + settings.value("systemsettings/colorscheme", "default").toString() + + "/" + + QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) + + ".ini", + QSettings::IniFormat); + + mp_ui->widget_Background->setStyleSheet(settings_cs.value("AppLauncherWidget/widget_Background").toString()); + mp_ui->widget_Home_Icon->setStyleSheet(settings_cs.value("AppLauncherWidget/widget_Home_Icon").toString()); +} + +void AppLauncherWidget::populateAppList() +{ + setStyleSheet("QTableWidget {background-color: transparent;}" + "QTableCornerButton::section {background-color: transparent;}"); + + if (0 == mp_appTable) + { + mp_appTable = new QTableWidget(this); + QObject::connect(mp_appTable, SIGNAL(cellClicked(int, int)), this, SLOT(on_tableView_clicked(int, int))); + } + else + { + mp_appTable->clear(); + } + + mp_appTable->setShowGrid(false); + mp_appTable->setFrameShape(QFrame::NoFrame); + mp_appTable->move(40, 40); + mp_appTable->resize(1000, 1920 - 40 - 40 - 60 - 60); + mp_appTable->horizontalHeader()->setVisible(false); + mp_appTable->verticalHeader()->setVisible(false); + mp_appTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mp_appTable->setRowCount(100); + mp_appTable->setColumnCount(APP_LIST_COLUMN_COUNT); + + int i; + + QStringList apps = mp_dBusAppFrameworkProxy->getAvailableAppNames(); + mp_appList->clear(); + + mp_appTable->setRowCount((apps.size() + (APP_LIST_COLUMN_COUNT - 1)) / APP_LIST_COLUMN_COUNT); + + if (apps.size() >= (9 * APP_LIST_COLUMN_COUNT)) + { + mp_appTable->resize(1000, 1920 - 40 - 40 - 60 - 60); + } + else + { + mp_appTable->resize(1000, mp_appTable->rowCount() * 190); + } + + + for (i = 0; i < (mp_appTable->rowCount() * APP_LIST_COLUMN_COUNT); i++) + { + mp_appTable->verticalHeader()->resizeSection(i, 190); + mp_appTable->horizontalHeader()->resizeSection(i, 190); + } + + AppInfo ai; + for (i = 0; i < apps.size(); ++i) + { + qDebug("new app: %s", apps.at(i).toStdString().c_str()); + ai.setName(apps.at(i)); + mp_appList->append(ai); + } + + for (i = 0; i < mp_appList->size(); i++) + { + mp_appTable->setItem(i / APP_LIST_COLUMN_COUNT, + i % APP_LIST_COLUMN_COUNT, + new QTableWidgetItem(mp_appList->at(i).getName())); + mp_appTable->item(i / APP_LIST_COLUMN_COUNT, + i % APP_LIST_COLUMN_COUNT)->setFlags(Qt::ItemIsEnabled); + mp_appTable->item(i / APP_LIST_COLUMN_COUNT, + i % APP_LIST_COLUMN_COUNT)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + } + + +} + +void AppLauncherWidget::on_tableView_clicked(int row, int col) +{ + if (mp_appList->size() > row * APP_LIST_COLUMN_COUNT + col) + { + int pid = mp_dBusAppFrameworkProxy->launchApp(mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName()); + qDebug("%d, %d: start app %s", row, col, mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName().toStdString().c_str()); + qDebug("pid: %d", pid); + } +} diff --git a/HomeScreen/src/applauncherwidget.h b/HomeScreen/src/applauncherwidget.h new file mode 100644 index 0000000..943f6d5 --- /dev/null +++ b/HomeScreen/src/applauncherwidget.h @@ -0,0 +1,51 @@ +/* + * 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 APPLAUNCHERWIDGET_H +#define APPLAUNCHERWIDGET_H + +#include <QWidget> +#include <QList> +#include <QTableWidget> +#include <include/appframework.hpp> +#include <appframework_proxy.h> + +namespace Ui { +class AppLauncherWidget; +} + +class AppLauncherWidget : public QWidget +{ + Q_OBJECT + +public: + explicit AppLauncherWidget(QWidget *parent = 0); + ~AppLauncherWidget(); +public slots: + void updateColorScheme(); + +private slots: + void on_tableView_clicked(int row, int col); + +private: + Ui::AppLauncherWidget *mp_ui; + QList<AppInfo> *mp_appList; + QTableWidget *mp_appTable; + org::agl::appframework *mp_dBusAppFrameworkProxy; + void populateAppList(); +}; + +#endif // APPLAUNCHERWIDGET_H diff --git a/HomeScreen/src/controlbarwidget.cpp b/HomeScreen/src/controlbarwidget.cpp index dee0207..2cce30b 100644 --- a/HomeScreen/src/controlbarwidget.cpp +++ b/HomeScreen/src/controlbarwidget.cpp @@ -16,18 +16,27 @@ #include "controlbarwidget.h" #include "ui_controlbarwidget.h" -#include "../interfaces/daynightmode.h" +#include <include/daynightmode.hpp> +#include <include/inputevent.hpp> #include <QSettings> ControlBarWidget::ControlBarWidget(QWidget *parent) : QWidget(parent), - mp_ui(new Ui::ControlBarWidget) + mp_ui(new Ui::ControlBarWidget), + mp_dBusInputEventProxy() { mp_ui->setupUi(this); + + qDebug("D-Bus: connect to org.agl.homescreenappframeworkbindertizen /AppFramework"); + mp_dBusInputEventProxy = new org::agl::inputevent("org.agl.inputeventmanager", + "/InputEvent", + QDBusConnection::sessionBus(), + 0); } ControlBarWidget::~ControlBarWidget() { + delete mp_dBusInputEventProxy; delete mp_ui; } @@ -49,6 +58,8 @@ void ControlBarWidget::updateColorScheme() mp_ui->pushButton_Home->setIcon(icon); icon.addFile(settings_cs.value(QString("ControlBarWidget/pushButton_Settings")).toString(), QSize(), QIcon::Normal, QIcon::Off); mp_ui->pushButton_Settings->setIcon(icon); + icon.addFile(settings_cs.value(QString("ControlBarWidget/pushButton_Nav")).toString(), QSize(), QIcon::Normal, QIcon::Off); + mp_ui->pushButton_Nav->setIcon(icon); } void ControlBarWidget::on_pushButton_Settings_clicked() @@ -60,3 +71,8 @@ void ControlBarWidget::on_pushButton_Home_clicked() { emit homeButtonPressed(); } + +void ControlBarWidget::on_pushButton_Nav_clicked() +{ + mp_dBusInputEventProxy->hardKeyPressed(InputEvent::HARDKEY_NAV); +} diff --git a/HomeScreen/src/controlbarwidget.h b/HomeScreen/src/controlbarwidget.h index 0ab382b..89e505c 100644 --- a/HomeScreen/src/controlbarwidget.h +++ b/HomeScreen/src/controlbarwidget.h @@ -18,6 +18,7 @@ #define CONTROLBARWIDGET_H #include <QWidget> +#include "inputevent_proxy.h" namespace Ui { class ControlBarWidget; @@ -39,9 +40,11 @@ signals: private slots: void on_pushButton_Settings_clicked(); void on_pushButton_Home_clicked(); + void on_pushButton_Nav_clicked(); private: Ui::ControlBarWidget *mp_ui; + org::agl::inputevent *mp_dBusInputEventProxy; }; #endif // CONTROLBARWIDGET_H diff --git a/HomeScreen/src/homescreencontrolinterface.cpp b/HomeScreen/src/homescreencontrolinterface.cpp new file mode 100644 index 0000000..defc202 --- /dev/null +++ b/HomeScreen/src/homescreencontrolinterface.cpp @@ -0,0 +1,42 @@ +#include "homescreencontrolinterface.h" + +HomeScreenControlInterface::HomeScreenControlInterface(QObject *parent) : + QObject(parent), + mp_homeScreenAdaptor(0), + mp_dBusAppFrameworkProxy() +{ + // publish dbus homescreen interface + mp_homeScreenAdaptor = new HomescreenAdaptor((QObject*)this); + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerObject("/HomeScreen", this); + dbus.registerService("org.agl.homescreen"); + + qDebug("D-Bus: connect to org.agl.homescreenappframeworkbindertizen /AppFramework"); + mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbindertizen", + "/AppFramework", + QDBusConnection::sessionBus(), + 0); +} + +HomeScreenControlInterface::~HomeScreenControlInterface() +{ + delete mp_dBusAppFrameworkProxy; + delete mp_homeScreenAdaptor; +} + +void HomeScreenControlInterface::hardKeyPressed(int key) +{ + int pid = -1; + + switch (key) + { + case InputEvent::HARDKEY_NAV: + qDebug("hardKeyPressed NAV key pressed!"); + pid = mp_dBusAppFrameworkProxy->launchApp("demoapp"); + qDebug("pid: %d", pid); + break; + default: + qDebug("hardKeyPressed %d", key); + break; + } +} diff --git a/HomeScreen/src/homescreencontrolinterface.h b/HomeScreen/src/homescreencontrolinterface.h new file mode 100644 index 0000000..3480d30 --- /dev/null +++ b/HomeScreen/src/homescreencontrolinterface.h @@ -0,0 +1,30 @@ +#ifndef HOMESCREENCONTROLINTERFACE_H +#define HOMESCREENCONTROLINTERFACE_H + +#include <QObject> +#include "include/homescreen.hpp" +#include "homescreen_adapter.h" +#include <include/appframework.hpp> +#include <appframework_proxy.h> + +class HomeScreenControlInterface : public QObject +{ + Q_OBJECT +public: + explicit HomeScreenControlInterface(QObject *parent = 0); + ~HomeScreenControlInterface(); + +signals: + +public slots: + +//from homescreen_adapter.h +public Q_SLOTS: // METHODS + void hardKeyPressed(int key); + +private: + HomescreenAdaptor *mp_homeScreenAdaptor; + org::agl::appframework *mp_dBusAppFrameworkProxy; +}; + +#endif // HOMESCREENCONTROLINTERFACE_H diff --git a/HomeScreen/src/main.cpp b/HomeScreen/src/main.cpp index be8b534..cc552f2 100644 --- a/HomeScreen/src/main.cpp +++ b/HomeScreen/src/main.cpp @@ -36,12 +36,16 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("HomeScreen"); - QCoreApplication::setApplicationVersion("0.1.1"); + QCoreApplication::setApplicationVersion("0.2.0"); - // maybe trigger the wayland compositor to position the surface correctly MainWindow w; - w.move(0, 0); w.show(); +#ifdef __arm__ + // trigger wayland compositor to position the surface correctly +#endif +#ifdef __i386__ + w.move(0, 0); +#endif #ifdef __arm__ diff --git a/HomeScreen/src/mainwindow.cpp b/HomeScreen/src/mainwindow.cpp index bf7735c..174f750 100644 --- a/HomeScreen/src/mainwindow.cpp +++ b/HomeScreen/src/mainwindow.cpp @@ -16,7 +16,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "../interfaces/daynightmode.h" +#include <include/daynightmode.hpp> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -24,15 +24,17 @@ MainWindow::MainWindow(QWidget *parent) : mp_statusBarWidget(0), mp_controlBarWidget(0), mp_settingsWidget(0), + mp_applauncherwidget(0), mp_popupWidget(0), - mp_dayNightModeProxy(0) + mp_dBusDayNightModeProxy(0), + mp_homeScreenControlInterface(0) { // this has to be adopted to the system setup - mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider" + mp_dBusDayNightModeProxy = 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))); + QObject::connect(mp_dBusDayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int))); // dbus setup QDBusConnection dbus = QDBusConnection::sessionBus(); @@ -42,6 +44,7 @@ MainWindow::MainWindow(QWidget *parent) : // no window decoration setWindowFlags(Qt::FramelessWindowHint); + mp_ui->setupUi(this); mp_statusBarWidget = new StatusBarWidget(this); @@ -58,36 +61,49 @@ MainWindow::MainWindow(QWidget *parent) : mp_settingsWidget->raise(); // apply layout mp_settingsWidget->move(0, 60); - mp_settingsWidget->hide(); + //mp_settingsWidget->hide(); + + mp_applauncherwidget = new AppLauncherWidget(this); + mp_applauncherwidget->raise(); + // apply layout + mp_applauncherwidget->move(0, 60); - mp_popupWidget = new PopupWidget(this); + 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(show())); - QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_settingsWidget, SLOT(hide())); + QObject::connect(mp_controlBarWidget, SIGNAL(settingsButtonPressed()), mp_settingsWidget, SLOT(raise())); + QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_applauncherwidget, SLOT(raise())); // apply color scheme updateColorScheme(); mp_statusBarWidget->updateColorScheme(); mp_controlBarWidget->updateColorScheme(); mp_settingsWidget->updateColorScheme(); + mp_applauncherwidget->updateColorScheme(); mp_popupWidget->updateColorScheme(); + // this is only useful during development and will be removed later setWindowIcon(QIcon(":/icons/home_day.png")); + + mp_homeScreenControlInterface = new HomeScreenControlInterface(this); } MainWindow::~MainWindow() { - delete mp_dayNightModeProxy; + delete mp_homeScreenControlInterface; + + delete mp_dBusDayNightModeProxy; delete mp_popupWidget; + delete mp_applauncherwidget; delete mp_settingsWidget; delete mp_controlBarWidget; delete mp_statusBarWidget; @@ -106,6 +122,7 @@ void MainWindow::dayNightModeSlot(int mode) mp_statusBarWidget->updateColorScheme(); mp_controlBarWidget->updateColorScheme(); mp_settingsWidget->updateColorScheme(); + mp_applauncherwidget->updateColorScheme(); mp_popupWidget->updateColorScheme(); } @@ -133,3 +150,12 @@ void MainWindow::changeEvent(QEvent* event) QMainWindow::changeEvent(event); } + +void MainWindow::on_pushButton_clicked() +{ + // start app + QProcess process; + QString file = "vlc"; + process.startDetached(file); + // manage ivi shell +} diff --git a/HomeScreen/src/mainwindow.h b/HomeScreen/src/mainwindow.h index d984c3e..cb2243e 100644 --- a/HomeScreen/src/mainwindow.h +++ b/HomeScreen/src/mainwindow.h @@ -20,9 +20,12 @@ #include <QMainWindow> #include "daynightmode_proxy.h" +#include "homescreencontrolinterface.h" + #include "statusbarwidget.h" #include "controlbarwidget.h" #include "settingswidget.h" +#include "applauncherwidget.h" #include "popupwidget.h" @@ -42,6 +45,7 @@ public: public Q_SLOTS: void dayNightModeSlot(int mode); + public slots: void updateColorScheme(); @@ -49,6 +53,9 @@ protected: // called when the translator loaded a new language set void changeEvent(QEvent* event); +private slots: + void on_pushButton_clicked(); + private: Ui::MainWindow *mp_ui; @@ -57,9 +64,12 @@ private: ControlBarWidget *mp_controlBarWidget; org::agl::daynightmode *mp_dBusDayNightMode_ControlBarWidget; SettingsWidget *mp_settingsWidget; + AppLauncherWidget *mp_applauncherwidget; PopupWidget *mp_popupWidget; - org::agl::daynightmode *mp_dayNightModeProxy; + org::agl::daynightmode *mp_dBusDayNightModeProxy; + + HomeScreenControlInterface *mp_homeScreenControlInterface; }; #endif // MAINWINDOW_H diff --git a/HomeScreen/src/popupwidget.cpp b/HomeScreen/src/popupwidget.cpp index 4a89771..0a27dff 100644 --- a/HomeScreen/src/popupwidget.cpp +++ b/HomeScreen/src/popupwidget.cpp @@ -16,7 +16,7 @@ #include "popupwidget.h" #include "ui_popupwidget.h" -#include "../interfaces/daynightmode.h" +#include <include/daynightmode.hpp> PopupWidget::PopupWidget(QWidget *parent) : QWidget(parent), @@ -29,7 +29,11 @@ PopupWidget::PopupWidget(QWidget *parent) : dbus.registerObject("/Popup", this); dbus.registerService("org.agl.homescreen"); + // no window decoration + setWindowFlags(Qt::FramelessWindowHint); + mp_ui->setupUi(this); + this->close(); } diff --git a/HomeScreen/src/popupwidget.h b/HomeScreen/src/popupwidget.h index a54a602..7a73b92 100644 --- a/HomeScreen/src/popupwidget.h +++ b/HomeScreen/src/popupwidget.h @@ -18,7 +18,7 @@ #define POPUPWIDGET_H #include <QWidget> -#include "../interfaces/popup.h" +#include <include/popup.hpp> #include "popup_adapter.h" namespace Ui { @@ -46,6 +46,8 @@ private: Ui::PopupWidget *mp_ui; PopupAdaptor *mp_popupAdaptor; + // for showPupupFor LayoutSelection + //QList<QPushButton> m_pushButtons; }; #endif // POPUPWIDGET_H diff --git a/HomeScreen/src/settingswidget.cpp b/HomeScreen/src/settingswidget.cpp index 9c6f190..9df4a1c 100644 --- a/HomeScreen/src/settingswidget.cpp +++ b/HomeScreen/src/settingswidget.cpp @@ -17,7 +17,7 @@ #include "settingswidget.h" #include "ui_settingswidget.h" #include <QSettings> -#include "../interfaces/daynightmode.h" +#include <include/daynightmode.hpp> SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent), diff --git a/HomeScreen/src/statusbarwidget.cpp b/HomeScreen/src/statusbarwidget.cpp index 442c3e7..5628172 100644 --- a/HomeScreen/src/statusbarwidget.cpp +++ b/HomeScreen/src/statusbarwidget.cpp @@ -16,7 +16,7 @@ #include "statusbarwidget.h" #include "ui_statusbarwidget.h" -#include "../interfaces/daynightmode.h" +#include <include/daynightmode.hpp> StatusBarWidget::StatusBarWidget(QWidget *parent) : QWidget(parent), |