on f621663 help sign in
unity8/tools/scopetool.cpp
102 lines 3.6 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 <QCommandLineParser>
28#include <QCommandLineOption>
29#include <libintl.h>
32// local
33#include <paths.h>
34#include "registry-tracker.h"
37int main(int argc, char *argv[])
39 /* Workaround Qt platform integration plugin not advertising itself
40 as having the following capabilities:
41 - QPlatformIntegration::ThreadedOpenGL
42 - QPlatformIntegration::BufferQueueingOpenGL
43 */
44 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
45 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
47 QGuiApplication::setApplicationName("Unity Scope Tool");
48 QGuiApplication *application;
49 application = new QGuiApplication(argc, argv);
51 QCommandLineParser parser;
52 parser.setApplicationDescription("Unity Scope Tool\n\n"
53 "This tool allows development and testing of scopes. Running it without\n"
54 "any arguments will open a session to all scopes available on the system.\n"
55 "Otherwise passing a path to a scope config file will open a session with\n"
56 "only that scope (assuming that the binary implementing the scope can be\n"
57 "found in the same directory as the config file).");
58 parser.addHelpOption();
59 parser.addPositionalArgument("scopes", "Paths to scope config files to spawn, optionally.", "[scopes...]");
61 QCommandLineOption includeSystemScopes("include-system-scopes",
62 "Initialize the registry with scopes installed on this system");
63 QCommandLineOption includeServerScopes("include-server-scopes",
64 "Initialize the registry with scopes on the default server");
66 parser.addOption(includeServerScopes);
67 parser.addOption(includeSystemScopes);
69 parser.process(*application);
71 QStringList extraScopes = parser.positionalArguments();
73 QScopedPointer<RegistryTracker> tracker;
74 if (!extraScopes.isEmpty()) {
75 bool systemScopes = parser.isSet(includeSystemScopes);
76 bool serverScopes = parser.isSet(includeServerScopes);
77 tracker.reset(new RegistryTracker(extraScopes, systemScopes, serverScopes));
78 }
80 bindtextdomain("unity8", translationDirectory().toUtf8().data());
82 QQuickView* view = new QQuickView();
83 view->setResizeMode(QQuickView::SizeRootObjectToView);
84 view->setTitle(QGuiApplication::applicationName());
85 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
87 QUrl source(::qmlDirectory() + "ScopeTool.qml");
88 prependImportPaths(view->engine(), ::overrideImportPaths());
89 prependImportPaths(view->engine(), ::nonMirImportPaths());
90 appendImportPaths(view->engine(), ::fallbackImportPaths());
92 view->setSource(source);
94 view->show();
96 int result = application->exec();
98 delete view;
99 delete application;
101 return result;