2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (C) 2016,2017 Konsulko Group
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include "pacontrolmodel.h"
21 #include <QtCore/QDebug>
22 #include <QtCore/QDir>
23 #include <QtCore/QStandardPaths>
24 #include <QtCore/QThread>
25 #include <QtGui/QGuiApplication>
26 #include <QtQml/QQmlApplicationEngine>
27 #include <QtQml/QQmlContext>
28 #include <QtQml/qqml.h>
29 #include <QtQuickControls2/QQuickStyle>
30 #include <QtQuick/qquickitem.h>
31 #include <QtQuick/qquickview.h>
34 #ifdef HAVE_LIBHOMESCREEN
35 #include <libhomescreen.hpp>
38 int main(int argc, char *argv[])
40 #ifdef HAVE_LIBHOMESCREEN
41 LibHomeScreen libHomeScreen;
43 if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
44 qWarning() << "renderAppToAreaAllowed is denied";
49 QGuiApplication app(argc, argv);
51 QQuickStyle::setStyle("AGL");
53 // Fire up PA client QThread
54 QThread* pat = new QThread;
55 PaClient* client = new PaClient();
56 client->moveToThread(pat);
59 // Register the PA Control Model
60 qmlRegisterType<PaControlModel>("PaControlModel", 1, 0, "PaControlModel");
62 QQmlApplicationEngine engine;
63 engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml")));
65 // Find the instantiated model QObject and connect the signals/slots
66 QList<QObject *> mobjs = engine.rootObjects();
67 PaControlModel *pacm = mobjs.first()->findChild<PaControlModel *>("pacm");
68 QObject::connect(client, SIGNAL(controlAdded(int, QString, int, int, const char *, int)),
69 pacm, SLOT(addOneControl(int, QString, int, int, const char *, int)));
70 QObject::connect(client, SIGNAL(volumeExternallyChanged(uint32_t, uint32_t, uint32_t, uint32_t)),
71 pacm, SLOT(changeExternalVolume(uint32_t, uint32_t, uint32_t, uint32_t)));
72 QObject::connect(pacm, SIGNAL(volumeChanged(uint32_t, uint32_t, uint32_t, uint32_t)),
73 client, SLOT(setVolume(uint32_t, uint32_t, uint32_t, uint32_t)));
75 // Initalize PA client