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_daynightmodeAdaptor(0),
25 mp_statusbarAdaptor(0),
28 // publish dbus day night mode interface
29 mp_daynightmodeAdaptor = new DaynightmodeAdaptor((QObject*)this);
30 // publish statusbar interface
31 mp_statusbarAdaptor = new StatusbarAdaptor((QObject*)this);
33 QDBusConnection dbus = QDBusConnection::sessionBus();
34 dbus.registerObject("/StatusBarWidget", this);
35 dbus.registerService("org.agl.mainwindow");
39 // callback every second
40 m_secondsTimerId = startTimer(1000);
43 StatusBarWidget::~StatusBarWidget()
45 delete mp_statusbarAdaptor;
46 delete mp_daynightmodeAdaptor;
50 void StatusBarWidget::setDayNightMode(int mode)
54 case SystemDayNight::DAYNIGHTMODE_DAY:
55 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
56 mp_ui->widget->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_stripes_day.png)"));
57 mp_ui->label_1->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
58 mp_ui->label_2->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
59 mp_ui->label_3->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
60 mp_ui->label_4_Time->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
61 mp_ui->label_5->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
62 mp_ui->label_6->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
63 mp_ui->label_7->setStyleSheet(QString("color: rgb(238, 238, 238); background-image: url(:/images/transparency.png);"));
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(:/images/transparency.png);"));
69 mp_ui->label_2->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(:/images/transparency.png);"));
70 mp_ui->label_3->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(:/images/transparency.png);"));
71 mp_ui->label_4_Time->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(:/images/transparency.png);"));
72 mp_ui->label_5->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(:/images/transparency.png);"));
73 mp_ui->label_6->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(:/images/transparency.png);"));
74 mp_ui->label_7->setStyleSheet(QString("color: rgb(177, 177, 177); background-image: url(:/images/transparency.png);"));
77 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
81 void StatusBarWidget::setStatus(int index, const QString &text)
86 mp_ui->label_1->setText(text);
89 mp_ui->label_2->setText(text);
92 mp_ui->label_3->setText(text);
95 qDebug("reserved for the time status");
98 mp_ui->label_5->setText(text);
101 mp_ui->label_6->setText(text);
104 mp_ui->label_7->setText(text);
111 void StatusBarWidget::timerEvent(QTimerEvent *e)
113 if (e->timerId() == m_secondsTimerId)
115 mp_ui->label_4_Time->setText(QDateTime::currentDateTime().toString("hh:mm"));