mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-16 00:42:44 +00:00
Troubleshoot Center Dialog (#12416)
* init * update translations * clarify warning for rebuild * auto fill issue field on github with gathered system information * add detection for linux package type * fix build errors * update * update * improve reading windows version * add multi file support for zip and use timestamp on exported zip name * fix errors * fix errorz * fix URL encoding * fix CPU info * use home or desktop as default location * fix distro name on flatpak * improve detecting local build on linux * check package type on all platforms * optimize margins * improve monitor detection * add support for adding text file to zip and add system info on export * exclude user related info from config * improve exporting profile info * fix linux monitor info * update * update detecting monitor info * Update TroubleshootDialog.cpp * Update TroubleshootDialog.cpp * Update TroubleshootDialog.cpp * revert scaling and resolution detection for linux * include project file to zip and notify after saving zip successfully saved * improve monitor info on mac * update * improve packing selection menu * update * Update TroubleshootDialog.cpp * Update TroubleshootDialog.cpp * Update TroubleshootDialog.cpp * Update TroubleshootDialog.cpp * update * update * make hash clickable * fix compatible process counting * export profiles overview instead copying to clipboard * auto restart app after cleaning system folder --------- Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
1
resources/images/OrcaSlicer_horizontal_dark.svg
Normal file
1
resources/images/OrcaSlicer_horizontal_dark.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="214" height="80" viewBox="0 0 214 80"><g id="b"><g id="c"><rect width="80" height="80" rx="9.57" ry="9.57" style="fill:#949494;"/></g></g><g id="d"><path id="e" d="M17.3,62.94c4.46,4.45,10.59,7.21,17.36,7.24,13.7.06,24.93-11.22,24.87-25-.03-6.81-2.77-12.97-7.2-17.45L17.31,62.94h0Z" style="fill:#292826;"/></g><g id="f"><path id="g" d="M52.32,27.73L17.3,62.94s.05.05.08.07c12.27-6.26,29.08-17.26,40.6-26.43-1.24-3.36-3.19-6.38-5.65-8.87" style="fill:#009789;"/></g><g id="h"><path id="i" d="M45.48,9.82c-13.67,0-24.77,11.15-24.77,24.91,0,6.85,2.75,13.05,7.2,17.56L62.94,17.07c-4.48-4.47-10.65-7.24-17.46-7.24" style="fill:#292826;"/></g><g id="j"><path id="k" d="M45.48,9.82c-4.74,0-9.17,1.34-12.93,3.65-2.02-.53-4.52-.95-7.39-.93-5,.03-9.08,1.39-11.85,2.65-.69.32-.58,1.33.16,1.49,1.82.39,4.22,1.19,6.59,2.95,1.5,1.1,2.64,2.33,3.5,3.48-1.82,3.47-2.85,7.42-2.85,11.61,0,2.5.37,4.92,1.05,7.2,1.04-2.32,2.14-3.87,2.5-4.36,2.27-3.13,4.68-4.76,8.23-7.15,2.62-1.77,6.26-3.84,16.7-8.14,0,0,3.27-.92,7.65-3.53,1.75-1.04,3.08-2.02,3.5-3.56.03-.11.06-.22.08-.32-4.15-3.17-9.33-5.04-14.95-5.04" style="fill:#262523;"/></g><g id="l"><path id="m" d="M49.61,18.19c.9,1.61-.91,4.37-4.06,6.17s-6.44,1.96-7.35.36c-.9-1.61.91-4.37,4.06-6.17,3.15-1.8,6.44-1.96,7.35-.36" style="fill:#949494;"/></g><path d="M142.44,48.1c-1.01,0-1.84.82-1.84,1.84v18.4c0,1.01.82,1.84,1.84,1.84s1.84-.82,1.84-1.84v-18.4c0-1.01-.82-1.84-1.84-1.84ZM190.71,48.1h-4.4c-6.09,0-11.04,4.96-11.04,11.04s4.96,11.04,11.04,11.04h4.4c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84h-4.4c-4.06,0-7.36-3.3-7.36-7.36s3.3-7.36,7.36-7.36h4.4c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84v-.02.02ZM190.71,57.31h-5.35c-1.01,0-1.84.82-1.84,1.84s.82,1.84,1.84,1.84h5.35c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84ZM105.69,70.18h-8.91c-1.01,0-1.83-.82-1.83-1.83s.81-1.83,1.83-1.83h8.91c1.53,0,2.78-1.24,2.78-2.78s-1.24-2.77-2.78-2.77h-4.31c-3.55,0-6.43-2.89-6.43-6.43s2.89-6.43,6.43-6.43h7.29c1.01,0,1.83.82,1.83,1.83s-.81,1.83-1.83,1.83h-7.29c-1.53,0-2.78,1.24-2.78,2.78s1.24,2.77,2.78,2.77h4.31c3.55,0,6.43,2.89,6.43,6.43s-2.89,6.43-6.43,6.43h0ZM165.89,65.28c-1.49.98-3.35,1.44-5.32,1.11-2.99-.51-5.4-2.88-5.96-5.85-.86-4.67,2.71-8.76,7.23-8.76,1.49,0,2.88.45,4.04,1.21.73.49,1.71.41,2.32-.22h0c.81-.81.71-2.17-.25-2.81-2.12-1.42-4.76-2.13-7.56-1.77-4.98.64-8.97,4.69-9.52,9.66-.75,6.65,4.46,12.32,10.96,12.32,2.23,0,4.31-.67,6.05-1.81.98-.65,1.15-2.03.32-2.86h0c-.63-.63-1.59-.71-2.32-.23h.01ZM132.24,66.5h-5.31c-2.53,0-4.6-2.07-4.6-4.6v-11.96c0-1.01-.82-1.84-1.84-1.84s-1.84.82-1.84,1.84v11.96c0,4.57,3.71,8.28,8.28,8.28h5.31c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84h0ZM211.96,51.79h-1.84c-4.03,0-7.32,3.27-7.36,7.3v9.27c0,1.01-.82,1.84-1.84,1.84s-1.84-.82-1.84-1.84v-9.27c.04-6.06,4.98-10.97,11.03-10.97h1.84c1.01,0,1.84.82,1.84,1.84s-.82,1.84-1.84,1.84h0Z" style="fill:#949494;"/><path d="M109.73,14.37c5.64,0,10.24,4.59,10.24,10.24s-4.59,10.24-10.24,10.24-10.24-4.59-10.24-10.24,4.59-10.24,10.24-10.24M109.73,9.82c-8.16,0-14.79,6.62-14.79,14.79s6.62,14.79,14.79,14.79,14.79-6.62,14.79-14.79-6.62-14.79-14.79-14.79h0ZM211.52,9.82c-1.26,0-2.27,1.02-2.27,2.27v1.86c-2.66-2.55-6.26-4.13-10.24-4.13-8.16,0-14.79,6.62-14.79,14.79s6.62,14.79,14.79,14.79c3.97,0,7.58-1.58,10.24-4.13v1.86c0,1.26,1.02,2.27,2.27,2.27s2.27-1.02,2.27-2.27V12.1c0-1.26-1.02-2.27-2.27-2.27h0ZM199.01,34.85c-5.64,0-10.24-4.59-10.24-10.24s4.59-10.24,10.24-10.24,10.24,4.59,10.24,10.24-4.59,10.24-10.24,10.24ZM148.11,9.82h-2.27c-8.16,0-14.79,6.62-14.79,14.79v12.51c0,1.26,1.02,2.27,2.27,2.27s2.27-1.02,2.27-2.27v-12.51c0-5.64,4.59-10.24,10.24-10.24h2.27c1.26,0,2.27-1.02,2.27-2.27s-1.02-2.27-2.27-2.27h0ZM175.38,33.05c-1.99,1.36-4.47,2.05-7.12,1.71-4.61-.59-8.31-4.35-8.84-8.97-.7-6.18,4.13-11.43,10.17-11.43,2.14,0,4.11.66,5.75,1.77.92.63,2.15.56,2.95-.24h0c1.02-1.02.83-2.7-.36-3.52-2.75-1.89-6.18-2.86-9.84-2.49-6.85.68-12.42,6.17-13.19,13.01-1,8.93,5.97,16.49,14.7,16.49,3.11,0,5.99-.95,8.36-2.59,1.18-.81,1.34-2.49.33-3.51h0c-.78-.78-2-.88-2.91-.26v.02h0Z" style="fill:#009789;"/></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
1
resources/images/OrcaSlicer_horizontal_light.svg
Normal file
1
resources/images/OrcaSlicer_horizontal_light.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="214" height="80" viewBox="0 0 214 80"><g id="b"><g id="c"><rect width="80" height="80" rx="9.57" ry="9.57" style="fill:#e9e9e9;"/></g></g><g id="d"><path id="e" d="M17.3,62.94c4.46,4.45,10.59,7.21,17.36,7.24,13.7.06,24.93-11.22,24.87-25-.03-6.81-2.77-12.97-7.2-17.45L17.31,62.94h0Z" style="fill:#292826;"/></g><g id="f"><path id="g" d="M52.32,27.73L17.3,62.94s.05.05.08.07c12.27-6.26,29.08-17.26,40.6-26.43-1.24-3.36-3.19-6.38-5.65-8.87" style="fill:#009789;"/></g><g id="h"><path id="i" d="M45.48,9.82c-13.67,0-24.77,11.15-24.77,24.91,0,6.85,2.75,13.05,7.2,17.56L62.94,17.07c-4.48-4.47-10.65-7.24-17.46-7.24" style="fill:#292826;"/></g><g id="j"><path id="k" d="M45.48,9.82c-4.74,0-9.17,1.34-12.93,3.65-2.02-.53-4.52-.95-7.39-.93-5,.03-9.08,1.39-11.85,2.65-.69.32-.58,1.33.16,1.49,1.82.39,4.22,1.19,6.59,2.95,1.5,1.1,2.64,2.33,3.5,3.48-1.82,3.47-2.85,7.42-2.85,11.61,0,2.5.37,4.92,1.05,7.2,1.04-2.32,2.14-3.87,2.5-4.36,2.27-3.13,4.68-4.76,8.23-7.15,2.62-1.77,6.26-3.84,16.7-8.14,0,0,3.27-.92,7.65-3.53,1.75-1.04,3.08-2.02,3.5-3.56.03-.11.06-.22.08-.32-4.15-3.17-9.33-5.04-14.95-5.04" style="fill:#262523;"/></g><g id="l"><path id="m" d="M49.61,18.19c.9,1.61-.91,4.37-4.06,6.17s-6.44,1.96-7.35.36c-.9-1.61.91-4.37,4.06-6.17,3.15-1.8,6.44-1.96,7.35-.36" style="fill:#fff;"/></g><path d="M142.44,48.1c-1.01,0-1.84.82-1.84,1.84v18.4c0,1.01.82,1.84,1.84,1.84s1.84-.82,1.84-1.84v-18.4c0-1.01-.82-1.84-1.84-1.84ZM190.71,48.1h-4.4c-6.09,0-11.04,4.96-11.04,11.04s4.96,11.04,11.04,11.04h4.4c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84h-4.4c-4.06,0-7.36-3.3-7.36-7.36s3.3-7.36,7.36-7.36h4.4c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84v-.02.02ZM190.71,57.31h-5.35c-1.01,0-1.84.82-1.84,1.84s.82,1.84,1.84,1.84h5.35c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84ZM105.69,70.18h-8.91c-1.01,0-1.83-.82-1.83-1.83s.81-1.83,1.83-1.83h8.91c1.53,0,2.78-1.24,2.78-2.78s-1.24-2.77-2.78-2.77h-4.31c-3.55,0-6.43-2.89-6.43-6.43s2.89-6.43,6.43-6.43h7.29c1.01,0,1.83.82,1.83,1.83s-.81,1.83-1.83,1.83h-7.29c-1.53,0-2.78,1.24-2.78,2.78s1.24,2.77,2.78,2.77h4.31c3.55,0,6.43,2.89,6.43,6.43s-2.89,6.43-6.43,6.43h0ZM165.89,65.28c-1.49.98-3.35,1.44-5.32,1.11-2.99-.51-5.4-2.88-5.96-5.85-.86-4.67,2.71-8.76,7.23-8.76,1.49,0,2.88.45,4.04,1.21.73.49,1.71.41,2.32-.22h0c.81-.81.71-2.17-.25-2.81-2.12-1.42-4.76-2.13-7.56-1.77-4.98.64-8.97,4.69-9.52,9.66-.75,6.65,4.46,12.32,10.96,12.32,2.23,0,4.31-.67,6.05-1.81.98-.65,1.15-2.03.32-2.86h0c-.63-.63-1.59-.71-2.32-.23h.01ZM132.24,66.5h-5.31c-2.53,0-4.6-2.07-4.6-4.6v-11.96c0-1.01-.82-1.84-1.84-1.84s-1.84.82-1.84,1.84v11.96c0,4.57,3.71,8.28,8.28,8.28h5.31c1.01,0,1.84-.82,1.84-1.84s-.82-1.84-1.84-1.84h0ZM211.96,51.79h-1.84c-4.03,0-7.32,3.27-7.36,7.3v9.27c0,1.01-.82,1.84-1.84,1.84s-1.84-.82-1.84-1.84v-9.27c.04-6.06,4.98-10.97,11.03-10.97h1.84c1.01,0,1.84.82,1.84,1.84s-.82,1.84-1.84,1.84h0Z" style="fill:#949494;"/><path d="M109.73,14.37c5.64,0,10.24,4.59,10.24,10.24s-4.59,10.24-10.24,10.24-10.24-4.59-10.24-10.24,4.59-10.24,10.24-10.24M109.73,9.82c-8.16,0-14.79,6.62-14.79,14.79s6.62,14.79,14.79,14.79,14.79-6.62,14.79-14.79-6.62-14.79-14.79-14.79h0ZM211.52,9.82c-1.26,0-2.27,1.02-2.27,2.27v1.86c-2.66-2.55-6.26-4.13-10.24-4.13-8.16,0-14.79,6.62-14.79,14.79s6.62,14.79,14.79,14.79c3.97,0,7.58-1.58,10.24-4.13v1.86c0,1.26,1.02,2.27,2.27,2.27s2.27-1.02,2.27-2.27V12.1c0-1.26-1.02-2.27-2.27-2.27h0ZM199.01,34.85c-5.64,0-10.24-4.59-10.24-10.24s4.59-10.24,10.24-10.24,10.24,4.59,10.24,10.24-4.59,10.24-10.24,10.24ZM148.11,9.82h-2.27c-8.16,0-14.79,6.62-14.79,14.79v12.51c0,1.26,1.02,2.27,2.27,2.27s2.27-1.02,2.27-2.27v-12.51c0-5.64,4.59-10.24,10.24-10.24h2.27c1.26,0,2.27-1.02,2.27-2.27s-1.02-2.27-2.27-2.27h0ZM175.38,33.05c-1.99,1.36-4.47,2.05-7.12,1.71-4.61-.59-8.31-4.35-8.84-8.97-.7-6.18,4.13-11.43,10.17-11.43,2.14,0,4.11.66,5.75,1.77.92.63,2.15.56,2.95-.24h0c1.02-1.02.83-2.7-.36-3.52-2.75-1.89-6.18-2.86-9.84-2.49-6.85.68-12.42,6.17-13.19,13.01-1,8.93,5.97,16.49,14.7,16.49,3.11,0,5.99-.95,8.36-2.59,1.18-.81,1.34-2.49.33-3.51h0c-.78-.78-2-.88-2.91-.26v.02h0Z" style="fill:#009789;"/></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -194,6 +194,7 @@ std::string debug_out_path(const char *name, ...);
|
||||
// smaller level means less log. level=5 means saving all logs.
|
||||
void set_log_path_and_level(const std::string& file, unsigned int level);
|
||||
void flush_logs();
|
||||
boost::filesystem::path get_log_file_name();
|
||||
|
||||
// A special type for strings encoded in the local Windows 8-bit code page.
|
||||
// This type is only needed for Perl bindings to relay to Perl that the string is raw, not UTF-8 encoded.
|
||||
|
||||
@@ -392,6 +392,14 @@ void flush_logs()
|
||||
return;
|
||||
}
|
||||
|
||||
// ORCA
|
||||
boost::filesystem::path get_log_file_name()
|
||||
{
|
||||
if (g_log_sink)
|
||||
return g_log_sink->locked_backend()->get_current_file_name();
|
||||
return {};
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// The following helpers are borrowed from the LLVM project https://github.com/llvm
|
||||
namespace WindowsSupport
|
||||
|
||||
@@ -466,6 +466,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
GUI/TextLines.hpp
|
||||
GUI/TickCode.cpp
|
||||
GUI/TickCode.hpp
|
||||
GUI/TroubleshootDialog.cpp
|
||||
GUI/TroubleshootDialog.hpp
|
||||
GUI/UnsavedChangesDialog.cpp
|
||||
GUI/UnsavedChangesDialog.hpp
|
||||
GUI/UpdateDialogs.cpp
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
#include "ParamsDialog.hpp"
|
||||
#include "KBShortcutsDialog.hpp"
|
||||
#include "DownloadProgressDialog.hpp"
|
||||
#include "TroubleshootDialog.hpp"
|
||||
|
||||
#include "BitmapCache.hpp"
|
||||
#include "Notebook.hpp"
|
||||
@@ -4116,6 +4117,12 @@ void GUI_App::keyboard_shortcuts()
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
void GUI_App::troubleshoot()
|
||||
{
|
||||
TroubleshootDialog dlg;
|
||||
if (dlg.ShowModal() == wxID_REMOVE)
|
||||
wxGetApp().mainframe->Close(false);
|
||||
}
|
||||
|
||||
void GUI_App::ShowUserGuide() {
|
||||
// BBS:Show NewUser Guide
|
||||
|
||||
@@ -467,6 +467,7 @@ public:
|
||||
void recreate_GUI(const wxString& message);
|
||||
void system_info();
|
||||
void keyboard_shortcuts();
|
||||
void troubleshoot();
|
||||
void load_project(wxWindow *parent, wxString& input_file) const;
|
||||
void import_model(wxWindow *parent, wxArrayString& input_files) const;
|
||||
void import_zip(wxWindow* parent, wxString& input_file) const;
|
||||
|
||||
@@ -2546,10 +2546,24 @@ static wxMenu* generate_help_menu()
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Setup Wizard"), _L("Setup Wizard"), [](wxCommandEvent &) {wxGetApp().ShowUserGuide();});
|
||||
|
||||
helpMenu->AppendSeparator();
|
||||
|
||||
// Open Config Folder
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Show Configuration Folder"), _L("Show Configuration Folder"),
|
||||
[](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); });
|
||||
|
||||
helpMenu->AppendSeparator();
|
||||
|
||||
// Troubleshoot center
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Troubleshoot Center"), "",
|
||||
[](wxCommandEvent&) { wxGetApp().troubleshoot(); });
|
||||
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Open Network Test"), _L("Open Network Test"), [](wxCommandEvent&) {
|
||||
NetworkTestDialog dlg(wxGetApp().mainframe);
|
||||
dlg.ShowModal();
|
||||
});
|
||||
|
||||
helpMenu->AppendSeparator();
|
||||
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Show Tip of the Day"), _L("Show Tip of the Day"), [](wxCommandEvent&) {
|
||||
wxGetApp().plater()->get_dailytips()->open();
|
||||
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
|
||||
@@ -2568,11 +2582,6 @@ static wxMenu* generate_help_menu()
|
||||
return true;
|
||||
});
|
||||
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Open Network Test"), _L("Open Network Test"), [](wxCommandEvent&) {
|
||||
NetworkTestDialog dlg(wxGetApp().mainframe);
|
||||
dlg.ShowModal();
|
||||
});
|
||||
|
||||
// About
|
||||
#ifndef __APPLE__
|
||||
wxString about_title = wxString::Format(_L("&About %s"), SLIC3R_APP_FULL_NAME);
|
||||
|
||||
1399
src/slic3r/GUI/TroubleshootDialog.cpp
Normal file
1399
src/slic3r/GUI/TroubleshootDialog.cpp
Normal file
File diff suppressed because it is too large
Load Diff
201
src/slic3r/GUI/TroubleshootDialog.hpp
Normal file
201
src/slic3r/GUI/TroubleshootDialog.hpp
Normal file
@@ -0,0 +1,201 @@
|
||||
#ifndef slic3r_GUI_TroublesootDialog_hpp_
|
||||
#define slic3r_GUI_TroublesootDialog_hpp_
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/zipstrm.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/dcbuffer.h>
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class TroubleshootDialog : public DPIDialog
|
||||
{
|
||||
|
||||
#define DESIGN_COMBOBOX_SIZE wxSize(FromDIP(120), -1)
|
||||
|
||||
public:
|
||||
TroubleshootDialog();
|
||||
//~TroubleshootDialog();
|
||||
|
||||
private:
|
||||
ScalableBitmap m_logo;
|
||||
wxStaticBitmap* m_header_logo;
|
||||
Label* m_logs_storage;
|
||||
int m_printers__act;
|
||||
int m_printers__usr;
|
||||
int m_filaments_act;
|
||||
int m_filaments_usr;
|
||||
int m_processes_act;
|
||||
int m_processes_usr;
|
||||
bool m_sys_panel_mode = true;
|
||||
|
||||
protected:
|
||||
wxFlexGridSizer* create_item_loaded_profiles();
|
||||
ComboBox* create_item_log_level_combo();
|
||||
|
||||
wxString GetTimestamp();
|
||||
|
||||
wxString GetSysInfoAll();
|
||||
//wxString GetConfigStr();
|
||||
wxString GetProfilesOverview();
|
||||
wxString GetOStype();
|
||||
wxString GetOSinfo();
|
||||
#ifdef __WINDOWS__
|
||||
wxString GetWinVersion();
|
||||
wxString GetWinDisplayVersion();
|
||||
#elif defined(__LINUX__)
|
||||
wxString GetLinuxDistroName();
|
||||
wxString GetLinuxDisplayServer();
|
||||
#endif
|
||||
wxString GetPackageType();
|
||||
wxString GetCPUinfo();
|
||||
wxString GetGPUinfo();
|
||||
wxString GetRAMinfo();
|
||||
wxString GetMONinfo();
|
||||
|
||||
void PackAll();
|
||||
void RebuildSystemProfiles();
|
||||
bool RestartApplication();
|
||||
void ClearLogs();
|
||||
void UpdateLogsStorage();
|
||||
|
||||
void BrowseFolder(std::string path);
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
static wxString get_cpu_info_from_registry();
|
||||
#else
|
||||
static std::map<std::string, std::string> parse_lscpu_etc(const std::string& name, char delimiter);
|
||||
#endif
|
||||
|
||||
bool ExportAsJson(const wxString& json_data, const wxString& export_name = wxEmptyString);
|
||||
bool ExportAsZip(const std::vector<wxString>& sources, const wxString& export_name);
|
||||
bool AddToZip(wxZipOutputStream& zip, const wxString& fullPathOrTextData, const wxString& rootDir);
|
||||
bool SaveAsZip(const std::vector<wxString>& sourcePaths, const wxString& zipFullPath);
|
||||
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
};
|
||||
|
||||
class CenteredMultiLinePanel : public wxPanel
|
||||
{
|
||||
static constexpr double m_block_gap = 0.55;
|
||||
static constexpr double m_line_height = 1.15;
|
||||
std::vector<wxString> m_lines;
|
||||
|
||||
public:
|
||||
CenteredMultiLinePanel(wxWindow* parent, const std::vector<wxString>& lines = {})
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE)
|
||||
{
|
||||
SetFont(Label::Body_14);
|
||||
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
Bind(wxEVT_PAINT, &CenteredMultiLinePanel::OnPaint, this);
|
||||
Bind(wxEVT_SIZE, &CenteredMultiLinePanel::OnSize, this);
|
||||
|
||||
SetText(lines);
|
||||
}
|
||||
|
||||
void SetText(const std::vector<wxString>& lines)
|
||||
{
|
||||
if(!lines.empty()){
|
||||
m_lines = lines;
|
||||
Refresh();
|
||||
UpdateMinSize();
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::vector<wxString> Wrap(wxDC& dc, const wxString& text, int maxW)
|
||||
{
|
||||
std::vector<wxString> out;
|
||||
wxString cur;
|
||||
for (const auto& word : wxSplit(text, ' ', true)) {
|
||||
wxString trial = cur.empty() ? word : cur + " " + word;
|
||||
wxCoord w, h;
|
||||
dc.GetTextExtent(trial, &w, &h);
|
||||
if (w <= maxW)
|
||||
cur = trial;
|
||||
else if (!cur.empty()){
|
||||
out.push_back(cur);
|
||||
cur = word;
|
||||
}
|
||||
else
|
||||
out.push_back(word);
|
||||
}
|
||||
if (!cur.empty())
|
||||
out.push_back(cur);
|
||||
return out;
|
||||
}
|
||||
|
||||
void OnPaint(wxPaintEvent&)
|
||||
{
|
||||
wxAutoBufferedPaintDC dc(this);
|
||||
dc.Clear();
|
||||
|
||||
int cWidth = GetClientSize().GetWidth();
|
||||
if (m_lines.empty() || cWidth < 50) return;
|
||||
|
||||
dc.SetTextForeground(GetForegroundColour());
|
||||
|
||||
int y = 0;
|
||||
for (size_t i = 0; i < m_lines.size(); ++i) {
|
||||
wxCoord tw, th;
|
||||
for (auto& line : Wrap(dc, m_lines[i], cWidth)) {
|
||||
line.Trim();
|
||||
line.Trim(false);
|
||||
dc.GetTextExtent(line, &tw, &th);
|
||||
dc.DrawText(line, (cWidth - tw) / 2, y);
|
||||
y += static_cast<int>(th * m_line_height);
|
||||
}
|
||||
if (i < m_lines.size() - 1)
|
||||
y += static_cast<int>(th * m_block_gap);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateMinSize()
|
||||
{
|
||||
if (m_lines.empty() || !GetParent()) {
|
||||
SetMinSize(wxDefaultSize);
|
||||
return;
|
||||
}
|
||||
wxClientDC dc(this);
|
||||
int cWidth = GetClientSize().GetWidth();
|
||||
|
||||
int y = 0;
|
||||
for (size_t i = 0; i < m_lines.size(); ++i) {
|
||||
wxCoord th;
|
||||
for (auto& line : Wrap(dc, m_lines[i], cWidth)) {
|
||||
dc.GetTextExtent(line, nullptr, &th);
|
||||
y += static_cast<int>(th * m_line_height);
|
||||
}
|
||||
if (i < m_lines.size() - 1)
|
||||
y += static_cast<int>(th * m_block_gap);
|
||||
}
|
||||
|
||||
if(GetMinSize().GetHeight() != y){
|
||||
SetMinSize(wxSize(-1, y));
|
||||
if(GetParent())
|
||||
GetParent()->Layout();
|
||||
}
|
||||
}
|
||||
|
||||
void OnSize(wxSizeEvent& e)
|
||||
{
|
||||
Refresh();
|
||||
UpdateMinSize();
|
||||
e.Skip();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user