3e33b8c60136634fa620d11e11ba80ce4d0aba9c
[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 "settings.h"
30 #include "filenaming.h"
31 #include "quillitem.h"
32 #include "displaystate.h"
33 #include "fsmonitor.h"
34 #include "cameraresources.h"
35 #include "compass.h"
36 #include "orientation.h"
37 #include "geocode.h"
38 #include "mountprotector.h"
39 #include "trackerstore.h"
40 #include "focusrectangle.h"
41 #include "sharehelper.h"
42 #include "deletehelper.h"
43 #include "galleryhelper.h"
44 #include "postcapturemodel.h"
45 #include "batteryinfo.h"
46 #include "gridlines.h"
47 #include "deviceinfo.h"
48 #include "devicekeys.h"
49
50 #ifdef QMLJSDEBUGGER
51 #include "qt_private/qdeclarativedebughelper_p.h"
52 #endif /* QMLJSDEBUGGER */
53
54 static void initQuill() {
55   // TODO: All these are hardcoded.
56   Quill::setPreviewLevelCount(1);
57   Quill::setPreviewSize(0, QSize(854, 480));
58   Quill::setMinimumPreviewSize(0, QSize(854, 480));
59   Quill::setThumbnailExtension("jpeg");
60   Quill::setThumbnailFlavorName(0, "screen");
61   Quill::setBackgroundRenderingColor(Qt::black);
62   QString tempPath(QDir::homePath() +  QDir::separator() + ".config" +
63                    QDir::separator() + "quill" + QDir::separator() + "tmp");
64   QDir().mkpath(tempPath);
65   Quill::setTemporaryFilePath(tempPath);
66   Quill::setDBusThumbnailingEnabled(true);
67   Quill::setThumbnailCreationEnabled(true);
68 }
69
70 Q_DECL_EXPORT int main(int argc, char *argv[]) {
71   QApplication::setAttribute(Qt::AA_X11InitThreads, true);
72   QApplication app(argc, argv);
73
74 #ifdef QMLJSDEBUGGER
75   QDeclarativeDebugHelper::enableDebugging();
76 #endif /* QMLJSDEBUGGER */
77
78   // Let's initialize Quill:
79   initQuill();
80
81   QDeclarativeView view;
82   view.setAttribute(Qt::WA_NoSystemBackground);
83   view.setViewport(new QGLWidget);
84   view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
85   view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
86   view.viewport()->setAttribute(Qt::WA_NoSystemBackground);
87
88   qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
89   qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
90   qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
91   qmlRegisterType<DisplayState>("CameraPlus", 1, 0, "DisplayState");
92   qmlRegisterType<FSMonitor>("CameraPlus", 1, 0, "FSMonitor");
93   qmlRegisterType<CameraResources>("CameraPlus", 1, 0, "CameraResources");
94   qmlRegisterType<Compass>("CameraPlus", 1, 0, "Compass");
95   qmlRegisterType<Orientation>("CameraPlus", 1, 0, "Orientation");
96   qmlRegisterType<Geocode>("CameraPlus", 1, 0, "ReverseGeocode");
97   qmlRegisterType<MountProtector>("CameraPlus", 1, 0, "MountProtector");
98   qmlRegisterType<TrackerStore>("CameraPlus", 1, 0, "TrackerStore");
99   qmlRegisterType<FocusRectangle>("CameraPlus", 1, 0, "FocusRectangle");
100   qmlRegisterType<ShareHelper>("CameraPlus", 1, 0, "ShareHelper");
101   qmlRegisterType<DeleteHelper>("CameraPlus", 1, 0, "DeleteHelper");
102   qmlRegisterType<GalleryHelper>("CameraPlus", 1, 0, "GalleryHelper");
103   qmlRegisterType<PostCaptureModel>("CameraPlus", 1, 0, "PostCaptureModel");
104   qmlRegisterType<BatteryInfo>("CameraPlus", 1, 0, "BatteryInfo");
105   qmlRegisterType<GridLines>("CameraPlus", 1, 0, "GridLines");
106   qmlRegisterType<DeviceInfo>("CameraPlus", 1, 0, "DeviceInfo");
107   qmlRegisterType<DeviceKeys>("CameraPlus", 1, 0, "DeviceKeys");
108
109   view.setSource(QUrl("qrc:/qml/main.qml"));
110
111   view.showFullScreen();
112
113   int ret = app.exec();
114   return ret;
115 }