8#include "quickquestionlistener.h"
10#include "core/question.h"
12#include <QCoreApplication>
15using namespace KNewStuffQuick;
17Q_GLOBAL_STATIC(QuickQuestionListener, s_quickQuestionListener)
18QuickQuestionListener *QuickQuestionListener::instance()
20 return s_quickQuestionListener;
23QuickQuestionListener::~QuickQuestionListener()
26 m_question->setResponse(KNSCore::Question::CancelResponse);
32 switch (question->questionType()) {
33 case KNSCore::Question::SelectFromListQuestion:
34 Q_EMIT askListQuestion(question->title(), question->question(), question->list());
36 case KNSCore::Question::ContinueCancelQuestion:
37 Q_EMIT askContinueCancelQuestion(question->title(), question->question());
39 case KNSCore::Question::InputTextQuestion:
40 Q_EMIT askTextInputQuestion(question->title(), question->question());
42 case KNSCore::Question::PasswordQuestion:
43 Q_EMIT askPasswordQuestion(question->title(), question->question());
45 case KNSCore::Question::YesNoQuestion:
47 Q_EMIT askYesNoQuestion(question->title(), question->question());
50 m_question = question;
53void KNewStuffQuick::QuickQuestionListener::passResponse(
bool responseIsContinue,
QString input)
56 if (responseIsContinue) {
57 m_question->setResponse(input);
58 switch (m_question->questionType()) {
59 case KNSCore::Question::ContinueCancelQuestion:
60 m_question->setResponse(KNSCore::Question::ContinueResponse);
62 case KNSCore::Question::YesNoQuestion:
63 m_question->setResponse(KNSCore::Question::YesResponse);
65 case KNSCore::Question::SelectFromListQuestion:
66 case KNSCore::Question::InputTextQuestion:
67 case KNSCore::Question::PasswordQuestion:
69 m_question->setResponse(KNSCore::Question::OKResponse);
73 switch (m_question->questionType()) {
74 case KNSCore::Question::YesNoQuestion:
75 m_question->setResponse(KNSCore::Question::NoResponse);
77 case KNSCore::Question::SelectFromListQuestion:
78 case KNSCore::Question::InputTextQuestion:
79 case KNSCore::Question::PasswordQuestion:
80 case KNSCore::Question::ContinueCancelQuestion:
82 m_question->setResponse(KNSCore::Question::CancelResponse);
90#include "moc_quickquestionlistener.cpp"
A way to ask a user a question from inside a GUI-less library (like KNewStuffCore)