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

View file

@ -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]
}

View file

@ -15,7 +15,7 @@ import Quickshell.Hyprland
Item { // Wrapper
id: root
required property var panelWindow
readonly property string xdgConfigHome: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0]
readonly property string xdgConfigHome: XdgDirectories.config
property string searchingText: ""
property bool showResults: searchingText != ""
property real searchBarHeight: searchBar.height + Appearance.sizes.elevationMargin * 2

View file

@ -6,7 +6,6 @@ import "./aiChat/"
import "root:/modules/common/functions/fuzzysort.js" as Fuzzy
import "root:/modules/common/functions/string_utils.js" as StringUtils
import "root:/modules/common/functions/file_utils.js" as FileUtils
import Qt.labs.platform
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
@ -21,7 +20,7 @@ Item {
property var inputField: messageInputField
readonly property var messages: Ai.messages
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 suggestionList: []

View file

@ -19,9 +19,9 @@ Item {
property var panelWindow
property var inputField: tagInputField
readonly property var responses: Booru.responses
property string previewDownloadPath: `${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/media/waifus`.replace("file://", "")
property string downloadPath: (StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + "/homework").replace("file://", "")
property string nsfwPath: (StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + "/homework/🌶️").replace("file://", "")
property string previewDownloadPath: `${XdgDirectories.cache}/media/waifus`.replace("file://", "")
property string downloadPath: (XdgDirectories.pictures + "/homework").replace("file://", "")
property string nsfwPath: (XdgDirectories.pictures + "/homework/🌶️").replace("file://", "")
property string commandPrefix: "/"
property real scrollOnNewResponse: 100
property int tagSuggestionDelay: 210

View file

@ -97,7 +97,7 @@ Button {
PointingHandInteraction {}
StyledToolTip {
content: StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)
content: `${StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)}\nClick for options`
}
background: Rectangle {

View file

@ -11,7 +11,6 @@ import QtQuick;
Singleton {
id: root
readonly property string xdgConfigHome: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0]
readonly property string interfaceRole: "interface"
readonly property string apiKeyEnvVarName: "API_KEY"
property Component aiMessageComponent: AiMessageData {}
@ -107,7 +106,7 @@ Singleton {
Process {
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 {
onRead: data => {
try {

View file

@ -12,7 +12,7 @@ import Qt.labs.platform
Singleton {
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 filePath: FileUtils.trimFileProtocol(`${root.fileDir}/${root.fileName}`)
property bool firstLoad: true

View file

@ -26,7 +26,7 @@ Singleton {
property var processedExpressions: ({})
property var renderedImagePaths: ({})
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)

View file

@ -5,11 +5,10 @@ import "root:/modules/common"
import QtQuick
import Quickshell
import Quickshell.Io
import Qt.labs.platform
Singleton {
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() {
themeFileView.reload()

View file

@ -1,6 +1,7 @@
pragma Singleton
pragma ComponentBehavior: Bound
import "root:/modules/common"
import QtQuick
import Quickshell
import Quickshell.Io
@ -9,10 +10,10 @@ import Qt.labs.platform
Singleton {
id: root
property var filePath: `${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/notifications/notifications.json`
property var filePath: `${XdgDirectories.cache}/notifications/notifications.json`
property var list: []
// 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
signal initDone();

View file

@ -11,7 +11,7 @@ import Qt.labs.platform
Singleton {
id: root
property string fileDir: `${StandardPaths.standardLocations(StandardPaths.StateLocation)[0]}`
property string fileDir: XdgDirectories.state
property string fileName: "states.json"
property string filePath: `${root.fileDir}/${root.fileName}`
property bool allowWriteback: false

View file

@ -1,6 +1,7 @@
pragma Singleton
pragma ComponentBehavior: Bound
import "root:/modules/common"
import Quickshell;
import Quickshell.Io;
import Qt.labs.platform
@ -8,7 +9,7 @@ import QtQuick;
Singleton {
id: root
property var filePath: `${StandardPaths.standardLocations(StandardPaths.StateLocation)[0]}/user/todo.json`
property var filePath: `${XdgDirectories.state}/user/todo.json`
property var list: []
function addItem(item) {