18import QtQuick.Controls as QQC2
20import org.kde.kirigami as Kirigami
21import org.kde.newstuff as NewStuff
22import org.kde.newstuff.core as NewStuffCore
27 property int questionType
29 anchors.centerIn: parent
34 margins: Kirigami.Units.largeSpacing
35 padding: Kirigami.Units.largeSpacing
38 switch (questionType) {
39 case NewStuffCore.Question.SelectFromListQuestion:
40 case NewStuffCore.Question.InputTextQuestion:
41 case NewStuffCore.Question.PasswordQuestion:
42 case NewStuffCore.Question.ContinueCancelQuestion:
44 return QQC2.Dialog.Ok | QQC2.Dialog.Cancel;
45 case NewStuffCore.Question.YesNoQuestion:
46 return QQC2.Dialog.Yes | QQC2.Dialog.No;
48 return QQC2.Dialog.NoButton;
53 target: NewStuff.QuickQuestionListener
55 function onAskListQuestion(title, question,
list) {
56 dialog.questionType = NewStuffCore.Question.SelectFromListQuestion;
58 questionLabel.text = question;
60 listView.model.append({ text:
list[i] });
62 listView.currentIndex = 0;
63 listView.visible =
true;
67 function onAskContinueCancelQuestion(title, question) {
68 dialog.questionType = NewStuffCore.Question.ContinueCancelQuestion;
70 questionLabel.text = question;
74 function onAskTextInputQuestion(title, question) {
75 dialog.questionType = NewStuffCore.Question.InputTextQuestion;
77 questionLabel.text = question;
78 textInput.visible =
true;
82 function onAskPasswordQuestion(title, question) {
83 dialog.questionType = NewStuffCore.Question.PasswordQuestion;
85 questionLabel.text = question;
86 textInput.echoMode = QQC2.TextInput.PasswordEchoOnEdit;
87 textInput.visible =
true;
91 function onAskYesNoQuestion(title, question) {
92 dialog.questionType = NewStuffCore.Question.YesNoQuestion;
94 questionLabel.text = question;
99 function passResponse(responseIsContinue) {
101 switch (dialog.questionType) {
102 case NewStuffCore.Question.SelectFromListQuestion:
103 input = listView.currentItem.text;
104 listView.model.clear();
105 listView.visible =
false;
107 case NewStuffCore.Question.InputTextQuestion:
108 input = textInput.text;
110 textInput.visible =
false;
112 case NewStuffCore.Question.PasswordQuestion:
113 input = textInput.text;
115 textInput.visible =
false;
116 textInput.echoMode = QQC2.TextInput.Normal;
118 case NewStuffCore.Question.ContinueCancelQuestion:
119 case NewStuffCore.Question.YesNoQuestion:
124 NewStuff.QuickQuestionListener.passResponse(responseIsContinue, input);
130 readonly
property real maxWidth: {
131 const bounds = dialog.parent;
135 return bounds.width - (dialog.leftPadding + dialog.leftMargin + dialog.rightMargin + dialog.rightPadding);
139 spacing:
Kirigami.Units.smallSpacing
143 Layout.maximumWidth: layout.maxWidth
149 spacing:
Kirigami.Units.smallSpacing
150 Layout.maximumWidth: layout.maxWidth
151 Layout.fillWidth:
true
157 delegate: QQC2.ItemDelegate {
158 width: listView.width
166 Layout.maximumWidth: layout.maxWidth
167 Layout.fillWidth:
true
KIOCORE_EXPORT QStringList list(const QString &fileClass)
qsizetype length() const const