1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

uncomment toast, and format

This commit is contained in:
bbedward
2025-07-24 19:46:05 -04:00
parent 762785b27a
commit fc52aa2c7a
21 changed files with 575 additions and 427 deletions

View File

@@ -11,7 +11,6 @@ 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` : ""
asynchronous: true
@@ -19,44 +18,45 @@ Image {
sourceSize.width: maxCacheSize
sourceSize.height: maxCacheSize
smooth: true
onImagePathChanged: {
if (imagePath) {
hashProcess.command = ["sha256sum", Paths.strip(imagePath)]
hashProcess.running = true
hashProcess.command = ["sha256sum", Paths.strip(imagePath)];
hashProcess.running = true;
} else {
source = ""
imageHash = ""
source = "";
imageHash = "";
}
}
onCachePathChanged: {
if (imageHash && cachePath) {
// Ensure cache directory exists before trying to load from cache
Paths.mkdir(Paths.imagecache)
source = cachePath
Paths.mkdir(Paths.imagecache);
source = cachePath;
}
}
onStatusChanged: {
if (source == cachePath && status === Image.Error) {
source = imagePath
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 => res.saveToFile(grabPath))
}
Paths.mkdir(Paths.imagecache);
const grabPath = cachePath;
if (visible && width > 0 && height > 0 && Window.window && Window.window.visible)
grabToImage((res) => {
return res.saveToFile(grabPath);
});
}
}
Process {
id: hashProcess
stdout: StdioCollector {
onStreamFinished: {
root.imageHash = text.split(" ")[0]
root.imageHash = text.split(" ")[0];
}
}
}
}
}

View File

@@ -18,11 +18,10 @@ Rectangle {
height: 60
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08)
onVisibleChanged: {
if (!visible && dropdownMenu.visible) {
if (!visible && dropdownMenu.visible)
dropdownMenu.close();
}
}
Column {
@@ -48,6 +47,7 @@ Rectangle {
wrapMode: Text.WordWrap
width: parent.width
}
}
Rectangle {
@@ -69,7 +69,6 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
if (dropdownMenu.visible) {
dropdownMenu.close();
@@ -85,6 +84,7 @@ Rectangle {
// Use a Row for the left-aligned content (icon + text)
Row {
id: contentRow
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Theme.spacingM
@@ -108,11 +108,13 @@ Rectangle {
width: dropdown.width - contentRow.x - expandIcon.width - Theme.spacingM - Theme.spacingS
elide: Text.ElideRight
}
}
// Anchor the expand icon to the right, outside of the Row
DankIcon {
id: expandIcon
name: "expand_more"
size: 20
color: Theme.surfaceVariantText
@@ -120,18 +122,21 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: Theme.spacingS
}
}
Popup {
id: dropdownMenu
parent: Overlay.overlay
width: 180
height: Math.min(200, root.options.length * 36 + 16)
padding: 0
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
background: Rectangle { color: "transparent" }
background: Rectangle {
color: "transparent"
}
contentItem: Rectangle {
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 1)
@@ -159,14 +164,14 @@ Rectangle {
anchors.leftMargin: Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingS
DankIcon {
name: root.optionIcons.length > index ? root.optionIcons[index] : ""
size: 18
color: root.currentValue === modelData ? Theme.primary : Theme.surfaceVariantText
visible: name !== ""
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: modelData
@@ -174,10 +179,12 @@ Rectangle {
color: root.currentValue === modelData ? Theme.primary : Theme.surfaceText
font.weight: root.currentValue === modelData ? Font.Medium : Font.Normal
}
}
MouseArea {
id: optionArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
@@ -187,9 +194,15 @@ Rectangle {
dropdownMenu.close();
}
}
}
}
}
}
}
}
}

View File

@@ -20,32 +20,29 @@ ScrollView {
property real wheelStepSize: 60
property bool hoverUpdatesSelection: true
property bool keyboardNavigationActive: false
signal keyboardNavigationReset()
signal keyboardNavigationReset()
signal itemClicked(int index, var modelData)
signal itemHovered(int index)
// Ensure the current item is visible
function ensureVisible(index) {
if (index < 0 || index >= grid.count) return;
if (index < 0 || index >= grid.count)
return ;
var itemY = Math.floor(index / grid.actualColumns) * grid.cellHeight;
var itemBottom = itemY + grid.cellHeight;
if (itemY < grid.contentY) {
if (itemY < grid.contentY)
grid.contentY = itemY;
} else if (itemBottom > grid.contentY + grid.height) {
else if (itemBottom > grid.contentY + grid.height)
grid.contentY = itemBottom - grid.height;
}
}
onCurrentIndexChanged: {
if (keyboardNavigationActive) {
if (keyboardNavigationActive)
ensureVisible(currentIndex);
}
}
}
clip: true
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
@@ -157,9 +154,9 @@ ScrollView {
cursorShape: Qt.PointingHandCursor
z: 10
onEntered: {
if (hoverUpdatesSelection && !keyboardNavigationActive) {
if (hoverUpdatesSelection && !keyboardNavigationActive)
currentIndex = index;
}
itemHovered(index);
}
onPositionChanged: {

View File

@@ -16,31 +16,29 @@ ScrollView {
property int itemSpacing: Theme.spacingS
property bool hoverUpdatesSelection: true
property bool keyboardNavigationActive: false
signal keyboardNavigationReset()
signal itemClicked(int index, var modelData)
signal itemHovered(int index)
// Ensure the current item is visible
function ensureVisible(index) {
if (index < 0 || index >= list.count) return;
if (index < 0 || index >= list.count)
return ;
var itemY = index * (itemHeight + itemSpacing);
var itemBottom = itemY + itemHeight;
if (itemY < list.contentY) {
if (itemY < list.contentY)
list.contentY = itemY;
} else if (itemBottom > list.contentY + list.height) {
else if (itemBottom > list.contentY + list.height)
list.contentY = itemBottom - list.height;
}
}
onCurrentIndexChanged: {
if (keyboardNavigationActive) {
if (keyboardNavigationActive)
ensureVisible(currentIndex);
}
}
}
clip: true
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
@@ -156,9 +154,9 @@ ScrollView {
cursorShape: Qt.PointingHandCursor
z: 10
onEntered: {
if (hoverUpdatesSelection && !keyboardNavigationActive) {
if (hoverUpdatesSelection && !keyboardNavigationActive)
listView.currentIndex = index;
}
itemHovered(index);
}
onPositionChanged: {

View File

@@ -58,7 +58,9 @@ Item {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
StyledRect {
@@ -85,15 +87,9 @@ Item {
visible: sliderMouseArea.containsMouse && slider.enabled
}
Behavior on scale {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
StyledRect {
id: valueTooltip
width: tooltipText.contentWidth + Theme.spacingS * 2
height: tooltipText.contentHeight + Theme.spacingXS * 2
radius: Theme.cornerRadiusSmall
@@ -105,9 +101,10 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
visible: (sliderMouseArea.containsMouse && slider.showValue) || (slider.isDragging && slider.showValue)
opacity: visible ? 1 : 0
Text {
id: tooltipText
text: slider.value + slider.unit
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
@@ -115,14 +112,25 @@ Item {
anchors.centerIn: parent
font.hintingPreference: Font.PreferFullHinting
}
Behavior on opacity {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
Behavior on scale {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
Item {
@@ -201,7 +209,9 @@ Item {
}
}
}
}
}
DankIcon {
@@ -211,6 +221,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
visible: slider.rightIcon.length > 0
}
}
}

View File

@@ -38,11 +38,10 @@ Rectangle {
readonly property real rightPadding: Theme.spacingM + (showClearButton && text.length > 0 ? 24 + Theme.spacingM : 0)
property real topPadding: Theme.spacingM
property real bottomPadding: Theme.spacingM
// Behavior control
property bool ignoreLeftRightKeys: false
property var keyForwardTargets: []
// Signals
signal textEdited()
signal editingFinished()
@@ -133,19 +132,16 @@ Rectangle {
onEditingFinished: root.editingFinished()
onAccepted: root.accepted()
onActiveFocusChanged: root.focusStateChanged(activeFocus)
Keys.forwardTo: root.ignoreLeftRightKeys ? root.keyForwardTargets : []
Keys.onLeftPressed: function(event) {
if (root.ignoreLeftRightKeys) {
if (root.ignoreLeftRightKeys)
event.accepted = true;
}
}
Keys.onRightPressed: function(event) {
if (root.ignoreLeftRightKeys) {
if (root.ignoreLeftRightKeys)
event.accepted = true;
}
}
MouseArea {