Use QtGraphicalEffects.LinearGradient

Instead of using a Rectangle and its gradient prop, since there's no
need for the rotation/scale hack and it gives better quality.
This commit is contained in:
miruka 2019-08-30 19:21:51 -04:00
parent f25a0d7c87
commit 92f6274458
4 changed files with 20 additions and 19 deletions

View File

@ -16,7 +16,6 @@
- Distribute fonts - Distribute fonts
- Backspace bug - Backspace bug
- Add missing shortcuts to config file - Add missing shortcuts to config file
- Zoom animation with gradient
- Show error if uploading avatar fails or file is corrupted - Show error if uploading avatar fails or file is corrupted

View File

@ -1,13 +1,13 @@
import QtQuick 2.12 import QtQuick 2.12
import QtGraphicalEffects 1.12
import "Base" import "Base"
Item { Item {
Rectangle { LinearGradient {
anchors.fill: parent anchors.fill: parent
scale: Math.max( start: Qt.point(0, 0)
2.25, Math.ceil(parent.parent.width / parent.parent.height) end: Qt.point(window.width, window.height)
)
rotation: -45
gradient: Gradient { gradient: Gradient {
GradientStop { position: 0.0; color: "#001b20" } GradientStop { position: 0.0; color: "#001b20" }
GradientStop { position: 1.0; color: "#3c2f4b" } GradientStop { position: 1.0; color: "#3c2f4b" }

View File

@ -2,6 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtQuick.Window 2.7 import QtQuick.Window 2.7
import QtGraphicalEffects 1.12
import "Base" import "Base"
import "SidePane" import "SidePane"
@ -43,16 +44,15 @@ Item {
asynchronous: false asynchronous: false
} }
Rectangle { LinearGradient {
id: mainUIGradient id: mainUIGradient
anchors.fill: parent anchors.fill: parent
scale: Math.max( start: theme.ui.gradientStart
2.25, Math.ceil(parent.parent.width / parent.parent.height) end: theme.ui.gradientEnd
)
rotation: theme.ui.gradientRotation
gradient: Gradient { gradient: Gradient {
GradientStop { position: 0.0; color: theme.ui.gradientStart } GradientStop { position: 0.0; color: theme.ui.gradientStartColor }
GradientStop { position: 1.0; color: theme.ui.gradientEnd } GradientStop { position: 1.0; color: theme.ui.gradientEndColor }
} }
} }

View File

@ -196,16 +196,18 @@ ui:
// If not specified, the gradient will be shown instead. // If not specified, the gradient will be shown instead.
url image: "" url image: ""
int gradientRotation: -45 point gradientStart: Qt.point(0, 0)
color gradientStart: point gradientEnd: Qt.point(window.width, window.height)
color gradientStartColor:
hsluv(colors.hue - 50, 100, colors.intensity * 8, 1.0) hsluv(colors.hue - 50, 100, colors.intensity * 8, 1.0)
color gradientEnd: color gradientEndColor:
hsluv(colors.hue + 20, 30, colors.intensity * 22, 1.0) hsluv(colors.hue + 20, 30, colors.intensity * 22, 1.0)
// To have a solid color instead, // To have a solid color instead,
// set gradientStart and gradientEnd to the same value. Example: // set gradientStartColor and gradientEndColor to the same value, e.g.:
// color gradientStart: hsluv(0, 0, 0, 0.8) // color gradientStartColor: hsluv(0, 0, 0, 0.8)
// color gradientEnd: hsluv(0, 0, 0, 0.8) // color gradientEndColor: hsluv(0, 0, 0, 0.8)