1 #include <QApplication>
2 //#include <QDeclarativeEngine>
3 #include <QDeclarativeComponent>
4 #include <q-extras/qemaemo5dynamicwidgethelper.h>
5 #include <q-extras/qtsingleapplication.h>
6 #include <q-extras/qesettingsmanager.h>
7 #include "ProcessObject.h"
8 #include "quickwidget.hpp"
9 #include "quickwidgetsettings.hpp"
10 #include "appeventlistener.hpp"
12 int main(int argc, char *argv[])
14 QApplication::setApplicationName("Quick Widgets");
15 QApplication::setOrganizationName("Marquarding");
16 // APP_VERSION and APP_BETA are defined in the .pro file
17 QApplication::setApplicationVersion(QString(APP_VERSION)
23 QtSingleApplication app(argc, argv);
24 qmlRegisterType<ProcessObject>("quickwidgets", 1,0, "Process");
26 qDebug() << "Launched quick widgets app";
30 qDebug() << "Another instance of the app is running.";
31 if (app.arguments().contains("in-background"))
33 qDebug() << "Closing that other instance.";
34 app.sendMessage(APP_MESSAGE_CLOSE);
38 qDebug() << "Asking it to offer to create a new widget.";
40 result = app.arguments().filter(".qml");
41 if (result.size() == 1 && QFile(result.last()).exists()) {
42 app.sendMessage(QFileInfo(result.last()).absoluteFilePath());
44 app.sendMessage(APP_MESSAGE_SETWIDGET);
50 app.setQuitOnLastWindowClosed(false);
51 AppEventListener::instance();
53 if (app.arguments().contains("forget-widgets"))
55 qDebug() << "We were asked to forget all widgets!";
56 QeMaemo5DynamicWidgetHelper::globalInstance()->forgetAllWidgets();
60 qDebug() << "Restoring all widgets";
61 QeMaemo5DynamicWidgetHelper::globalInstance()->restoreWidgets<QuickWidget>();
64 result = app.arguments().filter(".qml");
65 if (result.size() == 1 && QFile(result.last()).exists()) {
66 app.sendMessage(QFileInfo(result.last()).absoluteFilePath());
67 } else if (!app.arguments().contains("in-background"))
69 // setting for new widget
70 QuickWidgetSettings settingsDialog;
71 settingsDialog.exec();
72 //app.sendMessage(APP_MESSAGE_SETWIDGET);