1
0
Fork 0
VideoPlayer/src/main.cpp

72 lines
2.2 KiB
C++

#ifdef QRC_SOURCE_PATH
#include "runtimeqml/runtimeqml.h"
#endif
#include <cstdlib>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QProcessEnvironment>
#include "fileopendialog.h"
#include "filesavedialog.h"
#include "mpvobject.h"
int main( int argc, char *argv[] )
{
#ifdef __linux__
setenv("QT_QPA_PLATFORMTHEME", "gtk3", 0);
setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1);
#endif
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);
}
}
QProcess dpms;
dpms.start("xset", QStringList() << "-dpms");
#ifdef __linux__
QString newpath = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + "/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", "");
qDebug() << newpath;
setenv("PATH", newpath.toUtf8().constData(), 1);
#endif
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL );
qmlRegisterType<MpvObject>("player", 1, 0, "MpvObject");
qmlRegisterType<FileOpenDialog>("player", 1, 0, "FileOpenDialog");
qmlRegisterType<FileSaveDialog>("player", 1, 0, "FileSaveDialog");
std::setlocale(LC_NUMERIC, "C");
/*QQuickView *view = new QQuickView();
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->setSource(QUrl("qrc:///player/main.qml"));
view->show();*/
QQmlApplicationEngine engine;
#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
return app.exec();
}