1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-02 03:28:28 -04:00
Files
DankMaterialShell/quickshell/Modals/PolkitAuthModal.qml
2026-07-02 15:07:43 -04:00

71 lines
1.5 KiB
QML

import QtQuick
import Quickshell
import qs.Common
import qs.Services
import qs.Widgets
FloatingWindow {
id: root
property bool disablePopupTransparency: true
function show() {
if (contentLoader.item)
contentLoader.item.reset();
visible = true;
Qt.callLater(focusContent);
}
function hide() {
visible = false;
}
function focusContent() {
if (contentLoader.item)
contentLoader.item.focusPasswordField();
}
objectName: "polkitAuthModal"
title: I18n.tr("Authentication")
minimumSize: Qt.size(460, 220)
maximumSize: Qt.size(460, 220)
color: Theme.surfaceContainer
visible: false
onClosed: hide()
onVisibleChanged: {
if (visible) {
Qt.callLater(focusContent);
return;
}
if (contentLoader.item)
contentLoader.item.reset();
}
Connections {
target: PolkitService.agent
enabled: PolkitService.polkitAvailable
function onIsActiveChanged() {
if (!(PolkitService.agent?.isActive ?? false))
root.hide();
}
}
Loader {
id: contentLoader
anchors.fill: parent
active: root.visible
sourceComponent: PolkitAuthContent {
windowControls: windowControls
onCloseRequested: root.hide()
}
}
FloatingWindowControls {
id: windowControls
targetWindow: root
}
}