8 #include "quickquestionlistener.h" 10 #include "core/question.h" 12 #include <QCoreApplication> 16 class QuickQuestionListenerHelper {
18 QuickQuestionListenerHelper() : q(nullptr) {}
19 ~QuickQuestionListenerHelper() { }
20 QuickQuestionListenerHelper(
const QuickQuestionListenerHelper &) =
delete;
21 QuickQuestionListenerHelper& operator=(
const QuickQuestionListenerHelper &) =
delete;
22 QuickQuestionListener *q;
24 Q_GLOBAL_STATIC(QuickQuestionListenerHelper, s_kns3_quickQuestionListener)
26 class QuickQuestionListener::Private {
32 QuickQuestionListener *QuickQuestionListener::instance()
34 if(!s_kns3_quickQuestionListener()->q) {
35 new QuickQuestionListener;
37 return s_kns3_quickQuestionListener()->q;
40 QuickQuestionListener::QuickQuestionListener()
41 :
KNSCore::QuestionListener(nullptr)
45 s_kns3_quickQuestionListener()->q =
this;
48 QuickQuestionListener::~QuickQuestionListener()
51 d->question->setResponse(KNSCore::Question::CancelResponse);
58 d->question = question;
59 switch(question->questionType())
61 case KNSCore::Question::SelectFromListQuestion:
62 Q_EMIT askListQuestion(question->title(), question->question(), question->list());
64 case KNSCore::Question::ContinueCancelQuestion:
65 Q_EMIT askContinueCancelQuestion(d->question->title(), d->question->question());
67 case KNSCore::Question::InputTextQuestion:
68 Q_EMIT askTextInputQuestion(d->question->title(), d->question->question());
70 case KNSCore::Question::PasswordQuestion:
71 Q_EMIT askPasswordQuestion(d->question->title(), d->question->question());
73 case KNSCore::Question::YesNoQuestion:
75 Q_EMIT askYesNoQuestion(d->question->title(), d->question->question());
80 void KNewStuffQuick::QuickQuestionListener::passResponse(
bool responseIsContinue,
QString input)
83 if (responseIsContinue) {
84 d->question->setResponse(input);
85 switch(d->question->questionType())
87 case KNSCore::Question::ContinueCancelQuestion:
88 d->question->setResponse(KNSCore::Question::ContinueResponse);
90 case KNSCore::Question::YesNoQuestion:
91 d->question->setResponse(KNSCore::Question::YesResponse);
93 case KNSCore::Question::SelectFromListQuestion:
94 case KNSCore::Question::InputTextQuestion:
95 case KNSCore::Question::PasswordQuestion:
97 d->question->setResponse(KNSCore::Question::OKResponse);
101 switch(d->question->questionType())
103 case KNSCore::Question::YesNoQuestion:
104 d->question->setResponse(KNSCore::Question::NoResponse);
106 case KNSCore::Question::SelectFromListQuestion:
107 case KNSCore::Question::InputTextQuestion:
108 case KNSCore::Question::PasswordQuestion:
109 case KNSCore::Question::ContinueCancelQuestion:
111 d->question->setResponse(KNSCore::Question::CancelResponse);
115 d->question =
nullptr;
A way to ask a user a question from inside a GUI-less library (like KNewStuffCore) ...
Contains the core functionality for handling interaction with NewStuff providers. ...
void setParent(QObject *parent)