on a85cdba help sign in
unity8/tools/scopetool.cpp
84 lines 2.5 kB history raw
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * Authors:
5 * Gerry Boland <gerry.boland@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
20// Qt
21#include <QtQuick/QQuickView>
22#include <QtGui/QGuiApplication>
23#include <QtQml/QQmlEngine>
24#include <QtQml/QQmlContext>
25#include <QScopedPointer>
26#include <QDebug>
27#include <libintl.h>
30// local
31#include <paths.h>
32#include "registry-tracker.h"
35int main(int argc, char *argv[])
37 /* Workaround Qt platform integration plugin not advertising itself
38 as having the following capabilities:
39 - QPlatformIntegration::ThreadedOpenGL
40 - QPlatformIntegration::BufferQueueingOpenGL
41 */
42 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
43 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
45 QGuiApplication::setApplicationName("Unity Scope Tool");
46 QGuiApplication *application;
47 application = new QGuiApplication(argc, argv);
49 QStringList arguments = application->arguments();
50 QString scopesDir;
51 if (arguments.contains("--scope-dir")) {
52 int idx = arguments.indexOf("--scope-dir");
53 scopesDir = arguments[idx+1];
54 }
56 QScopedPointer<RegistryTracker> tracker;
57 if (!scopesDir.isEmpty()) {
58 tracker.reset(new RegistryTracker(scopesDir));
59 }
61 resolveIconTheme();
63 bindtextdomain("unity8", translationDirectory().toUtf8().data());
65 QQuickView* view = new QQuickView();
66 view->setResizeMode(QQuickView::SizeRootObjectToView);
67 view->setTitle(QGuiApplication::applicationName());
68 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
70 QUrl source(::qmlDirectory() + "ScopeTool.qml");
71 prependImportPaths(view->engine(), ::overrideImportPaths());
72 appendImportPaths(view->engine(), ::fallbackImportPaths());
74 view->setSource(source);
76 view->show();
78 int result = application->exec();
80 delete view;
81 delete application;
83 return result;