mediaplayer: playlistwithmetadata: remove unused playlist code
[apps/mediaplayer.git] / app / main.cpp
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <QtCore/QCommandLineParser>
18 #include <QtCore/QDebug>
19 #include <QtCore/QDir>
20 #include <QtCore/QStandardPaths>
21 #include <QtCore/QUrlQuery>
22 #include <QtGui/QGuiApplication>
23 #include <QtQml/QQmlApplicationEngine>
24 #include <QtQml/QQmlContext>
25 #include <QtQml/qqml.h>
26 #include <QtQuickControls2/QQuickStyle>
27
28 #ifdef HAVE_LIBHOMESCREEN
29 #include <libhomescreen.hpp>
30 #endif
31
32 int main(int argc, char *argv[])
33 {
34 #ifdef HAVE_LIBHOMESCREEN
35     LibHomeScreen libHomeScreen;
36
37     if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
38         qWarning() << "renderAppToAreaAllowed is denied";
39         return -1;
40     }
41 #endif
42
43     QGuiApplication app(argc, argv);
44
45     QQuickStyle::setStyle("AGL");
46
47     QQmlApplicationEngine engine;
48     QQmlContext *context = engine.rootContext();
49
50     QCommandLineParser parser;
51     parser.addPositionalArgument("port", app.translate("main", "port for binding"));
52     parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
53     parser.addHelpOption();
54     parser.addVersionOption();
55     parser.process(app);
56     QStringList positionalArguments = parser.positionalArguments();
57
58     if (positionalArguments.length() == 2) {
59         int port = positionalArguments.takeFirst().toInt();
60         QString secret = positionalArguments.takeFirst();
61         QUrl bindingAddress;
62         bindingAddress.setScheme(QStringLiteral("ws"));
63         bindingAddress.setHost(QStringLiteral("localhost"));
64         bindingAddress.setPort(port);
65         bindingAddress.setPath(QStringLiteral("/api"));
66         QUrlQuery query;
67         query.addQueryItem(QStringLiteral("token"), secret);
68         bindingAddress.setQuery(query);
69         context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
70     }
71
72     engine.load(QUrl(QStringLiteral("qrc:/MediaPlayer.qml")));
73
74     return app.exec();
75 }