void QtCodeToHtmlMainDialog::on_button_convert_clicked() { if (ui->tab_source->currentIndex() == 0) { //Convert code snippet const std::string source = std::string(std::tmpnam(0)) + (GetContentType() == c2h::ContentType::cpp ? ".cpp" : ".txt"); { const std::vector<std::string> v = EditToVector(ui->edit_source_snippet); std::ofstream f(source.c_str()); std::copy(v.begin(),v.end(),std::ostream_iterator<std::string>(f,"\n")); } c2h::Dialog d( GetPageType(), source, GetContentType(), GetTechInfo()); const std::vector<std::string> v = d.ToHtml(); Display(v); boost::filesystem::remove(source); } else { //Convert file or folder const std::string source = ui->edit_source->text().toStdString(); if (!boost::filesystem::exists(source)) { ui->button_convert->setText("Source (file or folder) does not exist"); ui->button_convert->setEnabled(false); return; } c2h::Dialog d( GetPageType(), source, GetContentType(), GetTechInfo()); const std::vector<std::string> v = d.ToHtml(); Display(v); } //Make a screenshot // QPixmap::grabWidget(this).save("ToolCodeToHtmlMainDialog.png"); }
void ribi::c2h::QtCodeToHtmlMainDialog::on_button_convert_clicked() noexcept { if (ui->tab_source->currentIndex() == 0) { //Convert code snippet const std::vector<std::string> v = EditToVector(ui->edit_source_snippet); const std::vector<std::string> w = Dialog::SnippetToHtml(v,SnippetType::cpp); Display(w); } else { //Convert file or folder const std::string source = ui->edit_source->text().toStdString(); if (!ribi::fileio::IsFolder(source) && !ribi::fileio::IsRegularFile(source)) { ui->button_convert->setText("Source (file or folder) does not exist"); ui->button_convert->setEnabled(false); return; } if (ribi::fileio::IsRegularFile(source)) { const std::vector<std::string> v { Dialog::FileToHtml(source) }; Display(v); } else { assert(ribi::fileio::IsFolder(source)); const std::vector<std::string> v { Dialog::FolderToHtml(source) }; Display(v); } } }