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 "controlbarwidget.h"
18 #include "ui_controlbarwidget.h"
20 ControlBarWidget::ControlBarWidget(QWidget *parent) :
22 mp_ui(new Ui::ControlBarWidget),
24 m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
25 mp_dayNightModeProxy(0)
27 // this has to be adopted to the system setup
28 mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
30 QDBusConnection::sessionBus(),
32 QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
37 ControlBarWidget::~ControlBarWidget()
39 delete mp_dayNightModeProxy;
40 if (0 != mp_settingsWidget)
42 delete mp_settingsWidget;
47 void ControlBarWidget::dayNightModeSlot(int mode)
52 case SystemDayNight::DAYNIGHTMODE_DAY:
53 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
54 mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_green_day.png)"));
56 icon.addFile(QStringLiteral(":/icons/home_day.png"), QSize(), QIcon::Normal, QIcon::Off);
57 mp_ui->pushButton_Home->setIcon(icon);
58 icon.addFile(QStringLiteral(":/icons/settings_day.png"), QSize(), QIcon::Normal, QIcon::Off);
59 mp_ui->pushButton_Settings->setIcon(icon);
61 case SystemDayNight::DAYNIGHTMODE_NIGHT:
62 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
63 mp_ui->widget_Background->setStyleSheet(QString("background-image: url(:/images/backgrounds/bg_green_night.png)"));
65 icon.addFile(QStringLiteral(":/icons/home_night.png"), QSize(), QIcon::Normal, QIcon::Off);
66 mp_ui->pushButton_Home->setIcon(icon);
67 icon.addFile(QStringLiteral(":/icons/settings_night.png"), QSize(), QIcon::Normal, QIcon::Off);
68 mp_ui->pushButton_Settings->setIcon(icon);
71 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
75 void ControlBarWidget::on_pushButton_Settings_clicked()
77 if (0 == mp_settingsWidget)
79 mp_settingsWidget = new SettingsWidget((QWidget*)parent());
82 mp_settingsWidget->move(0, 60);
83 mp_settingsWidget->show();
86 void ControlBarWidget::on_pushButton_Home_clicked()
88 if (0 != mp_settingsWidget)
90 mp_settingsWidget->hide();