diff --git a/Modules/GetIcons.qml b/Modules/GetIcons.qml index 293adc9..dad9408 100644 --- a/Modules/GetIcons.qml +++ b/Modules/GetIcons.qml @@ -10,6 +10,8 @@ Singleton { if (icon.includes("?path=")) { const [name, path] = icon.split("?path="); icon = Qt.resolvedUrl(`${path}/${name.slice(name.lastIndexOf("/") + 1)}`); + } else if (icon.includes("qspixmap") && id === "chrome_status_icon_1") { + icon = icon.replace("qspixmap", "icon/discord-tray"); } return icon; } diff --git a/Modules/TrayItem.qml b/Modules/TrayItem.qml index 7908060..1d4616b 100644 --- a/Modules/TrayItem.qml +++ b/Modules/TrayItem.qml @@ -30,22 +30,12 @@ MouseArea { IconImage { id: icon - anchors.fill: parent - layer.enabled: true - - layer.onEnabledChanged: { - if (layer.enabled && status === Image.Ready) - analyser.requestUpdate(); - } - - onStatusChanged: { - if (layer.enabled && status === Image.Ready) - analyser.requestUpdate(); - } - - source: GetIcons.getTrayIcon(root.item.id, root.item.icon) - - mipmap: false + anchors.centerIn: parent + height: 22 + width: 22 + source: root.item.icon + mipmap: true + smooth: false asynchronous: true ImageAnalyser { diff --git a/Modules/TrayMenu.qml b/Modules/TrayMenu.qml index 91d2d40..c96d980 100644 --- a/Modules/TrayMenu.qml +++ b/Modules/TrayMenu.qml @@ -16,22 +16,9 @@ PanelWindow { property var menuStack: [] property real scaleValue: 0 - property int height: calcHeight() + property int height: calcSize("h") property int entryHeight: 30 - property int maxWidth: { - let menuWidth = 0; - for ( let i = 0; i < listLayout.count; i++ ) { - if ( !listLayout.model.values[i].isSeparator ) { - let entry = listLayout.model.values[i]; - tempMetrics.text = entry.text; - let textWidth = tempMetrics.width + 20 + (entry.icon ?? "" ? 30 : 0) + (entry.hasChildren ? 30 : 0); - if ( textWidth > menuWidth ) { - menuWidth = textWidth; - } - } - } - return menuWidth; - } + property int maxWidth: calcSize("w") visible: false color: "transparent" @@ -42,36 +29,37 @@ PanelWindow { bottom: true } - function calcHeight() { - let count = 0; - let separatorCount = 0; - for (let i = 0; i < listLayout.count; i++) { - if (!listLayout.model.values[i].isSeparator) { - count++; - } else { - separatorCount++; - } - } - if ( root.menuStack.length > 0 ) { - backEntry.visible = true; - count++; - } - return (count * entryHeight) + ((count - 1) * 2) + (separatorCount * 3) + 10; - } - - function calcWidth() { - let menuWidth = 0; - for ( let i = 0; i < listLayout.count; i++ ) { - if ( !listLayout.model.values[i].isSeparator ) { - let entry = listLayout.model.values[i]; - tempMetrics.text = entry.text; - let textWidth = tempMetrics.width + 20 + (entry.icon ?? "" ? 30 : 0) + (entry.hasChildren ? 30 : 0); - if ( textWidth > menuWidth ) { - menuWidth = textWidth; + function calcSize(String) { + if ( String === "w" ) { + let menuWidth = 0; + for ( let i = 0; i < listLayout.count; i++ ) { + if ( !listLayout.model.values[i].isSeparator ) { + let entry = listLayout.model.values[i]; + tempMetrics.text = entry.text; + let textWidth = tempMetrics.width + 20 + (entry.icon ?? "" ? 30 : 0) + (entry.hasChildren ? 30 : 0); + if ( textWidth > menuWidth ) { + menuWidth = textWidth; + } } } + return menuWidth; + } + if ( String === "h" ) { + let count = 0; + let separatorCount = 0; + for (let i = 0; i < listLayout.count; i++) { + if (!listLayout.model.values[i].isSeparator) { + count++; + } else { + separatorCount++; + } + } + if ( root.menuStack.length > 0 ) { + backEntry.visible = true; + count++; + } + return (count * entryHeight) + ((count - 1) * 2) + (separatorCount * 3) + 10; } - return menuWidth; } function goBack() { @@ -165,7 +153,7 @@ PanelWindow { Rectangle { id: menuRect - x: root.trayItemRect.x - ( menuRect.implicitWidth / 2 ) + 10 + x: root.trayItemRect.x - ( menuRect.implicitWidth / 2 ) + 11 y: root.trayItemRect.y - 5 implicitHeight: root.height implicitWidth: root.maxWidth + 20 @@ -213,7 +201,7 @@ PanelWindow { ListView { id: listLayout Layout.fillWidth: true - Layout.preferredHeight: root.calcHeight() - ( root.menuStack.length > 0 ? root.entryHeight + 10 : 0 ) + Layout.preferredHeight: root.height - ( root.menuStack.length > 0 ? root.entryHeight + 10 : 0 ) spacing: 2 model: ScriptModel { values: [...root.menu?.children.values]