3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
7 #include "qmaemo5homescreenadaptor.h"
8 #include "marketstodayqmlview.h"
11 #include <QDeclarativeEngine>
12 #include <QDeclarativeContext>
14 //#include <QNetworkConfigurationManager>
16 #include <QGraphicsObject>
17 #include "logutility.h"
18 #include "connectionutility.h"
19 #include "sharedcontext.h"
21 int main(int argc, char *argv[])
24 bool isDesktopWidget = false;
26 if (argc > 2 && QString(argv[1]).contains("-plugin-id")) {
27 isDesktopWidget = true;
30 QApplication app(argc, argv);
32 //QNetworkConfigurationManager manager;
33 //ConnectionUtility connectionUtility;
35 //Signal to check available networks when auto-update is triggered
36 //QObject::connect(&manager,SIGNAL(updateCompleted()),&connectionUtility,SLOT(connectionListUpdated()));
39 MarketsTodayQMLView qmlView;
43 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
44 //For maemo fremantle or harmattan use a common path
45 strPath = QDir().homePath() + "/.marketstoday/OfflineStorage";
46 QDir configDir(strPath);
47 qDebug() << "Config path is " << strPath;
48 if (!configDir.exists()){
49 bool created = configDir.mkpath(strPath);
51 qDebug() << "Unable to create config directory at " << strPath;
54 qmlView.engine()->setOfflineStoragePath(strPath);
56 qmlView.engine()->setOfflineStoragePath("qml/OfflineStorage");
59 qmlView.setResizeMode(QDeclarativeView::SizeRootObjectToView);
60 qmlView.setWindowTitle("Markets Today");
62 LogUtility logUtility;
63 logUtility.logMessage(qmlView.engine()->offlineStoragePath());
65 SharedContext *sharedContextObj = new SharedContext(&qmlView);
66 sharedContextObj->setComponentToDisplay("StockQuotesUI");
67 qmlView.rootContext()->setContextProperty("sharedContext",sharedContextObj);
70 if (isDesktopWidget) {
71 QMaemo5HomescreenAdaptor *adaptor = new QMaemo5HomescreenAdaptor(&qmlView);
72 adaptor->setSettingsAvailable(true); //Use the standard widget settings button for home screen widget
73 QObject::connect(adaptor, SIGNAL(settingsRequested()), &qmlView, SLOT(displayConfigWindow()));
75 qmlView.setFixedSize(400,325);
76 qmlView.setSource(QUrl("qrc:/qml/MarketsTodayWidget.qml"));
80 #if defined(Q_WS_MAEMO_5)
81 //For Fremantle, use QML without harmattan-components
82 qmlView.setFixedSize(400,325);
83 qmlView.setSource(QUrl("qrc:/qml/MarketsTodayLegacyApp.qml"));
85 qmlView.setAttribute(Qt::WA_AutoOrientation,true);
86 qmlView.setSource(QUrl("qrc:/qml/MarketsTodayApp.qml"));
88 qmlView.showFullScreen();
91 QObject *rootObject = qmlView.rootObject();
92 //Singal to display stock quote details full screen
93 QObject::connect(rootObject, SIGNAL(showStockDetails(QString)), &qmlView, SLOT(displayStockDetails(QString)));
95 //Signal to reload configuration and update quotes after config window is clicked
96 QObject::connect(&qmlView, SIGNAL(initializeWidget()), rootObject, SLOT(initialize()));
98 //QObject::connect(rootObject, SIGNAL(checkNetworkStatus()), &connectionUtility, SLOT(checkConnectionStatus()));
99 //QObject::connect(&connectionUtility, SIGNAL(connectionsAvailable()), rootObject, SLOT(reloadData()));
100 QObject::connect((QObject*)qmlView.engine(), SIGNAL(quit()), &app, SLOT(quit()));