v0.1.0
[staging/HomeScreen.git] / HomeScreen / src / controlbarwidget.cpp
similarity index 68%
rename from src/controlbarwidget.cpp
rename to HomeScreen/src/controlbarwidget.cpp
index 4627a7b..e01fe26 100644 (file)
@@ -21,34 +21,30 @@ ControlBarWidget::ControlBarWidget(QWidget *parent) :
     QWidget(parent),
     mp_ui(new Ui::ControlBarWidget),
     mp_settingsWidget(0),
-    mp_dBusDayNightMode_SettingsWidget(0),
     m_dayNightMode(SystemDayNight::DAYNIGHTMODE_DAY), // TODO: read from system
-    mp_daynightmodeAdaptor(0)
+    mp_dayNightModeProxy(0)
 {
-    // publish dbus day night mode interface
-    mp_daynightmodeAdaptor = new DaynightmodeAdaptor((QObject*)this);
-    QDBusConnection dbus = QDBusConnection::sessionBus();
-    dbus.registerObject("/ControlBarWidget", this);
-    dbus.registerService("org.agl.mainwindow");
+    // 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)));
 
     mp_ui->setupUi(this);
 }
 
 ControlBarWidget::~ControlBarWidget()
 {
-    delete mp_daynightmodeAdaptor;
+    delete mp_dayNightModeProxy;
     if (0 != mp_settingsWidget)
     {
         delete mp_settingsWidget;
     }
-    if (0 == mp_dBusDayNightMode_SettingsWidget)
-    {
-        delete mp_dBusDayNightMode_SettingsWidget;
-    }
     delete mp_ui;
 }
 
-void ControlBarWidget::setDayNightMode(int mode)
+void ControlBarWidget::dayNightModeSlot(int mode)
 {
     QIcon icon;
     switch (mode)
@@ -74,12 +70,6 @@ void ControlBarWidget::setDayNightMode(int mode)
     default:
         m_dayNightMode = SystemDayNight::DAYNIGHTMODE_UNDEFINED;
     }
-
-    // settings widget if present
-    if (0 != mp_dBusDayNightMode_SettingsWidget)
-    {
-        mp_dBusDayNightMode_SettingsWidget->setDayNightMode(m_dayNightMode);
-    }
 }
 
 void ControlBarWidget::on_pushButton_Settings_clicked()
@@ -91,16 +81,6 @@ void ControlBarWidget::on_pushButton_Settings_clicked()
 
     mp_settingsWidget->move(0, 60);
     mp_settingsWidget->show();
-
-    if (0 == mp_dBusDayNightMode_SettingsWidget)
-    {
-        // connect to the dBus interface provided by the settings widget
-        mp_dBusDayNightMode_SettingsWidget = new org::agl::daynightmode("org.agl.mainwindow",
-                                                  "/SettingsWidget",
-                                                  QDBusConnection::sessionBus(),
-                                                  0);
-        mp_dBusDayNightMode_SettingsWidget->setDayNightMode(m_dayNightMode);
-    }
 }
 
 void ControlBarWidget::on_pushButton_Home_clicked()