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 "popupwidget.h"
18 #include "ui_popupwidget.h"
20 PopupWidget::PopupWidget(QWidget *parent) :
22 mp_ui(new Ui::PopupWidget),
23 m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
24 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)));
34 // publish dbus popup interface
35 mp_popupAdaptor = new PopupAdaptor((QObject*)this);
36 QDBusConnection dbus = QDBusConnection::sessionBus();
37 dbus.registerObject("/Popup", this);
38 dbus.registerService("org.agl.homescreen");
44 PopupWidget::~PopupWidget()
46 delete mp_dayNightModeProxy;
47 delete mp_popupAdaptor;
51 void PopupWidget::dayNightModeSlot(int mode)
55 case SystemDayNight::DAYNIGHTMODE_DAY:
56 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
57 mp_ui->widget_Popup->setStyleSheet(QString("QWidget { \
58 border: 1px solid #D3D3D3; \
60 background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(242, 242, 249, 255), stop:1 rgba(255, 255, 255, 255)); \
65 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
67 mp_ui->label_Text->setStyleSheet(QString("background-color: rgba(109, 109, 109, 0); \
68 background-image: url(:/images/transparency.png); \
69 border-image: url(:/images/transparency.png);"));
71 case SystemDayNight::DAYNIGHTMODE_NIGHT:
72 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
73 mp_ui->widget_Popup->setStyleSheet(QString("QWidget { \
74 border: 1px solid #D3D3D3; \
76 background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(147, 147, 151, 255), stop:1 rgba(255, 255, 255, 255)); \
81 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
83 mp_ui->label_Text->setStyleSheet(QString("background-color: rgba(109, 109, 109, 0); \
84 background-image: url(:/images/transparency.png); \
85 border-image: url(:/images/transparency.png);"));
88 m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
92 void PopupWidget::showPopup(int type, const QString &text)
96 qDebug("PopupWidget::showPopup: type %d, text %s", type, text.toStdString().c_str());
97 mp_ui->label_Text->setText(text);
100 void PopupWidget::on_pushButton_OK_clicked()