2018-10-27 16:11:29 +01:00
|
|
|
#ifdef QRC_SOURCE_PATH
|
|
|
|
#include "runtimeqml/runtimeqml.h"
|
|
|
|
#endif
|
2018-10-13 15:38:31 +01:00
|
|
|
|
2018-10-30 15:38:29 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
#include "MpvPlayerBackend.h"
|
2018-10-13 15:38:31 +01:00
|
|
|
#include <QApplication>
|
2018-10-23 11:37:51 +01:00
|
|
|
#include <QProcessEnvironment>
|
2018-11-06 07:39:42 +00:00
|
|
|
#include <QQmlApplicationEngine>
|
2018-10-13 15:38:31 +01:00
|
|
|
|
2018-10-31 07:53:38 +00:00
|
|
|
#ifdef WIN32
|
2018-10-30 16:16:53 +00:00
|
|
|
#include "setenv_mingw.hpp"
|
|
|
|
#endif
|
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
2018-10-13 15:38:31 +01:00
|
|
|
{
|
2018-11-06 07:39:42 +00:00
|
|
|
setenv("QT_QUICK_CONTROLS_STYLE", "Desktop", 1);
|
|
|
|
QApplication app(argc, argv);
|
|
|
|
app.setOrganizationName("KittehPlayer");
|
|
|
|
app.setOrganizationDomain("namedkitten.pw");
|
|
|
|
app.setApplicationName("KittehPlayer");
|
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (!qstrcmp(argv[i], "--update")) {
|
|
|
|
QString program =
|
|
|
|
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
|
|
|
"/usr/bin/appimageupdatetool";
|
|
|
|
QProcess updater;
|
|
|
|
updater.setProcessChannelMode(QProcess::ForwardedChannels);
|
|
|
|
updater.start(program,
|
|
|
|
QStringList()
|
|
|
|
<< QProcessEnvironment::systemEnvironment().value(
|
|
|
|
"APPIMAGE", ""));
|
|
|
|
updater.waitForFinished();
|
|
|
|
qDebug() << program;
|
|
|
|
exit(0);
|
2018-10-23 11:37:51 +01:00
|
|
|
}
|
2018-11-06 07:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QProcess dpms;
|
|
|
|
dpms.start("xset", QStringList() << "-dpms");
|
|
|
|
|
|
|
|
QString newpath =
|
|
|
|
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
|
|
|
"/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", "");
|
|
|
|
qDebug() << newpath;
|
|
|
|
setenv("PATH", newpath.toUtf8().constData(), 1);
|
2018-10-23 23:56:24 +01:00
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
2018-10-31 07:53:38 +00:00
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_NativeWindows);
|
|
|
|
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
|
|
|
std::setlocale(LC_NUMERIC, "C");
|
2018-10-13 15:38:31 +01:00
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
QQmlApplicationEngine engine;
|
2018-10-27 16:11:29 +01:00
|
|
|
#ifdef QRC_SOURCE_PATH
|
2018-11-06 07:39:42 +00:00
|
|
|
RuntimeQML* rt = new RuntimeQML(&engine, QRC_SOURCE_PATH "/qml.qrc");
|
2018-10-27 16:11:29 +01:00
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
rt->setAutoReload(true);
|
|
|
|
rt->setMainQmlFilename("main.qml");
|
|
|
|
rt->reload();
|
2018-10-27 16:11:29 +01:00
|
|
|
#else
|
2018-11-06 07:39:42 +00:00
|
|
|
engine.load(QUrl(QStringLiteral("qrc:///player/main.qml")));
|
2018-10-27 16:11:29 +01:00
|
|
|
#endif
|
|
|
|
|
2018-11-06 07:39:42 +00:00
|
|
|
return app.exec();
|
2018-10-13 15:38:31 +01:00
|
|
|
}
|