2 * Copyright (C) 2014-2016 Canonical, Ltd.
5 * Michael Zanetti <michael.zanetti@canonical.com>
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.
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.
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/>.
20#include <QtQuick/QQuickView>
21#include <QtGui/QGuiApplication>
22#include <QtQml/QQmlEngine>
23#include <QtQml/QQmlContext>
25#include <QCommandLineParser>
28#include <QQmlApplicationEngine>
30#include <QLibraryInfo>
34#include "../qmldebuggerutils.h"
35#ifdef UNITY8_ENABLE_TOUCH_EMULATION
36 #include "../MouseTouchAdaptor.h"
38#include "../CachingNetworkManagerFactory.h"
39#include "../UnixSignalHandler.h"
41int main(int argc, const char *argv[])
43 qSetMessagePattern("[%{time yyyy-MM-dd:hh:mm:ss.zzz}] %{if-category}%{category}: %{endif}%{message}");
44 if (enableQmlDebugger(argc, argv)) {
45 QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
48 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
50 QCommandLineParser parser;
51 parser.setApplicationDescription(QStringLiteral("Description: Unity 8 Shell Dash"));
52 parser.addHelpOption();
54 QCommandLineOption mousetouchOption(QStringLiteral("mousetouch"),
55 QStringLiteral("Allow the mouse to provide touch input"));
56 parser.addOption(mousetouchOption);
58 QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral("windowgeometry"),
59 QStringLiteral("Specify the window geometry as [<width>x<height>]"), QStringLiteral("windowgeometry"), QStringLiteral("1"));
60 parser.addOption(windowGeometryOption);
62 // FIXME Remove once we drop the need of the hint
63 QCommandLineOption desktopFileHintOption(QStringLiteral("desktop_file_hint"),
64 QStringLiteral("The desktop_file_hint option for QtMir"), QStringLiteral("hint_file"));
65 parser.addOption(desktopFileHintOption);
67 // Treat args with single dashes the same as arguments with two dashes
68 // Ex: -fullscreen == --fullscreen
69 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
70 parser.process(*application);
72 if (getenv("QT_LOAD_TESTABILITY")) {
73 QLibrary testLib(QStringLiteral("qttestability"));
75 typedef void (*TasInitialize)(void);
76 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
80 qCritical("Library qttestability resolve failed!");
83 qCritical("Library qttestability load failed!");
87 QTranslator qtTranslator;
88 if (qtTranslator.load(QLocale(), QStringLiteral("qt_"), qgetenv("SNAP"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
89 application->installTranslator(&qtTranslator);
92 bindtextdomain("unity8", translationDirectory().toUtf8().data());
95 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
96 // You will need this if you want to interact with touch-only components using a mouse
97 // Needed only when manually testing on a desktop.
98 MouseTouchAdaptor *mouseTouchAdaptor = 0;
99 if (parser.isSet(mousetouchOption)) {
100 mouseTouchAdaptor = MouseTouchAdaptor::instance();
104 QQmlApplicationEngine *engine = new QQmlApplicationEngine(application);
106 int initialWidth = -1;
107 int initialHeight = -1;
108 if (parser.isSet(windowGeometryOption) &&
109 parser.value(windowGeometryOption).split('x').size() == 2)
111 QStringList geom = parser.value(windowGeometryOption).split('x');
112 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
113 if (windowSize.isValid()) {
114 initialWidth = windowSize.width();
115 initialHeight = windowSize.height();
118 engine->rootContext()->setContextProperty("initialWidth", initialWidth);
119 engine->rootContext()->setContextProperty("initialHeight", initialHeight);
121 QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
122 prependImportPaths(engine, ::overrideImportPaths());
123 appendImportPaths(engine, ::fallbackImportPaths());
125 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
126 engine->setNetworkAccessManagerFactory(managerFactory);
128 engine->load(source);
130 UnixSignalHandler signalHandler([]{
131 QGuiApplication::exit(0);
133 signalHandler.setupUnixSignalHandlers();
135 int result = application->exec();
139 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
140 delete mouseTouchAdaptor;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list