refractor xdg dirs

This commit is contained in:
end-4
2025-05-16 16:02:05 +02:00
parent 9a68f80ffa
commit 8daa1702d0
12 changed files with 28 additions and 17 deletions
@@ -0,0 +1,12 @@
import Qt.labs.platform
import QtQuick
import Quickshell
pragma Singleton
pragma ComponentBehavior: Bound
Singleton {
readonly property string config: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0]
readonly property string state: StandardPaths.standardLocations(StandardPaths.StateLocation)[0]
readonly property string cache: StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]
readonly property string pictures: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
}
@@ -15,7 +15,7 @@ import Quickshell.Hyprland
Item { // Wrapper Item { // Wrapper
id: root id: root
required property var panelWindow required property var panelWindow
readonly property string xdgConfigHome: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0] readonly property string xdgConfigHome: XdgDirectories.config
property string searchingText: "" property string searchingText: ""
property bool showResults: searchingText != "" property bool showResults: searchingText != ""
property real searchBarHeight: searchBar.height + Appearance.sizes.elevationMargin * 2 property real searchBarHeight: searchBar.height + Appearance.sizes.elevationMargin * 2
@@ -6,7 +6,6 @@ import "./aiChat/"
import "root:/modules/common/functions/fuzzysort.js" as Fuzzy import "root:/modules/common/functions/fuzzysort.js" as Fuzzy
import "root:/modules/common/functions/string_utils.js" as StringUtils import "root:/modules/common/functions/string_utils.js" as StringUtils
import "root:/modules/common/functions/file_utils.js" as FileUtils import "root:/modules/common/functions/file_utils.js" as FileUtils
import Qt.labs.platform
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
@@ -21,7 +20,7 @@ Item {
property var inputField: messageInputField property var inputField: messageInputField
readonly property var messages: Ai.messages readonly property var messages: Ai.messages
property string commandPrefix: "/" property string commandPrefix: "/"
property string faviconDownloadPath: FileUtils.trimFileProtocol(`${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/media/favicons`) property string faviconDownloadPath: FileUtils.trimFileProtocol(`${XdgDirectories.cache}/media/favicons`)
property var suggestionQuery: "" property var suggestionQuery: ""
property var suggestionList: [] property var suggestionList: []
@@ -19,9 +19,9 @@ Item {
property var panelWindow property var panelWindow
property var inputField: tagInputField property var inputField: tagInputField
readonly property var responses: Booru.responses readonly property var responses: Booru.responses
property string previewDownloadPath: `${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/media/waifus`.replace("file://", "") property string previewDownloadPath: `${XdgDirectories.cache}/media/waifus`.replace("file://", "")
property string downloadPath: (StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + "/homework").replace("file://", "") property string downloadPath: (XdgDirectories.pictures + "/homework").replace("file://", "")
property string nsfwPath: (StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + "/homework/🌶️").replace("file://", "") property string nsfwPath: (XdgDirectories.pictures + "/homework/🌶️").replace("file://", "")
property string commandPrefix: "/" property string commandPrefix: "/"
property real scrollOnNewResponse: 100 property real scrollOnNewResponse: 100
property int tagSuggestionDelay: 210 property int tagSuggestionDelay: 210
@@ -97,7 +97,7 @@ Button {
PointingHandInteraction {} PointingHandInteraction {}
StyledToolTip { StyledToolTip {
content: StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength) content: `${StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)}\nClick for options`
} }
background: Rectangle { background: Rectangle {
+1 -2
View File
@@ -11,7 +11,6 @@ import QtQuick;
Singleton { Singleton {
id: root id: root
readonly property string xdgConfigHome: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0]
readonly property string interfaceRole: "interface" readonly property string interfaceRole: "interface"
readonly property string apiKeyEnvVarName: "API_KEY" readonly property string apiKeyEnvVarName: "API_KEY"
property Component aiMessageComponent: AiMessageData {} property Component aiMessageComponent: AiMessageData {}
@@ -107,7 +106,7 @@ Singleton {
Process { Process {
id: getOllamaModels id: getOllamaModels
command: ["bash", "-c", `${xdgConfigHome}/quickshell/scripts/ai/show-installed-ollama-models.sh`.replace(/file:\/\//, "")] command: ["bash", "-c", `${XdgDirectories.config}/quickshell/scripts/ai/show-installed-ollama-models.sh`.replace(/file:\/\//, "")]
stdout: SplitParser { stdout: SplitParser {
onRead: data => { onRead: data => {
try { try {
+1 -1
View File
@@ -12,7 +12,7 @@ import Qt.labs.platform
Singleton { Singleton {
id: root id: root
property string fileDir: `${StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0]}/illogical-impulse` property string fileDir: `${XdgDirectories.config}/illogical-impulse`
property string fileName: "config.json" property string fileName: "config.json"
property string filePath: FileUtils.trimFileProtocol(`${root.fileDir}/${root.fileName}`) property string filePath: FileUtils.trimFileProtocol(`${root.fileDir}/${root.fileName}`)
property bool firstLoad: true property bool firstLoad: true
@@ -26,7 +26,7 @@ Singleton {
property var processedExpressions: ({}) property var processedExpressions: ({})
property var renderedImagePaths: ({}) property var renderedImagePaths: ({})
property string microtexBinaryPath: Qt.resolvedUrl("/opt/MicroTeX/LaTeX") property string microtexBinaryPath: Qt.resolvedUrl("/opt/MicroTeX/LaTeX")
property string latexOutputPath: FileUtils.trimFileProtocol(`${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/latex`) property string latexOutputPath: FileUtils.trimFileProtocol(`${XdgDirectories.cache}/latex`)
signal renderFinished(string hash, string imagePath) signal renderFinished(string hash, string imagePath)
@@ -5,11 +5,10 @@ import "root:/modules/common"
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import Qt.labs.platform
Singleton { Singleton {
id: root id: root
property string filePath: `${StandardPaths.standardLocations(StandardPaths.StateLocation)[0]}/user/generated/colors.json` property string filePath: `${XdgDirectories.state}/user/generated/colors.json`
function reapplyTheme() { function reapplyTheme() {
themeFileView.reload() themeFileView.reload()
@@ -1,6 +1,7 @@
pragma Singleton pragma Singleton
pragma ComponentBehavior: Bound pragma ComponentBehavior: Bound
import "root:/modules/common"
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
@@ -9,10 +10,10 @@ import Qt.labs.platform
Singleton { Singleton {
id: root id: root
property var filePath: `${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/notifications/notifications.json` property var filePath: `${XdgDirectories.cache}/notifications/notifications.json`
property var list: [] property var list: []
// Quickshell's notification IDs starts at 1 on each run, while saved notifications // Quickshell's notification IDs starts at 1 on each run, while saved notifications
// can already contain higher IDs. This is a workaround to avoid id collisions // can already contain higher IDs. This is for avoiding id collisions
property int idOffset property int idOffset
signal initDone(); signal initDone();
@@ -11,7 +11,7 @@ import Qt.labs.platform
Singleton { Singleton {
id: root id: root
property string fileDir: `${StandardPaths.standardLocations(StandardPaths.StateLocation)[0]}` property string fileDir: XdgDirectories.state
property string fileName: "states.json" property string fileName: "states.json"
property string filePath: `${root.fileDir}/${root.fileName}` property string filePath: `${root.fileDir}/${root.fileName}`
property bool allowWriteback: false property bool allowWriteback: false
+2 -1
View File
@@ -1,6 +1,7 @@
pragma Singleton pragma Singleton
pragma ComponentBehavior: Bound pragma ComponentBehavior: Bound
import "root:/modules/common"
import Quickshell; import Quickshell;
import Quickshell.Io; import Quickshell.Io;
import Qt.labs.platform import Qt.labs.platform
@@ -8,7 +9,7 @@ import QtQuick;
Singleton { Singleton {
id: root id: root
property var filePath: `${StandardPaths.standardLocations(StandardPaths.StateLocation)[0]}/user/todo.json` property var filePath: `${XdgDirectories.state}/user/todo.json`
property var list: [] property var list: []
function addItem(item) { function addItem(item) {