Vuo  2.0.2
VuoDocumentationSidebar.cc
Go to the documentation of this file.
1 
11 
12 #include "VuoEditor.hh"
13 #include "VuoNodePopover.hh"
14 #include "VuoRendererFonts.hh"
15 #include "VuoStringUtilities.hh"
16 
21  QDockWidget(parent)
22 {
23  setFeatures(QDockWidget::DockWidgetClosable);
24 
25  setWindowTitle(generateGlslIsfTitle());
26 
27  scrollArea = new QScrollArea(this);
28  scrollArea->setWidgetResizable(true);
29  setWidget(scrollArea);
30 
31  label = new QLabel(this);
32  label->setFont(VuoRendererFonts::getSharedFonts()->portPopoverFont());
33  label->setMargin(8);
34  label->setWordWrap(true);
35  label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
36  label->setOpenExternalLinks(true);
37  scrollArea->setWidget(label);
38 
39  connect(static_cast<VuoEditor *>(qApp), &VuoEditor::darkInterfaceToggled, this, &VuoDocumentationSidebar::updateColor);
40  updateColor();
41 }
42 
46 void VuoDocumentationSidebar::updateColor()
47 {
48  bool isDark = static_cast<VuoEditor *>(qApp)->isInterfaceDark();
49 
51  QString titleTextColor = isDark ? "#303030" : "#808080";
52  QString titleBackgroundColor = isDark ? "#919191" : "#efefef";
53  QString contentBackgroundColor = isDark ? "#282828" : "#f9f9f9";
54  setStyleSheet(VUO_QSTRINGIFY(
55  QDockWidget {
56  titlebar-close-icon: url(:/Icons/dockwidget-close-%4.png);
57  font-size: 11px;
58  border: none;
59  color: %1;
60  }
61  QDockWidget::title {
62  text-align: left;
63  padding-left: 6px;
64  background-color: %2;
65  }
66  QScrollArea {
67  border-left: 1px solid %2;
68  border-right: none;
69  border-top: none;
70  border-bottom: none;
71  }
72  QLabel {
73  background-color: %3;
74  }
75  )
76  .arg(titleTextColor)
77  .arg(titleBackgroundColor)
78  .arg(contentBackgroundColor)
79  .arg(isDark ? "dark" : "light")
80  );
81 
82  QString content = VuoNodePopover::generateTextStyleString() +
83  generateGlslIsfText();
84  label->setText(content);
85 }
86 
90 QString VuoDocumentationSidebar::generateGlslIsfTitle()
91 {
92  return "GLSL/ISF Quick Reference";
93 }
94 
98 QString VuoDocumentationSidebar::generateGlslIsfText()
99 {
100  QFile file(QApplication::applicationDirPath().append("/../Resources/GlslIsfQuickReference.md"));
101  file.open(QIODevice::ReadOnly);
102  QTextStream textStream(&file);
103  string markdown = textStream.readAll().toStdString();
104  string html = VuoStringUtilities::generateHtmlFromMarkdown(markdown);
105  return QString::fromStdString(html);
106 }
107 
112 {
113  return label->selectedText();
114 }