From ae628012507aa382f1329f60a898aaa9ba46c21b Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Sat, 23 Oct 2021 20:13:25 +0200 Subject: [PATCH] Implemented "Details" section enclosing OpenGL extensions when copying sysinfo to clipboard for inserting into github issue. Fix of [Feature Request] Help => System Info => Copy to Clipboard: wrap list of extensions with
tag #6830 --- src/slic3r/GUI/GUI_App.cpp | 6 ++++-- src/slic3r/GUI/GUI_App.hpp | 4 +++- src/slic3r/GUI/OpenGLManager.cpp | 23 ++++++++++++++++------- src/slic3r/GUI/OpenGLManager.hpp | 4 +++- src/slic3r/GUI/SysInfoDialog.cpp | 4 ++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index b6b3ca91b6..787382c239 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -721,9 +721,11 @@ GUI_App::~GUI_App() delete preset_updater; } -std::string GUI_App::get_gl_info(bool format_as_html, bool extensions) +// If formatted for github, plaintext with OpenGL extensions enclosed into
. +// Otherwise HTML formatted for the system info dialog. +std::string GUI_App::get_gl_info(bool for_github) { - return OpenGLManager::get_gl_info().to_string(format_as_html, extensions); + return OpenGLManager::get_gl_info().to_string(for_github); } wxGLContext* GUI_App::init_glcontext(wxGLCanvas& canvas) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index d350da9693..ad42803f6b 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -172,7 +172,9 @@ public: // Process command line parameters cached in this->init_params, // load configs, STLs etc. void post_init(); - static std::string get_gl_info(bool format_as_html, bool extensions); + // If formatted for github, plaintext with OpenGL extensions enclosed into
. + // Otherwise HTML formatted for the system info dialog. + static std::string get_gl_info(bool for_github); wxGLContext* init_glcontext(wxGLCanvas& canvas); bool init_opengl(); diff --git a/src/slic3r/GUI/OpenGLManager.cpp b/src/slic3r/GUI/OpenGLManager.cpp index 3baa8a4dab..6616cc20d7 100644 --- a/src/slic3r/GUI/OpenGLManager.cpp +++ b/src/slic3r/GUI/OpenGLManager.cpp @@ -157,13 +157,16 @@ bool OpenGLManager::GLInfo::is_glsl_version_greater_or_equal_to(unsigned int maj return version_greater_or_equal_to(m_glsl_version, major, minor); } -std::string OpenGLManager::GLInfo::to_string(bool format_as_html, bool extensions) const +// If formatted for github, plaintext with OpenGL extensions enclosed into
. +// Otherwise HTML formatted for the system info dialog. +std::string OpenGLManager::GLInfo::to_string(bool for_github) const { if (!m_detected) detect(); std::stringstream out; + const bool format_as_html = ! for_github; std::string h2_start = format_as_html ? "" : ""; std::string h2_end = format_as_html ? "" : ""; std::string b_start = format_as_html ? "" : ""; @@ -176,18 +179,24 @@ std::string OpenGLManager::GLInfo::to_string(bool format_as_html, bool extension out << b_start << "Renderer: " << b_end << m_renderer << line_end; out << b_start << "GLSL version: " << b_end << m_glsl_version << line_end; - if (extensions) { + { std::vector extensions_list; std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, ""); - boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_off); + boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on); if (!extensions_list.empty()) { - out << h2_start << "Installed extensions:" << h2_end << line_end; + if (for_github) + out << "
\nInstalled extensions:\n"; + else + out << h2_start << "Installed extensions:" << h2_end << line_end; std::sort(extensions_list.begin(), extensions_list.end()); - for (const std::string& ext : extensions_list) { - out << ext << line_end; - } + for (const std::string& ext : extensions_list) + if (! ext.empty()) + out << ext << line_end; + + if (for_github) + out << "
\n"; } } diff --git a/src/slic3r/GUI/OpenGLManager.hpp b/src/slic3r/GUI/OpenGLManager.hpp index 716256e406..72a4e6bc07 100644 --- a/src/slic3r/GUI/OpenGLManager.hpp +++ b/src/slic3r/GUI/OpenGLManager.hpp @@ -46,7 +46,9 @@ public: bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const; bool is_glsl_version_greater_or_equal_to(unsigned int major, unsigned int minor) const; - std::string to_string(bool format_as_html, bool extensions) const; + // If formatted for github, plaintext with OpenGL extensions enclosed into
. + // Otherwise HTML formatted for the system info dialog. + std::string to_string(bool for_github) const; private: void detect() const; diff --git a/src/slic3r/GUI/SysInfoDialog.cpp b/src/slic3r/GUI/SysInfoDialog.cpp index 5475a36eaa..1a8542438c 100644 --- a/src/slic3r/GUI/SysInfoDialog.cpp +++ b/src/slic3r/GUI/SysInfoDialog.cpp @@ -158,7 +158,7 @@ SysInfoDialog::SysInfoDialog() "" "", bgr_clr_str, text_clr_str, text_clr_str, blacklisted_libraries_message, - get_mem_info(true), wxGetApp().get_gl_info(true, true), + get_mem_info(true), wxGetApp().get_gl_info(false), "" + _L("Eigen vectorization supported:") + " " + Eigen::SimdInstructionSetsInUse()); m_opengl_info_html->SetPage(text); @@ -215,7 +215,7 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect) void SysInfoDialog::onCopyToClipboard(wxEvent &) { wxTheClipboard->Open(); - const auto text = get_main_info(false) + "\n" + wxGetApp().get_gl_info(false, true); + const auto text = get_main_info(false) + "\n" + wxGetApp().get_gl_info(true); wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); }