~canonical-platform-qa/ubuntu-system-settings/cchange_ringtone_tests

« back to all changes in this revision

Viewing changes to wizard/main.cpp

  • Committer: CI bot
  • Author(s): Gerry Boland, Michał Sawicz
  • Date: 2014-07-29 20:53:39 UTC
  • mfrom: (757.5.7 use-qtComp)
  • Revision ID: ps-jenkins@lists.canonical.com-20140729205339-feqv45dq86w2p2wv
Use QtMir instead of the older Unity-Mir

Need for Qt Compositor. 
Approved by: Michael Terry, Michael Zanetti

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    QProcess::startDetached("initctl start ubuntu-system-settings-wizard-cleanup");
36
36
}
37
37
 
38
 
int startShell(int argc, const char** argv, void* server)
 
38
int main(int argc, const char *argv[])
39
39
{
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 */);
 
43
        isMirServer = true;
 
44
    }
41
45
 
42
46
    QGuiApplication::setApplicationName("System Settings Wizard");
43
 
    QGuiApplication *application;
44
 
 
45
 
    if (isUbuntuMirServer) {
46
 
        QLibrary unityMir("unity-mir", 1);
47
 
        unityMir.load();
48
 
 
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";
53
 
            return 4;
54
 
        }
55
 
 
56
 
        application = createQMirServerApplication(argc, argv, server);
57
 
    } else {
58
 
        application = new QGuiApplication(argc, (char**)argv);
59
 
    }
 
47
    QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
60
48
 
61
49
    bindtextdomain(I18N_DOMAIN, NULL);
62
50
    textdomain(I18N_DOMAIN);
63
51
 
64
52
    QQuickView* view = new QQuickView();
65
53
    view->setResizeMode(QQuickView::SizeRootObjectToView);
66
 
    view->setTitle("Qml Phone Shell"); // Fake to be the shell
67
 
 
68
 
    QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
69
 
    nativeInterface->setProperty("session", 1); // system session, receives all input events
 
54
    view->setTitle("Welcome Wizard");
70
55
 
71
56
    QString rootDir = qgetenv("UBUNTU_SYSTEM_SETTINGS_WIZARD_ROOT"); // for testing
72
57
    if (rootDir.isEmpty())
73
58
        rootDir = WIZARD_ROOT;
74
59
 
75
 
    if (!isUbuntuMirServer) {
 
60
    if (!isMirServer) {
76
61
        view->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR "/Ubuntu/SystemSettings/Wizard/NonMir");
77
62
    }
78
63
    view->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
86
71
 
87
72
    QObject::connect(view->engine(), &QQmlEngine::quit, quitViaUpstart);
88
73
 
89
 
    if (isUbuntuMirServer) {
 
74
    if (isMirServer) {
90
75
        view->showFullScreen();
91
76
    } else {
92
77
        view->show();
98
83
    delete application;
99
84
    return result;
100
85
}
101
 
 
102
 
int main(int argc, const char *argv[])
103
 
{
104
 
    /* Workaround Qt platform integration plugin not advertising itself
105
 
       as having the following capabilities:
106
 
        - QPlatformIntegration::ThreadedOpenGL
107
 
        - QPlatformIntegration::BufferQueueingOpenGL
108
 
    */
109
 
    setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
110
 
    setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
111
 
 
112
 
    // For ubuntumirserver/ubuntumirclient
113
 
    if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
114
 
        setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
115
 
 
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);
120
 
        unityMir.load();
121
 
        if (!unityMir.isLoaded()) {
122
 
            qDebug() << "Library unity-mir not found/loaded";
123
 
            return 1;
124
 
        }
125
 
 
126
 
        class QMirServer;
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";
131
 
            return 2;
132
 
        }
133
 
 
134
 
        QMirServer* mirServer = createQMirServer(argc, argv);
135
 
 
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";
140
 
            return 3;
141
 
        }
142
 
 
143
 
        return runWithClient(mirServer, startShell);
144
 
    } else {
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
148
 
            raise(SIGSTOP);
149
 
        }
150
 
        return startShell(argc, argv, nullptr);
151
 
    }
152
 
}