2 * This file is part of CameraPlus.
4 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <QApplication>
23 #include <QDeclarativeView>
24 #include <QDeclarativeContext>
25 #include <QDeclarativeEngine>
26 #include <QtDeclarative>
29 #include <QGuiApplication>
35 #include "filenaming.h"
37 #include "quillitem.h"
40 #include "deviceinfo.h"
41 #include "soundvolumecontrol.h"
42 #include "displaystate.h"
43 #include "fsmonitor.h"
44 #include "cameraresources.h"
46 #include "orientation.h"
47 #include "mountprotector.h"
48 #include "trackerstore.h"
49 #include "focusrectangle.h"
50 #include "sharehelper.h"
51 #include "deletehelper.h"
52 #include "galleryhelper.h"
53 #include "postcapturemodel.h"
54 #include "batteryinfo.h"
55 #include "gridlines.h"
56 #include "devicekeys.h"
57 #include "platformsettings.h"
58 #include "dbusservice.h"
59 #include "phoneprofile.h"
60 #include "platformquirks.h"
61 #include <MDeclarativeCache>
64 #include "qt_private/qdeclarativedebughelper_p.h"
65 #endif /* QMLJSDEBUGGER */
68 #include <QAbstractFileEngineHandler>
69 #include "qmlfileengine.h"
71 class QmlFileEngineHandler : public QAbstractFileEngineHandler {
72 QAbstractFileEngine *create(const QString& fileName) const {
73 QString fn = fileName.toLower();
74 if (fn.startsWith(':') && fn.endsWith(".qml")) {
75 return new QmlFileEngine(fileName);
83 Q_DECL_EXPORT int main(int argc, char *argv[]) {
85 QDeclarativeDebugHelper::enableDebugging();
86 #endif /* QMLJSDEBUGGER */
89 QApplication::setAttribute(Qt::AA_X11InitThreads, true);
90 QApplication *app = new QApplication(argc, argv);
91 app->setApplicationName("cameraplus");
93 QmlFileEngineHandler handler;
96 QDeclarativeView *view = MDeclarativeCache::qDeclarativeView();
98 QGuiApplication *app = MDeclarativeCache::qApplication(argc, argv);
99 app->setApplicationName("cameraplus");
101 QQuickView *view = MDeclarativeCache::qQuickView();
105 view->setAttribute(Qt::WA_NoSystemBackground);
106 view->setViewport(new QGLWidget);
107 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
108 view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
109 view->viewport()->setAttribute(Qt::WA_NoSystemBackground);
113 view->setResizeMode(QQuickView::SizeRootObjectToView);
117 qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
118 qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
120 qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
122 qmlRegisterType<Geocode>("CameraPlus", 1, 0, "ReverseGeocode");
123 qmlRegisterType<DeviceInfo>("CameraPlus", 1, 0, "DeviceInfo");
124 qmlRegisterType<SoundVolumeControl>("CameraPlus", 1, 0, "SoundVolumeControl");
125 qmlRegisterType<DisplayState>("CameraPlus", 1, 0, "DisplayState");
126 qmlRegisterType<FSMonitor>("CameraPlus", 1, 0, "FSMonitor");
127 qmlRegisterType<CameraResources>("CameraPlus", 1, 0, "CameraResources");
128 qmlRegisterType<Compass>("CameraPlus", 1, 0, "CameraCompass");
129 qmlRegisterType<Orientation>("CameraPlus", 1, 0, "CameraOrientation");
130 qmlRegisterType<MountProtector>("CameraPlus", 1, 0, "MountProtector");
131 qmlRegisterType<TrackerStore>("CameraPlus", 1, 0, "TrackerStore");
132 qmlRegisterType<FocusRectangle>("CameraPlus", 1, 0, "FocusRectangle");
133 qmlRegisterType<ShareHelper>("CameraPlus", 1, 0, "ShareHelper");
134 qmlRegisterType<DeleteHelper>("CameraPlus", 1, 0, "DeleteHelper");
135 qmlRegisterType<GalleryHelper>("CameraPlus", 1, 0, "GalleryHelper");
136 qmlRegisterType<PostCaptureModel>("CameraPlus", 1, 0, "PostCaptureModel");
137 qmlRegisterType<BatteryInfo>("CameraPlus", 1, 0, "BatteryInfo");
138 qmlRegisterType<GridLines>("CameraPlus", 1, 0, "GridLines");
139 qmlRegisterType<DeviceKeys>("CameraPlus", 1, 0, "DeviceKeys");
140 qmlRegisterType<PlatformSettings>("CameraPlus", 1, 0, "PlatformSettings");
141 qmlRegisterType<PhoneProfile>("CameraPlus", 1, 0, "PhoneProfile");
142 qmlRegisterType<PlatformQuirks>("CameraPlus", 1, 0, "PlatformQuirks");
144 view->setSource(QUrl("qrc:/qml/main.qml"));
147 if (view->status() == QQuickView::Error) {
148 qCritical() << "Errors loading QML:";
149 QList<QQmlError> errors = view->errors();
151 foreach (const QQmlError& error, errors) {
152 qCritical() << error.toString();
162 view->showFullScreen();
164 int ret = app->exec();