~ci-train-bot/unity8/unity8-ubuntu-zesty-2481

« back to all changes in this revision

Viewing changes to tools/scopetool.cpp

  • Committer: Michal Hruby
  • Date: 2013-12-20 15:27:59 UTC
  • mto: This revision was merged to the branch mainline in revision 613.
  • Revision ID: michal.mhr@gmail.com-20131220152759-7o59l2oqwleinknu
Cherrypick the unity-scope-tool

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
19
 
 
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>
 
28
 
 
29
 
 
30
// local
 
31
#include <paths.h>
 
32
#include "registry-tracker.h"
 
33
 
 
34
 
 
35
int main(int argc, const char *argv[])
 
36
{
 
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);
 
44
 
 
45
    QGuiApplication::setApplicationName("Unity Scope Tool");
 
46
    QGuiApplication *application;
 
47
    application = new QGuiApplication(argc, (char**)argv);
 
48
 
 
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
    }
 
55
 
 
56
    QScopedPointer<RegistryTracker> tracker;
 
57
    if (!scopesDir.isEmpty()) {
 
58
        tracker.reset(new RegistryTracker(scopesDir));
 
59
    }
 
60
 
 
61
    resolveIconTheme();
 
62
 
 
63
    bindtextdomain("unity8", translationDirectory().toUtf8().data());
 
64
 
 
65
    QQuickView* view = new QQuickView();
 
66
    view->setResizeMode(QQuickView::SizeRootObjectToView);
 
67
    view->setTitle(QGuiApplication::applicationName());
 
68
    view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
 
69
 
 
70
    QUrl source(::qmlDirectory() + "ScopeTool.qml");
 
71
    prependImportPaths(view->engine(), ::overrideImportPaths());
 
72
    appendImportPaths(view->engine(), ::fallbackImportPaths());
 
73
 
 
74
    view->setSource(source);
 
75
 
 
76
    view->show();
 
77
 
 
78
    int result = application->exec();
 
79
 
 
80
    delete view;
 
81
    delete application;
 
82
 
 
83
    return result;
 
84
}