Add Nav and Media app to control bar.
[staging/HomeScreen.git] / HomeScreen / src / controlbarwidget.cpp
1 /*
2  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "controlbarwidget.h"
18 #include "ui_controlbarwidget.h"
19 #include <include/daynightmode.hpp>
20 #include <include/inputevent.hpp>
21 #include <QSettings>
22
23 ControlBarWidget::ControlBarWidget(QWidget *parent) :
24     QWidget(parent),
25     mp_ui(new Ui::ControlBarWidget),
26     mp_dBusInputEventProxy()
27 {
28     mp_ui->setupUi(this);
29
30     qDebug("D-Bus: connect to org.agl.homescreenappframeworkbindertizen /AppFramework");
31     mp_dBusInputEventProxy = new org::agl::inputevent("org.agl.inputeventmanager",
32                                               "/InputEvent",
33                                               QDBusConnection::sessionBus(),
34                                               0);
35 }
36
37 ControlBarWidget::~ControlBarWidget()
38 {
39     delete mp_dBusInputEventProxy;
40     delete mp_ui;
41 }
42
43 void ControlBarWidget::updateColorScheme()
44 {
45     QSettings settings;
46     QSettings settings_cs(QApplication::applicationDirPath() +
47                           "/colorschemes/" +
48                           settings.value("systemsettings/colorscheme", "default").toString() +
49                           "/" +
50                           QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
51                           "/" +
52                           QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
53                           ".ini",
54                           QSettings::IniFormat);
55
56     QIcon icon;
57     mp_ui->widget_background->setStyleSheet(settings_cs.value(QString("ControlBarWidget/widget_background_css")).toString());
58
59     icon.addFile(settings_cs.value(QString("ControlBarWidget/pushButton_homeIcon_icon")).toString(), QSize(), QIcon::Normal, QIcon::Off);
60     mp_ui->pushButton_home->setIcon(icon);
61     mp_ui->pushButton_home->setStyleSheet(settings_cs.value(QString("ControlBarWidget/pushButton_homeIcon_css")).toString());
62     icon.addFile(settings_cs.value(QString("ControlBarWidget/pushButton_settingsIcon_icon")).toString(), QSize(), QIcon::Normal, QIcon::Off);
63     mp_ui->pushButton_settings->setIcon(icon);
64     mp_ui->pushButton_settings->setStyleSheet(settings_cs.value(QString("ControlBarWidget/pushButton_settingsIcon_css")).toString());
65     icon.addFile(settings_cs.value(QString("ControlBarWidget/pushButton_navIcon_icon")).toString(), QSize(), QIcon::Normal, QIcon::Off);
66     mp_ui->pushButton_nav->setIcon(icon);
67     mp_ui->pushButton_nav->setStyleSheet(settings_cs.value(QString("ControlBarWidget/pushButton_navIcon_css")).toString());
68 }
69
70 void ControlBarWidget::on_pushButton_home_clicked()
71 {
72     hideAppLayer();
73     homeButtonPressed();
74 }
75
76 void ControlBarWidget::on_pushButton_settings_clicked()
77 {
78     hideAppLayer();
79     settingsButtonPressed();
80 }
81
82 void ControlBarWidget::on_pushButton_nav_clicked()
83 {
84     mp_dBusInputEventProxy->hardKeyPressed(InputEvent::HARDKEY_NAV);
85 }
86
87 void ControlBarWidget::on_pushButton_media_clicked()
88 {
89     mp_dBusInputEventProxy->hardKeyPressed(InputEvent::HARDKEY_MEDIA);
90 }