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"
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/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
56 QSettings::IniFormat);
58 mp_ui->widget_Popup->setStyleSheet(settings_cs.value(QString("PopupWidget/widget_Popup")).toString());
59 mp_ui->label_Text->setStyleSheet(settings_cs.value(QString("PopupWidget/label_Text")).toString());
62 void PopupWidget::showPopup(int /*type*/, const QString &text)
64 m_sendComboBoxChoice = false;
65 mp_ui->comboBox->hide();
68 mp_ui->label_Text->setText(text);
71 void PopupWidget::showPopupComboBox(const QString &text, const QStringList &choices)
73 m_sendComboBoxChoice = true;
74 mp_ui->comboBox->addItems(choices);
75 mp_ui->comboBox->show();
78 mp_ui->label_Text->setText(text);
81 void PopupWidget::on_pushButton_OK_clicked()
83 if (m_sendComboBoxChoice)
85 comboBoxResult(mp_ui->comboBox->currentText());
86 m_sendComboBoxChoice = false;