Merge branch 'dev' into npanel-refactor
This commit is contained in:
commit
524135800e
21 changed files with 1234 additions and 322 deletions
|
|
@ -15,30 +15,125 @@ import "../../Helpers/FuzzySort.js" as Fuzzysort
|
|||
NLoader {
|
||||
id: appLauncher
|
||||
isLoaded: false
|
||||
// Clipboard state is persisted in Services/ClipboardService.qml
|
||||
|
||||
content: Component {
|
||||
NPanel {
|
||||
id: appLauncherPanel
|
||||
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||
|
||||
// No local timer/processes; use persistent Clipboard service
|
||||
|
||||
// Removed local clipboard processes; handled by Clipboard service
|
||||
|
||||
// Copy helpers via simple exec; avoid keeping processes alive locally
|
||||
function copyImageBase64(mime, base64) {
|
||||
Quickshell.execDetached(["sh", "-lc", `printf %s ${base64} | base64 -d | wl-copy -t '${mime}'`])
|
||||
// Import modular components
|
||||
Calculator {
|
||||
id: calculator
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
Quickshell.execDetached(["sh", "-lc", `printf %s ${text} | wl-copy -t text/plain;charset=utf-8`])
|
||||
ClipboardHistory {
|
||||
id: clipboardHistory
|
||||
}
|
||||
|
||||
function updateClipboardHistory() {
|
||||
ClipboardService.refresh()
|
||||
// Properties
|
||||
property var desktopEntries: DesktopEntries.applications.values
|
||||
property string searchText: ""
|
||||
property int selectedIndex: 0
|
||||
|
||||
// Refresh clipboard when user starts typing clipboard commands
|
||||
onSearchTextChanged: {
|
||||
if (searchText.startsWith(">clip")) {
|
||||
clipboardHistory.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
// Main filtering logic
|
||||
property var filteredEntries: {
|
||||
Logger.log("AppLauncher", "Total desktop entries:", desktopEntries ? desktopEntries.length : 0)
|
||||
if (!desktopEntries || desktopEntries.length === 0) {
|
||||
Logger.log("AppLauncher", "No desktop entries available")
|
||||
return []
|
||||
}
|
||||
|
||||
// Filter out entries that shouldn't be displayed
|
||||
var visibleEntries = desktopEntries.filter(entry => {
|
||||
if (!entry || entry.noDisplay) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
Logger.log("AppLauncher", "Visible entries:", visibleEntries.length)
|
||||
|
||||
var query = searchText ? searchText.toLowerCase() : ""
|
||||
var results = []
|
||||
|
||||
// Handle special commands
|
||||
if (query === ">") {
|
||||
results.push({
|
||||
"isCommand": true,
|
||||
"name": ">calc",
|
||||
"content": "Calculator - evaluate mathematical expressions",
|
||||
"icon": "calculate",
|
||||
"execute": executeCalcCommand
|
||||
})
|
||||
|
||||
results.push({
|
||||
"isCommand": true,
|
||||
"name": ">clip",
|
||||
"content": "Clipboard history - browse and restore clipboard items",
|
||||
"icon": "content_paste",
|
||||
"execute": executeClipCommand
|
||||
})
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// Handle clipboard history
|
||||
if (query.startsWith(">clip")) {
|
||||
return clipboardHistory.processQuery(query)
|
||||
}
|
||||
|
||||
// Handle calculator
|
||||
if (query.startsWith(">calc")) {
|
||||
return calculator.processQuery(query, "calc")
|
||||
}
|
||||
|
||||
// Handle direct math expressions after ">"
|
||||
if (query.startsWith(">") && query.length > 1 && !query.startsWith(">clip") && !query.startsWith(">calc")) {
|
||||
const mathResults = calculator.processQuery(query, "direct")
|
||||
if (mathResults.length > 0) {
|
||||
return mathResults
|
||||
}
|
||||
// If math evaluation fails, fall through to regular search
|
||||
}
|
||||
|
||||
// Regular app search
|
||||
if (!query) {
|
||||
results = results.concat(visibleEntries.sort(function (a, b) {
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
||||
}))
|
||||
} else {
|
||||
var fuzzyResults = Fuzzysort.go(query, visibleEntries, {
|
||||
"keys": ["name", "comment", "genericName"]
|
||||
})
|
||||
results = results.concat(fuzzyResults.map(function (r) {
|
||||
return r.obj
|
||||
}))
|
||||
}
|
||||
|
||||
Logger.log("AppLauncher", "Filtered entries:", results.length)
|
||||
return results
|
||||
}
|
||||
|
||||
// Command execution functions
|
||||
function executeCalcCommand() {
|
||||
searchText = ">calc "
|
||||
searchInput.cursorPosition = searchText.length
|
||||
}
|
||||
|
||||
function executeClipCommand() {
|
||||
searchText = ">clip "
|
||||
searchInput.cursorPosition = searchText.length
|
||||
}
|
||||
|
||||
// Navigation functions
|
||||
function selectNext() {
|
||||
if (filteredEntries.length > 0) {
|
||||
selectedIndex = Math.min(selectedIndex + 1, filteredEntries.length - 1)
|
||||
|
|
@ -67,233 +162,6 @@ NLoader {
|
|||
}
|
||||
}
|
||||
|
||||
property var desktopEntries: DesktopEntries.applications.values
|
||||
property string searchText: ""
|
||||
property int selectedIndex: 0
|
||||
|
||||
// Refresh clipboard when user starts typing clipboard commands
|
||||
onSearchTextChanged: {
|
||||
if (searchText.startsWith(">clip")) {
|
||||
ClipboardService.refresh()
|
||||
}
|
||||
}
|
||||
property var filteredEntries: {
|
||||
Logger.log("AppLauncher", "Total desktop entries:", desktopEntries ? desktopEntries.length : 0)
|
||||
if (!desktopEntries || desktopEntries.length === 0) {
|
||||
Logger.log("AppLauncher", "No desktop entries available")
|
||||
return []
|
||||
}
|
||||
|
||||
// Filter out entries that shouldn't be displayed
|
||||
var visibleEntries = desktopEntries.filter(entry => {
|
||||
if (!entry || entry.noDisplay) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
Logger.log("AppLauncher", "Visible entries:", visibleEntries.length)
|
||||
|
||||
var query = searchText ? searchText.toLowerCase() : ""
|
||||
var results = []
|
||||
|
||||
// Handle special commands
|
||||
if (query === ">") {
|
||||
results.push({
|
||||
"isCommand": true,
|
||||
"name": ">calc",
|
||||
"content": "Calculator - evaluate mathematical expressions",
|
||||
"icon": "tag",
|
||||
"execute": function () {
|
||||
searchText = ">calc "
|
||||
searchInput.cursorPosition = searchText.length
|
||||
}
|
||||
})
|
||||
|
||||
results.push({
|
||||
"isCommand": true,
|
||||
"name": ">clip",
|
||||
"content": "Clipboard history - browse and restore clipboard items",
|
||||
"icon": "content_paste",
|
||||
"execute": function () {
|
||||
searchText = ">clip "
|
||||
searchInput.cursorPosition = searchText.length
|
||||
}
|
||||
})
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// Handle clipboard history
|
||||
if (query.startsWith(">clip")) {
|
||||
const searchTerm = query.slice(5).trim()
|
||||
|
||||
ClipboardService.history.forEach(function (clip, index) {
|
||||
let searchContent = clip.type === 'image' ? clip.mimeType : clip.content || clip
|
||||
|
||||
if (!searchTerm || searchContent.toLowerCase().includes(searchTerm)) {
|
||||
let entry
|
||||
if (clip.type === 'image') {
|
||||
entry = {
|
||||
"isClipboard": true,
|
||||
"name": "Image from " + new Date(clip.timestamp).toLocaleTimeString(),
|
||||
"content": "Image: " + clip.mimeType,
|
||||
"icon": "image",
|
||||
"type": 'image',
|
||||
"data": clip.data,
|
||||
"execute": function () {
|
||||
const base64Data = clip.data.split(',')[1]
|
||||
copyImageBase64(clip.mimeType, base64Data)
|
||||
Quickshell.execDetached(["notify-send", "Clipboard", "Image copied: " + clip.mimeType])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const textContent = clip.content || clip
|
||||
let displayContent = textContent
|
||||
let previewContent = ""
|
||||
|
||||
displayContent = displayContent.replace(/\s+/g, ' ').trim()
|
||||
|
||||
if (displayContent.length > 50) {
|
||||
previewContent = displayContent
|
||||
displayContent = displayContent.split('\n')[0].substring(0, 50) + "..."
|
||||
}
|
||||
|
||||
entry = {
|
||||
"isClipboard": true,
|
||||
"name": displayContent,
|
||||
"content": previewContent || textContent,
|
||||
"icon": "content_paste",
|
||||
"execute": function () {
|
||||
Quickshell.clipboardText = String(textContent)
|
||||
copyText(String(textContent))
|
||||
var preview = (textContent.length > 50) ? textContent.slice(0, 50) + "…" : textContent
|
||||
Quickshell.execDetached(["notify-send", "Clipboard", "Text copied: " + preview])
|
||||
}
|
||||
}
|
||||
}
|
||||
results.push(entry)
|
||||
}
|
||||
})
|
||||
|
||||
if (results.length === 0) {
|
||||
results.push({
|
||||
"isClipboard": true,
|
||||
"name": "No clipboard history",
|
||||
"content": "No matching clipboard entries found",
|
||||
"icon": "content_paste_off"
|
||||
})
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// Handle direct math expressions after ">"
|
||||
if (query.startsWith(">") && query.length > 1 && !query.startsWith(">clip") && !query.startsWith(">calc")) {
|
||||
var mathExpr = query.slice(1).trim()
|
||||
// Check if it looks like a math expression (contains numbers and math operators)
|
||||
if (mathExpr && /[0-9+\-*/().]/.test(mathExpr)) {
|
||||
try {
|
||||
var sanitizedExpr = mathExpr.replace(/[^0-9+\-*/().\s]/g, '')
|
||||
var result = eval(sanitizedExpr)
|
||||
|
||||
if (isFinite(result) && !isNaN(result)) {
|
||||
var displayResult = Number.isInteger(result) ? result.toString() : result.toFixed(6).replace(/\.?0+$/, '')
|
||||
results.push({
|
||||
"isCalculator": true,
|
||||
"name": `${mathExpr} = ${displayResult}`,
|
||||
"result": result,
|
||||
"expr": mathExpr,
|
||||
"icon": "tag",
|
||||
"execute": function () {
|
||||
Quickshell.clipboardText = displayResult
|
||||
copyText(displayResult)
|
||||
Quickshell.execDetached(
|
||||
["notify-send", "Calculator", `${mathExpr} = ${displayResult} (copied to clipboard)`])
|
||||
}
|
||||
})
|
||||
return results
|
||||
}
|
||||
} catch (error) {
|
||||
// If math evaluation fails, fall through to regular search
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle calculator
|
||||
if (query.startsWith(">calc")) {
|
||||
var expr = searchText.slice(5).trim()
|
||||
if (expr && expr !== "") {
|
||||
try {
|
||||
// Simple evaluation - only allow basic math operations
|
||||
var sanitizedExpr = expr.replace(/[^0-9+\-*/().\s]/g, '')
|
||||
var result = eval(sanitizedExpr)
|
||||
|
||||
if (isFinite(result) && !isNaN(result)) {
|
||||
var displayResult = Number.isInteger(result) ? result.toString() : result.toFixed(6).replace(/\.?0+$/,
|
||||
'')
|
||||
results.push({
|
||||
"isCalculator": true,
|
||||
"name": `${expr} = ${displayResult}`,
|
||||
"result": result,
|
||||
"expr": expr,
|
||||
"icon": "tag",
|
||||
"execute": function () {
|
||||
Quickshell.clipboardText = displayResult
|
||||
copyText(displayResult)
|
||||
Quickshell.execDetached(
|
||||
["notify-send", "Calculator", `${expr} = ${displayResult} (copied to clipboard)`])
|
||||
}
|
||||
})
|
||||
} else {
|
||||
results.push({
|
||||
"isCalculator": true,
|
||||
"name": "Invalid expression",
|
||||
"content": "Please enter a valid mathematical expression",
|
||||
"icon": "tag",
|
||||
"execute": function () {}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
results.push({
|
||||
"isCalculator": true,
|
||||
"name": "Invalid expression",
|
||||
"content": "Please enter a valid mathematical expression",
|
||||
"icon": "tag",
|
||||
"execute": function () {}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// Show placeholder when just ">calc" is entered
|
||||
results.push({
|
||||
"isCalculator": true,
|
||||
"name": "Calculator",
|
||||
"content": "Enter a mathematical expression (e.g., 5+5, 2*3, 10/2)",
|
||||
"icon": "tag",
|
||||
"execute": function () {}
|
||||
})
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
// Regular app search
|
||||
if (!query) {
|
||||
results = results.concat(visibleEntries.sort(function (a, b) {
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
||||
}))
|
||||
} else {
|
||||
var fuzzyResults = Fuzzysort.go(query, visibleEntries, {
|
||||
"keys": ["name", "comment", "genericName"]
|
||||
})
|
||||
results = results.concat(fuzzyResults.map(function (r) {
|
||||
return r.obj
|
||||
}))
|
||||
}
|
||||
|
||||
Logger.log("AppLauncher", "Filtered entries:", results.length)
|
||||
return results
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Logger.log("AppLauncher", "Component completed")
|
||||
Logger.log("AppLauncher", "DesktopEntries available:", typeof DesktopEntries !== 'undefined')
|
||||
|
|
@ -302,7 +170,7 @@ NLoader {
|
|||
DesktopEntries.entries ? DesktopEntries.entries.length : 'undefined')
|
||||
}
|
||||
// Start clipboard refresh immediately on open
|
||||
updateClipboardHistory()
|
||||
clipboardHistory.refresh()
|
||||
}
|
||||
|
||||
// Main content container
|
||||
|
|
@ -368,7 +236,8 @@ NLoader {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
onTextChanged: {
|
||||
searchText = text
|
||||
selectedIndex = 0 // Reset selection when search changes
|
||||
// Defer selectedIndex reset to avoid binding loops
|
||||
Qt.callLater(() => selectedIndex = 0)
|
||||
}
|
||||
selectedTextColor: Color.mOnSurface
|
||||
selectionColor: Color.mPrimary
|
||||
|
|
@ -500,7 +369,7 @@ NLoader {
|
|||
visible: !parent.iconLoaded
|
||||
}
|
||||
|
||||
Text {
|
||||
NText {
|
||||
anchors.centerIn: parent
|
||||
visible: !parent.iconLoaded && !(modelData.isCalculator || modelData.isClipboard
|
||||
|| modelData.isCommand)
|
||||
|
|
|
|||
161
Modules/AppLauncher/Calculator.qml
Normal file
161
Modules/AppLauncher/Calculator.qml
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
import "../../Helpers/AdvancedMath.js" as AdvancedMath
|
||||
|
||||
QtObject {
|
||||
id: calculator
|
||||
|
||||
// Function to evaluate mathematical expressions
|
||||
function evaluate(expression) {
|
||||
if (!expression || expression.trim() === "") {
|
||||
return {
|
||||
"isValid": false,
|
||||
"result": "",
|
||||
"displayResult": "",
|
||||
"error": "Empty expression"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Try advanced math first
|
||||
if (typeof AdvancedMath !== 'undefined') {
|
||||
const result = AdvancedMath.evaluate(expression.trim())
|
||||
const displayResult = AdvancedMath.formatResult(result)
|
||||
|
||||
return {
|
||||
"isValid": true,
|
||||
"result": result,
|
||||
"displayResult": displayResult,
|
||||
"expression": expression,
|
||||
"error": ""
|
||||
}
|
||||
} 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(')
|
||||
|
||||
// Sanitize and evaluate
|
||||
if (!/^[0-9+\-*/().\s\w,]+$/.test(processed)) {
|
||||
throw new Error("Invalid characters in expression")
|
||||
}
|
||||
|
||||
const result = eval(processed)
|
||||
|
||||
if (!isFinite(result) || isNaN(result)) {
|
||||
throw new Error("Invalid result")
|
||||
}
|
||||
|
||||
const displayResult = Number.isInteger(result) ? result.toString() : result.toFixed(6).replace(/\.?0+$/, '')
|
||||
|
||||
return {
|
||||
"isValid": true,
|
||||
"result": result,
|
||||
"displayResult": displayResult,
|
||||
"expression": expression,
|
||||
"error": ""
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
"isValid": false,
|
||||
"result": "",
|
||||
"displayResult": "",
|
||||
"error": error.message || error.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate calculator entry for display
|
||||
function createEntry(expression, searchContext = "") {
|
||||
const evaluation = evaluate(expression)
|
||||
|
||||
if (!evaluation.isValid) {
|
||||
return {
|
||||
"isCalculator": true,
|
||||
"name": "Invalid expression",
|
||||
"content": evaluation.error,
|
||||
"icon": "error",
|
||||
"execute": function () {
|
||||
// Do nothing for invalid expressions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const displayName = searchContext === "calc"
|
||||
? `${expression} = ${evaluation.displayResult}`
|
||||
: `${expression} = ${evaluation.displayResult}`
|
||||
|
||||
return {
|
||||
"isCalculator": true,
|
||||
"name": displayName,
|
||||
"result": evaluation.result,
|
||||
"expr": expression,
|
||||
"displayResult": evaluation.displayResult,
|
||||
"icon": "calculate",
|
||||
"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)`
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create placeholder entry for empty calculator mode
|
||||
function createPlaceholderEntry() {
|
||||
return {
|
||||
"isCalculator": true,
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process calculator queries
|
||||
function processQuery(query, searchContext = "") {
|
||||
const results = []
|
||||
|
||||
if (searchContext === "calc") {
|
||||
// Handle ">calc" mode
|
||||
const expr = query.slice(5).trim()
|
||||
if (expr && expr !== "") {
|
||||
results.push(createEntry(expr, "calc"))
|
||||
} else {
|
||||
results.push(createPlaceholderEntry())
|
||||
}
|
||||
} else if (query.startsWith(">") && query.length > 1 && !query.startsWith(">clip") && !query.startsWith(">calc")) {
|
||||
// Handle direct math expressions after ">"
|
||||
const mathExpr = query.slice(1).trim()
|
||||
const evaluation = evaluate(mathExpr)
|
||||
|
||||
if (evaluation.isValid) {
|
||||
results.push(createEntry(mathExpr, "direct"))
|
||||
}
|
||||
// If invalid, don't add anything - let it fall through to regular search
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
}
|
||||
158
Modules/AppLauncher/ClipboardHistory.qml
Normal file
158
Modules/AppLauncher/ClipboardHistory.qml
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
import qs.Services
|
||||
|
||||
QtObject {
|
||||
id: clipboardHistory
|
||||
|
||||
// Copy helpers for different content types
|
||||
function copyImageBase64(mime, base64) {
|
||||
Quickshell.execDetached(["sh", "-lc", `printf %s ${base64} | base64 -d | wl-copy -t '${mime}'`])
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
// Use printf with proper quoting to handle special characters
|
||||
Quickshell.execDetached(["sh", "-c", `printf '%s' ${JSON.stringify(text)} | wl-copy -t text/plain`])
|
||||
}
|
||||
|
||||
// Create clipboard entry for display
|
||||
function createClipboardEntry(clip, index) {
|
||||
if (clip.type === 'image') {
|
||||
return {
|
||||
"isClipboard": true,
|
||||
"name": "Image from " + new Date(clip.timestamp).toLocaleTimeString(),
|
||||
"content": "Image: " + clip.mimeType,
|
||||
"icon": "image",
|
||||
"type": 'image',
|
||||
"data": clip.data,
|
||||
"timestamp": clip.timestamp,
|
||||
"index": index,
|
||||
"execute": function () {
|
||||
const dataParts = clip.data.split(',')
|
||||
const base64Data = dataParts.length > 1 ? dataParts[1] : clip.data
|
||||
copyImageBase64(clip.mimeType, base64Data)
|
||||
Quickshell.execDetached(["notify-send", "Clipboard", "Image copied: " + clip.mimeType])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Handle text content
|
||||
const textContent = clip.content || clip
|
||||
let displayContent = textContent
|
||||
let previewContent = ""
|
||||
|
||||
// Normalize whitespace for display
|
||||
displayContent = displayContent.replace(/\s+/g, ' ').trim()
|
||||
|
||||
// Create preview for long content
|
||||
if (displayContent.length > 50) {
|
||||
previewContent = displayContent
|
||||
displayContent = displayContent.split('\n')[0].substring(0, 50) + "..."
|
||||
}
|
||||
|
||||
return {
|
||||
"isClipboard": true,
|
||||
"name": displayContent,
|
||||
"content": previewContent || textContent,
|
||||
"icon": "content_paste",
|
||||
"type": 'text',
|
||||
"timestamp": clip.timestamp,
|
||||
"index": index,
|
||||
"textData": textContent, // Store the text data for the execute function
|
||||
"execute": function () {
|
||||
const text = this.textData || clip.content || clip
|
||||
Quickshell.clipboardText = String(text)
|
||||
copyText(String(text))
|
||||
var preview = (text.length > 50) ? text.slice(0, 50) + "…" : text
|
||||
Quickshell.execDetached(["notify-send", "Clipboard", "Text copied: " + preview])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create empty state entry
|
||||
function createEmptyEntry() {
|
||||
return {
|
||||
"isClipboard": true,
|
||||
"name": "No clipboard history",
|
||||
"content": "No matching clipboard entries found",
|
||||
"icon": "content_paste_off",
|
||||
"execute": function () {
|
||||
// Do nothing for empty state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process clipboard queries
|
||||
function processQuery(query) {
|
||||
const results = []
|
||||
|
||||
if (!query.startsWith(">clip")) {
|
||||
return results
|
||||
}
|
||||
|
||||
// Extract search term after ">clip "
|
||||
const searchTerm = query.slice(5).trim()
|
||||
|
||||
// Note: Clipboard refresh should be handled externally to avoid binding loops
|
||||
|
||||
// Process each clipboard item
|
||||
ClipboardService.history.forEach(function (clip, index) {
|
||||
let searchContent = clip.type === 'image' ? clip.mimeType : clip.content || clip
|
||||
|
||||
// Apply search filter if provided
|
||||
if (!searchTerm || searchContent.toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
const entry = createClipboardEntry(clip, index)
|
||||
results.push(entry)
|
||||
}
|
||||
})
|
||||
|
||||
// Show empty state if no results
|
||||
if (results.length === 0) {
|
||||
results.push(createEmptyEntry())
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// Create command entry for clipboard mode (deprecated - use direct creation in parent)
|
||||
function createCommandEntry() {
|
||||
return {
|
||||
"isCommand": true,
|
||||
"name": ">clip",
|
||||
"content": "Clipboard history - browse and restore clipboard items",
|
||||
"icon": "content_paste",
|
||||
"execute": function () {
|
||||
// This should be handled by the parent component
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility function to refresh clipboard
|
||||
function refresh() {
|
||||
ClipboardService.refresh()
|
||||
}
|
||||
|
||||
// Get clipboard history count
|
||||
function getHistoryCount() {
|
||||
return ClipboardService.history ? ClipboardService.history.length : 0
|
||||
}
|
||||
|
||||
// Get formatted timestamp for display
|
||||
function formatTimestamp(timestamp) {
|
||||
return new Date(timestamp).toLocaleTimeString()
|
||||
}
|
||||
|
||||
// Get clipboard entry by index
|
||||
function getEntryByIndex(index) {
|
||||
if (ClipboardService.history && index >= 0 && index < ClipboardService.history.length) {
|
||||
return ClipboardService.history[index]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// Clear all clipboard history
|
||||
function clearAll() {
|
||||
ClipboardService.clearHistory()
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import qs.Commons
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
|
@ -17,6 +18,8 @@ Variants {
|
|||
readonly property real scaling: ScalingService.scale(screen)
|
||||
screen: modelData
|
||||
|
||||
WlrLayershell.namespace: "noctalia-bar"
|
||||
|
||||
implicitHeight: Style.barHeight * scaling
|
||||
color: Color.transparent
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ Item {
|
|||
IpcHandler {
|
||||
target: "idleInhibitor"
|
||||
|
||||
function toggle() {// TODO
|
||||
function toggle() {
|
||||
return IdleInhibitorService.manualToggle()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +44,11 @@ Item {
|
|||
target: "lockScreen"
|
||||
|
||||
function toggle() {
|
||||
lockScreen.isLoaded = !lockScreen.isLoaded
|
||||
// Only lock if not already locked (prevents the red screen issue)
|
||||
// Note: No unlock via IPC for security reasons
|
||||
if (!lockScreen.isLoaded) {
|
||||
lockScreen.isLoaded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,14 +14,24 @@ 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
|
||||
interval: 250
|
||||
repeat: false
|
||||
onTriggered: lockScreen.isLoaded = false
|
||||
onTriggered: {
|
||||
Logger.log("LockScreen", "Unload timer triggered - setting isLoaded to false")
|
||||
lockScreen.isLoaded = false
|
||||
}
|
||||
}
|
||||
function scheduleUnloadAfterUnlock() {
|
||||
Logger.log("LockScreen", "Scheduling unload after unlock")
|
||||
unloadAfterUnlockTimer.start()
|
||||
}
|
||||
content: Component {
|
||||
|
|
@ -233,13 +243,13 @@ NLoader {
|
|||
|
||||
// Time display - Large and prominent with pulse animation
|
||||
Column {
|
||||
spacing: Style.marginS * scaling
|
||||
spacing: Style.marginXS * scaling
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Text {
|
||||
NText {
|
||||
id: timeText
|
||||
text: Qt.formatDateTime(new Date(), "HH:mm")
|
||||
font.family: "Inter"
|
||||
font.family: Settings.data.ui.fontBillboard
|
||||
font.pointSize: Style.fontSizeXXXL * 6 * scaling
|
||||
font.weight: Font.Bold
|
||||
font.letterSpacing: -2 * scaling
|
||||
|
|
@ -261,10 +271,10 @@ NLoader {
|
|||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
NText {
|
||||
id: dateText
|
||||
text: Qt.formatDateTime(new Date(), "dddd, MMMM d")
|
||||
font.family: "Inter"
|
||||
font.family: Settings.data.ui.fontBillboard
|
||||
font.pointSize: Style.fontSizeXXL * scaling
|
||||
font.weight: Font.Light
|
||||
color: Color.mOnSurface
|
||||
|
|
@ -404,10 +414,10 @@ NLoader {
|
|||
anchors.margins: Style.marginM * scaling
|
||||
spacing: Style.marginM * scaling
|
||||
|
||||
Text {
|
||||
NText {
|
||||
text: "SECURE TERMINAL"
|
||||
color: Color.mOnSurface
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
font.weight: Font.Bold
|
||||
Layout.fillWidth: true
|
||||
|
|
@ -424,10 +434,10 @@ NLoader {
|
|||
color: batteryIndicator.charging ? Color.mPrimary : Color.mOnSurface
|
||||
}
|
||||
|
||||
Text {
|
||||
NText {
|
||||
text: Math.round(batteryIndicator.percent) + "%"
|
||||
color: Color.mOnSurface
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
font.weight: Font.Bold
|
||||
}
|
||||
|
|
@ -450,19 +460,19 @@ NLoader {
|
|||
Layout.fillWidth: true
|
||||
spacing: Style.marginM * scaling
|
||||
|
||||
Text {
|
||||
NText {
|
||||
text: "root@noctalia:~$"
|
||||
color: Color.mPrimary
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
font.weight: Font.Bold
|
||||
}
|
||||
|
||||
Text {
|
||||
NText {
|
||||
id: welcomeText
|
||||
text: ""
|
||||
color: Color.mOnSurface
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
property int currentIndex: 0
|
||||
property string fullText: "Welcome back, " + Quickshell.env("USER") + "!"
|
||||
|
|
@ -488,18 +498,18 @@ NLoader {
|
|||
Layout.fillWidth: true
|
||||
spacing: Style.marginM * scaling
|
||||
|
||||
Text {
|
||||
NText {
|
||||
text: "root@noctalia:~$"
|
||||
color: Color.mPrimary
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
font.weight: Font.Bold
|
||||
}
|
||||
|
||||
Text {
|
||||
NText {
|
||||
text: "sudo unlock-session"
|
||||
color: Color.mOnSurface
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
}
|
||||
|
||||
|
|
@ -509,7 +519,7 @@ NLoader {
|
|||
width: 0
|
||||
height: 0
|
||||
visible: false
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
color: Color.mOnSurface
|
||||
echoMode: TextInput.Password
|
||||
|
|
@ -535,11 +545,11 @@ NLoader {
|
|||
}
|
||||
|
||||
// Visual password display with integrated cursor
|
||||
Text {
|
||||
NText {
|
||||
id: asterisksText
|
||||
text: "*".repeat(passwordInput.text.length)
|
||||
color: Color.mOnSurface
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
visible: passwordInput.activeFocus
|
||||
|
||||
|
|
@ -585,7 +595,7 @@ NLoader {
|
|||
}
|
||||
|
||||
// Status messages
|
||||
Text {
|
||||
NText {
|
||||
text: lock.authenticating ? "Authenticating..." : (lock.errorMessage !== "" ? "Authentication failed." : "")
|
||||
color: lock.authenticating ? Color.mPrimary : (lock.errorMessage !== "" ? Color.mError : Color.transparent)
|
||||
font.family: "DejaVu Sans Mono"
|
||||
|
|
@ -618,11 +628,11 @@ NLoader {
|
|||
Layout.alignment: Qt.AlignRight
|
||||
Layout.bottomMargin: -12 * scaling
|
||||
|
||||
Text {
|
||||
NText {
|
||||
anchors.centerIn: parent
|
||||
text: lock.authenticating ? "EXECUTING" : "EXECUTE"
|
||||
color: executeButtonArea.containsMouse ? Color.mOnPrimary : Color.mPrimary
|
||||
font.family: "DejaVu Sans Mono"
|
||||
font.family: Settings.data.ui.fontFixed
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
font.weight: Font.Bold
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,27 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Volume Step Size
|
||||
ColumnLayout {
|
||||
spacing: Style.marginS * scaling
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Style.marginM * scaling
|
||||
|
||||
NSpinBox {
|
||||
Layout.fillWidth: true
|
||||
label: "Volume Step Size"
|
||||
description: "Adjust the step size for volume changes (scroll wheel, keyboard shortcuts)."
|
||||
minimum: 1
|
||||
maximum: 25
|
||||
value: Settings.data.audio.volumeStep
|
||||
stepSize: 1
|
||||
suffix: "%"
|
||||
onValueChanged: {
|
||||
Settings.data.audio.volumeStep = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDivider {
|
||||
|
|
|
|||
|
|
@ -49,34 +49,17 @@ Item {
|
|||
spacing: Style.marginS * scaling
|
||||
Layout.fillWidth: true
|
||||
|
||||
NLabel {
|
||||
NSpinBox {
|
||||
Layout.fillWidth: true
|
||||
label: "Brightness Step Size"
|
||||
description: "Adjust the step size for brightness changes (scroll wheel, keyboard shortcuts)."
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Style.marginM * scaling
|
||||
|
||||
NSlider {
|
||||
Layout.fillWidth: true
|
||||
from: 1
|
||||
to: 50
|
||||
value: Settings.data.brightness.brightnessStep
|
||||
stepSize: 1
|
||||
onPressedChanged: {
|
||||
if (!pressed) {
|
||||
Settings.data.brightness.brightnessStep = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NText {
|
||||
text: Settings.data.brightness.brightnessStep + "%"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
color: Color.mOnSurface
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
font.weight: Style.fontWeightBold
|
||||
minimum: 1
|
||||
maximum: 50
|
||||
value: Settings.data.brightness.brightnessStep
|
||||
stepSize: 1
|
||||
suffix: "%"
|
||||
onValueChanged: {
|
||||
Settings.data.brightness.brightnessStep = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,6 +157,59 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Style.marginL * 2 * scaling
|
||||
Layout.bottomMargin: Style.marginL * scaling
|
||||
}
|
||||
|
||||
NText {
|
||||
text: "Fonts"
|
||||
font.pointSize: Style.fontSizeXXL * scaling
|
||||
font.weight: Style.fontWeightBold
|
||||
color: Color.mOnSurface
|
||||
Layout.bottomMargin: Style.marginS * scaling
|
||||
}
|
||||
|
||||
// Font configuration section
|
||||
ColumnLayout {
|
||||
spacing: Style.marginS * scaling
|
||||
Layout.fillWidth: true
|
||||
|
||||
NTextInput {
|
||||
label: "Default Font"
|
||||
description: "Main font used throughout the interface."
|
||||
text: Settings.data.ui.fontDefault
|
||||
placeholderText: "Roboto"
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
Settings.data.ui.fontDefault = text
|
||||
}
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
label: "Fixed Width Font"
|
||||
description: "Monospace font used for terminal and code display."
|
||||
text: Settings.data.ui.fontFixed
|
||||
placeholderText: "DejaVu Sans Mono"
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
Settings.data.ui.fontFixed = text
|
||||
}
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
label: "Billboard Font"
|
||||
description: "Large font used for clocks and prominent displays."
|
||||
text: Settings.data.ui.fontBillboard
|
||||
placeholderText: "Inter"
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
Settings.data.ui.fontBillboard = text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,17 @@ NBox {
|
|||
}
|
||||
}
|
||||
|
||||
// Idle Inhibitor
|
||||
NIconButton {
|
||||
icon: IdleInhibitorService.isInhibited ? "coffee" : "bedtime"
|
||||
tooltipText: IdleInhibitorService.isInhibited ? "Disable Keep Awake" : "Enable Keep Awake"
|
||||
colorBg: IdleInhibitorService.isInhibited ? Color.mPrimary : Color.mSurfaceVariant
|
||||
colorFg: IdleInhibitorService.isInhibited ? Color.mOnPrimary : Color.mPrimary
|
||||
onClicked: {
|
||||
IdleInhibitorService.manualToggle()
|
||||
}
|
||||
}
|
||||
|
||||
// Wallpaper
|
||||
NIconButton {
|
||||
icon: "image"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue