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 "statusbarwidget.h"
18 #include "ui_statusbarwidget.h"
20 StatusBarWidget::StatusBarWidget(QWidget *parent) :
22 mp_ui(new Ui::StatusBarWidget),
23 m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
24 mp_dayNightModeProxy(0),
25 mp_statusbarAdaptor(0),
26 mp_statusbarIconURIs(new QMap<int, QString>)
28 // this has to be adopted to the system setup
29 mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
31 QDBusConnection::sessionBus(),
33 QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
35 // publish statusbar interface
36 mp_statusbarAdaptor = new StatusbarAdaptor((QObject*)this);
38 QDBusConnection dbus = QDBusConnection::sessionBus();
39 dbus.registerObject("/StatusBar", this);
40 dbus.registerService("org.agl.homescreen");
45 StatusBarWidget::~StatusBarWidget()
47 delete mp_statusbarAdaptor;
48 delete mp_dayNightModeProxy;
52 void StatusBarWidget::dayNightModeSlot(int mode)
56 case SystemDayNight::DAYNIGHTMODE_DAY:
57 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
58 mp_ui->widget->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_stripes_day.png)"));
59 mp_ui->label_1->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(1) + QString("); background-repeat: no-repeat;"));
60 mp_ui->label_2->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(2) + QString("); background-repeat: no-repeat;"));
61 mp_ui->label_3->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(3) + QString("); background-repeat: no-repeat;"));
62 mp_ui->label_4->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(4) + QString("); background-repeat: no-repeat;"));
63 mp_ui->label_5->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(5) + QString("); background-repeat: no-repeat;"));
65 case SystemDayNight::DAYNIGHTMODE_NIGHT:
66 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
67 mp_ui->widget->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_stripes_night.png)"));
68 mp_ui->label_1->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(1) + QString("); background-repeat: no-repeat;"));
69 mp_ui->label_2->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(2) + QString("); background-repeat: no-repeat;"));
70 mp_ui->label_3->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(3) + QString("); background-repeat: no-repeat;"));
71 mp_ui->label_4->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(4) + QString("); background-repeat: no-repeat;"));
72 mp_ui->label_5->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(5) + QString("); background-repeat: no-repeat;"));
75 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
79 QList<int> StatusBarWidget::getAvailablePlaceholders()
83 // for now, all are available
93 QString StatusBarWidget::getStatusIcon(int placeholderIndex)
95 return mp_statusbarIconURIs->value(placeholderIndex);
98 QString StatusBarWidget::getStatusText(int placeholderIndex)
102 switch (placeholderIndex)
105 result = mp_ui->label_1->text();
108 result = mp_ui->label_2->text();
111 result = mp_ui->label_3->text();
114 result = mp_ui->label_4->text();
117 result = mp_ui->label_5->text();
126 void StatusBarWidget::setStatusIcon(int placeholderIndex, const QString &iconURI)
128 mp_statusbarIconURIs->insert(placeholderIndex, iconURI);
130 switch (m_dayNightMode)
132 case SystemDayNight::DAYNIGHTMODE_DAY:
133 switch (placeholderIndex)
136 mp_ui->label_1->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
139 mp_ui->label_2->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
142 mp_ui->label_3->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
145 mp_ui->label_4->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
148 mp_ui->label_5->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
154 case SystemDayNight::DAYNIGHTMODE_NIGHT:
155 switch (placeholderIndex)
158 mp_ui->label_1->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
161 mp_ui->label_2->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
164 mp_ui->label_3->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
167 mp_ui->label_4->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
170 mp_ui->label_5->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(") + mp_statusbarIconURIs->value(placeholderIndex) + QString("); background-repeat: no-repeat;"));
181 void StatusBarWidget::setStatusText(int placeholderIndex, const QString &text)
183 switch (placeholderIndex)
186 mp_ui->label_1->setText(text);
189 mp_ui->label_2->setText(text);
192 mp_ui->label_3->setText(text);
195 mp_ui->label_4->setText(text);
198 mp_ui->label_5->setText(text);