Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/test-fixtures/ui/task-services/Vault.qml

Raw
import QtQuick

Item {
    property var clipboardService: null
    property bool unlocked: true
    property string status: "unlocked"
    property var profile: ({
            serverUrl: "https://vault.example.invalid",
            account: "fixture@example.invalid"
        })
    property bool setupEditing: false
    property bool setupSaving: false
    property bool connectionBusy: false
    property bool connectionTesting: false
    property string connectionResult: ""
    property string setupError: ""
    property string setupUrlDraft: ""
    property string setupAccountDraft: ""
    property bool lockPending: false
    property int lockGeneration: 0
    property bool panelOpen: false
    property string message: ""
    property string feedback: ""
    property string repromptError: ""
    property var cache: ({
            available: false,
            stale: false
        })
    property var challenge: ({
            providers: []
        })
    property bool verificationPending: false
    property int secondFactorProvider: -1
    property string secondFactorDraft: ""
    property string query: ""
    property string selectedId: "item-0"
    property real resultScrollPosition: 0
    property real detailScrollPosition: 0
    property var detail: ({
            id: "item-0",
            title: "fixture item 0",
            itemType: "note",
            fields: [],
            uris: [],
            notes: "",
            attachments: []
        })
    readonly property var items: Array.from({
        length: 20
    }, (_, i) => ({
                id: `item-${i}`,
                title: `fixture item ${i}`,
                itemType: "note",
                favorite: false,
                subtitle: "synthetic"
            }))
    readonly property var visibleItems: unlocked ? items.filter(item => item.title.includes(query)) : []
    readonly property var groupedItems: visibleItems.length > 0 ? [
        {
            label: "items",
            items: visibleItems
        }
    ] : []

    function prepareOpen(appId) {
    }
    function secondFactorHint() {
        return "verification code";
    }
    function sectionExpanded(name) {
        return true;
    }
    function isRevealed(id) {
        return false;
    }
    function select(id) {
        selectedId = id;
        const item = items.find(row => row.id === id);
        detail = item ? Object.assign({}, item, {
            fields: [],
            uris: [],
            notes: "",
            attachments: []
        }) : ({});
    }
    function moveSelection(delta) {
        const index = visibleItems.findIndex(row => row.id === selectedId);
        if (visibleItems.length > 0)
            select(visibleItems[Math.max(0, Math.min(visibleItems.length - 1, index + delta))].id);
    }
    function refreshDetail() {
        select(selectedId);
    }
    function beginSetup() {
        setupEditing = true;
    }
    function cancelSetup() {
        setupEditing = false;
    }
    function lock() {
        unlocked = false;
        status = "locked";
        lockGeneration++;
        query = "";
        selectedId = "";
        detail = ({});
        resultScrollPosition = 0;
        detailScrollPosition = 0;
    }
}