1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

better fuzzy search, sweeping clean and qmlfmt of Widgets

This commit is contained in:
bbedward
2025-09-03 12:52:03 -04:00
parent 886c6877d5
commit d4db8a01fe
50 changed files with 2112 additions and 2010 deletions

View File

@@ -1,5 +1,4 @@
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
@@ -9,8 +8,7 @@ Image {
property string imagePath: ""
property string imageHash: ""
property int maxCacheSize: 512
readonly property string cachePath: imageHash ? `${Paths.stringify(
Paths.imagecache)}/${imageHash}@${maxCacheSize}x${maxCacheSize}.png` : ""
readonly property string cachePath: imageHash ? `${Paths.stringify(Paths.imagecache)}/${imageHash}@${maxCacheSize}x${maxCacheSize}.png` : ""
asynchronous: true
fillMode: Image.PreserveAspectCrop
@@ -18,32 +16,34 @@ Image {
sourceSize.height: maxCacheSize
smooth: true
onImagePathChanged: {
if (imagePath) {
hashProcess.command = ["sha256sum", Paths.strip(imagePath)]
hashProcess.running = true
} else {
if (!imagePath) {
source = ""
imageHash = ""
return
}
hashProcess.command = ["sha256sum", Paths.strip(imagePath)]
hashProcess.running = true
}
onCachePathChanged: {
if (imageHash && cachePath) {
Paths.mkdir(Paths.imagecache)
source = cachePath
if (!imageHash || !cachePath) {
return
}
Paths.mkdir(Paths.imagecache)
source = cachePath
}
onStatusChanged: {
if (source == cachePath && status === Image.Error) {
source = imagePath
} else if (source == imagePath && status === Image.Ready && imageHash
&& cachePath) {
Paths.mkdir(Paths.imagecache)
const grabPath = cachePath
if (visible && width > 0 && height > 0 && Window.window
&& Window.window.visible)
grabToImage(res => {
return res.saveToFile(grabPath)
})
return
}
if (source != imagePath || status !== Image.Ready || !imageHash || !cachePath) {
return
}
Paths.mkdir(Paths.imagecache)
const grabPath = cachePath
if (visible && width > 0 && height > 0 && Window.window && Window.window.visible) {
grabToImage(res => res.saveToFile(grabPath))
}
}
@@ -51,9 +51,7 @@ Image {
id: hashProcess
stdout: StdioCollector {
onStreamFinished: {
root.imageHash = text.split(" ")[0]
}
onStreamFinished: root.imageHash = text.split(" ")[0]
}
}
}

View File

@@ -8,7 +8,6 @@ StyledRect {
property string iconName: ""
property int iconSize: Theme.iconSize - 4
property color iconColor: Theme.surfaceText
property color hoverColor: Theme.primaryHover
property color backgroundColor: "transparent"
property bool circular: true
property int buttonSize: 32
@@ -30,8 +29,6 @@ StyledRect {
StateLayer {
stateColor: Theme.primary
cornerRadius: root.radius
onClicked: {
root.clicked()
}
onClicked: root.clicked()
}
}

View File

@@ -1,13 +1,9 @@
import QtQuick
import QtQuick.Effects
import qs.Common
Item {
id: root
property int screenWidth: parent.width
property int screenHeight: parent.height
anchors.fill: parent
Rectangle {
@@ -33,28 +29,25 @@ Item {
rotation: 35
}
Item {
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.leftMargin: Theme.spacingXL * 2
anchors.bottomMargin: Theme.spacingXL * 2
opacity: 0.25
StyledText {
anchors.left: parent.left
anchors.bottom: parent.bottom
text: `
`
text: `
`
isMonospace: true
font.pixelSize: Theme.fontSizeLarge * 1.2
color: Theme.primary
}
}
}
}

View File

@@ -1,4 +1,4 @@
import "../Common/fuzzysort.js" as FuzzySort
import "../Common/fzf.js" as Fzf
import QtQuick
import QtQuick.Controls
import qs.Common
@@ -11,10 +11,10 @@ Rectangle {
property string description: ""
property string currentValue: ""
property var options: []
property var optionIcons: [] // Array of icon names corresponding to options
property var optionIcons: []
property bool forceRecreate: false
property bool enableFuzzySearch: false
property int popupWidthOffset: 0 // How much wider the popup should be than the button
property int popupWidthOffset: 0
property int maxPopupHeight: 400
signal valueChanged(string value)
@@ -23,20 +23,20 @@ Rectangle {
height: 60
radius: Theme.cornerRadius
color: "transparent"
Component.onCompleted: {
forceRecreateTimer.start()
}
Component.onCompleted: forceRecreateTimer.start()
Component.onDestruction: {
var popup = popupLoader.item
if (popup && popup.visible)
const popup = popupLoader.item
if (popup && popup.visible) {
popup.close()
}
}
onVisibleChanged: {
var popup = popupLoader.item
if (!visible && popup && popup.visible)
const popup = popupLoader.item
if (!visible && popup && popup.visible) {
popup.close()
else if (visible)
} else if (visible) {
forceRecreateTimer.start()
}
}
Timer {
@@ -44,12 +44,9 @@ Rectangle {
interval: 50
repeat: false
onTriggered: {
root.forceRecreate = !root.forceRecreate
}
onTriggered: root.forceRecreate = !root.forceRecreate
}
Column {
anchors.left: parent.left
anchors.right: dropdown.left
@@ -95,16 +92,20 @@ Rectangle {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
var popup = popupLoader.item
if (popup && popup.visible) {
popup.close()
} else if (popup) {
var pos = dropdown.mapToItem(Overlay.overlay, 0,
dropdown.height + 4)
popup.x = pos.x - (root.popupWidthOffset / 2)
popup.y = pos.y
popup.open()
const popup = popupLoader.item
if (!popup) {
return
}
if (popup.visible) {
popup.close()
return
}
const pos = dropdown.mapToItem(Overlay.overlay, 0, dropdown.height + 4)
popup.x = pos.x - (root.popupWidthOffset / 2)
popup.y = pos.y
popup.open()
}
}
@@ -118,9 +119,8 @@ Rectangle {
DankIcon {
name: {
var currentIndex = root.options.indexOf(root.currentValue)
return root.optionIcons.length > currentIndex
&& currentIndex >= 0 ? root.optionIcons[currentIndex] : ""
const currentIndex = root.options.indexOf(root.currentValue)
return currentIndex >= 0 && root.optionIcons.length > currentIndex ? root.optionIcons[currentIndex] : ""
}
size: 18
color: Theme.surfaceVariantText
@@ -131,9 +131,7 @@ Rectangle {
text: root.currentValue
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText
width: root.width <= 60 ?
(dropdown.width - expandIcon.width - Theme.spacingS * 2) :
(dropdown.width - contentRow.x - expandIcon.width - Theme.spacingM - Theme.spacingS)
width: root.width <= 60 ? dropdown.width - expandIcon.width - Theme.spacingS * 2 : dropdown.width - contentRow.x - expandIcon.width - Theme.spacingM - Theme.spacingS
elide: root.width <= 60 ? Text.ElideNone : Text.ElideRight
horizontalAlignment: root.width <= 60 ? Text.AlignHCenter : Text.AlignLeft
}
@@ -169,61 +167,61 @@ Rectangle {
property string searchQuery: ""
property var filteredOptions: []
property int selectedIndex: -1
property var fzfFinder: new Fzf.Finder(root.options, {
"selector": option => option,
"limit": 50,
"casing": "case-insensitive"
})
function updateFilteredOptions() {
if (!root.enableFuzzySearch || searchQuery.length === 0) {
filteredOptions = root.options
} else {
var results = FuzzySort.go(searchQuery, root.options, {
"limit": 50,
"threshold": -10000
})
filteredOptions = results.map(function (result) {
return result.target
})
selectedIndex = -1
return
}
const results = fzfFinder.find(searchQuery)
filteredOptions = results.map(result => result.item)
selectedIndex = -1
}
function selectNext() {
if (filteredOptions.length > 0) {
selectedIndex = (selectedIndex + 1) % filteredOptions.length
listView.positionViewAtIndex(selectedIndex,
ListView.Contain)
if (filteredOptions.length === 0) {
return
}
selectedIndex = (selectedIndex + 1) % filteredOptions.length
listView.positionViewAtIndex(selectedIndex, ListView.Contain)
}
function selectPrevious() {
if (filteredOptions.length > 0) {
selectedIndex = selectedIndex
<= 0 ? filteredOptions.length - 1 : selectedIndex - 1
listView.positionViewAtIndex(selectedIndex,
ListView.Contain)
if (filteredOptions.length === 0) {
return
}
selectedIndex = selectedIndex <= 0 ? filteredOptions.length - 1 : selectedIndex - 1
listView.positionViewAtIndex(selectedIndex, ListView.Contain)
}
function selectCurrent() {
if (selectedIndex >= 0
&& selectedIndex < filteredOptions.length) {
root.currentValue = filteredOptions[selectedIndex]
root.valueChanged(filteredOptions[selectedIndex])
close()
if (selectedIndex < 0 || selectedIndex >= filteredOptions.length) {
return
}
root.currentValue = filteredOptions[selectedIndex]
root.valueChanged(filteredOptions[selectedIndex])
close()
}
parent: Overlay.overlay
width: dropdown.width + root.popupWidthOffset
height: Math.min(root.maxPopupHeight,
(root.enableFuzzySearch ? 54 : 0) + Math.min(
filteredOptions.length, 10) * 36 + 16)
height: Math.min(root.maxPopupHeight, (root.enableFuzzySearch ? 54 : 0) + Math.min(filteredOptions.length, 10) * 36 + 16)
padding: 0
modal: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
onOpened: {
searchQuery = ""
updateFilteredOptions()
if (root.enableFuzzySearch && searchField.visible)
if (root.enableFuzzySearch && searchField.visible) {
searchField.forceActiveFocus()
}
}
background: Rectangle {
@@ -231,9 +229,7 @@ Rectangle {
}
contentItem: Rectangle {
color: Qt.rgba(Theme.surfaceContainer.r,
Theme.surfaceContainer.g,
Theme.surfaceContainer.b, 1)
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 1)
border.color: Theme.primarySelected
border.width: 1
radius: Theme.cornerRadius
@@ -288,28 +284,18 @@ Rectangle {
model: filteredOptions
spacing: 2
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
interactive: true
flickDeceleration: 1500 // Touch only in Qt 6.9+ // Lower = more momentum, longer scrolling
maximumFlickVelocity: 2000 // Touch only in Qt 6.9+ // Higher = faster maximum scroll speed
flickDeceleration: 1500
maximumFlickVelocity: 2000
boundsBehavior: Flickable.DragAndOvershootBounds
boundsMovement: Flickable.FollowBoundsBehavior
pressDelay: 0
flickableDirection: Flickable.VerticalFlick
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AsNeeded
}
ScrollBar.horizontal: ScrollBar {
policy: ScrollBar.AlwaysOff
}
delegate: Rectangle {
property bool isSelected: selectedIndex === index
property bool isCurrentValue: root.currentValue === modelData
property int optionIndex: root.options.indexOf(
modelData)
property int optionIndex: root.options.indexOf(modelData)
width: ListView.view.width
height: 32
@@ -323,9 +309,7 @@ Rectangle {
spacing: Theme.spacingS
DankIcon {
name: optionIndex >= 0
&& root.optionIcons.length
> optionIndex ? root.optionIcons[optionIndex] : ""
name: optionIndex >= 0 && root.optionIcons.length > optionIndex ? root.optionIcons[optionIndex] : ""
size: 18
color: isCurrentValue ? Theme.primary : Theme.surfaceVariantText
visible: name !== ""

View File

@@ -1,6 +1,7 @@
import QtQuick
import QtQuick.Controls
import qs.Common
import qs.Widgets
Flickable {
id: flickable
@@ -11,7 +12,6 @@ Flickable {
property real friction: 0.95
property real minMomentumVelocity: 50
property real maxMomentumVelocity: 2500
// Internal: controls transient scrollbar visibility
property bool _scrollBarActive: false
flickDeceleration: 1500
@@ -38,16 +38,15 @@ Flickable {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
// Activate scrollbar on any wheel interaction
flickable._scrollBarActive = true
hideScrollBarTimer.restart()
let currentTime = Date.now()
let timeDelta = currentTime - lastWheelTime
vbar._scrollBarActive = true
vbar.hideTimer.restart()
const currentTime = Date.now()
const timeDelta = currentTime - lastWheelTime
lastWheelTime = currentTime
const deltaY = event.angleDelta.y
const isMouseWheel = Math.abs(deltaY) >= 120
&& (Math.abs(deltaY) % 120) === 0
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
if (isMouseWheel) {
momentumTimer.stop()
@@ -56,16 +55,13 @@ Flickable {
momentum = 0
const lines = Math.floor(Math.abs(deltaY) / 120)
const scrollAmount = (deltaY > 0 ? -lines : lines)
* flickable.mouseWheelSpeed
const scrollAmount = (deltaY > 0 ? -lines : lines) * flickable.mouseWheelSpeed
let newY = flickable.contentY + scrollAmount
newY = Math.max(
0, Math.min(
flickable.contentHeight - flickable.height,
newY))
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
if (flickable.flicking)
flickable.cancelFlick()
if (flickable.flicking) {
flickable.cancelFlick()
}
flickable.contentY = newY
} else {
@@ -83,22 +79,14 @@ Flickable {
"delta": delta,
"time": currentTime
})
velocitySamples = velocitySamples.filter(s => {
return currentTime
- s.time < 100
})
velocitySamples = velocitySamples.filter(s => currentTime - s.time < 100)
if (velocitySamples.length > 1) {
let totalDelta = velocitySamples.reduce(
(sum, s) => {
return sum + s.delta
}, 0)
let timeSpan = currentTime - velocitySamples[0].time
if (timeSpan > 0)
flickable.momentumVelocity = Math.max(
-flickable.maxMomentumVelocity,
Math.min(flickable.maxMomentumVelocity,
totalDelta / timeSpan * 1000))
const totalDelta = velocitySamples.reduce((sum, s) => sum + s.delta, 0)
const timeSpan = currentTime - velocitySamples[0].time
if (timeSpan > 0) {
flickable.momentumVelocity = Math.max(-flickable.maxMomentumVelocity, Math.min(flickable.maxMomentumVelocity, totalDelta / timeSpan * 1000))
}
}
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
@@ -109,13 +97,11 @@ Flickable {
}
let newY = flickable.contentY - delta
newY = Math.max(
0, Math.min(
flickable.contentHeight - flickable.height,
newY))
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
if (flickable.flicking)
flickable.cancelFlick()
if (flickable.flicking) {
flickable.cancelFlick()
}
flickable.contentY = newY
}
@@ -135,12 +121,11 @@ Flickable {
}
}
// Show scrollbar while flicking / momentum
onMovementStarted: {
_scrollBarActive = true
hideScrollBarTimer.stop()
vbar._scrollBarActive = true
vbar.hideTimer.stop()
}
onMovementEnded: hideScrollBarTimer.restart()
onMovementEnded: vbar.hideTimer.restart()
Timer {
id: momentumTimer
@@ -148,17 +133,11 @@ Flickable {
repeat: true
onTriggered: {
let newY = flickable.contentY - flickable.momentumVelocity * 0.016
let maxY = Math.max(0, flickable.contentHeight - flickable.height)
const newY = flickable.contentY - flickable.momentumVelocity * 0.016
const maxY = Math.max(0, flickable.contentHeight - flickable.height)
if (newY < 0) {
flickable.contentY = 0
stop()
flickable.isMomentumActive = false
flickable.momentumVelocity = 0
return
} else if (newY > maxY) {
flickable.contentY = maxY
if (newY < 0 || newY > maxY) {
flickable.contentY = newY < 0 ? 0 : maxY
stop()
flickable.isMomentumActive = false
flickable.momentumVelocity = 0
@@ -166,7 +145,6 @@ Flickable {
}
flickable.contentY = newY
flickable.momentumVelocity *= flickable.friction
if (Math.abs(flickable.momentumVelocity) < 5) {
@@ -185,50 +163,7 @@ Flickable {
easing.type: Easing.OutQuad
}
// Styled vertical scrollbar (auto-hide, no track)
ScrollBar.vertical: ScrollBar {
ScrollBar.vertical: DankScrollbar {
id: vbar
policy: flickable.contentHeight
> flickable.height ? ScrollBar.AsNeeded : ScrollBar.AlwaysOff
minimumSize: 0.08
implicitWidth: 10
interactive: true
hoverEnabled: true
z: 1000
opacity: (policy !== ScrollBar.AlwaysOff)
&& (vbar.pressed || vbar.hovered || vbar.active
|| flickable.moving || flickable.flicking
|| flickable.isMomentumActive
|| flickable._scrollBarActive) ? 1 : 0
visible: policy !== ScrollBar.AlwaysOff
Behavior on opacity {
NumberAnimation {
duration: 160
easing.type: Easing.OutQuad
}
}
contentItem: Rectangle {
implicitWidth: 6
radius: width / 2
color: vbar.pressed ? Theme.primary : (vbar.hovered || vbar.active
|| flickable.moving
|| flickable.flicking
|| flickable.isMomentumActive
|| flickable._scrollBarActive ? Theme.outline : Theme.outlineMedium)
opacity: vbar.pressed ? 1 : (vbar.hovered || vbar.active
|| flickable.moving
|| flickable.flicking
|| flickable.isMomentumActive
|| flickable._scrollBarActive ? 1 : 0.6)
}
background: Item {}
}
Timer {
id: hideScrollBarTimer
interval: 1200
onTriggered: flickable._scrollBarActive = false
}
}

View File

@@ -1,10 +1,10 @@
import QtQuick
import QtQuick.Controls
import qs.Widgets
GridView {
id: gridView
// Kinetic scrolling momentum properties
property real momentumVelocity: 0
property bool isMomentumActive: false
property real friction: 0.95
@@ -18,14 +18,17 @@ GridView {
pressDelay: 0
flickableDirection: Flickable.VerticalFlick
onMovementStarted: {
vbar._scrollBarActive = true
vbar.hideTimer.stop()
}
onMovementEnded: vbar.hideTimer.restart()
WheelHandler {
id: wheelHandler
// Tunable parameters for responsive scrolling
property real mouseWheelSpeed: 60
// Higher = faster mouse wheel
property real touchpadSpeed: 1.8
// Touchpad sensitivity
property real momentumRetention: 0.92
property real lastWheelTime: 0
property real momentum: 0
@@ -38,17 +41,17 @@ GridView {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
let currentTime = Date.now()
let timeDelta = currentTime - lastWheelTime
vbar._scrollBarActive = true
vbar.hideTimer.restart()
const currentTime = Date.now()
const timeDelta = currentTime - lastWheelTime
lastWheelTime = currentTime
// Detect mouse wheel vs touchpad
const deltaY = event.angleDelta.y
const isMouseWheel = Math.abs(deltaY) >= 120
&& (Math.abs(deltaY) % 120) === 0
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
if (isMouseWheel) {
// Fixed scrolling for mouse wheel - 2 cells per click
momentumTimer.stop()
isMomentumActive = false
velocitySamples = []
@@ -56,55 +59,34 @@ GridView {
const lines = Math.floor(Math.abs(deltaY) / 120)
const scrollAmount = (deltaY > 0 ? -lines : lines) * cellHeight * 0.35
// 0.15 cells per wheel click
let newY = contentY + scrollAmount
newY = Math.max(0,
Math.min(contentHeight - height, newY))
newY = Math.max(0, Math.min(contentHeight - height, newY))
if (flicking)
cancelFlick()
if (flicking) {
cancelFlick()
}
contentY = newY
} else {
// Touchpad - existing smooth kinetic scrolling
// Stop any existing momentum
momentumTimer.stop()
isMomentumActive = false
// Calculate scroll delta based on input type
let delta = 0
if (event.pixelDelta.y !== 0)
// Touchpad with pixel precision
delta = event.pixelDelta.y * touchpadSpeed
else
// Fallback for touchpad without pixel delta
delta = event.angleDelta.y / 120 * cellHeight * 1.2
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * touchpadSpeed : event.angleDelta.y / 120 * cellHeight * 1.2
// Track velocity for momentum
velocitySamples.push({
"delta": delta,
"time": currentTime
})
velocitySamples = velocitySamples.filter(s => {
return currentTime
- s.time < 100
})
velocitySamples = velocitySamples.filter(s => currentTime - s.time < 100)
// Calculate momentum velocity from samples
if (velocitySamples.length > 1) {
let totalDelta = velocitySamples.reduce(
(sum, s) => {
return sum + s.delta
}, 0)
let timeSpan = currentTime - velocitySamples[0].time
if (timeSpan > 0)
momentumVelocity = Math.max(
-maxMomentumVelocity,
Math.min(maxMomentumVelocity,
totalDelta / timeSpan * 1000))
const totalDelta = velocitySamples.reduce((sum, s) => sum + s.delta, 0)
const timeSpan = currentTime - velocitySamples[0].time
if (timeSpan > 0) {
momentumVelocity = Math.max(-maxMomentumVelocity, Math.min(maxMomentumVelocity, totalDelta / timeSpan * 1000))
}
}
// Apply momentum for touchpad (smooth continuous scrolling)
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
momentum = momentum * momentumRetention + delta * 0.15
delta += momentum
@@ -112,14 +94,12 @@ GridView {
momentum = 0
}
// Apply scrolling with proper bounds checking
let newY = contentY - delta
newY = Math.max(0,
Math.min(contentHeight - height, newY))
newY = Math.max(0, Math.min(contentHeight - height, newY))
// Cancel any conflicting flicks and apply new position
if (flicking)
cancelFlick()
if (flicking) {
cancelFlick()
}
contentY = newY
}
@@ -127,35 +107,27 @@ GridView {
event.accepted = true
}
onActiveChanged: {
if (!active && Math.abs(momentumVelocity) >= minMomentumVelocity) {
startMomentum()
} else if (!active) {
velocitySamples = []
momentumVelocity = 0
if (!active) {
if (Math.abs(momentumVelocity) >= minMomentumVelocity) {
startMomentum()
} else {
velocitySamples = []
momentumVelocity = 0
}
}
}
}
// Physics-based momentum timer for kinetic scrolling
Timer {
id: momentumTimer
interval: 16 // ~60 FPS
interval: 16
repeat: true
onTriggered: {
// Apply velocity to position
let newY = contentY - momentumVelocity * 0.016
let maxY = Math.max(0, contentHeight - height)
const newY = contentY - momentumVelocity * 0.016
const maxY = Math.max(0, contentHeight - height)
// Stop momentum at boundaries instead of bouncing
if (newY < 0) {
contentY = 0
stop()
isMomentumActive = false
momentumVelocity = 0
return
} else if (newY > maxY) {
contentY = maxY
if (newY < 0 || newY > maxY) {
contentY = newY < 0 ? 0 : maxY
stop()
isMomentumActive = false
momentumVelocity = 0
@@ -163,11 +135,8 @@ GridView {
}
contentY = newY
// Apply friction
momentumVelocity *= friction
// Stop if velocity too low
if (Math.abs(momentumVelocity) < 5) {
stop()
isMomentumActive = false
@@ -176,13 +145,15 @@ GridView {
}
}
// Smooth return to bounds animation
NumberAnimation {
id: returnToBoundsAnimation
target: gridView
property: "contentY"
duration: 300
easing.type: Easing.OutQuad
}
ScrollBar.vertical: DankScrollbar {
id: vbar
}
}

View File

@@ -8,7 +8,7 @@ StyledText {
property alias size: icon.font.pixelSize
property alias color: icon.color
property bool filled: false
property real fill: filled ? 1 : 0
property real fill: filled ? 1.0 : 0.0
property int grade: Theme.isLightMode ? 0 : -25
property int weight: filled ? 500 : 400
@@ -18,12 +18,12 @@ StyledText {
color: Theme.surfaceText
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.variableAxes: ({
"FILL": fill.toFixed(1),
"GRAD": grade,
"opsz": 24,
"wght": weight
})
font.variableAxes: {
"FILL": fill.toFixed(1),
"GRAD": grade,
"opsz": 24,
"wght": weight
}
Behavior on fill {
NumberAnimation {

View File

@@ -10,7 +10,6 @@ Rectangle {
id: root
property string currentIcon: ""
property string currentText: ""
property string iconType: "icon" // "icon" or "text"
signal iconSelected(string iconName, string iconType)
@@ -19,12 +18,15 @@ Rectangle {
height: 32
radius: Theme.cornerRadius
color: Theme.surfaceContainer
border.color: dropdownLoader.active ? Theme.primary : (mouseArea.containsMouse ? Theme.outline : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.5))
border.color: dropdownLoader.active ? Theme.primary : Theme.outline
border.width: 1
property var iconCategories: [{
"name": "Numbers",
"icons": ["looks_one", "looks_two", "looks_3", "looks_4", "looks_5", "looks_6", "filter_1", "filter_2", "filter_3", "filter_4", "filter_5", "filter_6", "filter_7", "filter_8", "filter_9", "filter_9_plus", "plus_one", "exposure_plus_1", "exposure_plus_2"]
}, {
"name": "Workspace",
"icons": ["work", "laptop", "desktop_windows", "code", "terminal", "build", "settings", "folder", "view_module", "dashboard", "apps", "grid_view"]
"icons": ["work", "laptop", "desktop_windows", "folder", "view_module", "dashboard", "apps", "grid_view"]
}, {
"name": "Development",
"icons": ["code", "terminal", "bug_report", "build", "engineering", "integration_instructions", "data_object", "schema", "api", "webhook"]
@@ -36,7 +38,7 @@ Rectangle {
"icons": ["music_note", "headphones", "mic", "videocam", "photo", "movie", "library_music", "album", "radio", "volume_up"]
}, {
"name": "System",
"icons": ["memory", "storage", "developer_board", "monitor", "keyboard", "mouse", "battery_std", "wifi", "bluetooth", "security"]
"icons": ["memory", "storage", "developer_board", "monitor", "keyboard", "mouse", "battery_std", "wifi", "bluetooth", "security", "settings"]
}, {
"name": "Navigation",
"icons": ["home", "arrow_forward", "arrow_back", "expand_more", "expand_less", "menu", "close", "search", "filter_list", "sort"]
@@ -45,21 +47,12 @@ Rectangle {
"icons": ["add", "remove", "edit", "delete", "save", "download", "upload", "share", "content_copy", "content_paste", "content_cut", "undo", "redo"]
}, {
"name": "Status",
"icons": ["check", "close", "error", "warning", "info", "done", "pending", "schedule", "update", "sync", "offline_bolt"]
"icons": ["check", "error", "warning", "info", "done", "pending", "schedule", "update", "sync", "offline_bolt"]
}, {
"name": "Fun",
"icons": ["celebration", "cake", "star", "favorite", "pets", "sports_esports", "local_fire_department", "bolt", "auto_awesome", "diamond"]
}]
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
dropdownLoader.active = !dropdownLoader.active
}
}
Row {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
@@ -67,29 +60,26 @@ Rectangle {
spacing: Theme.spacingS
DankIcon {
name: root.iconType === "icon"
&& root.currentIcon ? root.currentIcon : (root.iconType
=== "text" ? "text_fields" : "add")
name: (root.iconType === "icon" && root.currentIcon) ? root.currentIcon : (root.iconType === "text" ? "text_fields" : "add")
size: 16
color: root.currentIcon
|| root.currentText ? Theme.surfaceText : Theme.outline
color: root.currentIcon ? Theme.surfaceText : Theme.outline
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: {
if (root.iconType === "text" && root.currentText)
return root.currentText
if (root.iconType === "icon" && root.currentIcon)
return root.currentIcon
return "Choose icon or text"
}
text: root.currentIcon ? root.currentIcon : "Choose icon"
font.pixelSize: Theme.fontSizeSmall
color: root.currentIcon
|| root.currentText ? Theme.surfaceText : Theme.outline
color: root.currentIcon ? Theme.surfaceText : Theme.outline
anchors.verticalCenter: parent.verticalCenter
width: 160
elide: Text.ElideRight
MouseArea {
anchors.fill: parent
onClicked: {
dropdownLoader.active = !dropdownLoader.active
}
}
}
}
@@ -116,7 +106,6 @@ Rectangle {
color: "transparent"
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
anchors {
top: true
@@ -125,37 +114,58 @@ Rectangle {
bottom: true
}
// Click outside to close
// Top area - above popup
MouseArea {
anchors.fill: parent
onClicked: dropdownLoader.active = false
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: popupContainer.y
onClicked: {
dropdownLoader.active = false
}
}
// Bottom area - below popup
MouseArea {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: popupContainer.bottom
anchors.bottom: parent.bottom
onClicked: {
dropdownLoader.active = false
}
}
// Left area - left of popup
MouseArea {
anchors.left: parent.left
anchors.top: popupContainer.top
anchors.bottom: popupContainer.bottom
width: popupContainer.x
onClicked: {
dropdownLoader.active = false
}
}
// Right area - right of popup
MouseArea {
anchors.right: parent.right
anchors.top: popupContainer.top
anchors.bottom: popupContainer.bottom
anchors.left: popupContainer.right
onClicked: {
dropdownLoader.active = false
}
}
Rectangle {
id: popupContainer
width: 320
height: Math.min(500, dropdownContent.implicitHeight + 32)
x: {
// Get the root picker's position relative to the screen
var pickerPos = root.mapToItem(null, 0, 0)
return Math.max(16, Math.min(pickerPos.x,
parent.width - width - 16))
}
y: {
// Position below the picker button
var pickerPos = root.mapToItem(null, 0, root.height + 4)
return Math.max(16, Math.min(pickerPos.y,
parent.height - height - 16))
}
x: Math.max(16, Math.min(root.mapToItem(null, 0, 0).x, parent.width - width - 16))
y: Math.max(16, Math.min(root.mapToItem(null, 0, root.height + 4).y, parent.height - height - 16))
radius: Theme.cornerRadius
color: Theme.surface
border.color: Theme.outline
border.width: 1
// Prevent this from closing the dropdown when clicked
MouseArea {
anchors.fill: parent
// Don't propagate clicks to parent
}
layer.enabled: true
layer.effect: MultiEffect {
@@ -166,95 +176,48 @@ Rectangle {
shadowVerticalOffset: 4
}
// Close button
Rectangle {
width: 24
height: 24
radius: 12
color: closeMouseArea.containsMouse ? Theme.errorHover : "transparent"
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: Theme.spacingS
anchors.rightMargin: Theme.spacingS
z: 1
DankIcon {
name: "close"
size: 16
color: closeMouseArea.containsMouse ? Theme.error : Theme.outline
anchors.centerIn: parent
}
MouseArea {
id: closeMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
dropdownLoader.active = false
}
}
}
DankFlickable {
anchors.fill: parent
anchors.margins: Theme.spacingS
contentHeight: dropdownContent.height
clip: true
pressDelay: 0
Column {
id: dropdownContent
width: parent.width
spacing: Theme.spacingM
// Custom text section
Rectangle {
width: parent.width
height: customTextSection.implicitHeight + Theme.spacingS * 2
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceVariant.r,
Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.3)
Column {
id: customTextSection
anchors.fill: parent
anchors.margins: Theme.spacingS
spacing: Theme.spacingS
StyledText {
text: "Custom Text"
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
color: Theme.surfaceText
}
Rectangle {
width: parent.width
height: 28
radius: Theme.cornerRadius
color: Theme.surfaceContainer
border.color: customTextInput.activeFocus ? Theme.primary : Theme.outline
border.width: 1
Row {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Theme.spacingS
spacing: Theme.spacingS
DankIcon {
name: "text_fields"
size: 14
color: Theme.outline
anchors.verticalCenter: parent.verticalCenter
}
TextInput {
id: customTextInput
anchors.verticalCenter: parent.verticalCenter
width: 200
text: root.iconType === "text" ? root.currentText : ""
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
selectByMouse: true
onEditingFinished: {
var trimmedText = text.trim()
if (trimmedText) {
root.iconSelected(
trimmedText,
"text")
dropdownLoader.active = false
}
}
}
}
StyledText {
anchors.left: parent.left
anchors.leftMargin: Theme.spacingS + 14 + Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
text: "1-2 characters"
font.pixelSize: Theme.fontSizeSmall
color: Theme.outline
opacity: 0.6
visible: customTextInput.text === ""
}
}
}
}
// Icon categories
Repeater {
model: root.iconCategories
@@ -298,9 +261,7 @@ Rectangle {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
root.iconSelected(
modelData,
"icon")
root.iconSelected(modelData, "icon")
dropdownLoader.active = false
}
}
@@ -323,14 +284,8 @@ Rectangle {
}
function setIcon(iconName, type) {
if (type === "text") {
root.currentText = iconName
root.currentIcon = ""
root.iconType = "text"
} else {
root.currentIcon = iconName
root.currentText = ""
root.iconType = "icon"
}
root.iconType = type
root.iconType = "icon"
root.currentIcon = iconName
}
}

View File

@@ -1,17 +1,14 @@
import QtQuick
import QtQuick.Controls
import qs.Widgets
ListView {
id: listView
property real mouseWheelSpeed: 60
// Simple position preservation
property real savedY: 0
property bool justChanged: false
property bool isUserScrolling: false
// Kinetic scrolling momentum properties
property real momentumVelocity: 0
property bool isMomentumActive: false
property real friction: 0.95
@@ -25,8 +22,15 @@ ListView {
pressDelay: 0
flickableDirection: Flickable.VerticalFlick
onMovementStarted: isUserScrolling = true
onMovementEnded: isUserScrolling = false
onMovementStarted: {
isUserScrolling = true
vbar._scrollBarActive = true
vbar.hideTimer.stop()
}
onMovementEnded: {
isUserScrolling = false
vbar.hideTimer.restart()
}
onContentYChanged: {
if (!justChanged && isUserScrolling) {
@@ -35,7 +39,6 @@ ListView {
justChanged = false
}
// Restore position when model changes
onModelChanged: {
justChanged = true
contentY = savedY
@@ -43,10 +46,7 @@ ListView {
WheelHandler {
id: wheelHandler
// Tunable parameters for responsive scrolling
property real touchpadSpeed: 1.8 // Touchpad sensitivity
property real momentumRetention: 0.92
property real touchpadSpeed: 1.8
property real lastWheelTime: 0
property real momentum: 0
property var velocitySamples: []
@@ -59,16 +59,16 @@ ListView {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
isUserScrolling = true // Mark as user interaction
isUserScrolling = true
vbar._scrollBarActive = true
vbar.hideTimer.restart()
let currentTime = Date.now()
let timeDelta = currentTime - lastWheelTime
const currentTime = Date.now()
const timeDelta = currentTime - lastWheelTime
lastWheelTime = currentTime
// Detect mouse wheel vs touchpad, seems like assuming based on the increments is the only way in QT
const deltaY = event.angleDelta.y
const isMouseWheel = Math.abs(deltaY) >= 120
&& (Math.abs(deltaY) % 120) === 0
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
if (isMouseWheel) {
momentumTimer.stop()
@@ -79,13 +79,11 @@ ListView {
const lines = Math.floor(Math.abs(deltaY) / 120)
const scrollAmount = (deltaY > 0 ? -lines : lines) * mouseWheelSpeed
let newY = listView.contentY + scrollAmount
newY = Math.max(
0,
Math.min(listView.contentHeight - listView.height,
newY))
newY = Math.max(0, Math.min(listView.contentHeight - listView.height, newY))
if (listView.flicking)
listView.cancelFlick()
if (listView.flicking) {
listView.cancelFlick()
}
listView.contentY = newY
savedY = newY
@@ -93,61 +91,43 @@ ListView {
momentumTimer.stop()
isMomentumActive = false
// Calculate scroll delta based on input type
let delta = 0
if (event.pixelDelta.y !== 0) {
// Touchpad with pixel precision
delta = event.pixelDelta.y * touchpadSpeed
} else {
// Fallback for touchpad without pixel delta
delta = event.angleDelta.y / 8 * touchpadSpeed
}
// Track velocity for momentum
velocitySamples.push({
"delta": delta,
"time": currentTime
})
velocitySamples = velocitySamples.filter(s => {
return currentTime
- s.time < 100
})
velocitySamples = velocitySamples.filter(s => currentTime - s.time < 100)
// Calculate momentum velocity from samples
if (velocitySamples.length > 1) {
let totalDelta = velocitySamples.reduce(
(sum, s) => {
return sum + s.delta
}, 0)
let timeSpan = currentTime - velocitySamples[0].time
if (timeSpan > 0)
momentumVelocity = Math.max(
-maxMomentumVelocity,
Math.min(maxMomentumVelocity,
totalDelta / timeSpan * 1000))
const totalDelta = velocitySamples.reduce((sum, s) => sum + s.delta, 0)
const timeSpan = currentTime - velocitySamples[0].time
if (timeSpan > 0) {
momentumVelocity = Math.max(-maxMomentumVelocity, Math.min(maxMomentumVelocity, totalDelta / timeSpan * 1000))
}
}
// Apply momentum for touchpad (smooth continuous scrolling)
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
momentum = momentum * momentumRetention + delta * 0.15
momentum = momentum * 0.92 + delta * 0.15
delta += momentum
} else {
momentum = 0
}
// Apply scrolling with proper bounds checking
let newY = listView.contentY - delta
newY = Math.max(
0,
Math.min(listView.contentHeight - listView.height,
newY))
newY = Math.max(0, Math.min(listView.contentHeight - listView.height, newY))
// Cancel any conflicting flicks and apply new position
if (listView.flicking)
listView.cancelFlick()
if (listView.flicking) {
listView.cancelFlick()
}
listView.contentY = newY
savedY = newY // Update saved position
savedY = newY
}
event.accepted = true
@@ -156,8 +136,6 @@ ListView {
onActiveChanged: {
if (!active) {
isUserScrolling = false
// Start momentum if applicable (touchpad only)
if (Math.abs(momentumVelocity) >= minMomentumVelocity) {
startMomentum()
} else {
@@ -168,28 +146,18 @@ ListView {
}
}
// Physics-based momentum timer for kinetic scrolling (touchpad only)
Timer {
id: momentumTimer
interval: 16 // ~60 FPS
interval: 16
repeat: true
onTriggered: {
// Apply velocity to position
let newY = contentY - momentumVelocity * 0.016
let maxY = Math.max(0, contentHeight - height)
const newY = contentY - momentumVelocity * 0.016
const maxY = Math.max(0, contentHeight - height)
// Stop momentum at boundaries instead of bouncing
if (newY < 0) {
contentY = 0
savedY = 0
stop()
isMomentumActive = false
momentumVelocity = 0
return
} else if (newY > maxY) {
contentY = maxY
savedY = maxY
if (newY < 0 || newY > maxY) {
contentY = newY < 0 ? 0 : maxY
savedY = contentY
stop()
isMomentumActive = false
momentumVelocity = 0
@@ -197,12 +165,9 @@ ListView {
}
contentY = newY
savedY = newY // Keep updating saved position during momentum
// Apply friction
savedY = newY
momentumVelocity *= friction
// Stop if velocity too low
if (Math.abs(momentumVelocity) < 5) {
stop()
isMomentumActive = false
@@ -211,12 +176,7 @@ ListView {
}
}
// Smooth return to bounds animation
NumberAnimation {
id: returnToBoundsAnimation
target: listView
property: "contentY"
duration: 300
easing.type: Easing.OutQuad
ScrollBar.vertical: DankScrollbar {
id: vbar
}
}

View File

@@ -11,7 +11,6 @@ Item {
property string placeholderText: "Search for a location..."
property bool _internalChange: false
property bool isLoading: false
property string helperTextState: "default" // "default", "prompt", "searching", "found", "not_found"
property string currentSearchText: ""
signal locationSelected(string displayName, string coordinates)
@@ -21,10 +20,8 @@ Item {
dropdownHideTimer.stop()
if (locationSearcher.running)
locationSearcher.running = false
isLoading = false
searchResultsModel.clear()
helperTextState = "default"
}
width: parent.width
@@ -47,7 +44,6 @@ Item {
searchResultsModel.clear()
root.isLoading = true
root.helperTextState = "searching"
const searchLocation = locationInput.text
root.currentSearchText = searchLocation
const encodedLocation = encodeURIComponent(searchLocation)
@@ -79,7 +75,6 @@ Item {
root.isLoading = false
if (exitCode !== 0) {
searchResultsModel.clear()
root.helperTextState = "not_found"
}
}
@@ -92,19 +87,16 @@ Item {
root.isLoading = false
searchResultsModel.clear()
if (!raw || raw[0] !== "[") {
root.helperTextState = "not_found"
return
}
try {
const data = JSON.parse(raw)
if (data.length === 0) {
root.helperTextState = "not_found"
return
}
for (var i = 0; i < Math.min(data.length, 5); i++) {
const location = data[i]
if (location.display_name && location.lat
&& location.lon) {
if (location.display_name && location.lat && location.lon) {
const parts = location.display_name.split(', ')
let cleanName = parts[0]
if (parts.length > 1) {
@@ -119,9 +111,8 @@ Item {
})
}
}
root.helperTextState = "found"
} catch (e) {
root.helperTextState = "not_found"
}
}
}
@@ -147,23 +138,18 @@ Item {
onTextEdited: {
if (root._internalChange)
return
if (getActiveFocus()) {
if (text.length > 2) {
root.isLoading = true
root.helperTextState = "searching"
locationSearchTimer.restart()
} else {
root.resetSearchState()
root.helperTextState = "prompt"
}
}
}
onFocusStateChanged: hasFocus => {
if (hasFocus) {
dropdownHideTimer.stop()
if (text.length <= 2)
root.helperTextState = "prompt"
} else {
dropdownHideTimer.start()
}
@@ -171,38 +157,13 @@ Item {
}
DankIcon {
name: {
if (root.isLoading)
return "hourglass_empty"
if (searchResultsModel.count > 0)
return "check_circle"
if (locationInput.getActiveFocus()
&& locationInput.text.length > 2 && !root.isLoading)
return "error"
return ""
}
name: root.isLoading ? "hourglass_empty" : (searchResultsModel.count > 0 ? "check_circle" : "error")
size: Theme.iconSize - 4
color: {
if (root.isLoading)
return Theme.surfaceVariantText
if (searchResultsModel.count > 0)
return Theme.success || Theme.primary
if (locationInput.getActiveFocus()
&& locationInput.text.length > 2)
return Theme.error
return "transparent"
}
color: root.isLoading ? Theme.surfaceVariantText : (searchResultsModel.count > 0 ? Theme.primary : Theme.error)
anchors.right: parent.right
anchors.rightMargin: Theme.spacingM
anchors.verticalCenter: parent.verticalCenter
opacity: (locationInput.getActiveFocus()
&& locationInput.text.length > 2) ? 1 : 0
opacity: (locationInput.getActiveFocus() && locationInput.text.length > 2) ? 1 : 0
Behavior on opacity {
NumberAnimation {
@@ -219,17 +180,13 @@ Item {
property bool hovered: false
width: parent.width
height: Math.min(
Math.max(
searchResultsModel.count * 38 + Theme.spacingS * 2,
50), 200)
height: Math.min(Math.max(searchResultsModel.count * 38 + Theme.spacingS * 2, 50), 200)
y: searchInputField.height
radius: Theme.cornerRadius
color: Theme.popupBackground()
border.color: Theme.primarySelected
border.width: 1
visible: locationInput.getActiveFocus() && locationInput.text.length > 2
&& (searchResultsModel.count > 0 || root.isLoading)
visible: locationInput.getActiveFocus() && locationInput.text.length > 2 && (searchResultsModel.count > 0 || root.isLoading)
MouseArea {
anchors.fill: parent
@@ -258,40 +215,6 @@ Item {
model: searchResultsModel
spacing: 2
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
interactive: true
flickDeceleration: 1500
maximumFlickVelocity: 2000
boundsBehavior: Flickable.DragAndOvershootBounds
boundsMovement: Flickable.FollowBoundsBehavior
pressDelay: 0
flickableDirection: Flickable.VerticalFlick
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
WheelHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
property real momentum: 0
onWheel: event => {
if (event.pixelDelta.y !== 0) {
// Touchpad with pixel delta
momentum = event.pixelDelta.y * 1.8
} else {
// Mouse wheel with angle delta
momentum = (event.angleDelta.y / 120)
* ((36 + parent.spacing) * 2.5) // ~2.5 items per wheel step
}
let newY = parent.contentY - momentum
newY = Math.max(
0, Math.min(
parent.contentHeight - parent.height,
newY))
parent.contentY = newY
momentum *= 0.92 // Decay for smooth momentum
event.accepted = true
}
}
delegate: StyledRect {
width: searchResultsList.width
height: 36
@@ -345,8 +268,7 @@ Item {
text: root.isLoading ? "Searching..." : "No locations found"
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceVariantText
visible: searchResultsList.count === 0
&& locationInput.text.length > 2
visible: searchResultsList.count === 0 && locationInput.text.length > 2
}
}
}

View File

@@ -34,28 +34,13 @@ PanelWindow {
closeTimer.restart()
}
function resetHideTimer() {
if (shouldBeVisible && enableMouseInteraction) {
// Only restart timer if we're not currently hovering
let isHovered = (enableMouseInteraction && mouseArea.containsMouse) || osdContainer.childHovered
if (!isHovered) {
hideTimer.restart()
}
}
}
function stopHideTimer() {
if (enableMouseInteraction)
hideTimer.stop()
}
function updateHoverState() {
let isHovered = (enableMouseInteraction && mouseArea.containsMouse) || osdContainer.childHovered
if (enableMouseInteraction) {
if (isHovered) {
stopHideTimer()
hideTimer.stop()
} else if (shouldBeVisible) {
resetHideTimer()
hideTimer.restart()
}
}
}
@@ -85,7 +70,7 @@ PanelWindow {
interval: autoHideInterval
repeat: false
onTriggered: {
if (!enableMouseInteraction || !osdContainer.containsMouse) {
if (!enableMouseInteraction || !mouseArea.containsMouse) {
hide()
} else {
hideTimer.restart()
@@ -107,7 +92,6 @@ PanelWindow {
Rectangle {
id: osdContainer
property bool containsMouse: enableMouseInteraction && mouseArea.containsMouse
property bool childHovered: false
width: osdWidth
@@ -130,15 +114,10 @@ PanelWindow {
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
z: -1
onContainsMouseChanged: {
updateHoverState()
}
onContainsMouseChanged: updateHoverState()
}
onChildHoveredChanged: {
root.updateHoverState()
}
onChildHoveredChanged: updateHoverState()
Loader {
id: contentLoader
@@ -153,7 +132,6 @@ PanelWindow {
shadowVerticalOffset: 4
shadowBlur: 0.8
shadowColor: Qt.rgba(0, 0, 0, 0.3)
shadowOpacity: 0.3
}
Behavior on opacity {
@@ -174,4 +152,4 @@ PanelWindow {
mask: Region {
item: osdContainer
}
}
}

View File

@@ -69,11 +69,8 @@ PanelWindow {
anchors.fill: parent
enabled: shouldBeVisible
onClicked: mouse => {
var localPos = mapToItem(contentContainer,
mouse.x, mouse.y)
if (localPos.x < 0 || localPos.x > contentContainer.width
|| localPos.y < 0
|| localPos.y > contentContainer.height) {
var localPos = mapToItem(contentContainer, mouse.x, mouse.y)
if (localPos.x < 0 || localPos.x > contentContainer.width || localPos.y < 0 || localPos.y > contentContainer.height) {
backgroundClicked()
close()
}
@@ -88,23 +85,11 @@ PanelWindow {
readonly property real calculatedX: {
if (positioning === "center") {
var centerX = triggerX + (triggerWidth / 2) - (popupWidth / 2)
if (centerX >= Theme.spacingM
&& centerX + popupWidth <= screenWidth - Theme.spacingM)
return centerX
if (centerX < Theme.spacingM)
return Theme.spacingM
if (centerX + popupWidth > screenWidth - Theme.spacingM)
return screenWidth - popupWidth - Theme.spacingM
return centerX
return Math.max(Theme.spacingM, Math.min(screenWidth - popupWidth - Theme.spacingM, centerX))
} else if (positioning === "left") {
return Math.max(Theme.spacingM, triggerX)
} else if (positioning === "right") {
return Math.min(screenWidth - popupWidth - Theme.spacingM,
triggerX + triggerWidth - popupWidth)
return Math.min(screenWidth - popupWidth - Theme.spacingM, triggerX + triggerWidth - popupWidth)
}
return triggerX
}
@@ -141,25 +126,15 @@ PanelWindow {
Item {
anchors.fill: parent
focus: true
Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) {
close()
event.accepted = true
} else {
event.accepted = false
}
}
Component.onCompleted: {
forceActiveFocus()
}
onVisibleChanged: {
if (visible) {
forceActiveFocus()
}
}
if (event.key === Qt.Key_Escape) {
close()
event.accepted = true
}
}
Component.onCompleted: forceActiveFocus()
onVisibleChanged: if (visible)
forceActiveFocus()
}
}
}

43
Widgets/DankScrollbar.qml Normal file
View File

@@ -0,0 +1,43 @@
import QtQuick
import QtQuick.Controls
import qs.Common
ScrollBar {
id: scrollbar
property bool _scrollBarActive: false
property alias hideTimer: hideScrollBarTimer
property bool _isParentMoving: parent && (parent.moving || parent.flicking || parent.isMomentumActive)
property bool _shouldShow: pressed || hovered || active || _isParentMoving || _scrollBarActive
policy: (parent && parent.contentHeight > parent.height) ? ScrollBar.AsNeeded : ScrollBar.AlwaysOff
minimumSize: 0.08
implicitWidth: 10
interactive: true
hoverEnabled: true
z: 1000
opacity: (policy !== ScrollBar.AlwaysOff && _shouldShow) ? 1.0 : 0.0
visible: policy !== ScrollBar.AlwaysOff
Behavior on opacity {
NumberAnimation {
duration: 160
easing.type: Easing.OutQuad
}
}
contentItem: Rectangle {
implicitWidth: 6
radius: width / 2
color: scrollbar.pressed ? Theme.primary : scrollbar._shouldShow ? Theme.outline : Theme.outlineMedium
opacity: scrollbar.pressed ? 1.0 : scrollbar._shouldShow ? 1.0 : 0.6
}
background: Item {}
Timer {
id: hideScrollBarTimer
interval: 1200
onTriggered: scrollbar._scrollBarActive = false
}
}

View File

@@ -22,6 +22,15 @@ Item {
height: 40
function updateValueFromPosition(x) {
let ratio = Math.max(0, Math.min(1, (x - sliderHandle.width / 2) / (sliderTrack.width - sliderHandle.width)))
let newValue = Math.round(minimum + ratio * (maximum - minimum))
if (newValue !== value) {
value = newValue
sliderValueChanged(newValue)
}
}
Row {
anchors.centerIn: parent
width: parent.width
@@ -41,9 +50,7 @@ Item {
property int leftIconWidth: slider.leftIcon.length > 0 ? Theme.iconSize : 0
property int rightIconWidth: slider.rightIcon.length > 0 ? Theme.iconSize : 0
width: parent.width - (leftIconWidth + rightIconWidth
+ (slider.leftIcon.length > 0 ? Theme.spacingM : 0)
+ (slider.rightIcon.length > 0 ? Theme.spacingM : 0))
width: parent.width - (leftIconWidth + rightIconWidth + (slider.leftIcon.length > 0 ? Theme.spacingM : 0) + (slider.rightIcon.length > 0 ? Theme.spacingM : 0))
height: 6
radius: 3
color: slider.enabled ? Theme.surfaceVariantAlpha : Theme.surfaceLight
@@ -52,9 +59,7 @@ Item {
StyledRect {
id: sliderFill
width: (parent.width - sliderHandle.width) * (
(slider.value - slider.minimum) / (slider.maximum - slider.minimum)
) + sliderHandle.width
width: (parent.width - sliderHandle.width) * ((slider.value - slider.minimum) / (slider.maximum - slider.minimum)) + sliderHandle.width
height: parent.height
radius: parent.radius
color: slider.enabled ? Theme.primary : Theme.surfaceVariantText
@@ -74,15 +79,11 @@ Item {
height: 18
radius: 9
color: slider.enabled ? Theme.primary : Theme.surfaceVariantText
border.color: slider.enabled ? Qt.lighter(Theme.primary,
1.3) : Qt.lighter(
Theme.surfaceVariantText,
1.3)
border.color: slider.enabled ? Qt.lighter(Theme.primary, 1.3) : Qt.lighter(Theme.surfaceVariantText, 1.3)
border.width: 2
x: sliderFill.width - width
anchors.verticalCenter: parent.verticalCenter
scale: sliderMouseArea.containsMouse
|| sliderMouseArea.pressed ? 1.2 : 1
scale: sliderMouseArea.containsMouse || sliderMouseArea.pressed ? 1.2 : 1
StyledRect {
anchors.centerIn: parent
@@ -107,8 +108,7 @@ Item {
anchors.bottom: parent.top
anchors.bottomMargin: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
visible: (sliderMouseArea.containsMouse && slider.showValue)
|| (slider.isDragging && slider.showValue)
visible: (sliderMouseArea.containsMouse && slider.showValue) || (slider.isDragging && slider.showValue)
opacity: visible ? 1 : 0
StyledText {
@@ -147,76 +147,32 @@ Item {
id: sliderMouseArea
property bool isDragging: false
property real scrollAccumulator: 0
property real touchpadThreshold: 20
anchors.fill: parent
anchors.topMargin: -10
anchors.bottomMargin: -10
hoverEnabled: true
cursorShape: slider.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: slider.enabled
preventStealing: true
acceptedButtons: Qt.LeftButton
onWheel: (wheelEvent) => {
if (!slider.enabled || !slider.wheelEnabled) {
wheelEvent.accepted = false
return
}
const deltaY = wheelEvent.angleDelta.y
const isMouseWheel = Math.abs(deltaY) >= 120
&& (Math.abs(deltaY) % 120) === 0
let currentValue = slider.value
if (isMouseWheel) {
// Direct mouse wheel action - 5% steps
let step = Math.max(1, (slider.maximum - slider.minimum) / 20)
let newValue
if (deltaY > 0)
newValue = Math.min(slider.maximum, currentValue + step)
else
newValue = Math.max(slider.minimum, currentValue - step)
newValue = Math.round(newValue)
if (newValue !== slider.value) {
slider.value = newValue
slider.sliderValueChanged(newValue)
}
} else {
// Touchpad - accumulate then apply 1% steps
scrollAccumulator += deltaY
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
let step = Math.max(0.5, (slider.maximum - slider.minimum) / 100)
let newValue
if (scrollAccumulator > 0)
newValue = Math.min(slider.maximum, currentValue + step)
else
newValue = Math.max(slider.minimum, currentValue - step)
newValue = Math.round(newValue)
if (newValue !== slider.value) {
slider.value = newValue
slider.sliderValueChanged(newValue)
}
scrollAccumulator = 0
}
}
wheelEvent.accepted = true
}
onWheel: wheelEvent => {
if (!slider.wheelEnabled)
return
let step = Math.max(1, (maximum - minimum) / 20)
let newValue = wheelEvent.angleDelta.y > 0 ? Math.min(maximum, value + step) : Math.max(minimum, value - step)
newValue = Math.round(newValue)
if (newValue !== value) {
value = newValue
sliderValueChanged(newValue)
}
wheelEvent.accepted = true
}
onPressed: mouse => {
if (slider.enabled) {
slider.isDragging = true
sliderMouseArea.isDragging = true
let ratio = Math.max(
0, Math.min(1, (
mouse.x - sliderHandle.width / 2) / (
width - sliderHandle.width)))
let newValue = Math.round(
slider.minimum + ratio
* (slider.maximum - slider.minimum))
slider.value = newValue
slider.sliderValueChanged(newValue)
updateValueFromPosition(mouse.x)
}
}
onReleased: {
@@ -227,68 +183,16 @@ Item {
}
}
onPositionChanged: mouse => {
if (pressed && slider.isDragging
&& slider.enabled) {
let ratio = Math.max(
0, Math.min(1, (
mouse.x - sliderHandle.width / 2) / (
width - sliderHandle.width)))
let newValue = Math.round(
slider.minimum + ratio
* (slider.maximum - slider.minimum))
slider.value = newValue
slider.sliderValueChanged(
newValue)
if (pressed && slider.isDragging && slider.enabled) {
updateValueFromPosition(mouse.x)
}
}
onClicked: mouse => {
if (slider.enabled && !slider.isDragging) {
let ratio = Math.max(
0, Math.min(1, (
mouse.x - sliderHandle.width / 2) / (
width - sliderHandle.width)))
let newValue = Math.round(
slider.minimum + ratio
* (slider.maximum - slider.minimum))
slider.value = newValue
slider.sliderValueChanged(newValue)
updateValueFromPosition(mouse.x)
}
}
}
MouseArea {
id: sliderGlobalMouseArea
anchors.fill: sliderContainer
enabled: slider.isDragging
visible: false
preventStealing: true
onPositionChanged: mouse => {
if (slider.isDragging
&& slider.enabled) {
let globalPos = mapToItem(
sliderTrack,
mouse.x, mouse.y)
let ratio = Math.max(
0, Math.min(
1,
globalPos.x / sliderTrack.width))
let newValue = Math.round(
slider.minimum + ratio
* (slider.maximum - slider.minimum))
slider.value = newValue
slider.sliderValueChanged(
newValue)
}
}
onReleased: {
if (slider.isDragging && slider.enabled) {
slider.isDragging = false
sliderMouseArea.isDragging = false
slider.sliderDragFinished(slider.value)
}
}
}
}
}

View File

@@ -26,19 +26,11 @@ Item {
id: tabRepeater
Rectangle {
property int tabCount: tabRepeater.count
property bool isActive: tabBar.currentIndex === index
property bool hasIcon: tabBar.showIcons && modelData
&& ("icon" in modelData)
&& modelData.icon
&& modelData.icon.length > 0
property bool hasText: modelData && ("text" in modelData)
&& modelData.text
&& modelData.text.length > 0
property bool hasIcon: tabBar.showIcons && modelData && modelData.icon && modelData.icon.length > 0
property bool hasText: modelData && modelData.text && modelData.text.length > 0
width: tabBar.equalWidthTabs ? (tabBar.width - tabBar.spacing * (tabCount - 1))
/ tabCount : contentRow.implicitWidth
+ Theme.spacingM * 2
width: tabBar.equalWidthTabs ? (tabBar.width - tabBar.spacing * (tabRepeater.count - 1)) / tabRepeater.count : contentRow.implicitWidth + Theme.spacingM * 2
height: tabBar.tabHeight
radius: Theme.cornerRadius
color: isActive ? Theme.primaryPressed : tabArea.containsMouse ? Theme.primaryHoverLight : "transparent"
@@ -52,19 +44,19 @@ Item {
DankIcon {
name: modelData.icon || ""
size: Theme.iconSize - 4
color: parent.parent.isActive ? Theme.primary : Theme.surfaceText
color: isActive ? Theme.primary : Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
visible: parent.parent.hasIcon
visible: hasIcon
}
StyledText {
text: modelData.text || ""
font.pixelSize: Theme.fontSizeMedium
color: parent.parent.isActive ? Theme.primary : Theme.surfaceText
font.weight: parent.parent.isActive ? Font.Medium : Font.Normal
color: isActive ? Theme.primary : Theme.surfaceText
font.weight: isActive ? Font.Medium : Font.Normal
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 1
visible: parent.parent.hasText
visible: hasText
}
}

View File

@@ -10,34 +10,24 @@ StyledRect {
property string placeholderText: ""
property alias font: textInput.font
property alias textColor: textInput.color
property alias selectByMouse: textInput.selectByMouse
property alias enabled: textInput.enabled
property alias echoMode: textInput.echoMode
property alias verticalAlignment: textInput.verticalAlignment
property alias cursorVisible: textInput.cursorVisible
property alias readOnly: textInput.readOnly
property alias validator: textInput.validator
property alias inputMethodHints: textInput.inputMethodHints
property alias maximumLength: textInput.maximumLength
property string leftIconName: ""
property int leftIconSize: Theme.iconSize
property color leftIconColor: Theme.surfaceVariantText
property color leftIconFocusedColor: Theme.primary
property bool showClearButton: false
property color backgroundColor: Qt.rgba(Theme.surfaceContainer.r,
Theme.surfaceContainer.g,
Theme.surfaceContainer.b, 0.9)
property color backgroundColor: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.9)
property color focusedBorderColor: Theme.primary
property color normalBorderColor: Theme.outlineStrong
property color placeholderColor: Theme.outlineButton
property int borderWidth: 1
property int focusedBorderWidth: 2
property real cornerRadius: Theme.cornerRadius
readonly property real leftPadding: Theme.spacingM
+ (leftIconName ? leftIconSize + Theme.spacingM : 0)
readonly property real rightPadding: Theme.spacingM + (showClearButton
&& text.length
> 0 ? 24 + Theme.spacingM : 0)
readonly property real leftPadding: Theme.spacingM + (leftIconName ? leftIconSize + Theme.spacingM : 0)
readonly property real rightPadding: Theme.spacingM + (showClearButton && text.length > 0 ? 24 + Theme.spacingM : 0)
property real topPadding: Theme.spacingM
property real bottomPadding: Theme.spacingM
property bool ignoreLeftRightKeys: false
@@ -51,47 +41,22 @@ StyledRect {
function getActiveFocus() {
return textInput.activeFocus
}
function getFocus() {
return textInput.focus
}
function setFocus(value) {
textInput.focus = value
}
function forceActiveFocus() {
textInput.forceActiveFocus()
}
function selectAll() {
textInput.selectAll()
}
function clear() {
textInput.clear()
}
function paste() {
textInput.paste()
}
function copy() {
textInput.copy()
}
function cut() {
textInput.cut()
}
function insertText(str) {
textInput.insert(textInput.cursorPosition, str)
}
function clearFocus() {
textInput.focus = false
}
width: 200
height: 48
radius: cornerRadius
@@ -129,14 +94,14 @@ StyledRect {
onAccepted: root.accepted()
onActiveFocusChanged: root.focusStateChanged(activeFocus)
Keys.forwardTo: root.ignoreLeftRightKeys ? root.keyForwardTargets : []
Keys.onLeftPressed: function (event) {
if (root.ignoreLeftRightKeys)
event.accepted = true
}
Keys.onRightPressed: function (event) {
if (root.ignoreLeftRightKeys)
event.accepted = true
}
Keys.onLeftPressed: event => {
if (root.ignoreLeftRightKeys)
event.accepted = true
}
Keys.onRightPressed: event => {
if (root.ignoreLeftRightKeys)
event.accepted = true
}
MouseArea {
anchors.fill: parent

View File

@@ -15,43 +15,45 @@ Item {
signal clicked
signal toggled(bool checked)
width: (text && !hideText) ? parent.width : 48
height: (text && !hideText) ? 60 : 24
readonly property bool showText: text && !hideText
width: showText ? parent.width : 48
height: showText ? 60 : 24
function handleClick() {
if (!enabled) {
return
}
checked = !checked
clicked()
toggled(checked)
}
StyledRect {
id: background
anchors.fill: parent
radius: (toggle.text && !toggle.hideText) ? Theme.cornerRadius : 0
color: (toggle.text
&& !toggle.hideText) ? Theme.surfaceHover : "transparent"
visible: (toggle.text && !toggle.hideText)
radius: showText ? Theme.cornerRadius : 0
color: showText ? Theme.surfaceHover : "transparent"
visible: showText
StateLayer {
visible: (toggle.text && !toggle.hideText)
visible: showText
disabled: !toggle.enabled
stateColor: Theme.primary
cornerRadius: parent.radius
onClicked: {
if (toggle.enabled) {
toggle.checked = !toggle.checked
toggle.clicked()
toggle.toggled(toggle.checked)
}
}
onClicked: toggle.handleClick()
}
}
Row {
id: textRow
anchors.left: parent.left
anchors.right: toggleTrack.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Theme.spacingM
anchors.rightMargin: Theme.spacingM
spacing: Theme.spacingXS
visible: (toggle.text && !toggle.hideText)
visible: showText
Column {
anchors.verticalCenter: parent.verticalCenter
@@ -78,15 +80,14 @@ Item {
StyledRect {
id: toggleTrack
width: toggle.text ? 48 : parent.width
height: toggle.text ? 24 : parent.height
width: text ? 48 : parent.width
height: text ? 24 : parent.height
anchors.right: parent.right
anchors.rightMargin: toggle.text ? Theme.spacingM : 0
anchors.rightMargin: text ? Theme.spacingM : 0
anchors.verticalCenter: parent.verticalCenter
radius: height / 2
color: (toggle.checked
&& toggle.enabled) ? Theme.primary : Theme.surfaceVariantAlpha
opacity: toggle.toggling ? 0.6 : (toggle.enabled ? 1 : 0.4)
color: (checked && enabled) ? Theme.primary : Theme.surfaceVariantAlpha
opacity: toggling ? 0.6 : (enabled ? 1 : 0.4)
StyledRect {
id: toggleHandle
@@ -96,18 +97,9 @@ Item {
radius: 10
color: Theme.surface
anchors.verticalCenter: parent.verticalCenter
x: (toggle.checked && toggle.enabled) ? parent.width - width - 2 : 2
StyledRect {
anchors.centerIn: parent
width: parent.width + 2
height: parent.height + 2
radius: (parent.width + 2) / 2
color: "transparent"
border.color: Qt.rgba(0, 0, 0, 0.1)
border.width: 1
z: -1
}
x: (checked && enabled) ? parent.width - width - 2 : 2
border.color: Qt.rgba(0, 0, 0, 0.1)
border.width: 1
Behavior on x {
NumberAnimation {
@@ -122,13 +114,7 @@ Item {
disabled: !toggle.enabled
stateColor: Theme.primary
cornerRadius: parent.radius
onClicked: {
if (toggle.enabled) {
toggle.checked = !toggle.checked
toggle.clicked()
toggle.toggled(toggle.checked)
}
}
onClicked: toggle.handleClick()
}
}
}

View File

@@ -1,222 +0,0 @@
import QtQuick
import QtQuick.Controls
import qs.Common
import qs.Widgets
Popup {
id: root
property var allWidgets: []
property string targetSection: ""
property bool isOpening: false
signal widgetSelected(string widgetId, string targetSection)
function safeOpen() {
if (!isOpening && !visible) {
isOpening = true
open()
}
}
width: 400
height: 450
modal: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
onOpened: {
isOpening = false
}
onClosed: {
isOpening = false
allWidgets = []
targetSection = ""
}
background: Rectangle {
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g,
Theme.surfaceContainer.b, 1)
border.color: Theme.primarySelected
border.width: 1
radius: Theme.cornerRadius
}
contentItem: Item {
anchors.fill: parent
DankActionButton {
iconName: "close"
iconSize: Theme.iconSize - 2
iconColor: Theme.outline
hoverColor: Theme.primaryContainer
anchors.top: parent.top
anchors.topMargin: Theme.spacingM
anchors.right: parent.right
anchors.rightMargin: Theme.spacingM
onClicked: root.close()
}
Column {
id: contentColumn
spacing: Theme.spacingM
anchors.fill: parent
anchors.margins: Theme.spacingL
anchors.topMargin: Theme.spacingL + 30 // Space for close button
Row {
width: parent.width
spacing: Theme.spacingM
DankIcon {
name: "add_circle"
size: Theme.iconSize
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: "Add Widget to " + root.targetSection + " Section"
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.Medium
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
}
}
StyledText {
text: "Select a widget to add to the " + root.targetSection.toLowerCase(
) + " section of the top bar. You can add multiple instances of the same widget if needed."
font.pixelSize: Theme.fontSizeSmall
color: Theme.outline
width: parent.width
wrapMode: Text.WordWrap
}
ScrollView {
width: parent.width
height: parent.height - 120 // Leave space for header and description
clip: true
DankListView {
id: widgetList
spacing: Theme.spacingS
model: root.allWidgets
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
interactive: true
flickDeceleration: 1500
maximumFlickVelocity: 2000
boundsBehavior: Flickable.DragAndOvershootBounds
boundsMovement: Flickable.FollowBoundsBehavior
pressDelay: 0
flickableDirection: Flickable.VerticalFlick
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
WheelHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
property real momentum: 0
onWheel: event => {
if (event.pixelDelta.y !== 0) {
// Touchpad with pixel delta
momentum = event.pixelDelta.y * 1.8
} else {
// Mouse wheel with angle delta
momentum = (event.angleDelta.y / 120)
* ((60 + parent.spacing)
* 2.5) // ~2.5 items per wheel step
}
let newY = parent.contentY - momentum
newY = Math.max(
0, Math.min(
parent.contentHeight - parent.height,
newY))
parent.contentY = newY
momentum *= 0.92 // Decay for smooth momentum
event.accepted = true
}
}
delegate: Rectangle {
width: widgetList.width
height: 60
radius: Theme.cornerRadius
color: widgetArea.containsMouse ? Theme.primaryHover : Qt.rgba(
Theme.surfaceVariant.r,
Theme.surfaceVariant.g,
Theme.surfaceVariant.b,
0.3)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.2)
border.width: 1
Row {
anchors.fill: parent
anchors.margins: Theme.spacingM
spacing: Theme.spacingM
DankIcon {
name: modelData.icon
size: Theme.iconSize
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: 2
width: parent.width - Theme.iconSize - Theme.spacingM * 3
StyledText {
text: modelData.text
font.pixelSize: Theme.fontSizeMedium
font.weight: Font.Medium
color: Theme.surfaceText
elide: Text.ElideRight
width: parent.width
}
StyledText {
text: modelData.description
font.pixelSize: Theme.fontSizeSmall
color: Theme.outline
elide: Text.ElideRight
width: parent.width
wrapMode: Text.WordWrap
}
}
DankIcon {
name: "add"
size: Theme.iconSize - 4
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: widgetArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
root.widgetSelected(modelData.id,
root.targetSection)
root.close()
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
}
}
}
}
}

View File

@@ -1,24 +1,22 @@
import QtQuick
import qs.Common
import qs.Widgets
MouseArea {
id: root
property bool disabled: false
property color stateColor: Theme.surfaceText
property real cornerRadius: parent?.radius ?? Theme.cornerRadius
property real cornerRadius: parent && parent.radius !== undefined ? parent.radius : Theme.cornerRadius
readonly property real stateOpacity: disabled ? 0 : pressed ? 0.12 : containsMouse ? 0.08 : 0
anchors.fill: parent
cursorShape: disabled ? undefined : Qt.PointingHandCursor
hoverEnabled: true
Rectangle {
id: hoverLayer
anchors.fill: parent
radius: root.cornerRadius
color: Qt.rgba(
root.stateColor.r, root.stateColor.g, root.stateColor.b,
root.disabled ? 0 : root.pressed ? 0.12 : root.containsMouse ? 0.08 : 0)
color: Qt.rgba(stateColor.r, stateColor.g, stateColor.b, stateOpacity)
}
}

View File

@@ -2,32 +2,36 @@ import QtQuick
import qs.Common
Rectangle {
id: root
color: "transparent"
radius: Appearance.rounding.normal
readonly property var standardAnimation: {
"duration": Appearance.anim.durations.normal,
"easing.type": Easing.BezierSpline,
"easing.bezierCurve": Appearance.anim.curves.standard
}
Behavior on color {
ColorAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
duration: standardAnimation.duration
easing.type: standardAnimation["easing.type"]
easing.bezierCurve: standardAnimation["easing.bezierCurve"]
}
}
Behavior on radius {
NumberAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
duration: standardAnimation.duration
easing.type: standardAnimation["easing.type"]
easing.bezierCurve: standardAnimation["easing.bezierCurve"]
}
}
Behavior on opacity {
NumberAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
duration: standardAnimation.duration
easing.type: standardAnimation["easing.type"]
easing.bezierCurve: standardAnimation["easing.bezierCurve"]
}
}
}

View File

@@ -3,22 +3,30 @@ import qs.Common
import qs.Services
Text {
id: root
property bool isMonospace: false
color: Theme.surfaceText
font.pixelSize: Appearance.fontSize.normal
font.family: {
var requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily
var defaultFont = isMonospace ? SettingsData.defaultMonoFontFamily : SettingsData.defaultFontFamily
readonly property string resolvedFontFamily: {
const requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily
const defaultFont = isMonospace ? SettingsData.defaultMonoFontFamily : SettingsData.defaultFontFamily
if (requestedFont === defaultFont) {
var availableFonts = Qt.fontFamilies()
if (!availableFonts.includes(requestedFont))
const availableFonts = Qt.fontFamilies()
if (!availableFonts.includes(requestedFont)) {
return isMonospace ? "Monospace" : "DejaVu Sans"
}
}
return requestedFont
}
readonly property var standardAnimation: {
"duration": Appearance.anim.durations.normal,
"easing.type": Easing.BezierSpline,
"easing.bezierCurve": Appearance.anim.curves.standard
}
color: Theme.surfaceText
font.pixelSize: Appearance.fontSize.normal
font.family: resolvedFontFamily
font.weight: SettingsData.fontWeight
wrapMode: Text.WordWrap
elide: Text.ElideRight
@@ -27,17 +35,17 @@ Text {
Behavior on color {
ColorAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
duration: standardAnimation.duration
easing.type: standardAnimation["easing.type"]
easing.bezierCurve: standardAnimation["easing.bezierCurve"]
}
}
Behavior on opacity {
NumberAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
duration: standardAnimation.duration
easing.type: standardAnimation["easing.type"]
easing.bezierCurve: standardAnimation["easing.bezierCurve"]
}
}
}

View File

@@ -6,15 +6,15 @@ import Quickshell.Widgets
import qs.Common
IconImage {
id: root
property string colorOverride: ""
property real brightnessOverride: 0.5
property real contrastOverride: 1
readonly property bool hasColorOverride: colorOverride !== ""
smooth: true
asynchronous: true
layer.enabled: colorOverride !== ""
layer.enabled: hasColorOverride
Process {
running: true
@@ -22,8 +22,7 @@ IconImage {
stdout: StdioCollector {
onStreamFinished: () => {
root.source = Quickshell.iconPath(
this.text.trim(), true)
source = Quickshell.iconPath(text.trim(), true)
}
}
}