2 * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "mainwindow.h"
18 #include "ui_mainwindow.h"
19 #include <include/daynightmode.hpp>
21 MainWindow::MainWindow(QWidget *parent) :
23 mp_ui(new Ui::MainWindow),
24 mp_statusBarWidget(0),
25 mp_controlBarWidget(0),
27 //mp_applauncherwidget(0),
29 mp_layoutHandler(new LayoutHandler()),
30 mp_dBusDayNightModeProxy(0),
31 mp_proximityAdaptor(0),
32 mp_homeScreenControlInterface(0)
34 // this has to be adopted to the system setup
35 mp_dBusDayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
37 QDBusConnection::sessionBus(),
39 QObject::connect(mp_dBusDayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
41 mp_proximityAdaptor = new ProximityAdaptor((QObject*)this);
44 QDBusConnection dbus = QDBusConnection::sessionBus();
45 dbus.registerObject("/Proximity", this);
46 dbus.registerService("org.agl.homescreen");
48 // no window decoration
49 setWindowFlags(Qt::FramelessWindowHint);
53 mp_statusBarWidget = new StatusBarWidget(this);
54 mp_statusBarWidget->raise();
56 mp_statusBarWidget->move(0, 0);
58 mp_controlBarWidget = new ControlBarWidget(this);
59 mp_controlBarWidget->raise();
61 mp_controlBarWidget->move(0, 1920-60);
63 mp_settingsWidget = new SettingsWidget(this);
64 mp_settingsWidget->raise();
66 mp_settingsWidget->move(0, 60);
67 //mp_settingsWidget->hide();
69 /*mp_applauncherwidget = new AppLauncherWidget(this);
70 mp_applauncherwidget->raise();
72 mp_applauncherwidget->move(0, 60);*/
75 mp_popupWidget = new PopupWidget();
76 mp_controlBarWidget->raise();
78 mp_popupWidget->move(0, 0);
81 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), this, SLOT(updateColorScheme()));
82 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_statusBarWidget, SLOT(updateColorScheme()));
83 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_controlBarWidget, SLOT(updateColorScheme()));
84 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_settingsWidget, SLOT(updateColorScheme()));
85 QObject::connect(mp_settingsWidget, SIGNAL(colorSchemeChanged()), mp_popupWidget, SLOT(updateColorScheme()));
87 QObject::connect(mp_controlBarWidget, SIGNAL(settingsButtonPressed()), mp_settingsWidget, SLOT(raise()));
88 //QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_applauncherwidget, SLOT(raise()));
89 QObject::connect(mp_controlBarWidget, SIGNAL(hideAppLayer()), mp_layoutHandler, SLOT(hideAppLayer()));
91 //QObject::connect(mp_applauncherwidget, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int)));
92 //QObject::connect(mp_applauncherwidget, SIGNAL(showAppLayer()), mp_layoutHandler, SLOT(showAppLayer()));
98 // this is only useful during development and will be removed later
99 setWindowIcon(QIcon(":/icons/home_day.png"));
101 // mp_applauncherwidget->populateAppList();
102 //mp_layoutHandler->setUpLayouts();
104 mp_homeScreenControlInterface = new HomeScreenControlInterface(this);
105 // QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestGetAllSurfacesOfProcess(int)), mp_layoutHandler, SLOT(requestGetAllSurfacesOfProcess(int)));
106 QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestGetSurfaceStatus(int)), mp_layoutHandler, SLOT(requestGetSurfaceStatus(int)));
107 QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int)));
108 QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestRenderSurfaceToArea(int, int)), mp_layoutHandler, SLOT(requestRenderSurfaceToArea(int,int)));
109 QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestRenderSurfaceToAreaAllowed(int, int)), mp_layoutHandler, SLOT(requestRenderSurfaceToAreaAllowed(int,int)));
110 QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestSurfaceIdToFullScreen(int)), mp_layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
112 QObject::connect(mp_popupWidget, SIGNAL(comboBoxResult(QString)), mp_layoutHandler, SLOT(setLayoutByName(QString)));
115 MainWindow::~MainWindow()
117 delete mp_homeScreenControlInterface;
119 delete mp_dBusDayNightModeProxy;
121 delete mp_layoutHandler;
123 delete mp_popupWidget;
124 //delete mp_applauncherwidget;
125 delete mp_settingsWidget;
126 delete mp_controlBarWidget;
127 delete mp_statusBarWidget;
128 delete mp_proximityAdaptor;
132 void MainWindow::dayNightModeSlot(int mode)
135 settings.setValue("systemsettings/daynightmode", mode);
136 // make sure that everything is written to the settings file before continuing
142 void MainWindow::setObjectDetected(bool detected)
144 qDebug("setObjectDetected %s", detected ? "true" : "false");
146 settings.setValue("systemsettings/proximityobjectdetected", detected);
147 // make sure that everything is written to the settings file before continuing
153 void MainWindow::updateColorScheme()
156 QSettings settings_cs(QApplication::applicationDirPath() +
158 settings.value("systemsettings/colorscheme", "default").toString() +
160 QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
162 QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
164 QSettings::IniFormat);
166 mp_ui->widget_background->setStyleSheet(settings_cs.value("MainWindow/widget_background_css").toString());
167 mp_ui->widget_homeIcon->setStyleSheet(settings_cs.value("MainWindow/widget_homeIcon_css").toString());
170 mp_statusBarWidget->updateColorScheme();
171 mp_controlBarWidget->updateColorScheme();
172 mp_settingsWidget->updateColorScheme();
173 //mp_applauncherwidget->updateColorScheme();
174 mp_popupWidget->updateColorScheme();
177 void MainWindow::changeEvent(QEvent* event)
179 if (QEvent::LanguageChange == event->type())
181 mp_ui->retranslateUi(this);
184 QMainWindow::changeEvent(event);