diff --git a/openscad.pro b/openscad.pro index 50d7aca6..66e4c355 100644 --- a/openscad.pro +++ b/openscad.pro @@ -213,7 +213,8 @@ FORMS += src/MainWindow.ui \ src/OpenCSGWarningDialog.ui \ src/AboutDialog.ui \ src/FontListDialog.ui \ - src/ProgressWidget.ui + src/ProgressWidget.ui \ + src/LibraryInfoDialog.ui HEADERS += src/typedefs.h \ src/version_check.h \ @@ -306,7 +307,8 @@ src/FontCache.h \ src/CsgInfo.h \ \ src/AutoUpdater.h \ - src/legacyeditor.h + src/legacyeditor.h \ + src/LibraryInfoDialog.h SOURCES += src/version_check.cc \ src/ProgressWidget.cc \ @@ -393,7 +395,8 @@ src/FontCache.cc \ src/openscad.cc \ src/mainwin.cc \ src/FontListDialog.cc \ - src/legacyeditor.cc + src/legacyeditor.cc \ + src/LibraryInfoDialog.cc # ClipperLib SOURCES += src/polyclipping/clipper.cpp diff --git a/src/LibraryInfoDialog.cc b/src/LibraryInfoDialog.cc new file mode 100644 index 00000000..15173d69 --- /dev/null +++ b/src/LibraryInfoDialog.cc @@ -0,0 +1,59 @@ + +#include "LibraryInfoDialog.h" + +#include +#include +#include +#include "LibraryInfo.h" + +LibraryInfoDialog::LibraryInfoDialog(const QString& rendererInfo) +{ + setupUi(this); + connect(this->okButton, SIGNAL(clicked()), this, SLOT(accept())); + update_library_info(rendererInfo); +} + +LibraryInfoDialog::~LibraryInfoDialog() +{ + +} + +void LibraryInfoDialog::update_library_info(const QString& rendererInfo) +{ + //Get library infos + QString info(LibraryInfo::info().c_str()); + info += rendererInfo; + + //Parse infos and make it html + info = info.replace("\n", "
"); + + bool end = false; + int startIndex = 0; + while(!end) + { + int endIndex = info.indexOf(":", startIndex); + if(endIndex != -1) + { + //add bold to property name + info = info.insert(startIndex, ""); + endIndex += 3; + info = info.replace(endIndex, 1, ":"); + startIndex = info.indexOf("
", endIndex); + + //handle property with multiple lines + int endInd = info.indexOf(":", startIndex); + if(endInd != -1) + { + QStringRef lines(&info, startIndex, endInd - startIndex); + int lastIndex = lines.lastIndexOf("
"); + startIndex = lastIndex != -1 ? lastIndex+startIndex : startIndex; + } + } + else + { + end = true; + } + } + + this->infoTextBox->setHtml(info); +} diff --git a/src/LibraryInfoDialog.h b/src/LibraryInfoDialog.h new file mode 100644 index 00000000..b0465ca6 --- /dev/null +++ b/src/LibraryInfoDialog.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include +#include "ui_LibraryInfoDialog.h" + +class LibraryInfoDialog : public QDialog, public Ui::LibraryInfoDialog +{ + Q_OBJECT; + +public: + LibraryInfoDialog(const QString& rendererInfo); + virtual ~LibraryInfoDialog(); + + void update_library_info(const QString& rendererInfo); +}; diff --git a/src/LibraryInfoDialog.ui b/src/LibraryInfoDialog.ui new file mode 100644 index 00000000..44a82f98 --- /dev/null +++ b/src/LibraryInfoDialog.ui @@ -0,0 +1,72 @@ + + + LibraryInfoDialog + + + + 0 + 0 + 587 + 466 + + + + Lib & Build Info + + + + QLayout::SetDefaultConstraint + + + 6 + + + + + + 0 + 0 + + + + + 0 + 20 + + + + OpenSCAD Detailed Library and Build Information + + + + + + + + 0 + 0 + + + + true + + + + + + + + 0 + 0 + + + + &OK + + + + + + + + diff --git a/src/MainWindow.h b/src/MainWindow.h index 2843102d..49b11045 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -111,7 +111,7 @@ private: EditorInterface *editor; - class QMessageBox *openglbox; + class LibraryInfoDialog* library_info_dialog; class FontListDialog *font_list_dialog; private slots: diff --git a/src/mainwin.cc b/src/mainwin.cc index 85b5a75a..841d8043 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -45,6 +45,7 @@ #endif #include "AboutDialog.h" #include "FontListDialog.h" +#include "LibraryInfoDialog.h" #ifdef ENABLE_OPENCSG #include "CSGTermEvaluator.h" #include "OpenCSGRenderer.h" @@ -59,7 +60,6 @@ #include "CocoaUtils.h" #endif #include "PlatformUtils.h" -#include "LibraryInfo.h" #include #include @@ -166,7 +166,7 @@ bool MainWindow::mdiMode = false; bool MainWindow::undockMode = false; MainWindow::MainWindow(const QString &filename) - : root_inst("group"), font_list_dialog(NULL), tempFile(NULL), progresswidget(NULL) + : root_inst("group"), library_info_dialog(NULL), font_list_dialog(NULL), tempFile(NULL), progresswidget(NULL) { setupUi(this); @@ -201,7 +201,6 @@ MainWindow::MainWindow(const QString &filename) top_ctx.registerBuiltin(); - this->openglbox = NULL; root_module = NULL; absolute_root_node = NULL; this->root_chain = NULL; @@ -2273,15 +2272,12 @@ MainWindow::helpManual() void MainWindow::helpLibrary() { - QString info(LibraryInfo::info().c_str()); - info += QString(qglview->getRendererInfo().c_str()); - if (!this->openglbox) { - this->openglbox = new QMessageBox(QMessageBox::Information, - "OpenGL Info", "OpenSCAD Detailed Library and Build Information", - QMessageBox::Ok, this); - } - this->openglbox->setDetailedText(info); - this->openglbox->show(); + if (!this->library_info_dialog) { + QString rendererInfo(qglview->getRendererInfo().c_str()); + LibraryInfoDialog *dialog = new LibraryInfoDialog(rendererInfo); + this->library_info_dialog = dialog; + } + this->library_info_dialog->show(); } void MainWindow::helpFontInfo()