Skip to content

Commit

Permalink
make --opengl switch actually work (TM)
Browse files Browse the repository at this point in the history
  • Loading branch information
akdor1154 committed Mar 16, 2015
1 parent 296d276 commit 917641d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
41 changes: 35 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@

int main(int argc, char * argv[])
{
QApplication app(argc, argv);
app.setApplicationName("Qt WebEngine Kiosk");
QStringList qargv;
for (int i=0; i<argc; i++) {
qargv.append(QString(argv[i]));
}

//QApplication::setApplicationName("Qt WebEngine Kiosk");

QCommandLineParser parser;
parser.setApplicationDescription("A kiosk browser based on Qt's Chromium-derived WebEngine component");
parser.addHelpOption();
parser.addVersionOption();

QStringList glModes;
QMetaEnum glMode = MainWindow::staticMetaObject.enumerator(MainWindow::staticMetaObject.indexOfEnumerator("GlMode"));
for (int value = 0; value < glMode.keyCount(); value++) {
glModes.append(QString(glMode.valueToKey(value)));
QMetaEnum glModeEnum = MainWindow::staticMetaObject.enumerator(MainWindow::staticMetaObject.indexOfEnumerator("GlMode"));
for (int value = 0; value < glModeEnum.keyCount(); value++) {
glModes.append(QString(glModeEnum.valueToKey(value)));
}

QList<QCommandLineOption> options = QList<QCommandLineOption>({
Expand All @@ -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();
Expand Down
22 changes: 0 additions & 22 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit 917641d

Please sign in to comment.