Example #1
0
Upload::Upload( Wt::WContainerWidget* pcw ) {
  
  //Wt::WContainerWidget *container = new Wt::WContainerWidget();

  Wt::WFileUpload *fu = new Wt::WFileUpload( pcw );
  fu->setFileTextSize( 10000 ); // Set the maximum file size (in KB )
  fu->setProgressBar(new Wt::WProgressBar());
  fu->setMargin(10, Wt::Right);

  // Provide a button to start uploading.
  Wt::WPushButton *uploadButton = new Wt::WPushButton("Send", pcw );
  uploadButton->setMargin(10, Wt::Left | Wt::Right);

  Wt::WText *out = new Wt::WText( pcw );

  // Upload when the button is clicked.
  uploadButton->clicked().connect(std::bind([=] () {
      fu->upload();
      uploadButton->disable();
  }));

  // Upload automatically when the user entered a file.
  fu->changed().connect(std::bind([=] () {
      fu->upload();
      uploadButton->disable();
      std::string s( "File upload is changed." );
      out->setText( s );
  }));

  // React to a succesfull upload.
  fu->uploaded().connect(std::bind([=] () {
    std::string s( "File upload is finished: " );
    s += fu->clientFileName().toUTF8();
    s += ",";
    //s += fu->fileTextSize()
    s += fu->spoolFileName();
    //fu->stealSpooledFile()
    out->setText( s );
  }));

  // React to a file upload problem.
  fu->fileTooLarge().connect(std::bind([=] () {
      out->setText("File is too large.");
  }));
}
Example #2
0
EarMobileUI::EarMobileUI(const Wt::WEnvironment& env)
  : Wt::WApplication(env)
{
    setTitle("Ear Mobile interface"); 
this->log("notice")<<"Making mobile UI";
    Wt::WBootstrapTheme *theme = new Wt::WBootstrapTheme();
///    theme->setResponsive(true);
    theme->setVersion(Wt::WBootstrapTheme::Version3); 
   // this->removeMetaHeader(Wt::MetaHeaderType::MetaName,"viewport");
    //this->addMetaHeader("viewport",
//			   "width=device-width, height=device-height, initial-scale=2");
//  this->addMetaHeader("viewport",
//			   "width=1024");
  setTheme(theme);
   

Wt::WTemplate *html = new Wt::WTemplate(Wt::WString(
"<div width='device-width' scale='4'   >"
	"<div>"
		"${start-button} ${stop-button} ${play-time}"
	"</div>"
	"<div>"
		"${fragment-tree}"
	"</div>"
"</div>"
),root());

 
this->log("notice")<<"Making button container";
    //Wt::WContainerWidget *buttonContainer = new Wt::WContainerWidget(root());
    //buttonContainer->setMaximumSize(500,Wt::WLength::Auto);
    //Wt::WHBoxLayout *buttonBox = new Wt::WHBoxLayout();
    //buttonContainer->setLayout(buttonBox);
    playPauseButton = new Wt::WPushButton("Play from start");
    //buttonBox->addWidget(playPauseButton);
    playPauseButton->clicked().connect(std::bind([=] ()
    {
this->log("notice")<<"interactnig to pause";
	zmq_conn::interact(std::string("event:pause"));
    }));
    html->bindWidget("start-button",playPauseButton);
    Wt::WPushButton *stopButton = new Wt::WPushButton("Stop"); 
    //buttonBox->addWidget(stopButton);
    html->bindWidget("stop-button",stopButton);

    stopButton->clicked().connect(std::bind([=] ()
    {
this->log("notice")<<"interactnig to stop";
	zmq_conn::interact(std::string("event:stop"));
    }));
    stopButton->setMargin(5, Wt::Left);
    posText = new TimeWidget();
    posText->setMargin(5, Wt::Left);
    html->bindWidget("play-time",posText);
    //buttonBox->addWidget(posText);
   


//    Wt::WContainerWidget *fragmentContainer = new Wt::WContainerWidget(root());
    fragmentTree = new Wt::WTreeTable();
 html->bindWidget("fragment-tree",fragmentTree);
//    fragmentTree->addColumn("",500);
//    fragmentTree->resize(
//			Wt::WLength(100,Wt::WLength::Unit::Percentage), //Width
//			Wt::WLength(80,Wt::WLength::Unit::Percentage)); //Heigth
/*   Wt::WTimer *inputtimer = new Wt::WTimer();   
   inputtimer->setInterval(2500); //For some reason, this actually segfaults (on a RPi) when it fires, before calling updateInputs. Calling updateInputs from any other place works, including the other timer. I'll try and find out the cause later, now it runs
   inputtimer->timeout().connect(std::bind([=] ()
   {
std::cout<< "updating inputs " <<std::endl;
       updateInputs();
   }));
   inputtimer->start();
*/

   updateInputs();


    Wt::WTimer *timer = new Wt::WTimer();  
    timer->setInterval(100);
    timer->timeout().connect(std::bind([=] ()
    {
	Wt::Json::Object posj ;
	bool playing;
	Wt::Json::Object playingj;

	zmq::socket_t *socket = zmq_conn::connect();
	posj = zmq_conn::interact(std::string("pos?"),socket);
	playingj = zmq_conn::interact(std::string("playing?"),socket);
	zmq_conn::disconnect(socket);

	Wt::Json::Value posjv = posj.get("pos");	
	const long long track_time = posjv;
	posText->setTime(track_time);
	mark_current_fragment(fragmentTree,track_time);
	playing = playingj.get("playing");
	if (playing)
	{
		playPauseButton->setText("Pause");
	}
	else
	{
		if(track_time > 0)
		{
			playPauseButton->setText("Continue");
		}
		else
		{
			playPauseButton->setText("Play from start");
		}
	}
updateInputs();
    }));
    timer->start();





 
}
Example #3
0
void ChamadaForm::_initialize(){
	Wt::Dbo::Transaction transaction(_dbSession);

	Wt::WText* title = new Wt::WText("<h3>Diario de Classe: " + Wt::WDate::currentDate().toString("dd/MM/yyyy").toUTF8() + "</h3> <br></br><br></br>");

		addWidget(title);
		Wt::WPushButton* fazerChamada = new Wt::WPushButton("Percorrer turma", this);

		fazerChamada->setStyleClass("btn btn-primary");

		fazerChamada->clicked().connect(std::bind([=](){
			new AutoChamada(_dbSession, sortList);
		}));

		fazerChamada->setMargin(20, Wt::Bottom);
		_list =  new Wt::WTable(this);


		Wt::WPushButton* save = new Wt::WPushButton("Salvar", this);
		save->setStyleClass("btn btn-success");
		save->setMargin(10, Wt::Right);
		save->clicked().connect(std::bind([=](){
			_save();
			delete this;
		}));

		Wt::WPushButton* cancel = new Wt::WPushButton("Cancelar", this);
		cancel->setStyleClass("btn btn-primary");
		cancel->clicked().connect(std::bind([=](){
			delete this;
		}));

	_list->setWidth(Wt::WLength("100%"));
	_list->addStyleClass("table-striped table-hover");
	_list->setMargin(50, Wt::Bottom);
	new Wt::WText("Aluno", _list->elementAt(0,0));
	new Wt::WText("Presente", _list->elementAt(0,1));
	_list->setHeaderCount(1);


	for(auto i : _disciplina->turma()->alunos()){
		Wt::WCheckBox* checkbox = new Wt::WCheckBox();
		sortList.push_back(std::make_pair(checkbox, i));
	}

	auto sortAlg = [](std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>> par1, std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>>par2){
		return par1.second->usuario()->nome() < par2.second->usuario()->nome();
	};

	std::sort(std::begin(sortList), std::end(sortList), sortAlg);

	for(auto i : sortList){
		int row = _list->rowCount();
		Wt::WText* name = new Wt::WText(i.second->usuario()->nome() + " " + i.second->usuario()->sobrenome(), _list->elementAt(row, 0));
		name->setMargin(10, Wt::Right);
		_list->elementAt(row, 1)->addWidget(i.first);
		_list->elementAt(row, 1)->setHeight(40);
		_list->elementAt(row, 1)->setWidth(100);

	}
}