3 #include <Wt/WPushButton.h> 5 #include <Wt/WApplication.h> 6 #include <Wt/WLineEdit.h> 8 #include "PopupQuestion.h" 10 Wtx::PopupQuestion::PopupQuestion(
const std::string & question,
const std::string & answer,
const std::string & placeholder )
11 :
Wt::WDialog(
"Alert")
13 contents()-> addNew<Wt::WText>(question);
14 contents()-> addNew<Wt::WBreak>();
15 auto textEdit = contents()-> addNew<Wt::WLineEdit>(answer);
16 textEdit-> setPlaceholderText( placeholder );
17 contents()-> addNew<Wt::WBreak>();
18 contents()-> addNew<Wt::WPushButton>(
"Ok")->
19 clicked().connect( [=]()
21 m_answered.emit( textEdit-> valueText().toUTF8() );
25 contents()-> addNew<Wt::WPushButton>(
"Cancel")->
26 clicked().connect(
this, &Wt::WDialog::reject );
28 rejectWhenEscapePressed();
34 Wtx::PopupQuestion * Wtx::PopupQuestion::ask(
const std::string & question,
const std::string & answer,
const std::string & placeholder )
36 auto popup = wApp-> addChild( std::make_unique<Wtx::PopupQuestion>( question, answer, placeholder ) );
37 popup-> finished().connect( [=](){ wApp-> removeChild(popup); });
41 Wt::Signal<std::string> & Wtx::PopupQuestion::answered()