summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp55
1 files changed, 49 insertions, 6 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 7fdff20..11b1230 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -13,14 +13,57 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <QtAGLExtras/AGLApplication>
#include <QtQml/QQmlApplicationEngine>
+#include <QtGui/QGuiApplication>
+#include <QDebug>
+#include <QUrlQuery>
+#include <QCommandLineParser>
+#include <QtQml/QQmlContext>
+
int main(int argc, char *argv[])
{
- AGLApplication app(argc, argv);
- app.setApplicationName("VideoPlayer");
- app.setupApplicationRole("Video");
- app.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
- return app.exec();
+
+ setenv("QT_QPA_PLATFORM", "wayland", 1);
+ int port;
+ QString token;
+
+ QCommandLineParser parser;
+ QGuiApplication app(argc, argv);
+
+ parser.addPositionalArgument("port",
+ app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret",
+ app.translate("main", "secret for binding"));
+
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ if (positionalArguments.length() == 2) {
+ port = positionalArguments.takeFirst().toInt();
+ token = positionalArguments.takeFirst();
+ qInfo() << "setting port:" << port << ", token:" << token;
+ } else {
+ qInfo() << "Need to specify port and token";
+ exit(EXIT_FAILURE);
+ }
+
+ QUrl bindingAddress;
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), token);
+ bindingAddress.setQuery(query);
+
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
+ engine.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
+
+ return app.exec();
+
}