diff options
| author | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
|---|---|---|
| committer | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
| commit | 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch) | |
| tree | ab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/WifiQRCodeModal.qml | |
| parent | 5d94c0a7d44a2255b81815a52a7056a94a39842d (diff) | |
| download | RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.tar.gz RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.zip | |
Replaced file structures for themes in the correct format
Diffstat (limited to 'raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/WifiQRCodeModal.qml')
| -rw-r--r-- | raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/WifiQRCodeModal.qml | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/WifiQRCodeModal.qml b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/WifiQRCodeModal.qml new file mode 100644 index 0000000..06ffab7 --- /dev/null +++ b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modals/WifiQRCodeModal.qml @@ -0,0 +1,170 @@ +import QtQuick +import QtQuick.Layouts +import QtQuick.Effects +import Quickshell +import Quickshell.Io +import qs.Modals.Common +import qs.Modals.FileBrowser +import qs.Common +import qs.Services +import qs.Widgets + +DankModal { + id: root + visible: false + layerNamespace: "dms:wifi-qrcode" + + property bool disablePopupTransparency: true + property string wifiSSID: "" + property string themedQrCodePath: "" + property string normalQrCodePath: "" + modalWidth: 420 + modalHeight: 480 + onBackgroundClicked: hide() + onOpened: { + Qt.callLater(() => { + modalFocusScope.forceActiveFocus(); + contentLoader.item.wifiSSID = wifiSSID; + contentLoader.item.themedQrCodePath = themedQrCodePath; + contentLoader.item.saveBrowserLoader = saveBrowserLoader; + }); + } + + function show(ssid) { + wifiSSID = ssid; + fetchNetworkQRCode(ssid); + } + + function hide() { + if (themedQrCodePath !== "") { + deleteQRCodeFile(themedQrCodePath); + } + if (normalQrCodePath !== "") { + deleteQRCodeFile(normalQrCodePath); + } + close(); + } + + function fetchNetworkQRCode(ssid) { + // TODO: Add loading UI? + + DMSService.sendRequest("network.qrcode", { + ssid: ssid + }, response => { + if (response.error) { + ToastService.showError("Failed to fetch network QR code: ", JSON.stringify(response.error)); + } else if (response.result) { + themedQrCodePath = response.result[0]; + normalQrCodePath = response.result[1]; + open(); + } + }); + } + + function deleteQRCodeFile(path) { + DMSService.sendRequest("network.delete-qrcode", { + path: path + }, response => { + if (response.error) { + ToastService.showError(`Failed to remove QR code at ${path}: `, JSON.stringify(response.error)); + } + }) + } + + LazyLoader { + id: saveBrowserLoader + active: false + + FileBrowserSurfaceModal { + id: saveBrowser + + browserTitle: I18n.tr("Save QR Code") + browserIcon: "qr_code" + browserType: "default" + fileExtensions: ["*.png"] + allowStacking: true + saveMode: true + defaultFileName: `${root.wifiSSID ?? "wifi-qrcode"}.png` + onFileSelected: path => { + const cleanPath = decodeURI(path.toString().replace(/^file:\/\//, '')); + const fileName = cleanPath.split('/').pop(); + const fileUrl = "file://" + cleanPath; + + copyQrCodeProcess.exec(["cp", root.normalQrCodePath, cleanPath, "-f"]) + } + + Process { + id: copyQrCodeProcess + stdout: StdioCollector { + onStreamFinished: { + saveBrowser.close(); + } + } + } + } + } + + content: Component { + Item { + id: theItem + property alias themedQrCodePath: qrCodeImg.source + property var saveBrowserLoader: null + property string wifiSSID: "" + anchors.fill: parent + + Column { + anchors.fill: parent + anchors.margins: Theme.spacingL + spacing: Theme.spacingL + + RowLayout { + id: modalTitle + width: parent.width + + StyledText { + text: I18n.tr("WiFi QR code for ") + theItem.wifiSSID + font.pixelSize: Theme.fontSizeLarge + color: Theme.surfaceText + font.weight: Font.Bold + Layout.alignment: Qt.AlignLeft + } + + DankActionButton { + iconName: "save" + iconSize: Theme.iconSize - 4 + iconColor: Theme.surfaceText + onClicked: { + saveBrowserLoader.active = true; + if (saveBrowserLoader.item) { + saveBrowserLoader.item.open(); + } + } + Layout.alignment: Qt.AlignRight + } + + DankActionButton { + iconName: "close" + iconSize: Theme.iconSize - 4 + iconColor: Theme.surfaceText + onClicked: root.hide() + Layout.alignment: Qt.AlignRight + } + } + + Image { + id: qrCodeImg + height: parent.height - parent.spacing - modalTitle.height + width: height + anchors.horizontalCenter: parent.horizontalCenter + + MultiEffect { + source: qrCodeImg + anchors.fill: source + colorization: 1.0 + colorizationColor: Theme.primary + } + } + } + } + } +} |