diff options
author | Sami Nurmenniemi <sami.nurmenniemi@qt.io> | 2018-09-20 15:20:51 +0300 |
---|---|---|
committer | Sami Nurmenniemi <sami.nurmenniemi@qt.io> | 2018-09-21 06:18:29 +0000 |
commit | b3cc14bd1d8717dbdb6e538aaa330a2733ba2d1f (patch) | |
tree | 2b7e3063eba26a9128724bd0310c1104a0bac0e7 | |
parent | ce4d3833f5193168fb61392d08f61e73997632eb (diff) |
Use Material style only on devices with gpu
Fixes: QTBUG-70493
Change-Id: I7fad1c5d46fc5741e5831a72e189f4a8c2b1dfd1
Reviewed-by: Kari Hormi <kari.hormi@qt.io>
-rw-r--r-- | src/engine.cpp | 14 | ||||
-rw-r--r-- | src/engine.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 9 |
3 files changed, 16 insertions, 9 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index b30e75a..c29a61c 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -56,7 +56,7 @@ Engine::Engine(QQuickItem *parent) , m_intro_done(false) , m_apps_ready(false) , m_fps_enabled(false) - , m_glAvailable(true) + , m_glAvailable(checkForGlAvailability()) { m_state = ENGINE_STATE_RUNNING; @@ -74,13 +74,13 @@ Engine::Engine(QQuickItem *parent) m_screenHeight = m_screenSize.height(); connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(windowChanged(QQuickWindow*))); +} - //Check for software renderer - QString renderer = qgetenv("QMLSCENE_DEVICE"); - if (renderer.toLower() == "softwarecontext") { - m_glAvailable = false; - emit glAvailableChanged(false); - } +bool Engine::checkForGlAvailability() +{ + QQuickWindow window; + return ((window.sceneGraphBackend() != "software") && + (window.sceneGraphBackend() != "softwarecontext")); } void Engine::updateReadyness() diff --git a/src/engine.h b/src/engine.h index 608f34f..c65f431 100644 --- a/src/engine.h +++ b/src/engine.h @@ -75,6 +75,8 @@ public: QString applicationName() const { return m_applicationName; } QString applicationDescription() const { return m_applicationDescription; } + static bool checkForGlAvailability(); + Q_INVOKABLE QUrl fromUserInput(const QString& userInput) { return QUrl::fromUserInput(userInput); } Q_INVOKABLE int sensibleButtonSize() const; Q_INVOKABLE int titleBarSize() const; diff --git a/src/main.cpp b/src/main.cpp index 2500a4a..54d406e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -129,10 +129,15 @@ int main(int argc, char **argv) QtSquareImageProvider squareImageProvider; QtImageMaskProvider imageMaskProvider; + // Material style can be set only for devices supporting GL QSettings styleSettings; QString style = styleSettings.value("style").toString(); - if (style.isEmpty() || style == "Default") - styleSettings.setValue("style", "Material"); + if (Engine::checkForGlAvailability()) { + if (style.isEmpty() || style == "Default") + styleSettings.setValue("style", "Material"); + } else { + qDebug()<<"No GL available, skipping Material style"; + } QQuickStyle::setStyle(styleSettings.value("style").toString()); QSettings launcherSettings("QtLauncher", "colorSettings"); |