mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
favicon for links in clipboard entries
This commit is contained in:
parent
1a79012c61
commit
fb2c9ac7df
2 changed files with 36 additions and 14 deletions
|
|
@ -15,14 +15,16 @@ import Quickshell.Hyprland
|
|||
IconImage {
|
||||
id: root
|
||||
property string url
|
||||
property string displayText
|
||||
|
||||
property real size: 32
|
||||
property string downloadUserAgent: ConfigOptions?.networking.userAgent ?? ""
|
||||
property string faviconDownloadPath: FileUtils.trimFileProtocol(`${XdgDirectories.cache}/media/favicons`)
|
||||
property string domainName: url.includes("vertexaisearch") ? displayText : StringUtils.getBaseUrl(url)
|
||||
property string domainName: url.includes("vertexaisearch") ? displayText : StringUtils.getDomain(url)
|
||||
property string faviconUrl: `https://www.google.com/s2/favicons?domain=${domainName}&sz=32`
|
||||
property string fileName: `${domainName}.ico`
|
||||
property string faviconFilePath: `${faviconDownloadPath}/${fileName}`
|
||||
property string urlToLoad
|
||||
|
||||
Process {
|
||||
id: faviconDownloadProcess
|
||||
|
|
@ -31,11 +33,13 @@ IconImage {
|
|||
onExited: (exitCode, exitStatus) => {
|
||||
console.log("Favicon download process exited with code:", exitCode, "and status:", exitStatus)
|
||||
console.log("Favicon file path:", faviconFilePath)
|
||||
root.faviconUrl = root.faviconFilePath
|
||||
root.urlToLoad = root.faviconFilePath
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("URL: ", root.url)
|
||||
console.log("DOMAIN: ", root.domainName)
|
||||
console.log("faviconDownloadPath: ", faviconDownloadPath)
|
||||
console.log("faviconFilePath: ", faviconFilePath)
|
||||
console.log("faviconUrl: ", root.faviconUrl)
|
||||
|
|
@ -45,7 +49,7 @@ IconImage {
|
|||
faviconDownloadProcess.running = true
|
||||
}
|
||||
|
||||
source: Qt.resolvedUrl(root.faviconUrl)
|
||||
source: Qt.resolvedUrl(root.urlToLoad)
|
||||
implicitSize: root.size
|
||||
|
||||
layer.enabled: true
|
||||
|
|
|
|||
|
|
@ -56,8 +56,16 @@ RippleButton {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
property string displayContent: highlightContent(root.itemName, root.query)
|
||||
|
||||
property list<string> urls: {
|
||||
if (!root.itemName) return [];
|
||||
// Regular expression to match URLs
|
||||
const urlRegex = /https?:\/\/[^\s<>"{}|\\^`[\]]+/gi;
|
||||
const matches = root.itemName.match(urlRegex)
|
||||
.filter(url => !url.includes("…")) // Elided = invalid
|
||||
return matches ? matches : [];
|
||||
}
|
||||
|
||||
visible: root.entryShown
|
||||
property int horizontalMargin: 10
|
||||
|
|
@ -144,16 +152,26 @@ RippleButton {
|
|||
visible: root.itemType && root.itemType != qsTr("App")
|
||||
text: root.itemType
|
||||
}
|
||||
StyledText {
|
||||
Layout.fillWidth: true
|
||||
id: nameText
|
||||
textFormat: Text.StyledText // RichText also works, but StyledText ensures elide work
|
||||
font.pixelSize: Appearance.font.pixelSize.small
|
||||
font.family: Appearance.font.family[root.fontType]
|
||||
color: Appearance.m3colors.m3onSurface
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
elide: Text.ElideRight
|
||||
text: `${root.displayContent}`
|
||||
RowLayout {
|
||||
Repeater {
|
||||
model: root.query == root.itemName ? [] : root.urls
|
||||
Favicon {
|
||||
required property var modelData
|
||||
size: parent.height
|
||||
url: modelData
|
||||
}
|
||||
}
|
||||
StyledText {
|
||||
Layout.fillWidth: true
|
||||
id: nameText
|
||||
textFormat: Text.StyledText // RichText also works, but StyledText ensures elide work
|
||||
font.pixelSize: Appearance.font.pixelSize.small
|
||||
font.family: Appearance.font.family[root.fontType]
|
||||
color: Appearance.m3colors.m3onSurface
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
elide: Text.ElideRight
|
||||
text: `${root.displayContent}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue