35
35
QProcess::startDetached("initctl start ubuntu-system-settings-wizard-cleanup");
38
int startShell(int argc, const char** argv, void* server)
38
int main(int argc, const char *argv[])
40
const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
40
bool isMirServer = false;
41
if (qgetenv("QT_QPA_PLATFORM") == "ubuntumirclient") {
42
setenv("QT_QPA_PLATFORM", "mirserver", 1 /* overwrite */);
42
46
QGuiApplication::setApplicationName("System Settings Wizard");
43
QGuiApplication *application;
45
if (isUbuntuMirServer) {
46
QLibrary unityMir("unity-mir", 1);
49
typedef QGuiApplication* (*createServerApplication_t)(int&, const char **, void*);
50
createServerApplication_t createQMirServerApplication = (createServerApplication_t) unityMir.resolve("createQMirServerApplication");
51
if (!createQMirServerApplication) {
52
qDebug() << "unable to resolve symbol: createQMirServerApplication";
56
application = createQMirServerApplication(argc, argv, server);
58
application = new QGuiApplication(argc, (char**)argv);
47
QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
61
49
bindtextdomain(I18N_DOMAIN, NULL);
62
50
textdomain(I18N_DOMAIN);
64
52
QQuickView* view = new QQuickView();
65
53
view->setResizeMode(QQuickView::SizeRootObjectToView);
66
view->setTitle("Qml Phone Shell"); // Fake to be the shell
68
QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
69
nativeInterface->setProperty("session", 1); // system session, receives all input events
54
view->setTitle("Welcome Wizard");
71
56
QString rootDir = qgetenv("UBUNTU_SYSTEM_SETTINGS_WIZARD_ROOT"); // for testing
72
57
if (rootDir.isEmpty())
73
58
rootDir = WIZARD_ROOT;
75
if (!isUbuntuMirServer) {
76
61
view->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR "/Ubuntu/SystemSettings/Wizard/NonMir");
78
63
view->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
98
83
delete application;
102
int main(int argc, const char *argv[])
104
/* Workaround Qt platform integration plugin not advertising itself
105
as having the following capabilities:
106
- QPlatformIntegration::ThreadedOpenGL
107
- QPlatformIntegration::BufferQueueingOpenGL
109
setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
110
setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
112
// For ubuntumirserver/ubuntumirclient
113
if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
114
setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
116
// If we use unity-mir directly, we automatically link to the Mir-server
117
// platform-api bindings, which result in unexpected behaviour when
118
// running the non-Mir scenario.
119
QLibrary unityMir("unity-mir", 1);
121
if (!unityMir.isLoaded()) {
122
qDebug() << "Library unity-mir not found/loaded";
127
typedef QMirServer* (*createServer_t)(int, const char **);
128
createServer_t createQMirServer = (createServer_t) unityMir.resolve("createQMirServer");
129
if (!createQMirServer) {
130
qDebug() << "unable to resolve symbol: createQMirServer";
134
QMirServer* mirServer = createQMirServer(argc, argv);
136
typedef int (*runWithClient_t)(QMirServer*, std::function<int(int, const char**, void*)>);
137
runWithClient_t runWithClient = (runWithClient_t) unityMir.resolve("runQMirServerWithClient");
138
if (!runWithClient) {
139
qDebug() << "unable to resolve symbol: runWithClient";
143
return runWithClient(mirServer, startShell);
145
if (qgetenv("UPSTART_JOB") == "unity8") {
146
// Emit SIGSTOP as expected by upstart, under Mir it's unity-mir that will raise it.
147
// see http://upstart.ubuntu.com/cookbook/#expect-stop
150
return startShell(argc, argv, nullptr);