2 * Copyright (C) 2016, 2017 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"
19 #include <include/daynightmode.hpp>
21 PopupWidget::PopupWidget(QWidget *parent) :
23 mp_ui(new Ui::PopupWidget),
25 m_sendComboBoxChoice(false)
27 // publish dbus popup interface
28 mp_popupAdaptor = new PopupAdaptor((QObject*)this);
29 QDBusConnection dbus = QDBusConnection::sessionBus();
30 dbus.registerObject("/Popup", this);
31 dbus.registerService("org.agl.homescreen");
33 // no window decoration
34 setWindowFlags(Qt::FramelessWindowHint);
41 PopupWidget::~PopupWidget()
43 delete mp_popupAdaptor;
47 void PopupWidget::updateColorScheme()
50 QSettings settings_cs(QApplication::applicationDirPath() +
52 settings.value("systemsettings/colorscheme", "default").toString() +
54 QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
56 QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
58 QSettings::IniFormat);
60 mp_ui->widget_popup->setStyleSheet(settings_cs.value(QString("PopupWidget/widget_popup_css")).toString());
61 mp_ui->label_text->setStyleSheet(settings_cs.value(QString("PopupWidget/label_text_css")).toString());
64 void PopupWidget::showPopup(int /*type*/, const QString &text)
66 m_sendComboBoxChoice = false;
67 mp_ui->comboBox_choice->hide();
70 mp_ui->label_text->setText(text);
73 void PopupWidget::showPopupComboBox(const QString &text, const QStringList &choices)
75 mp_ui->comboBox_choice->clear();
76 m_sendComboBoxChoice = true;
77 mp_ui->comboBox_choice->addItems(choices);
78 mp_ui->comboBox_choice->show();
81 mp_ui->label_text->setText(text);
84 void PopupWidget::on_pushButton_OK_clicked()
86 if (m_sendComboBoxChoice)
88 emit comboBoxResult(mp_ui->comboBox_choice->currentText());
89 m_sendComboBoxChoice = false;