diff --git a/Modules/Bar/ActiveWindow.qml b/Modules/Bar/ActiveWindow.qml index 194ec21..921f211 100644 --- a/Modules/Bar/ActiveWindow.qml +++ b/Modules/Bar/ActiveWindow.qml @@ -9,10 +9,10 @@ Row { anchors.verticalCenter: parent.verticalCenter spacing: Style.marginSmall * scaling visible: Settings.data.bar.showActiveWindow - + property bool showingFullTitle: false property int lastWindowIndex: -1 - + // Timer to hide full title after window switch Timer { id: fullTitleTimer @@ -23,7 +23,7 @@ Row { titleText.text = getDisplayText() } } - + // Update text when window changes Connections { target: typeof Niri !== "undefined" ? Niri : null @@ -37,7 +37,7 @@ Row { titleText.text = getDisplayText() } } - + // Window icon NText { id: windowIcon @@ -49,21 +49,21 @@ Row { color: Colors.mPrimary visible: getDisplayText() !== "" } - + // Window title container Item { id: titleContainer width: titleText.width height: titleText.height anchors.verticalCenter: parent.verticalCenter - + Behavior on width { NumberAnimation { duration: 300 easing.type: Easing.OutCubic } } - + NText { id: titleText text: getDisplayText() @@ -73,79 +73,76 @@ Row { verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } - - // Mouse area for hover detection - MouseArea { - id: titleContainerMouseArea - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.IBeamCursor - onEntered: { - titleText.text = getDisplayText() - } - onExited: { - titleText.text = getDisplayText() - } - } - } - + // Mouse area for hover detection + MouseArea { + id: titleContainerMouseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.IBeamCursor + onEntered: { + titleText.text = getDisplayText() + } + onExited: { + titleText.text = getDisplayText() + } + } + } function getDisplayText() { // Check if Niri service is available if (typeof Niri === "undefined") { return "" } - + // Get the focused window data - const focusedWindow = Niri.focusedWindowIndex >= 0 && Niri.focusedWindowIndex < Niri.windows.length - ? Niri.windows[Niri.focusedWindowIndex] - : null - + const focusedWindow = Niri.focusedWindowIndex >= 0 + && Niri.focusedWindowIndex < Niri.windows.length ? Niri.windows[Niri.focusedWindowIndex] : null + if (!focusedWindow) { return "" } - + const appId = focusedWindow.appId || "" const title = focusedWindow.title || "" - + // If no appId, fall back to title processing if (!appId) { if (!title || title === "(No active window)" || title === "(Unnamed window)") { return "" } - + // Extract program name from title (before first space or special characters) const programName = title.split(/[\s\-_]/)[0] - + if (programName.length <= 2 || programName === title) { return truncateTitle(title) } - + if (showingFullTitle || titleContainerMouseArea.containsMouse || isGenericName(programName)) { return truncateTitle(title) } - + return programName } - + // Use appId for program name, show full title on hover or window switch if (showingFullTitle || titleContainerMouseArea.containsMouse) { return truncateTitle(title || appId) } - + return appId } - + function truncateTitle(title) { if (title.length > 50) { return title.substring(0, 47) + "..." } return title } - + function isGenericName(name) { const genericNames = ["window", "application", "app", "program", "process", "unknown"] return genericNames.includes(name.toLowerCase()) } -} \ No newline at end of file +} diff --git a/Modules/Settings/Tabs/ColorSchemeTab.qml b/Modules/Settings/Tabs/ColorSchemeTab.qml index 35a583c..de3a886 100644 --- a/Modules/Settings/Tabs/ColorSchemeTab.qml +++ b/Modules/Settings/Tabs/ColorSchemeTab.qml @@ -9,27 +9,27 @@ ColumnLayout { id: root spacing: 0 - + // Helper function to get color from scheme file function getSchemeColor(schemePath, colorKey) { // Extract scheme name from path var schemeName = schemePath.split("/").pop().replace(".json", "") - + // Try to get from cached data first if (schemeColorsCache[schemeName] && schemeColorsCache[schemeName][colorKey]) { return schemeColorsCache[schemeName][colorKey] } - + // Return a default color if not cached yet return "#000000" } - + // Cache for scheme colors property var schemeColorsCache: ({}) - + // Array to hold FileView objects property var fileViews: [] - + // Load color scheme data when schemes are available Connections { target: ColorSchemes @@ -37,11 +37,11 @@ ColumnLayout { loadSchemeColors() } } - + function loadSchemeColors() { // Clear existing cache schemeColorsCache = {} - + // Destroy existing FileViews for (var i = 0; i < fileViews.length; i++) { if (fileViews[i]) { @@ -49,19 +49,19 @@ ColumnLayout { } } fileViews = [] - + // Create FileViews for each scheme for (var i = 0; i < ColorSchemes.schemes.length; i++) { var schemePath = ColorSchemes.schemes[i] var schemeName = schemePath.split("/").pop().replace(".json", "") - + // Create FileView component var component = Qt.createComponent("SchemeFileView.qml") if (component.status === Component.Ready) { var fileView = component.createObject(root, { - "path": schemePath, - "schemeName": schemeName - }) + "path": schemePath, + "schemeName": schemeName + }) fileViews.push(fileView) } else { // Fallback: create inline FileView @@ -69,28 +69,28 @@ ColumnLayout { } } } - + function createInlineFileView(schemePath, schemeName) { var fileViewQml = ` - import QtQuick - import Quickshell.Io - - FileView { - property string schemeName: "${schemeName}" - path: "${schemePath}" - blockLoading: true - - onLoaded: { - try { - var jsonData = JSON.parse(text()) - root.schemeLoaded(schemeName, jsonData) - } catch (e) { - console.warn("Failed to parse JSON for scheme:", schemeName, e) - } - } - } + import QtQuick + import Quickshell.Io + + FileView { + property string schemeName: "${schemeName}" + path: "${schemePath}" + blockLoading: true + + onLoaded: { + try { + var jsonData = JSON.parse(text()) + root.schemeLoaded(schemeName, jsonData) + } catch (e) { + console.warn("Failed to parse JSON for scheme:", schemeName, e) + } + } + } ` - + try { var fileView = Qt.createQmlObject(fileViewQml, root, "dynamicFileView_" + schemeName) fileViews.push(fileView) @@ -98,12 +98,12 @@ ColumnLayout { console.warn("Failed to create FileView for scheme:", schemeName, e) } } - + function schemeLoaded(schemeName, jsonData) { console.log("Loading scheme colors for:", schemeName) - + var colors = {} - + // Extract colors from JSON data if (jsonData && typeof jsonData === 'object') { colors.mPrimary = jsonData.mPrimary || jsonData.primary || "#000000" @@ -116,21 +116,21 @@ ColumnLayout { } else { // Default colors colors = { - mPrimary: "#000000", - mSecondary: "#000000", - mTertiary: "#000000", - mError: "#ff0000", - mSurface: "#ffffff", - mOnSurface: "#000000", - mOutline: "#666666" + "mPrimary": "#000000", + "mSecondary": "#000000", + "mTertiary": "#000000", + "mError": "#ff0000", + "mSurface": "#ffffff", + "mOnSurface": "#000000", + "mOutline": "#666666" } } - + // Update cache var newCache = schemeColorsCache newCache[schemeName] = colors schemeColorsCache = newCache - + console.log("Cached colors for", schemeName, ":", JSON.stringify(colors)) } @@ -204,7 +204,7 @@ ColumnLayout { Repeater { model: ColorSchemes.schemes - + Rectangle { id: schemeCard Layout.fillWidth: true @@ -213,9 +213,9 @@ ColumnLayout { color: getSchemeColor(modelData, "mSurface") border.width: 2 border.color: Settings.data.colorSchemes.predefinedScheme === modelData ? Colors.mPrimary : Colors.mOutline - + property string schemePath: modelData - + // Mouse area for selection MouseArea { anchors.fill: parent @@ -227,24 +227,24 @@ ColumnLayout { } hoverEnabled: true cursorShape: Qt.PointingHandCursor - + onEntered: { schemeCard.scale = 1.05 schemeCard.border.width = 3 } - + onExited: { schemeCard.scale = 1.0 schemeCard.border.width = 2 } } - + // Card content ColumnLayout { anchors.fill: parent anchors.margins: 16 * scaling spacing: 8 * scaling - + // Scheme name NText { text: { @@ -259,13 +259,13 @@ ColumnLayout { elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter } - + // Color swatches RowLayout { spacing: 8 * scaling Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - + // Primary color swatch Rectangle { width: 28 * scaling @@ -273,7 +273,7 @@ ColumnLayout { radius: 14 * scaling color: getSchemeColor(modelData, "mPrimary") } - + // Secondary color swatch Rectangle { width: 28 * scaling @@ -281,7 +281,7 @@ ColumnLayout { radius: 14 * scaling color: getSchemeColor(modelData, "mSecondary") } - + // Tertiary color swatch Rectangle { width: 28 * scaling @@ -289,7 +289,7 @@ ColumnLayout { radius: 14 * scaling color: getSchemeColor(modelData, "mTertiary") } - + // Error color swatch Rectangle { width: 28 * scaling @@ -299,7 +299,7 @@ ColumnLayout { } } } - + // Selection indicator Rectangle { visible: Settings.data.colorSchemes.predefinedScheme === schemePath @@ -310,7 +310,7 @@ ColumnLayout { height: 24 * scaling radius: 12 * scaling color: Colors.mPrimary - + NText { anchors.centerIn: parent text: "✓" @@ -319,18 +319,25 @@ ColumnLayout { color: Colors.mOnPrimary } } - + // Smooth animations Behavior on scale { - NumberAnimation { duration: 200; easing.type: Easing.OutCubic } + NumberAnimation { + duration: 200 + easing.type: Easing.OutCubic + } } - + Behavior on border.color { - ColorAnimation { duration: 300 } + ColorAnimation { + duration: 300 + } } - + Behavior on border.width { - NumberAnimation { duration: 200 } + NumberAnimation { + duration: 200 + } } } } @@ -339,4 +346,4 @@ ColumnLayout { } } } -} \ No newline at end of file +} diff --git a/Services/Workspaces.qml b/Services/Workspaces.qml index 574a577..12acdba 100644 --- a/Services/Workspaces.qml +++ b/Services/Workspaces.qml @@ -30,6 +30,7 @@ Singleton { return } } catch (e) { + } if (typeof Niri !== "undefined") {