summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikko Gronoff <mikko.gronoff@qt.io>2018-09-21 10:17:52 +0300
committerMikko Gronoff <mikko.gronoff@qt.io>2018-09-21 10:20:20 +0300
commitcd36ba030e95688c453873df5b391a5f847d562a (patch)
tree0aef28b4732fa6e8491ff8cb4cf8acd3dce96fdb
parent3ac7e7975a7e70dc42558a83dd7a24baf1992c8b (diff)
parentee06ee8e32d5512d69c4425ae7984410ee5afe5e (diff)
Merge remote-tracking branch 'origin/5.11' into 5.12
* origin/5.11: ee06ee8 Use a smoother looping animation in loading indicator f8e7d81 media player: change default video b3cc14b Use Material style only on devices with gpu Change-Id: I097552a1d935e527f786cc160a322441be3ea167
-rw-r--r--qml/BusyIndicator.qml31
-rw-r--r--src/circularindicator.cpp18
-rw-r--r--src/circularindicator.h10
-rw-r--r--src/engine.cpp14
-rw-r--r--src/engine.h2
-rw-r--r--src/main.cpp13
6 files changed, 48 insertions, 40 deletions
diff --git a/qml/BusyIndicator.qml b/qml/BusyIndicator.qml
index f2c9d80..2d45ef6 100644
--- a/qml/BusyIndicator.qml
+++ b/qml/BusyIndicator.qml
@@ -39,43 +39,44 @@ CircularIndicator {
SequentialAnimation {
running: true
- // Fill 1/5 of the circle before starting looping
+ // Fill 20 degrees of the circle before starting looping
NumberAnimation {
target: circularIndicator
- property: "endAngle"
+ property: "spanAngle"
from: 0
- to: 72
+ to: 20
duration: 200
}
SequentialAnimation {
loops: Animation.Infinite
- // Fill rest of the circle
+ // Fill the circle, except have both caps still visible
NumberAnimation {
target: circularIndicator
- property: "endAngle"
- from: 72
- to: 360
+ property: "spanAngle"
+ from: 20
+ to: 345
duration: 800
}
- // Fill 1/5 of the circle and clear previous fill
+ // Clear the circle, except for a 20 degree head start. The head start is to
+ // avoid an abrupt change in the cap of the indicator arc from an end to a beginning.
ParallelAnimation {
NumberAnimation {
target: circularIndicator
property: "startAngle"
- from: -360
- to: 0
- duration: 200
+ from: 0
+ to: 360
+ duration: 800
onStopped: circularIndicator.startAngle = 0
}
NumberAnimation {
target: circularIndicator
- property: "endAngle"
- from: 360
- to: 72
- duration: 200
+ property: "spanAngle"
+ from: 345
+ to: 20
+ duration: 800
}
}
}
diff --git a/src/circularindicator.cpp b/src/circularindicator.cpp
index d923b68..f3f5a31 100644
--- a/src/circularindicator.cpp
+++ b/src/circularindicator.cpp
@@ -31,7 +31,7 @@
CircularIndicator::CircularIndicator(QQuickItem *parent)
: QQuickPaintedItem(parent)
, m_startAngle(0)
- , m_endAngle(360)
+ , m_spanAngle(360)
, m_lineWidth(10)
, m_progressColor(QColor(255, 0, 0))
, m_backgroundColor(QColor(240, 240, 240))
@@ -58,18 +58,18 @@ void CircularIndicator::setStartAngle(int angle)
update();
}
-int CircularIndicator::endAngle() const
+int CircularIndicator::spanAngle() const
{
- return m_endAngle;
+ return m_spanAngle;
}
-void CircularIndicator::setEndAngle(int angle)
+void CircularIndicator::setSpanAngle(int angle)
{
- if (angle == m_endAngle)
+ if (angle == m_spanAngle)
return;
- m_endAngle = angle;
- emit endAngleChanged(m_endAngle);
+ m_spanAngle = angle;
+ emit spanAngleChanged(m_spanAngle);
update();
}
@@ -156,11 +156,11 @@ void CircularIndicator::paint(QPainter *painter)
painter->setPen(pen);
painter->drawArc(indicatorRect, 0, 360 * 16);
- if (m_startAngle == m_endAngle)
+ if (m_startAngle == m_spanAngle)
return;
// Draw the foreground
pen.setColor(m_progressColor);
painter->setPen(pen);
- painter->drawArc(indicatorRect, (90 - m_startAngle) * 16, -m_endAngle * 16);
+ painter->drawArc(indicatorRect, (90 - m_startAngle) * 16, -m_spanAngle * 16);
}
diff --git a/src/circularindicator.h b/src/circularindicator.h
index 9131317..a03c742 100644
--- a/src/circularindicator.h
+++ b/src/circularindicator.h
@@ -36,7 +36,7 @@ class CircularIndicator : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(int startAngle READ startAngle WRITE setStartAngle NOTIFY startAngleChanged)
- Q_PROPERTY(int endAngle READ endAngle WRITE setEndAngle NOTIFY endAngleChanged)
+ Q_PROPERTY(int spanAngle READ spanAngle WRITE setSpanAngle NOTIFY spanAngleChanged)
Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged)
Q_PROPERTY(QColor progressColor READ progressColor WRITE setProgressColor NOTIFY progressColorChanged)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
@@ -47,7 +47,7 @@ public:
~CircularIndicator();
int startAngle() const;
- int endAngle() const;
+ int spanAngle() const;
int lineWidth() const;
QColor progressColor() const;
QColor backgroundColor() const;
@@ -55,7 +55,7 @@ public:
public slots:
void setStartAngle(int angle);
- void setEndAngle(int angle);
+ void setSpanAngle(int angle);
void setLineWidth(int width);
void setProgressColor(const QColor &color);
void setBackgroundColor(const QColor &color);
@@ -63,7 +63,7 @@ public slots:
signals:
void startAngleChanged(int);
- void endAngleChanged(int);
+ void spanAngleChanged(int);
void lineWidthChanged(int);
void progressColorChanged(QColor);
void backgroundColorChanged(QColor);
@@ -74,7 +74,7 @@ protected:
private:
int m_startAngle;
- int m_endAngle;
+ int m_spanAngle;
int m_lineWidth;
QColor m_progressColor;
QColor m_backgroundColor;
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..4c41ca6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Device Creation.
@@ -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");
@@ -145,7 +150,7 @@ int main(int argc, char **argv)
engine.rootContext()->setContextProperty("_secondaryGrey", launcherSettings.value("secondaryGrey", "#3a4055"));
engine.rootContext()->setContextProperty("VideosLocation", launcherSettings.value("videosLocation", "file:///data/videos"));
- engine.rootContext()->setContextProperty("DefaultVideoUrl", launcherSettings.value("defaultVideoUrl", "file:///data/videos/Qt+for+Device+Creation.mp4"));
+ engine.rootContext()->setContextProperty("DefaultVideoUrl", launcherSettings.value("defaultVideoUrl", "file:///data/videos/Qt+for+Designers+and+Developers.mp4"));
engine.addImageProvider("QtImage", &imageProvider);
engine.addImageProvider("QtSquareImage", &squareImageProvider);