Replaced QtMobility BatteryInfo
[harmattan/cameraplus] / src / main.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <QApplication>
22 #include <QDeclarativeView>
23 #include <QDeclarativeContext>
24 #include <QDeclarativeEngine>
25 #include <QtDeclarative>
26 #include <QGLWidget>
27 #include <QuillFile>
28
29 #include "imports/plugin.h"
30
31 #include "settings.h"
32 #include "filenaming.h"
33 #include "quillitem.h"
34 #include "displaystate.h"
35 #include "fsmonitor.h"
36 #include "cameraresources.h"
37 #include "compass.h"
38 #include "orientation.h"
39 #include "geocode.h"
40 #include "mountprotector.h"
41 #include "trackerstore.h"
42 #include "focusrectangle.h"
43 #include "sharehelper.h"
44 #include "deletehelper.h"
45 #include "galleryhelper.h"
46 #include "postcapturemodel.h"
47 #include "batteryinfo.h"
48
49 static void initQuill() {
50   // TODO: All these are hardcoded.
51   Quill::setPreviewLevelCount(1);
52   Quill::setPreviewSize(0, QSize(854, 480));
53   Quill::setMinimumPreviewSize(0, QSize(854, 480));
54   Quill::setThumbnailExtension("jpeg");
55   Quill::setThumbnailFlavorName(0, "screen");
56   Quill::setBackgroundRenderingColor(Qt::black);
57   QString tempPath(QDir::homePath() +  QDir::separator() + ".config" +
58                    QDir::separator() + "quill" + QDir::separator() + "tmp");
59   QDir().mkpath(tempPath);
60   Quill::setTemporaryFilePath(tempPath);
61   Quill::setDBusThumbnailingEnabled(true);
62   Quill::setThumbnailCreationEnabled(true);
63 }
64
65 Q_DECL_EXPORT int main(int argc, char *argv[]) {
66   QApplication::setAttribute(Qt::AA_X11InitThreads, true);
67   QApplication app(argc, argv);
68
69   // Let's initialize Quill:
70   initQuill();
71
72   QDeclarativeView view;
73   view.setViewport(new QGLWidget);
74   view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
75   view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
76
77   Plugin::registerTypes(view.engine());
78   qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
79   qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
80   qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
81   qmlRegisterType<DisplayState>("CameraPlus", 1, 0, "DisplayState");
82   qmlRegisterType<FSMonitor>("CameraPlus", 1, 0, "FSMonitor");
83   qmlRegisterType<CameraResources>("CameraPlus", 1, 0, "CameraResources");
84   qmlRegisterType<Compass>("CameraPlus", 1, 0, "Compass");
85   qmlRegisterType<Orientation>("CameraPlus", 1, 0, "Orientation");
86   qmlRegisterType<Geocode>("CameraPlus", 1, 0, "ReverseGeocode");
87   qmlRegisterType<MountProtector>("CameraPlus", 1, 0, "MountProtector");
88   qmlRegisterType<TrackerStore>("CameraPlus", 1, 0, "TrackerStore");
89   qmlRegisterType<FocusRectangle>("CameraPlus", 1, 0, "FocusRectangle");
90   qmlRegisterType<ShareHelper>("CameraPlus", 1, 0, "ShareHelper");
91   qmlRegisterType<DeleteHelper>("CameraPlus", 1, 0, "DeleteHelper");
92   qmlRegisterType<GalleryHelper>("CameraPlus", 1, 0, "GalleryHelper");
93   qmlRegisterType<PostCaptureModel>("CameraPlus", 1, 0, "PostCaptureModel");
94   qmlRegisterType<BatteryInfo>("CameraPlus", 1, 0, "BatteryInfo");
95
96   view.setSource(QUrl("qrc:/qml/main.qml"));
97
98   view.showFullScreen();
99
100   int ret = app.exec();
101   return ret;
102 }