Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/AddSourceDialog.qml
Show All 21 Lines | |||||
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
23 | import org.kde.kirigami 2.2 as Kirigami | 23 | import org.kde.kirigami 2.2 as Kirigami | ||
24 | 24 | | |||
25 | Popup | 25 | Popup | ||
26 | { | 26 | { | ||
27 | id: newSourceDialog | 27 | id: newSourceDialog | ||
28 | parent: applicationWindow().overlay | 28 | parent: applicationWindow().overlay | ||
29 | modal: true | 29 | modal: true | ||
30 | focus: true | ||||
30 | 31 | | |||
31 | x: (parent.width - width)/2 | 32 | x: (parent.width - width)/2 | ||
32 | y: (parent.height - height)/2 | 33 | y: (parent.height - height)/2 | ||
33 | 34 | | |||
34 | property string displayName | 35 | property string displayName | ||
35 | property QtObject source | 36 | property QtObject source | ||
36 | 37 | | |||
37 | ColumnLayout { | 38 | ColumnLayout { | ||
38 | id: info | 39 | id: info | ||
39 | anchors { | 40 | anchors { | ||
40 | left: parent.left | 41 | left: parent.left | ||
41 | right: parent.right | 42 | right: parent.right | ||
42 | } | 43 | } | ||
43 | 44 | | |||
44 | Kirigami.Icon { | | |||
45 | Layout.alignment: Qt.AlignRight | | |||
46 | visible: !Kirigami.Settings.isMobile | | |||
47 | width: Kirigami.Units.iconSizes.smallMedium | | |||
48 | height: width | | |||
49 | source: "dialog-close" | | |||
50 | MouseArea { | | |||
51 | anchors.fill: parent | | |||
52 | onClicked: newSourceDialog.close(); | | |||
53 | } | | |||
54 | } | | |||
55 | | ||||
56 | Kirigami.Heading { | 45 | Kirigami.Heading { | ||
57 | level: 4 | 46 | level: 3 | ||
58 | Layout.fillWidth: true | 47 | Layout.fillWidth: true | ||
59 | text: i18n("Specify the new source for %1", displayName) | 48 | text: i18n("Add a new %1 repository", displayName) | ||
60 | } | 49 | } | ||
61 | Label { | 50 | Label { | ||
62 | id: description | 51 | id: description | ||
63 | Layout.fillWidth: true | 52 | Layout.fillWidth: true | ||
64 | Layout.fillHeight: true | 53 | Layout.fillHeight: true | ||
65 | wrapMode: Text.WordWrap | 54 | wrapMode: Text.WordWrap | ||
66 | textFormat: Text.PlainText | 55 | textFormat: Text.PlainText | ||
67 | text: source.idDescription | 56 | text: source.idDescription | ||
68 | } | 57 | } | ||
69 | 58 | | |||
70 | TextField { | 59 | TextField { | ||
71 | id: repository | 60 | id: repository | ||
72 | Layout.fillWidth: true | 61 | Layout.fillWidth: true | ||
73 | Keys.onEnterPressed: newSourceDialog.accept() | 62 | Keys.onReturnPressed: okButton.clicked() | ||
apol: onAccepted: | |||||
63 | Keys.onEnterPressed: okButton.clicked() | ||||
74 | focus: true | 64 | focus: true | ||
75 | onTextChanged: color = Kirigami.Theme.textColor | 65 | onTextChanged: color = Kirigami.Theme.textColor | ||
76 | } | 66 | } | ||
77 | 67 | | |||
78 | DialogButtonBox { | 68 | DialogButtonBox { | ||
79 | Layout.fillWidth: true | 69 | Layout.fillWidth: true | ||
80 | standardButtons: DialogButtonBox.Ok | DialogButtonBox.Close | | |||
81 | 70 | | |||
82 | onAccepted: if (source.addSource(repository.text)) { | 71 | Button { | ||
83 | newSourceDialog.visible = false | 72 | id: okButton | ||
73 | DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole | ||||
74 | text: i18n("Add") | ||||
75 | icon.name: "list-add" | ||||
76 | onClicked: if (source.addSource(repository.text)) { | ||||
77 | newSourceDialog.close() | ||||
84 | } else { | 78 | } else { | ||
85 | repository.color = Kirigami.Theme.negativeTextColor | 79 | repository.color = Kirigami.Theme.negativeTextColor | ||
86 | } | 80 | } | ||
87 | } | 81 | } | ||
82 | | ||||
83 | Button { | ||||
84 | id: cancelButton | ||||
85 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | ||||
86 | text: i18n("Cancel") | ||||
87 | icon.name: "dialog-cancel" | ||||
88 | onClicked: newSourceDialog.close() | ||||
89 | } | ||||
90 | } | ||||
88 | } | 91 | } | ||
89 | } | 92 | } |
onAccepted: