First integration of new HMI design
[staging/HomeScreen.git] / HomeScreen / src / applauncher.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 "applauncher.h"
18 #include <include/daynightmode.hpp>
19 #include <QSettings>
20 #include <QApplication>
21 #ifdef __i386__
22     #include <QProcess>
23 #endif
24
25 AppLauncher::AppLauncher(QObject *parent) :
26     QObject(parent),
27     m_appList(),
28     mp_dBusAppFrameworkProxy()
29 {
30     /*AppInfo ai;
31     for (int i = 0; i < 100; ++i)
32     {
33         ai.setName("test" + QString::number(i));
34         mp_appList->append(ai);
35     }*/
36
37     qDebug("D-Bus: connect to org.agl.homescreenappframeworkbinder /AppFramework");
38     mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbinder",
39                                               "/AppFramework",
40                                               QDBusConnection::sessionBus(),
41                                               0);
42 }
43
44 AppLauncher::~AppLauncher()
45 {
46     delete mp_dBusAppFrameworkProxy;
47 }
48
49 void AppLauncher::updateColorScheme()
50 {
51     QSettings settings;
52     QSettings settings_cs(QApplication::applicationDirPath() +
53                           "/colorschemes/" +
54                           settings.value("systemsettings/colorscheme", "default").toString() +
55                           "/" +
56                           QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
57                           "/" +
58                           QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
59                           ".ini",
60                           QSettings::IniFormat);
61
62     //mp_ui->widget_background->setStyleSheet(settings_cs.value("AppLauncherWidget/widget_Background").toString());
63     //mp_ui->widget_homeIcon->setStyleSheet(settings_cs.value("AppLauncherWidget/widget_Home_Icon").toString());
64
65     //setStyleSheet(settings_cs.value("AppLauncherWidget/common_css").toString());
66 }
67
68 void AppLauncher::populateAppList()
69 {
70     int i;
71
72     m_appList = mp_dBusAppFrameworkProxy->getAvailableApps();
73 }
74
75 void AppLauncher::on_tableView_clicked(int row, int col)
76 {
77 /*    if (m_appList.size() > row * APP_LIST_COLUMN_COUNT + col)
78     {
79         int pid = mp_dBusAppFrameworkProxy->launchApp(m_appList.at(row * APP_LIST_COLUMN_COUNT + col).id());
80         qDebug("%d, %d: start app %s", row, col, m_appList.at(row * APP_LIST_COLUMN_COUNT + col).id().toStdString().c_str());
81         qDebug("pid: %d", pid);
82
83         // the new app wants to be visible by default
84         emit newRequestsToBeVisibleApp(pid);
85
86         emit showAppLayer();
87     }*/
88 }