66#include < QQmlContext>
77#include < QSettings>
88#include < QMessageBox>
9+ #include < QQuickWindow>
910#include < easylogging++.h>
1011#include < qredisclient/redisclient.h>
1112
@@ -38,6 +39,7 @@ Application::Application(int &argc, char **argv)
3839 // Init components required for models and qml
3940 initLog ();
4041 initAppInfo ();
42+ processCmdArgs ();
4143 initAppFonts ();
4244 initRedisClient ();
4345 initUpdater ();
@@ -121,10 +123,34 @@ void Application::registerQmlRootObjects()
121123}
122124
123125void Application::initQml ()
124- {
126+ {
127+ if (m_renderingBackend == " auto" ) {
128+ #ifdef Q_OS_WIN
129+ // Experimental
130+ // Use DirectX 12 on Windows 10
131+ if (QSysInfo::productVersion () == " 10" ) {
132+ QQuickWindow::setSceneGraphBackend (QSGRendererInterface::Direct3D12);
133+ } else {
134+ // Use software renderer on older versions
135+ QQuickWindow::setSceneGraphBackend (QSGRendererInterface::Software);
136+ }
137+ #endif
138+ } else {
139+ QQuickWindow::setSceneGraphBackend (m_renderingBackend);
140+ }
141+
125142 registerQmlTypes ();
126143 registerQmlRootObjects ();
127- m_engine.load (QUrl (QStringLiteral (" qrc:///app.qml" )));
144+
145+ try {
146+ m_engine.load (QUrl (QStringLiteral (" qrc:///app.qml" )));
147+ } catch (...) {
148+ qDebug () << " Failed to load app window. Retrying with software renderer..." ;
149+ QQuickWindow::setSceneGraphBackend (QSGRendererInterface::Software);
150+ m_engine.load (QUrl (QStringLiteral (" qrc:///app.qml" )));
151+ }
152+
153+ qDebug () << " Rendering backend:" << QQuickWindow::sceneGraphBackend ();
128154}
129155
130156void Application::initLog ()
@@ -148,19 +174,8 @@ void Application::initLog()
148174
149175void Application::initConnectionsManager ()
150176{
151- // Parse optional arguments first
152- QCommandLineParser parser;
153- QCommandLineOption settingsDir (
154- " settings-dir" ,
155- " (Optional) Directory where RDM looks/saves .rdm directory with connections.json file" ,
156- " settingsDir" ,
157- QDir::homePath ()
158- );
159- parser.addOption (settingsDir);
160- parser.process (*this );
161-
162177 // connection manager
163- ConfigManager confManager (parser. value (settingsDir) );
178+ ConfigManager confManager (m_settingsDir );
164179 if (confManager.migrateOldConfig (" connections.xml" , " connections.json" )) {
165180 LOG (INFO) << " Migrate connections.xml to connections.json" ;
166181 }
@@ -236,6 +251,31 @@ void Application::installTranslator()
236251 }
237252}
238253
254+ void Application::processCmdArgs ()
255+ {
256+ QCommandLineParser parser;
257+ QCommandLineOption settingsDir (
258+ " settings-dir" ,
259+ " (Optional) Directory where RDM looks/saves .rdm directory with connections.json file" ,
260+ " settingsDir" ,
261+ QDir::homePath ()
262+ );
263+ QCommandLineOption renderingBackend (
264+ " rendering-backend" ,
265+ " (Optional) QML rendering backend [software|opengl|d3d12|'']" ,
266+ " renderingBackend" ,
267+ " auto"
268+ );
269+ parser.addHelpOption ();
270+ parser.addVersionOption ();
271+ parser.addOption (settingsDir);
272+ parser.addOption (renderingBackend);
273+ parser.process (*this );
274+
275+ m_settingsDir = parser.value (settingsDir);
276+ m_renderingBackend = parser.value (renderingBackend);
277+ }
278+
239279void Application::OnNewUpdateAvailable (QString &url)
240280{
241281 QMessageBox::information (nullptr , " New update available" ,
0 commit comments