prepend 'emit' keyword whenever emiting signal
[staging/HomeScreen.git] / HomeScreen / src / popupwidget.cpp
index 81ffdf7..6cf00b1 100644 (file)
 
 #include "popupwidget.h"
 #include "ui_popupwidget.h"
+#include <include/daynightmode.hpp>
 
 PopupWidget::PopupWidget(QWidget *parent) :
     QWidget(parent),
     mp_ui(new Ui::PopupWidget),
-    m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
-    mp_dayNightModeProxy(0),
-    mp_popupAdaptor(0)
+    mp_popupAdaptor(0),
+    m_sendComboBoxChoice(false)
 {
-    // this has to be adopted to the system setup
-    mp_dayNightModeProxy = new org::agl::daynightmode("org.agl.homescreen.simulator", //"org.agl.systeminfoprovider"
-                                                      "/",
-                                                      QDBusConnection::sessionBus(),
-                                                      0);
-    QObject::connect(mp_dayNightModeProxy, SIGNAL(dayNightMode(int)), this, SLOT(dayNightModeSlot(int)));
-
     // publish dbus popup interface
     mp_popupAdaptor = new PopupAdaptor((QObject*)this);
     QDBusConnection dbus = QDBusConnection::sessionBus();
     dbus.registerObject("/Popup", this);
     dbus.registerService("org.agl.homescreen");
 
+    // no window decoration
+    setWindowFlags(Qt::FramelessWindowHint);
+
     mp_ui->setupUi(this);
+
     this->close();
 }
 
 PopupWidget::~PopupWidget()
 {
-    delete mp_dayNightModeProxy;
     delete mp_popupAdaptor;
     delete mp_ui;
 }
 
-void PopupWidget::dayNightModeSlot(int mode)
+void PopupWidget::updateColorScheme()
 {
-    switch (mode)
-    {
-    case SystemDayNight::DAYNIGHTMODE_DAY:
-        m_dayNightMode = SystemDayNight::DAYNIGHTMODE_DAY;
-        mp_ui->widget_Popup->setStyleSheet(QString("QWidget { \
-                                                   border: 1px solid #D3D3D3; \
-                                                   border-radius: 8px; \
-                                                   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)); \
-                                                   color: #333; \
-                                                   padding: 0px; \
-                                                   }  \
-                                                   QWidget:on { \
-                                                   background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
-                                                   }"));
-        mp_ui->label_Text->setStyleSheet(QString("background-color: rgba(109, 109, 109, 0); \
-                                                 background-image: url(:/images/transparency.png); \
-                                                 border-image: url(:/images/transparency.png);"));
-        break;
-    case SystemDayNight::DAYNIGHTMODE_NIGHT:
-        m_dayNightMode = SystemDayNight::DAYNIGHTMODE_NIGHT;
-        mp_ui->widget_Popup->setStyleSheet(QString("QWidget { \
-                                                   border: 1px solid #D3D3D3; \
-                                                   border-radius: 8px; \
-                                                   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)); \
-                                                   color: #333; \
-                                                   padding: 0px; \
-                                                   }  \
-                                                   QWidget:on { \
-                                                   background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE); \
-                                                   }"));
-        mp_ui->label_Text->setStyleSheet(QString("background-color: rgba(109, 109, 109, 0); \
-                                                 background-image: url(:/images/transparency.png); \
-                                                 border-image: url(:/images/transparency.png);"));
-        break;
-    default:
-        m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
-    }
+    QSettings settings;
+    QSettings settings_cs(QApplication::applicationDirPath() +
+                          "/colorschemes/" +
+                          settings.value("systemsettings/colorscheme", "default").toString() +
+                          "/" +
+                          QString::number(settings.value("systemsettings/proximityobjectdetected", false).toBool()) +
+                          "/" +
+                          QString::number(settings.value("systemsettings/daynightmode", SystemDayNight::DAYNIGHTMODE_DAY).toInt()) +
+                          ".ini",
+                          QSettings::IniFormat);
+
+    mp_ui->widget_popup->setStyleSheet(settings_cs.value(QString("PopupWidget/widget_popup_css")).toString());
+    mp_ui->label_text->setStyleSheet(settings_cs.value(QString("PopupWidget/label_text_css")).toString());
 }
 
-void PopupWidget::showPopup(int type, const QString &text)
+void PopupWidget::showPopup(int /*type*/, const QString &text)
 {
+    m_sendComboBoxChoice = false;
+    mp_ui->comboBox_choice->hide();
     this->show();
     this->raise();
-    qDebug("PopupWidget::showPopup: type %d, text %s", type, text.toStdString().c_str());
-    mp_ui->label_Text->setText(text);
+    mp_ui->label_text->setText(text);
+}
+
+void PopupWidget::showPopupComboBox(const QString &text, const QStringList &choices)
+{
+    mp_ui->comboBox_choice->clear();
+    m_sendComboBoxChoice = true;
+    mp_ui->comboBox_choice->addItems(choices);
+    mp_ui->comboBox_choice->show();
+    this->show();
+    this->raise();
+    mp_ui->label_text->setText(text);
 }
 
 void PopupWidget::on_pushButton_OK_clicked()
 {
+    if (m_sendComboBoxChoice)
+    {
+        emit comboBoxResult(mp_ui->comboBox_choice->currentText());
+        m_sendComboBoxChoice = false;
+    }
     this->close();
 }