Using the Tizen application manager to receive information about installed apps and...
[staging/HomeScreen.git] / HomeScreen / src / popupwidget.cpp
1 /*
2  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "popupwidget.h"
18 #include "ui_popupwidget.h"
19 #include <include/daynightmode.hpp>
20
21 PopupWidget::PopupWidget(QWidget *parent) :
22     QWidget(parent),
23     mp_ui(new Ui::PopupWidget),
24     mp_popupAdaptor(0)
25 {
26     // publish dbus popup interface
27     mp_popupAdaptor = new PopupAdaptor((QObject*)this);
28     QDBusConnection dbus = QDBusConnection::sessionBus();
29     dbus.registerObject("/Popup", this);
30     dbus.registerService("org.agl.homescreen");
31
32     // no window decoration
33     setWindowFlags(Qt::FramelessWindowHint);
34
35     mp_ui->setupUi(this);
36
37     this->close();
38 }
39
40 PopupWidget::~PopupWidget()
41 {
42     delete mp_popupAdaptor;
43     delete mp_ui;
44 }
45
46 void PopupWidget::updateColorScheme()
47 {
48     QSettings settings;
49     QSettings settings_cs(QApplication::applicationDirPath() +
50                           "/colorschemes/" +
51                           settings.value("systemsettings/colorscheme", "default").toString() +
52                           "/" +
53                           QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
54                           ".ini",
55                           QSettings::IniFormat);
56
57     mp_ui->widget_Popup->setStyleSheet(settings_cs.value(QString("PopupWidget/widget_Popup")).toString());
58     mp_ui->label_Text->setStyleSheet(settings_cs.value(QString("PopupWidget/label_Text")).toString());
59 }
60
61 void PopupWidget::showPopup(int /*type*/, const QString &text)
62 {
63     this->show();
64     this->raise();
65     mp_ui->label_Text->setText(text);
66 }
67
68 void PopupWidget::on_pushButton_OK_clicked()
69 {
70     this->close();
71 }