|
| 1 | +/* |
| 2 | + * Copyright (C) 2023 by Matthieu Gallien <[email protected]> |
| 3 | + * |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, but |
| 10 | + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 11 | + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * for more details. |
| 13 | + */ |
| 14 | + |
| 15 | +import QtQuick 2.15 |
| 16 | +import QtQuick.Layouts 1.15 |
| 17 | +import QtQuick.Controls 2.15 |
| 18 | +import QtQml.Models 2.15 |
| 19 | + |
| 20 | +import com.nextcloud.desktopclient 1.0 |
| 21 | +import Style 1.0 |
| 22 | + |
| 23 | +import "./tray" |
| 24 | + |
| 25 | +ApplicationWindow { |
| 26 | + id: root |
| 27 | + |
| 28 | + required property var tokensInfo |
| 29 | + required property var keysInfo |
| 30 | + |
| 31 | + flags: Qt.Window | Qt.Dialog |
| 32 | + visible: true |
| 33 | + modality: Qt.ApplicationModal |
| 34 | + |
| 35 | + width: 400 |
| 36 | + height: 600 |
| 37 | + minimumWidth: 400 |
| 38 | + minimumHeight: 600 |
| 39 | + |
| 40 | + title: qsTr('Token Encryption Key Chooser') |
| 41 | + |
| 42 | + // TODO: Rather than setting all these palette colours manually, |
| 43 | + // create a custom style and do it for all components globally |
| 44 | + palette { |
| 45 | + text: Style.ncTextColor |
| 46 | + windowText: Style.ncTextColor |
| 47 | + buttonText: Style.ncTextColor |
| 48 | + brightText: Style.ncTextBrightColor |
| 49 | + highlight: Style.lightHover |
| 50 | + highlightedText: Style.ncTextColor |
| 51 | + light: Style.lightHover |
| 52 | + midlight: Style.ncSecondaryTextColor |
| 53 | + mid: Style.darkerHover |
| 54 | + dark: Style.menuBorder |
| 55 | + button: Style.buttonBackgroundColor |
| 56 | + window: Style.backgroundColor |
| 57 | + base: Style.backgroundColor |
| 58 | + toolTipBase: Style.backgroundColor |
| 59 | + toolTipText: Style.ncTextColor |
| 60 | + } |
| 61 | + |
| 62 | + onClosing: function(close) { |
| 63 | + Systray.destroyDialog(self); |
| 64 | + close.accepted = true |
| 65 | + } |
| 66 | + |
| 67 | + ColumnLayout { |
| 68 | + anchors.fill: parent |
| 69 | + anchors.leftMargin: 20 |
| 70 | + anchors.rightMargin: 20 |
| 71 | + anchors.bottomMargin: 20 |
| 72 | + anchors.topMargin: 20 |
| 73 | + spacing: 15 |
| 74 | + z: 2 |
| 75 | + |
| 76 | + EnforcedPlainTextLabel { |
| 77 | + text: qsTr("Available Keys for end-to-end Encryption:") |
| 78 | + font.bold: true |
| 79 | + font.pixelSize: Style.bigFontPixelSizeResolveConflictsDialog |
| 80 | + Layout.fillWidth: true |
| 81 | + } |
| 82 | + |
| 83 | + ScrollView { |
| 84 | + Layout.fillWidth: true |
| 85 | + Layout.fillHeight: true |
| 86 | + |
| 87 | + clip: true |
| 88 | + |
| 89 | + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff |
| 90 | + |
| 91 | + ListView { |
| 92 | + id: tokensListView |
| 93 | + |
| 94 | + model: DelegateModel { |
| 95 | + model: keysInfo |
| 96 | + |
| 97 | + delegate: ItemDelegate { |
| 98 | + width: tokensListView.contentItem.width |
| 99 | + |
| 100 | + text: modelData.label |
| 101 | + |
| 102 | + highlighted: tokensListView.currentIndex === index |
| 103 | + |
| 104 | + onClicked: function() { tokensListView.currentIndex = index } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | + DialogButtonBox { |
| 111 | + Layout.fillWidth: true |
| 112 | + |
| 113 | + Button { |
| 114 | + text: qsTr("Choose") |
| 115 | + DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole |
| 116 | + } |
| 117 | + Button { |
| 118 | + text: qsTr("Cancel") |
| 119 | + DialogButtonBox.buttonRole: DialogButtonBox.RejectRole |
| 120 | + } |
| 121 | + |
| 122 | + onAccepted: function() { |
| 123 | + Systray.destroyDialog(conflictsDialog) |
| 124 | + } |
| 125 | + |
| 126 | + onRejected: function() { |
| 127 | + Systray.destroyDialog(conflictsDialog) |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + Rectangle { |
| 133 | + color: Style.backgroundColor |
| 134 | + anchors.fill: parent |
| 135 | + z: 1 |
| 136 | + } |
| 137 | +} |
0 commit comments