Warning, /utilities/keysmith/src/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-License-Identifier: GPL-3.0-or-later
0003  * SPDX-FileCopyrightText: 2019 Bhushan Shah <bshah@kde.org>
0004  * SPDX-FileCopyrightText: 2019-2021 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
0005  */
0006 
0007 import QtQml 2.15
0008 import org.kde.kirigami 2.20 as Kirigami
0009 
0010 import Keysmith.Application 1.0 as Application
0011 
0012 Kirigami.ApplicationWindow {
0013     id: root
0014 
0015     width: Kirigami.Units.gridUnit * 20
0016     height: Kirigami.Units.gridUnit * 30
0017 
0018     function routeToUrl(route) {
0019         switch (route) {
0020         case Application.Navigation.Error:
0021             return "qrc:/ErrorPage.qml"
0022         case Application.Navigation.UnlockAccounts:
0023             return "qrc:/UnlockAccounts.qml"
0024         case Application.Navigation.RenameAccount:
0025             return "qrc:/RenameAccount.qml"
0026         case Application.Navigation.AccountsOverview:
0027             return "qrc:/AccountsOverview.qml"
0028         case Application.Navigation.AddAccount:
0029             return "qrc:/AddAccount.qml"
0030         case Application.Navigation.SetupPassword:
0031             return "qrc:/SetupPassword.qml"
0032         }
0033         return 'bug';
0034     }
0035 
0036     Connections {
0037         target: Application.Keysmith.navigation
0038 
0039         function onRouted(route, data) {
0040             console.log(route, data)
0041             const pageUrl = routeToUrl(route);
0042             while (root.pageStack.depth > 1) {
0043                 root.pageStack.pop();
0044             }
0045             if (root.pageStack.depth === 0) {
0046                 root.pageStack.push(pageUrl, {
0047                     vm: data,
0048                 });
0049             } else {
0050                 root.pageStack.replace(pageUrl, {
0051                     vm: data,
0052                 });
0053             }
0054         }
0055 
0056         function onPushed(route, data) {
0057             const pageUrl = routeToUrl(route);
0058             root.pageStack.push(pageUrl, {
0059                 vm: data,
0060             });
0061         }
0062     }
0063 }