Skip to content
Snippets Groups Projects

Enable Markdown support in display of skill description in Skill Manager Gui

Merged Rainer Kartmann requested to merge skill-description-markdown-support into master
6 files
+ 255
104
Compare changes
  • Side-by-side
  • Inline
Files
6
#include "SkillDescriptionWidget.h"
#include <sstream>
#include <QGridLayout>
#include <QLabel>
#include <QTextEdit>
#include <ArmarXGui/libraries/ArmarXGuiBase/widgets/cpp-markdown/markdown.h> // ToDo: Move cpp-markdown to own Axii module.
namespace armarx
{
static std::string
markdownToHtml(const std::string& markdownText, size_t spacesPerTab = 2)
{
::markdown::Document document(spacesPerTab);
document.read(markdownText);
std::stringstream html;
document.write(html);
return html.str();
}
SkillDescriptionWidget::SkillDescriptionWidget(QWidget* parent) : QWidget{parent}
{
QGridLayout* layout = new QGridLayout;
setLayout(layout);
layout->setMargin(0);
int row = 0;
int col = 0;
layout->addWidget(new QLabel("Name:"), row, col++);
name = new QLabel;
layout->addWidget(name, row, col++);
// Add some padding.
layout->addWidget(new QLabel(), row, col++);
{
QLabel* label = new QLabel("Timeout:");
label->setAlignment(Qt::AlignmentFlag::AlignRight);
layout->addWidget(label, row, col++);
}
timeout = new QLabel;
timeout->setAlignment(Qt::AlignmentFlag::AlignRight);
layout->addWidget(timeout, row, col++);
++row;
int numCols = col;
col = 0;
description = new QTextEdit;
description->setReadOnly(true);
layout->addWidget(description, row, col, 1, numCols);
++row;
}
void
SkillDescriptionWidget::setSkillDescription(const skills::SkillDescription& desc)
{
name->setText(QString::fromStdString(desc.skillId.skillName));
description->setHtml(QString::fromStdString(markdownToHtml(desc.description)));
std::stringstream timeoutStr;
timeoutStr << desc.timeout;
timeout->setText(QString::fromStdString(timeoutStr.str()));
}
} // namespace armarx
Loading