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-10-13 15:38:31 +01:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
2018-10-23 11:37:51 +01:00
|
|
|
#include <QProcessEnvironment>
|
2018-10-30 11:05:31 +00:00
|
|
|
#include "fileopendialog.h"
|
|
|
|
#include "filesavedialog.h"
|
|
|
|
#include "mpvobject.h"
|
2018-10-13 15:38:31 +01:00
|
|
|
|
|
|
|
int main( int argc, char *argv[] )
|
|
|
|
{
|
2018-10-30 15:54:17 +00:00
|
|
|
#ifdef __linux__
|
2018-10-29 14:19:12 +00:00
|
|
|
setenv("QT_QPA_PLATFORMTHEME", "gtk3", 0);
|
2018-10-28 14:56:54 +00:00
|
|
|
setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1);
|
2018-10-30 15:50:39 +00:00
|
|
|
#endif
|
2018-10-13 15:38:31 +01:00
|
|
|
QApplication app(argc, argv);
|
2018-10-24 17:41:41 +01:00
|
|
|
app.setOrganizationName("KittehPlayer");
|
|
|
|
app.setOrganizationDomain("namedkitten.pw");
|
|
|
|
app.setApplicationName("KittehPlayer");
|
2018-10-23 11:37:51 +01:00
|
|
|
|
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (!qstrcmp(argv[i], "--update")) {
|
2018-10-23 13:43:27 +01:00
|
|
|
QString program = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + "/usr/bin/appimageupdatetool";
|
2018-10-23 11:37:51 +01:00
|
|
|
QProcess updater;
|
|
|
|
updater.setProcessChannelMode(QProcess::ForwardedChannels);
|
|
|
|
updater.start(program, QStringList() << QProcessEnvironment::systemEnvironment().value("APPIMAGE", ""));
|
2018-10-23 14:57:06 +01:00
|
|
|
updater.waitForFinished();
|
2018-10-23 11:37:51 +01:00
|
|
|
qDebug() << program;
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-23 23:56:24 +01:00
|
|
|
QProcess dpms;
|
|
|
|
dpms.start("xset", QStringList() << "-dpms");
|
|
|
|
|
2018-10-30 15:54:17 +00:00
|
|
|
#ifdef __linux__
|
2018-10-27 17:05:14 +01:00
|
|
|
QString newpath = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + "/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", "");
|
2018-10-28 14:56:54 +00:00
|
|
|
qDebug() << newpath;
|
2018-10-30 15:50:39 +00:00
|
|
|
setenv("PATH", newpath.toUtf8().constData(), 1);
|
|
|
|
#endif
|
2018-10-29 14:19:12 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL );
|
2018-10-13 15:38:31 +01:00
|
|
|
qmlRegisterType<MpvObject>("player", 1, 0, "MpvObject");
|
2018-10-29 14:19:12 +00:00
|
|
|
qmlRegisterType<FileOpenDialog>("player", 1, 0, "FileOpenDialog");
|
|
|
|
qmlRegisterType<FileSaveDialog>("player", 1, 0, "FileSaveDialog");
|
2018-10-13 15:38:31 +01:00
|
|
|
|
|
|
|
std::setlocale(LC_NUMERIC, "C");
|
|
|
|
|
|
|
|
/*QQuickView *view = new QQuickView();
|
|
|
|
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
|
|
|
view->setSource(QUrl("qrc:///player/main.qml"));
|
|
|
|
view->show();*/
|
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
2018-10-27 16:11:29 +01:00
|
|
|
#ifdef QRC_SOURCE_PATH
|
|
|
|
RuntimeQML *rt = new RuntimeQML(&engine, QRC_SOURCE_PATH"/qml.qrc");
|
|
|
|
|
|
|
|
rt->setAutoReload(true);
|
|
|
|
rt->setMainQmlFilename("main.qml");
|
|
|
|
rt->reload();
|
|
|
|
#else
|
|
|
|
engine.load(QUrl(QStringLiteral("qrc:///player/main.qml")));
|
|
|
|
#endif
|
|
|
|
|
2018-10-13 15:38:31 +01:00
|
|
|
return app.exec();
|
|
|
|
}
|