formatting

This commit is contained in:
quadbyte 2025-08-20 11:40:16 -04:00
parent c0a068ddc0
commit 0fca050ce3
8 changed files with 93 additions and 103 deletions

View file

@ -36,18 +36,13 @@ QtObject {
console.log("AdvancedMath not available, using basic eval")
// Basic preprocessing for common functions
var processed = expression.trim()
.replace(/\bpi\b/gi, Math.PI)
.replace(/\be\b/gi, Math.E)
.replace(/\bsqrt\s*\(/g, 'Math.sqrt(')
.replace(/\bsin\s*\(/g, 'Math.sin(')
.replace(/\bcos\s*\(/g, 'Math.cos(')
.replace(/\btan\s*\(/g, 'Math.tan(')
.replace(/\blog\s*\(/g, 'Math.log10(')
.replace(/\bln\s*\(/g, 'Math.log(')
.replace(/\bexp\s*\(/g, 'Math.exp(')
.replace(/\bpow\s*\(/g, 'Math.pow(')
.replace(/\babs\s*\(/g, 'Math.abs(')
var processed = expression.trim(
).replace(/\bpi\b/gi,
Math.PI).replace(/\be\b/gi,
Math.E).replace(/\bsqrt\s*\(/g,
'Math.sqrt(').replace(/\bsin\s*\(/g,
'Math.sin(').replace(/\bcos\s*\(/g,
'Math.cos(').replace(/\btan\s*\(/g, 'Math.tan(').replace(/\blog\s*\(/g, 'Math.log10(').replace(/\bln\s*\(/g, 'Math.log(').replace(/\bexp\s*\(/g, 'Math.exp(').replace(/\bpow\s*\(/g, 'Math.pow(').replace(/\babs\s*\(/g, 'Math.abs(')
// Sanitize and evaluate
if (!/^[0-9+\-*/().\s\w,]+$/.test(processed)) {
@ -90,15 +85,13 @@ QtObject {
"name": "Invalid expression",
"content": evaluation.error,
"icon": "error",
"execute": function () {
// Do nothing for invalid expressions
"execute": function () {// Do nothing for invalid expressions
}
}
}
const displayName = searchContext === "calc"
? `${expression} = ${evaluation.displayResult}`
: `${expression} = ${evaluation.displayResult}`
const displayName = searchContext
=== "calc" ? `${expression} = ${evaluation.displayResult}` : `${expression} = ${evaluation.displayResult}`
return {
"isCalculator": true,
@ -110,12 +103,10 @@ QtObject {
"execute": function () {
Quickshell.clipboardText = evaluation.displayResult
// Also copy using shell command for better compatibility
Quickshell.execDetached(["sh", "-lc", `printf %s ${evaluation.displayResult} | wl-copy -t text/plain;charset=utf-8`])
Quickshell.execDetached([
"notify-send",
"Calculator",
`${expression} = ${evaluation.displayResult} (copied to clipboard)`
])
Quickshell.execDetached(
["sh", "-lc", `printf %s ${evaluation.displayResult} | wl-copy -t text/plain;charset=utf-8`])
Quickshell.execDetached(
["notify-send", "Calculator", `${expression} = ${evaluation.displayResult} (copied to clipboard)`])
}
}
}
@ -127,8 +118,7 @@ QtObject {
"name": "Calculator",
"content": "Try: sqrt(16), sin(1), cos(0), pi*2, exp(1), pow(2,8), abs(-5)",
"icon": "calculate",
"execute": function () {
// Do nothing for placeholder
"execute": function () {// Do nothing for placeholder
}
}
}

View file

@ -58,8 +58,9 @@ QtObject {
"type": 'text',
"timestamp": clip.timestamp,
"index": index,
"textData": textContent, // Store the text data for the execute function
"execute": function () {
"textData": textContent,
"execute"// Store the text data for the execute function
: function () {
const text = this.textData || clip.content || clip
Quickshell.clipboardText = String(text)
copyText(String(text))
@ -77,8 +78,7 @@ QtObject {
"name": "No clipboard history",
"content": "No matching clipboard entries found",
"icon": "content_paste_off",
"execute": function () {
// Do nothing for empty state
"execute": function () {// Do nothing for empty state
}
}
}
@ -122,8 +122,7 @@ QtObject {
"name": ">clip",
"content": "Clipboard history - browse and restore clipboard items",
"icon": "content_paste",
"execute": function () {
// This should be handled by the parent component
"execute": function () {// This should be handled by the parent component
}
}
}

View file

@ -105,7 +105,8 @@ Singleton {
return {
"type": 'text',
"content": item,
"timestamp": new Date().getTime() - 1000 // Make it slightly older
"timestamp": new Date().getTime(
) - 1000 // Make it slightly older
}
}
return item
@ -158,7 +159,8 @@ Singleton {
return {
"type": 'text',
"content": item,
"timestamp": new Date().getTime() - 1000 // Make it slightly older
"timestamp": new Date().getTime(
) - 1000 // Make it slightly older
}
}
return item

View file

@ -37,6 +37,7 @@ Singleton {
Logger.log("IdleInhibitor", "Using systemd-inhibit strategy")
return
} catch (e) {
// systemd-inhibit not found, try Wayland tools
}
@ -46,6 +47,7 @@ Singleton {
Logger.log("IdleInhibitor", "Using wayhibitor strategy")
return
} catch (e) {
// wayhibitor not found
}
@ -86,7 +88,8 @@ Singleton {
const shouldInhibit = activeInhibitors.length > 0
if (shouldInhibit === isInhibited) {
return // No change needed
return
// No change needed
}
if (shouldInhibit) {
@ -115,7 +118,8 @@ Singleton {
// Stop system inhibition
function stopInhibition() {
if (!isInhibited) return
if (!isInhibited)
return
if (inhibitorProcess.running) {
inhibitorProcess.signal(15) // SIGTERM
@ -127,13 +131,8 @@ Singleton {
// Systemd inhibition using systemd-inhibit
function startSystemdInhibition() {
inhibitorProcess.command = [
"systemd-inhibit",
"--what=idle:sleep:handle-lid-switch",
"--why=" + reason,
"--mode=block",
"sleep", "infinity"
]
inhibitorProcess.command = ["systemd-inhibit", "--what=idle:sleep:handle-lid-switch", "--why="
+ reason, "--mode=block", "sleep", "infinity"]
inhibitorProcess.running = true
}
@ -148,14 +147,14 @@ Singleton {
id: inhibitorProcess
running: false
onExited: function(exitCode, exitStatus) {
onExited: function (exitCode, exitStatus) {
if (isInhibited) {
Logger.warn("IdleInhibitor", "Inhibitor process exited unexpectedly:", exitCode)
isInhibited = false
}
}
onStarted: function() {
onStarted: function () {
Logger.log("IdleInhibitor", "Inhibitor process started successfully")
}
}

View file

@ -83,7 +83,7 @@ RowLayout {
root.hovering = false
root.exited()
}
onWheel: function(wheel) {
onWheel: function (wheel) {
if (wheel.angleDelta.y > 0 && spinBox.value < spinBox.to) {
spinBox.increase()
} else if (wheel.angleDelta.y < 0 && spinBox.value > spinBox.from) {