X-Git-Url: http://git.maemo.org/git/?p=quick-widgets;a=blobdiff_plain;f=appeventlistener.cpp;fp=appeventlistener.cpp;h=4dfdd81f23c17b474e5881d471bfd8667fa4ac74;hp=0000000000000000000000000000000000000000;hb=dfed50eedc532f1136575c876c46a7eb104a37e5;hpb=811ce53d2a7d3d73625c8eceb3b57e7a84d2d87c;ds=sidebyside diff --git a/appeventlistener.cpp b/appeventlistener.cpp new file mode 100644 index 0000000..4dfdd81 --- /dev/null +++ b/appeventlistener.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +#include "appeventlistener.hpp" +#include "quickwidgetsettings.hpp" + +static AppEventListener *_instance = NULL; + +AppEventListener* AppEventListener::instance() +{ + if (_instance == NULL) + _instance = new AppEventListener(QCoreApplication::instance()); + + return _instance; +} + +AppEventListener::AppEventListener(QObject *parent) : + QObject(parent) +{ + // Connect to the QtSingleApplication's event + QObject::connect(QtSingleApplication::instance(), SIGNAL(messageReceived(const QString&)), this, SLOT(receiveMessage(const QString&))); +} + +void AppEventListener::receiveMessage(const QString& message) +{ + if (message == APP_MESSAGE_ADDWIDGET) + { + qDebug() << "TTTTTTEEEEST"; + QuickWidgetSettings settings; + settings.exec(); + } + else if (message == APP_MESSAGE_CLOSE) + { + ((QApplication*)sender())->quit(); + } +} +