X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=src%2Fmain.cpp;h=abfad897cb3a32ebb433bb800ada53e1a5173190;hb=f64ec59e63bc8379b80393ff7c8e241e448e8234;hp=f49dab19c0e19ec9426c37ce5224bc620132f73f;hpb=73bb83f1b7216276411bf79508f7e367b266e50f;p=harmattan%2Fcameraplus diff --git a/src/main.cpp b/src/main.cpp index f49dab1..abfad89 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * Copyright (C) 2012-2013 Mohammed Sameer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,82 +18,146 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#if defined(QT4) #include #include #include #include #include #include -#include - -#include "imports/plugin.h" +#elif defined(QT5) +#include +#include +#include +#endif #include "settings.h" #include "filenaming.h" +#ifdef HARMATTAN #include "quillitem.h" +#endif +#include "geocode.h" +#include "deviceinfo.h" +#include "soundvolumecontrol.h" #include "displaystate.h" #include "fsmonitor.h" #include "cameraresources.h" #include "compass.h" #include "orientation.h" -#include "geocode.h" #include "mountprotector.h" #include "trackerstore.h" #include "focusrectangle.h" #include "sharehelper.h" #include "deletehelper.h" #include "galleryhelper.h" +#include "postcapturemodel.h" +#include "batteryinfo.h" +#include "gridlines.h" +#include "devicekeys.h" +#include "platformsettings.h" +#include "dbusservice.h" +#include -static void initQuill() { - // TODO: All these are hardcoded. - Quill::setPreviewLevelCount(1); - Quill::setPreviewSize(0, QSize(854, 480)); - Quill::setMinimumPreviewSize(0, QSize(854, 480)); - Quill::setThumbnailExtension("jpeg"); - Quill::setThumbnailFlavorName(0, "screen"); - Quill::setBackgroundRenderingColor(Qt::black); - QString tempPath(QDir::homePath() + QDir::separator() + ".config" + - QDir::separator() + "quill" + QDir::separator() + "tmp"); - QDir().mkpath(tempPath); - Quill::setTemporaryFilePath(tempPath); - Quill::setDBusThumbnailingEnabled(true); - Quill::setThumbnailCreationEnabled(true); -} +#ifdef QMLJSDEBUGGER +#include "qt_private/qdeclarativedebughelper_p.h" +#endif /* QMLJSDEBUGGER */ + +#if defined(QT4) +#include +#include "qmlfileengine.h" + +class QmlFileEngineHandler : public QAbstractFileEngineHandler { + QAbstractFileEngine *create(const QString& fileName) const { + QString fn = fileName.toLower(); + if (fn.startsWith(':') && fn.endsWith(".qml")) { + return new QmlFileEngine(fileName); + } + + return 0; + } +}; +#endif Q_DECL_EXPORT int main(int argc, char *argv[]) { +#if defined(QT4) QApplication::setAttribute(Qt::AA_X11InitThreads, true); - QApplication app(argc, argv); + QApplication *app = new QApplication(argc, argv); + + QmlFileEngineHandler handler; + Q_UNUSED(handler); + + QDeclarativeView *view = MDeclarativeCache::qDeclarativeView(); +#elif defined(QT5) + QGuiApplication *app = MDeclarativeCache::qApplication(argc, argv); + QQuickView *view = MDeclarativeCache::qQuickView(); +#endif - // Let's initialize Quill: - initQuill(); +#ifdef QMLJSDEBUGGER + QDeclarativeDebugHelper::enableDebugging(); +#endif /* QMLJSDEBUGGER */ - QDeclarativeView view; - view.setViewport(new QGLWidget); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); +#if defined(QT4) + view->setAttribute(Qt::WA_NoSystemBackground); + view->setViewport(new QGLWidget); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + view->viewport()->setAttribute(Qt::WA_NoSystemBackground); +#endif + +#if defined(QT5) + view->setResizeMode(QQuickView::SizeRootObjectToView); + // TODO: +#endif - Plugin::registerTypes(view.engine()); qmlRegisterType("CameraPlus", 1, 0, "Settings"); qmlRegisterType("CameraPlus", 1, 0, "FileNaming"); +#ifdef HARMATTAN qmlRegisterType("CameraPlus", 1, 0, "QuillItem"); +#endif + qmlRegisterType("CameraPlus", 1, 0, "ReverseGeocode"); + qmlRegisterType("CameraPlus", 1, 0, "DeviceInfo"); + qmlRegisterType("CameraPlus", 1, 0, "SoundVolumeControl"); qmlRegisterType("CameraPlus", 1, 0, "DisplayState"); qmlRegisterType("CameraPlus", 1, 0, "FSMonitor"); qmlRegisterType("CameraPlus", 1, 0, "CameraResources"); - qmlRegisterType("CameraPlus", 1, 0, "Compass"); - qmlRegisterType("CameraPlus", 1, 0, "Orientation"); - qmlRegisterType("CameraPlus", 1, 0, "ReverseGeocode"); + qmlRegisterType("CameraPlus", 1, 0, "CameraCompass"); + qmlRegisterType("CameraPlus", 1, 0, "CameraOrientation"); qmlRegisterType("CameraPlus", 1, 0, "MountProtector"); qmlRegisterType("CameraPlus", 1, 0, "TrackerStore"); qmlRegisterType("CameraPlus", 1, 0, "FocusRectangle"); qmlRegisterType("CameraPlus", 1, 0, "ShareHelper"); qmlRegisterType("CameraPlus", 1, 0, "DeleteHelper"); qmlRegisterType("CameraPlus", 1, 0, "GalleryHelper"); + qmlRegisterType("CameraPlus", 1, 0, "PostCaptureModel"); + qmlRegisterType("CameraPlus", 1, 0, "BatteryInfo"); + qmlRegisterType("CameraPlus", 1, 0, "GridLines"); + qmlRegisterType("CameraPlus", 1, 0, "DeviceKeys"); + qmlRegisterType("CameraPlus", 1, 0, "PlatformSettings"); + + view->setSource(QUrl("qrc:/qml/main.qml")); + +#if defined(QT5) + if (view->status() == QQuickView::Error) { + qCritical() << "Errors loading QML:"; + QList errors = view->errors(); + + foreach (const QQmlError& error, errors) { + qCritical() << error.toString(); + } + + delete view; + delete app; + + return 1; + } +#endif + + view->showFullScreen(); - QUrl sourceUrl = QUrl::fromLocalFile(QDir::currentPath() + "/main.qml"); - view.setSource(sourceUrl); + int ret = app->exec(); - view.showFullScreen(); + delete view; + delete app; - int ret = app.exec(); return ret; }