Add a new tab in the viewer */
| 3185 | /** Add a new tab in the viewer |
| 3186 | */ |
| 3187 | G4bool G4UIQt::AddViewerTabFromFile(std::string fileName, std::string title) |
| 3188 | { |
| 3189 | if (fViewerTabWidget == nullptr) { |
| 3190 | return false; |
| 3191 | } |
| 3192 | |
| 3193 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
| 3194 | if (UI == nullptr) return false; |
| 3195 | std::ifstream file(UI->FindMacroPath(fileName.c_str()).data()); |
| 3196 | if (file) { |
| 3197 | std::string content((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>())); |
| 3198 | |
| 3199 | auto text = new QTextEdit(); |
| 3200 | text->setAcceptRichText(true); |
| 3201 | text->setContentsMargins(5, 5, 5, 5); |
| 3202 | text->setText(QString("<pre>") + content.c_str() + "</pre>"); |
| 3203 | text->setReadOnly(true); |
| 3204 | fViewerTabWidget->addTab(text, title.c_str()); |
| 3205 | } |
| 3206 | else { |
| 3207 | return false; |
| 3208 | } |
| 3209 | return true; |
| 3210 | } |
| 3211 | |
| 3212 | /** Add a new tab widget. |
| 3213 | Create the tab if it was not done |