-#include <QApplication>\r
-#include <q-extras/qemaemo5dynamicwidgethelper.h>\r
-#include <q-extras/qtsingleapplication.h>\r
-#include <q-extras/qesettingsmanager.h>\r
-#include "quickwidget.hpp"\r
-#include "quickwidgetsettings.hpp"\r
-#include "appeventlistener.hpp"\r
-\r
-int main(int argc, char *argv[])\r
-{\r
- QApplication::setApplicationName("Quick Widgets");\r
- QApplication::setOrganizationName("Marquarding");\r
- // APP_VERSION and APP_BETA are defined in the .pro file\r
- QApplication::setApplicationVersion(QString(APP_VERSION)\r
-#if APP_BETA\r
- + " beta"\r
-#endif\r
- );\r
-\r
- QtSingleApplication app(argc, argv);\r
- qDebug() << "Launched quick widgets app";\r
-\r
- if (app.isRunning())\r
- {\r
- qDebug() << "Another instance of the app is running.";\r
- if (app.arguments().contains("in-background"))\r
- {\r
- qDebug() << "Closing that other instance.";\r
- app.sendMessage(APP_MESSAGE_CLOSE);\r
- }\r
- else\r
- {\r
- qDebug() << "Asking it to offer to create a new widget.";\r
- app.sendMessage(APP_MESSAGE_ADDWIDGET);\r
- return 0;\r
- }\r
- }\r
-\r
- app.setQuitOnLastWindowClosed(false);\r
- AppEventListener::instance();\r
-\r
- if (app.arguments().contains("forget-widgets"))\r
- {\r
- qDebug() << "We were asked to forget all widgets!";\r
- QeMaemo5DynamicWidgetHelper::globalInstance()->forgetAllWidgets();\r
- }\r
- else\r
- {\r
- qDebug() << "Restoring all widgets";\r
- QeMaemo5DynamicWidgetHelper::globalInstance()->restoreWidgets<QuickWidget>();\r
- }\r
-\r
- if (!app.arguments().contains("in-background"))\r
- {\r
- // setting for new widget\r
- QuickWidgetSettings settingsDialog;\r
- settingsDialog.exec();\r
- //app.sendMessage(APP_MESSAGE_ADDWIDGET);\r
- }\r
- return app.exec();\r
-}\r
+#include <QApplication>
+//#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <q-extras/qemaemo5dynamicwidgethelper.h>
+#include <q-extras/qtsingleapplication.h>
+#include <q-extras/qesettingsmanager.h>
+#include "ProcessObject.h"
+#include "quickwidget.hpp"
+#include "quickwidgetsettings.hpp"
+#include "appeventlistener.hpp"
+
+int main(int argc, char *argv[])
+{
+ QApplication::setApplicationName("Quick Widgets");
+ QApplication::setOrganizationName("Marquarding");
+ // APP_VERSION and APP_BETA are defined in the .pro file
+ QApplication::setApplicationVersion(QString(APP_VERSION)
+#if APP_BETA
+ + " beta"
+#endif
+ );
+
+ QtSingleApplication app(argc, argv);
+ qmlRegisterType<ProcessObject>("quickwidgets", 1,0, "Process");
+
+ qDebug() << "Launched quick widgets app";
+
+ if (app.isRunning())
+ {
+ qDebug() << "Another instance of the app is running.";
+ if (app.arguments().contains("in-background"))
+ {
+ qDebug() << "Closing that other instance.";
+ app.sendMessage(APP_MESSAGE_CLOSE);
+ }
+ else
+ {
+ qDebug() << "Asking it to offer to create a new widget.";
+ QStringList result;
+ result = app.arguments().filter(".qml");
+ if (result.size() == 1 && QFile(result.last()).exists()) {
+ app.sendMessage(QFileInfo(result.last()).absoluteFilePath());
+ } else {
+ app.sendMessage(APP_MESSAGE_SETWIDGET);
+ }
+ return 0;
+ }
+ }
+
+ app.setQuitOnLastWindowClosed(false);
+ AppEventListener::instance();
+
+ if (app.arguments().contains("forget-widgets"))
+ {
+ qDebug() << "We were asked to forget all widgets!";
+ QeMaemo5DynamicWidgetHelper::globalInstance()->forgetAllWidgets();
+ }
+ else
+ {
+ qDebug() << "Restoring all widgets";
+ QeMaemo5DynamicWidgetHelper::globalInstance()->restoreWidgets<QuickWidget>();
+ }
+ QStringList result;
+ result = app.arguments().filter(".qml");
+ if (result.size() == 1 && QFile(result.last()).exists()) {
+ app.sendMessage(QFileInfo(result.last()).absoluteFilePath());
+ } else if (!app.arguments().contains("in-background"))
+ {
+ // setting for new widget
+ QuickWidgetSettings settingsDialog;
+ settingsDialog.exec();
+ //app.sendMessage(APP_MESSAGE_SETWIDGET);
+ }
+ return app.exec();
+}