2 * Copyright (C) 2016 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"
20 MainWindow::MainWindow(QWidget *parent) :
22 mp_ui(new Ui::MainWindow),
23 mp_statusBarWidget(0),
24 mp_controlBarWidget(0),
25 m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
26 mp_dayNightModeProxy(0),
29 // this has to be adopted to the system setup
30 mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
32 QDBusConnection::sessionBus(),
34 QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
37 QDBusConnection dbus = QDBusConnection::sessionBus();
39 dbus.registerObject("/MainWindow", this);
40 dbus.registerService("org.agl.homescreen");
42 // no window decoration
43 setWindowFlags(Qt::FramelessWindowHint);
46 mp_statusBarWidget = new StatusBarWidget(this);
47 mp_statusBarWidget->raise();
49 mp_statusBarWidget->move(0, 0);
51 mp_controlBarWidget = new ControlBarWidget(this);
52 mp_controlBarWidget->raise();
54 mp_controlBarWidget->move(0, 1920-60);
56 mp_popupWidget = new PopupWidget(this);
57 mp_controlBarWidget->raise();
59 mp_popupWidget->move(0, 0);
61 setWindowIcon(QIcon(":/icons/home_day.png"));
64 MainWindow::~MainWindow()
66 delete mp_popupWidget;
67 delete mp_dayNightModeProxy;
68 delete mp_statusBarWidget;
72 void MainWindow::dayNightModeSlot(int mode)
76 case SystemDayNight::DAYNIGHTMODE_DAY:
77 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
78 mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_blue_day.png)"));
80 mp_ui->widget_Home_Icon->setStyleSheet(QString("border-image: url(:/icons/home_day.png) 0 0 0 0 stretch stretch;"));
83 case SystemDayNight::DAYNIGHTMODE_NIGHT:
84 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
85 mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_blue_night.png)"));
87 mp_ui->widget_Home_Icon->setStyleSheet(QString("border-image: url(:/icons/home_night.png) 0 0 0 0 stretch stretch;"));
91 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
95 void MainWindow::changeEvent(QEvent* event)
97 if (QEvent::LanguageChange == event->type())
99 mp_ui->retranslateUi(this);
102 QMainWindow::changeEvent(event);