From 917641d337df18f751a0c2e951b7daebc6276198 Mon Sep 17 00:00:00 2001 From: Jarrad Whitaker Date: Mon, 16 Mar 2015 12:00:09 +1100 Subject: [PATCH] make --opengl switch actually work (TM) --- src/main.cpp | 41 +++++++++++++++++++++++++++++++++++------ src/mainwindow.cpp | 22 ---------------------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c1e600b..5378a64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,8 +39,12 @@ int main(int argc, char * argv[]) { - QApplication app(argc, argv); - app.setApplicationName("Qt WebEngine Kiosk"); + QStringList qargv; + for (int i=0; i options = QList({ @@ -62,8 +66,33 @@ int main(int argc, char * argv[]) }); parser.addOptions(options); - parser.process(app); + parser.parse(qargv); + qDebug() << parser.errorText(); + QString glMode; + if ((glMode = parser.value("opengl")).isEmpty()) + glMode = "auto"; + switch (glModeEnum.keyToValue(glMode.toUpper().toLatin1())) { + case MainWindow::NATIVE: + QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); + qDebug() << "attempting to use native OpenGL"; + break; + case MainWindow::ANGLE: + QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); + qDebug() << "attempting to use OpenGL ES (or ANGLE, on Windows)"; + break; + case MainWindow::SOFTWARE: + qDebug() << "using software rendering"; + QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); + break; + case MainWindow::AUTO: + default: + qDebug() << "using automatic gl"; + break; + } + + QApplication app(argc, argv); + parser.process(app); MainWindow *browser = new MainWindow(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fe6e996..0acc676 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -177,29 +177,7 @@ void MainWindow::init(QCommandLineParser &options) manualScreen = ok ? monitorNum : 0; } - QMetaEnum glModeEnum = MainWindow::staticMetaObject.enumerator(MainWindow::staticMetaObject.indexOfEnumerator("GlMode")); - QString glMode; - if ((glMode = options.value("opengl")).isEmpty()) { - glMode = mainSettings->value("application/opengl_mode").toString(); - } - switch (glModeEnum.keyToValue(glMode.toUpper().toLatin1())) { - case NATIVE: - qApp->setAttribute(Qt::AA_UseDesktopOpenGL); - qDebug() << "attempting to use native OpenGL"; - break; - case ANGLE: - qApp->setAttribute(Qt::AA_UseOpenGLES); - qDebug() << "attempting to use OpenGL ES (or ANGLE, on Windows)"; - break; - case SOFTWARE: - qDebug() << "using software rendering"; - qApp->setAttribute(Qt::AA_UseSoftwareOpenGL); - break; - case AUTO: - default: - break; - } if (mainSettings->value("signals/enable").toBool()) { connect(handler, SIGNAL(sigUSR1()), SLOT(unixSignalUsr1()));