formatting
This commit is contained in:
parent
c0a068ddc0
commit
0fca050ce3
8 changed files with 93 additions and 103 deletions
|
|
@ -224,10 +224,10 @@ Singleton {
|
|||
property string fontDefault: "Roboto" // Default font for all text
|
||||
property string fontFixed: "DejaVu Sans Mono" // Fixed width font for terminal
|
||||
property string fontBillboard: "Inter" // Large bold font for clocks and prominent displays
|
||||
|
||||
|
||||
// Legacy compatibility
|
||||
property string fontFamily: fontDefault // Keep for backward compatibility
|
||||
|
||||
|
||||
// Idle inhibitor state
|
||||
property bool idleInhibitorEnabled: false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,20 +34,15 @@ QtObject {
|
|||
} else {
|
||||
// Fallback to basic evaluation
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +139,7 @@ QtObject {
|
|||
// Handle direct math expressions after ">"
|
||||
const mathExpr = query.slice(1).trim()
|
||||
const evaluation = evaluate(mathExpr)
|
||||
|
||||
|
||||
if (evaluation.isValid) {
|
||||
results.push(createEntry(mathExpr, "direct"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ import qs.Widgets
|
|||
|
||||
NLoader {
|
||||
id: lockScreen
|
||||
|
||||
|
||||
// Log state changes to help debug lock screen issues
|
||||
onIsLoadedChanged: {
|
||||
Logger.log("LockScreen", "State changed - isLoaded:", isLoaded)
|
||||
}
|
||||
|
||||
|
||||
// Allow a small grace period after unlocking so the compositor releases the lock surfaces
|
||||
Timer {
|
||||
id: unloadAfterUnlockTimer
|
||||
|
|
|
|||
|
|
@ -101,15 +101,16 @@ Singleton {
|
|||
if (!exists) {
|
||||
// Normalize existing history and add the new image
|
||||
const normalizedHistory = root.history.map(item => {
|
||||
if (typeof item === 'string') {
|
||||
return {
|
||||
"type": 'text',
|
||||
"content": item,
|
||||
"timestamp": new Date().getTime() - 1000 // Make it slightly older
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
if (typeof item === 'string') {
|
||||
return {
|
||||
"type": 'text',
|
||||
"content": item,
|
||||
"timestamp": new Date().getTime(
|
||||
) - 1000 // Make it slightly older
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
root.history = [entry, ...normalizedHistory].slice(0, maxHistory)
|
||||
saveHistory()
|
||||
}
|
||||
|
|
@ -133,7 +134,7 @@ Singleton {
|
|||
|
||||
onExited: (exitCode, exitStatus) => {
|
||||
textProcess.isLoading = false
|
||||
|
||||
|
||||
if (exitCode === 0) {
|
||||
const content = String(stdout.text).trim()
|
||||
if (content && content.length > 0) {
|
||||
|
|
@ -154,15 +155,16 @@ Singleton {
|
|||
if (!exists) {
|
||||
// Normalize existing history entries
|
||||
const normalizedHistory = root.history.map(item => {
|
||||
if (typeof item === 'string') {
|
||||
return {
|
||||
"type": 'text',
|
||||
"content": item,
|
||||
"timestamp": new Date().getTime() - 1000 // Make it slightly older
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
if (typeof item === 'string') {
|
||||
return {
|
||||
"type": 'text',
|
||||
"content": item,
|
||||
"timestamp": new Date().getTime(
|
||||
) - 1000 // Make it slightly older
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
|
||||
root.history = [entry, ...normalizedHistory].slice(0, maxHistory)
|
||||
saveHistory()
|
||||
|
|
@ -204,7 +206,7 @@ Singleton {
|
|||
try {
|
||||
// Ensure we don't exceed the maximum history limit
|
||||
const limitedHistory = root.history.slice(0, maxHistory)
|
||||
|
||||
|
||||
historyAdapter.history = limitedHistory
|
||||
historyAdapter.timestamp = Time.timestamp
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Singleton {
|
|||
Component.onCompleted: {
|
||||
Logger.log("IdleInhibitor", "Service started")
|
||||
detectStrategy()
|
||||
|
||||
|
||||
// Restore previous state from settings
|
||||
if (Settings.data.ui.idleInhibitorEnabled) {
|
||||
addInhibitor("manual", "Restored from previous session")
|
||||
|
|
@ -37,18 +37,20 @@ Singleton {
|
|||
Logger.log("IdleInhibitor", "Using systemd-inhibit strategy")
|
||||
return
|
||||
} catch (e) {
|
||||
|
||||
// systemd-inhibit not found, try Wayland tools
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
var waylandResult = Quickshell.execDetached(["which", "wayhibitor"])
|
||||
strategy = "wayland"
|
||||
Logger.log("IdleInhibitor", "Using wayhibitor strategy")
|
||||
return
|
||||
} catch (e) {
|
||||
|
||||
// wayhibitor not found
|
||||
}
|
||||
|
||||
|
||||
Logger.warn("IdleInhibitor", "No suitable inhibitor found - will try systemd as fallback")
|
||||
strategy = "systemd" // Fallback to systemd even if not detected
|
||||
}
|
||||
|
|
@ -84,9 +86,10 @@ Singleton {
|
|||
// Update the actual system inhibition
|
||||
function updateInhibition(newReason = reason) {
|
||||
const shouldInhibit = activeInhibitors.length > 0
|
||||
|
||||
|
||||
if (shouldInhibit === isInhibited) {
|
||||
return // No change needed
|
||||
return
|
||||
// No change needed
|
||||
}
|
||||
|
||||
if (shouldInhibit) {
|
||||
|
|
@ -99,7 +102,7 @@ Singleton {
|
|||
// Start system inhibition
|
||||
function startInhibition(newReason) {
|
||||
reason = newReason
|
||||
|
||||
|
||||
if (strategy === "systemd") {
|
||||
startSystemdInhibition()
|
||||
} else if (strategy === "wayland") {
|
||||
|
|
@ -108,32 +111,28 @@ Singleton {
|
|||
Logger.warn("IdleInhibitor", "No inhibition strategy available")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
isInhibited = true
|
||||
Logger.log("IdleInhibitor", "Started inhibition:", reason)
|
||||
}
|
||||
|
||||
// Stop system inhibition
|
||||
function stopInhibition() {
|
||||
if (!isInhibited) return
|
||||
|
||||
if (!isInhibited)
|
||||
return
|
||||
|
||||
if (inhibitorProcess.running) {
|
||||
inhibitorProcess.signal(15) // SIGTERM
|
||||
}
|
||||
|
||||
|
||||
isInhibited = false
|
||||
Logger.log("IdleInhibitor", "Stopped inhibition")
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
@ -147,15 +146,15 @@ Singleton {
|
|||
Process {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ Image {
|
|||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ RowLayout {
|
|||
property bool enabled: true
|
||||
property bool hovering: false
|
||||
property int baseSize: Style.baseWidgetSize
|
||||
|
||||
|
||||
// Convenience properties for common naming
|
||||
property alias minimum: spinBox.from
|
||||
property alias maximum: spinBox.to
|
||||
|
|
@ -55,10 +55,10 @@ RowLayout {
|
|||
// Value
|
||||
Rectangle {
|
||||
id: spinBoxContainer
|
||||
|
||||
implicitWidth: 100 * scaling // Wider for better proportions
|
||||
implicitHeight: (root.baseSize - 4) * scaling // Slightly shorter than toggle
|
||||
radius: height * 0.5 // Fully rounded like toggle
|
||||
|
||||
implicitWidth: 100 * scaling // Wider for better proportions
|
||||
implicitHeight: (root.baseSize - 4) * scaling // Slightly shorter than toggle
|
||||
radius: height * 0.5 // Fully rounded like toggle
|
||||
color: Color.mSurfaceVariant
|
||||
border.color: root.hovering ? Color.mPrimary : Color.mOutline
|
||||
border.width: 1
|
||||
|
|
@ -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) {
|
||||
|
|
@ -95,29 +95,29 @@ RowLayout {
|
|||
// Decrease button (left)
|
||||
Rectangle {
|
||||
id: decreaseButton
|
||||
width: parent.height * 0.8 // Make it circular
|
||||
width: parent.height * 0.8 // Make it circular
|
||||
height: parent.height * 0.8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: parent.height * 0.1
|
||||
radius: width * 0.5 // Perfect circle
|
||||
radius: width * 0.5 // Perfect circle
|
||||
color: decreaseArea.containsMouse ? Color.mPrimary : "transparent"
|
||||
opacity: root.enabled && spinBox.value > spinBox.from ? 1.0 : 0.3
|
||||
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
easing.type: Easing.InOutCubic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NIcon {
|
||||
anchors.centerIn: parent
|
||||
text: "remove"
|
||||
font.pointSize: Style.fontSizeS * scaling
|
||||
color: decreaseArea.containsMouse ? Color.mOnPrimary : Color.mPrimary
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: decreaseArea
|
||||
anchors.fill: parent
|
||||
|
|
@ -127,33 +127,33 @@ RowLayout {
|
|||
onClicked: spinBox.decrease()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Increase button (right)
|
||||
Rectangle {
|
||||
id: increaseButton
|
||||
width: parent.height * 0.8 // Make it circular
|
||||
width: parent.height * 0.8 // Make it circular
|
||||
height: parent.height * 0.8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: parent.height * 0.1
|
||||
radius: width * 0.5 // Perfect circle
|
||||
radius: width * 0.5 // Perfect circle
|
||||
color: increaseArea.containsMouse ? Color.mPrimary : "transparent"
|
||||
opacity: root.enabled && spinBox.value < spinBox.to ? 1.0 : 0.3
|
||||
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
easing.type: Easing.InOutCubic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NIcon {
|
||||
anchors.centerIn: parent
|
||||
text: "add"
|
||||
font.pointSize: Style.fontSizeS * scaling
|
||||
color: increaseArea.containsMouse ? Color.mOnPrimary : Color.mPrimary
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: increaseArea
|
||||
anchors.fill: parent
|
||||
|
|
@ -163,7 +163,7 @@ RowLayout {
|
|||
onClicked: spinBox.increase()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Center value display
|
||||
SpinBox {
|
||||
id: spinBox
|
||||
|
|
@ -172,23 +172,23 @@ RowLayout {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.margins: 4 * scaling
|
||||
height: parent.height
|
||||
|
||||
|
||||
background: Item {}
|
||||
up.indicator: Item {}
|
||||
down.indicator: Item {}
|
||||
|
||||
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
font.family: Settings.data.ui.fontDefault
|
||||
|
||||
|
||||
from: 0
|
||||
to: 100
|
||||
stepSize: 1
|
||||
editable: false // Only use buttons/scroll
|
||||
editable: false // Only use buttons/scroll
|
||||
enabled: root.enabled
|
||||
|
||||
|
||||
contentItem: Item {
|
||||
anchors.fill: parent
|
||||
|
||||
|
||||
NText {
|
||||
anchors.centerIn: parent
|
||||
text: root.prefix + spinBox.value + root.suffix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue