Settings rework...
This commit is contained in:
parent
74b233798d
commit
fb68300746
63 changed files with 7139 additions and 1026 deletions
51
Components/Avatar.qml
Normal file
51
Components/Avatar.qml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import qs.Settings
|
||||
import QtQuick.Effects
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
|
||||
Image {
|
||||
id: avatarImage
|
||||
anchors.fill: parent
|
||||
source: "file://" + Settings.settings.profileImage
|
||||
visible: false
|
||||
mipmap: true
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
|
||||
MultiEffect {
|
||||
anchors.fill: parent
|
||||
source: avatarImage
|
||||
maskEnabled: true
|
||||
maskSource: mask
|
||||
visible: Settings.settings.profileImage !== ""
|
||||
}
|
||||
|
||||
Item {
|
||||
id: mask
|
||||
anchors.fill: parent
|
||||
layer.enabled: true
|
||||
visible: false
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: avatarImage.width / 2
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback icon
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "person"
|
||||
font.family: "Material Symbols Outlined"
|
||||
font.pixelSize: 24
|
||||
color: Theme.onAccent
|
||||
visible: Settings.settings.profileImage === undefined || Settings.settings.profileImage === ""
|
||||
z: 0
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,7 @@ Rectangle {
|
|||
id: circularProgressBar
|
||||
color: "transparent"
|
||||
|
||||
// Properties
|
||||
property real progress: 0.0 // 0.0 to 1.0
|
||||
property real progress: 0.0
|
||||
property int size: 80
|
||||
property color backgroundColor: Theme.surfaceVariant
|
||||
property color progressColor: Theme.accentPrimary
|
||||
|
|
@ -19,7 +18,7 @@ Rectangle {
|
|||
|
||||
// Notch properties
|
||||
property bool hasNotch: false
|
||||
property real notchSize: 0.25 // Size of the notch as a fraction of the circle
|
||||
property real notchSize: 0.25
|
||||
property string notchIcon: ""
|
||||
property int notchIconSize: 12
|
||||
property color notchIconColor: Theme.accentPrimary
|
||||
|
|
@ -32,6 +31,7 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
|
||||
onPaint: {
|
||||
// Setup canvas context and calculate dimensions
|
||||
var ctx = getContext("2d")
|
||||
var centerX = width / 2
|
||||
var centerY = height / 2
|
||||
|
|
@ -41,25 +41,22 @@ Rectangle {
|
|||
var notchStartAngle = -notchAngle / 2
|
||||
var notchEndAngle = notchAngle / 2
|
||||
|
||||
// Clear canvas
|
||||
ctx.reset()
|
||||
|
||||
// Background circle
|
||||
ctx.strokeStyle = backgroundColor
|
||||
ctx.lineWidth = strokeWidth
|
||||
ctx.lineCap = "round"
|
||||
ctx.beginPath()
|
||||
|
||||
if (hasNotch) {
|
||||
// Draw background circle with notch on the right side
|
||||
// Draw the arc excluding the notch area (notch is at 0 radians, right side)
|
||||
// Draw background arc with notch gap
|
||||
ctx.arc(centerX, centerY, radius, notchEndAngle, 2 * Math.PI + notchStartAngle)
|
||||
} else {
|
||||
// Draw full background circle
|
||||
ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI)
|
||||
}
|
||||
ctx.stroke()
|
||||
|
||||
// Progress arc
|
||||
// Draw progress arc
|
||||
if (progress > 0) {
|
||||
ctx.strokeStyle = progressColor
|
||||
ctx.lineWidth = strokeWidth
|
||||
|
|
@ -67,15 +64,11 @@ Rectangle {
|
|||
ctx.beginPath()
|
||||
|
||||
if (hasNotch) {
|
||||
// Calculate progress with notch consideration
|
||||
// Calculate progress arc with notch gap
|
||||
var availableAngle = 2 * Math.PI - notchAngle
|
||||
var progressAngle = availableAngle * progress
|
||||
|
||||
// Start from where the notch cutout begins (top-right) and go clockwise
|
||||
var adjustedStartAngle = notchEndAngle
|
||||
var adjustedEndAngle = adjustedStartAngle + progressAngle
|
||||
|
||||
// Ensure we don't exceed the available space
|
||||
if (adjustedEndAngle > 2 * Math.PI + notchStartAngle) {
|
||||
adjustedEndAngle = 2 * Math.PI + notchStartAngle
|
||||
}
|
||||
|
|
@ -84,6 +77,7 @@ Rectangle {
|
|||
ctx.arc(centerX, centerY, radius, adjustedStartAngle, adjustedEndAngle)
|
||||
}
|
||||
} else {
|
||||
// Draw full progress arc
|
||||
ctx.arc(centerX, centerY, radius, startAngle, startAngle + (2 * Math.PI * progress))
|
||||
}
|
||||
ctx.stroke()
|
||||
|
|
|
|||
|
|
@ -8,18 +8,22 @@ Window {
|
|||
property bool tooltipVisible: false
|
||||
property Item targetItem: null
|
||||
property int delay: 300
|
||||
|
||||
property bool positionAbove: true
|
||||
|
||||
flags: Qt.ToolTip | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
|
||||
color: "transparent"
|
||||
visible: false
|
||||
|
||||
minimumWidth: tooltipText.implicitWidth + 24
|
||||
minimumHeight: tooltipText.implicitHeight + 16
|
||||
property var _timerObj: null
|
||||
|
||||
onTooltipVisibleChanged: {
|
||||
if (tooltipVisible) {
|
||||
if (delay > 0) {
|
||||
if (_timerObj) { _timerObj.destroy(); _timerObj = null; }
|
||||
_timerObj = Qt.createQmlObject('import QtQuick 2.0; Timer { interval: ' + delay + '; running: true; repeat: false; onTriggered: tooltipWindow._showNow() }', tooltipWindow);
|
||||
_timerObj = Qt.createQmlObject(
|
||||
'import QtQuick 2.0; Timer { interval: ' + delay + '; running: true; repeat: false; onTriggered: tooltipWindow._showNow() }',
|
||||
tooltipWindow);
|
||||
} else {
|
||||
_showNow();
|
||||
}
|
||||
|
|
@ -27,30 +31,45 @@ Window {
|
|||
_hideNow();
|
||||
}
|
||||
}
|
||||
|
||||
function _showNow() {
|
||||
width = Math.max(50, tooltipText.implicitWidth + 24)
|
||||
height = Math.max(50, tooltipText.implicitHeight + 16)
|
||||
|
||||
if (!targetItem) return;
|
||||
var pos = targetItem.mapToGlobal(0, targetItem.height);
|
||||
x = pos.x - width / 2 + targetItem.width / 2;
|
||||
y = pos.y + 12;
|
||||
|
||||
if (positionAbove) {
|
||||
// Position tooltip above the target item
|
||||
var pos = targetItem.mapToGlobal(0, 0);
|
||||
x = pos.x - width / 2 + targetItem.width / 2;
|
||||
y = pos.y - height - 12; // 12 px margin above
|
||||
} else {
|
||||
// Position tooltip below the target item
|
||||
var pos = targetItem.mapToGlobal(0, targetItem.height);
|
||||
x = pos.x - width / 2 + targetItem.width / 2;
|
||||
y = pos.y + 12; // 12 px margin below
|
||||
}
|
||||
visible = true;
|
||||
}
|
||||
|
||||
function _hideNow() {
|
||||
visible = false;
|
||||
if (_timerObj) { _timerObj.destroy(); _timerObj = null; }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: tooltipWindow.targetItem
|
||||
function onXChanged() {
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow()
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow();
|
||||
}
|
||||
function onYChanged() {
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow()
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow();
|
||||
}
|
||||
function onWidthChanged() {
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow()
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow();
|
||||
}
|
||||
function onHeightChanged() {
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow()
|
||||
if (tooltipWindow.visible) tooltipWindow._showNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +82,7 @@ Window {
|
|||
opacity: 0.97
|
||||
z: 1
|
||||
}
|
||||
|
||||
Text {
|
||||
id: tooltipText
|
||||
text: tooltipWindow.text
|
||||
|
|
@ -76,15 +96,16 @@ Window {
|
|||
padding: 8
|
||||
z: 2
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onExited: tooltipWindow.tooltipVisible = false
|
||||
cursorShape: Qt.ArrowCursor
|
||||
}
|
||||
|
||||
onTextChanged: {
|
||||
width = Math.max(minimumWidth, tooltipText.implicitWidth + 24);
|
||||
height = Math.max(minimumHeight, tooltipText.implicitHeight + 16);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue