2018-10-25 10:48:19 +00:00
|
|
|
#include "SysInfoDialog.hpp"
|
2018-11-26 13:41:58 +00:00
|
|
|
#include "I18N.hpp"
|
|
|
|
#include "3DScene.hpp"
|
|
|
|
#include "GUI.hpp"
|
2018-10-25 10:48:19 +00:00
|
|
|
|
2019-02-19 09:09:41 +00:00
|
|
|
#include <string>
|
|
|
|
|
2018-10-25 10:48:19 +00:00
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/platinfo.h>
|
2019-02-04 09:35:16 +00:00
|
|
|
#include "GUI_App.hpp"
|
2019-02-11 13:14:35 +00:00
|
|
|
#include "wxExtensions.hpp"
|
2018-10-25 10:48:19 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
std::string get_main_info(bool format_as_html)
|
|
|
|
{
|
|
|
|
std::stringstream out;
|
|
|
|
|
|
|
|
std::string b_start = format_as_html ? "<b>" : "";
|
|
|
|
std::string b_end = format_as_html ? "</b>" : "";
|
|
|
|
std::string line_end = format_as_html ? "<br>" : "\n";
|
|
|
|
|
|
|
|
if (!format_as_html)
|
2019-04-15 14:14:19 +00:00
|
|
|
out << b_start << SLIC3R_APP_NAME << b_end << line_end;
|
2018-10-25 10:48:19 +00:00
|
|
|
out << b_start << "Version: " << b_end << SLIC3R_VERSION << line_end;
|
2019-05-13 16:01:00 +00:00
|
|
|
out << b_start << "Build: " << b_end << SLIC3R_BUILD_ID << line_end;
|
2018-10-25 10:48:19 +00:00
|
|
|
out << line_end;
|
|
|
|
out << b_start << "Operating System: " << b_end << wxPlatformInfo::Get().GetOperatingSystemFamilyName() << line_end;
|
|
|
|
out << b_start << "System Architecture: " << b_end << wxPlatformInfo::Get().GetArchName() << line_end;
|
|
|
|
out << b_start <<
|
|
|
|
#if defined _WIN32
|
|
|
|
"Windows Version: "
|
|
|
|
#else
|
|
|
|
// Hopefully some kind of unix / linux.
|
|
|
|
"System Version: "
|
|
|
|
#endif
|
|
|
|
<< b_end << wxPlatformInfo::Get().GetOperatingSystemDescription() << line_end;
|
|
|
|
|
|
|
|
return out.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
SysInfoDialog::SysInfoDialog()
|
2019-04-18 13:22:10 +00:00
|
|
|
: DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L("System Information")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
|
2018-10-25 10:48:19 +00:00
|
|
|
{
|
|
|
|
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
|
|
|
SetBackgroundColour(bgr_clr);
|
2019-04-18 13:05:17 +00:00
|
|
|
SetFont(wxGetApp().normal_font());
|
|
|
|
|
2018-10-25 10:48:19 +00:00
|
|
|
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
|
2019-02-06 08:49:32 +00:00
|
|
|
hsizer->SetMinSize(wxSize(50 * wxGetApp().em_unit(), -1));
|
2018-10-25 10:48:19 +00:00
|
|
|
|
|
|
|
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
2019-02-06 11:04:17 +00:00
|
|
|
main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10);
|
2018-10-25 10:48:19 +00:00
|
|
|
|
|
|
|
// logo
|
2019-05-13 10:13:28 +00:00
|
|
|
m_logo_bmp = ScalableBitmap(this, "PrusaSlicer_192px.png", 192);
|
2019-04-18 13:05:17 +00:00
|
|
|
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
|
|
|
|
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
|
2018-10-25 10:48:19 +00:00
|
|
|
|
|
|
|
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
hsizer->Add(vsizer, 1, wxEXPAND|wxLEFT, 20);
|
|
|
|
|
|
|
|
// title
|
|
|
|
{
|
2019-04-15 14:14:19 +00:00
|
|
|
wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_APP_NAME, wxDefaultPosition, wxDefaultSize);
|
2019-04-24 23:45:00 +00:00
|
|
|
wxFont title_font = wxGetApp().bold_font();
|
2018-10-25 10:48:19 +00:00
|
|
|
title_font.SetFamily(wxFONTFAMILY_ROMAN);
|
2018-12-05 15:24:43 +00:00
|
|
|
title_font.SetPointSize(22);
|
2018-10-25 10:48:19 +00:00
|
|
|
title->SetFont(title_font);
|
2019-02-06 08:49:32 +00:00
|
|
|
vsizer->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxTOP, wxGetApp().em_unit()/*50*/);
|
2018-10-25 10:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// main_info_text
|
2019-04-24 23:45:00 +00:00
|
|
|
wxFont font = wxGetApp().normal_font();
|
2018-10-25 10:48:19 +00:00
|
|
|
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
|
|
|
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
|
|
|
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
|
|
|
|
|
|
|
const int fs = font.GetPointSize() - 1;
|
2018-10-25 13:59:27 +00:00
|
|
|
int size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };
|
2018-10-25 10:48:19 +00:00
|
|
|
|
2019-04-18 13:05:17 +00:00
|
|
|
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER);
|
2018-10-25 10:48:19 +00:00
|
|
|
{
|
2019-04-18 13:05:17 +00:00
|
|
|
m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
|
|
|
|
m_html->SetBorders(2);
|
2018-10-25 10:48:19 +00:00
|
|
|
const auto text = wxString::Format(
|
|
|
|
"<html>"
|
|
|
|
"<body bgcolor= %s link= %s>"
|
|
|
|
"<font color=%s>"
|
|
|
|
"%s"
|
|
|
|
"</font>"
|
|
|
|
"</body>"
|
|
|
|
"</html>", bgr_clr_str, text_clr_str, text_clr_str,
|
|
|
|
get_main_info(true));
|
2019-04-18 13:05:17 +00:00
|
|
|
m_html->SetPage(text);
|
|
|
|
vsizer->Add(m_html, 1, wxEXPAND | wxBOTTOM, wxGetApp().em_unit());
|
2018-10-25 10:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// opengl_info
|
2019-04-18 13:05:17 +00:00
|
|
|
m_opengl_info_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
|
2018-10-25 10:48:19 +00:00
|
|
|
{
|
2019-04-18 13:05:17 +00:00
|
|
|
m_opengl_info_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
|
|
|
|
m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
|
|
|
|
m_opengl_info_html->SetBorders(10);
|
2018-10-25 10:48:19 +00:00
|
|
|
const auto text = wxString::Format(
|
|
|
|
"<html>"
|
|
|
|
"<body bgcolor= %s link= %s>"
|
|
|
|
"<font color=%s>"
|
|
|
|
"%s"
|
|
|
|
"</font>"
|
|
|
|
"</body>"
|
|
|
|
"</html>", bgr_clr_str, text_clr_str, text_clr_str,
|
|
|
|
_3DScene::get_gl_info(true, true));
|
2019-04-18 13:05:17 +00:00
|
|
|
m_opengl_info_html->SetPage(text);
|
|
|
|
main_sizer->Add(m_opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15);
|
2018-10-25 10:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK);
|
2019-05-16 14:06:57 +00:00
|
|
|
m_btn_copy_to_clipboard = new wxButton(this, wxID_ANY, _(L("Copy to Clipboard")), wxDefaultPosition, wxDefaultSize);
|
2019-04-25 13:06:44 +00:00
|
|
|
|
|
|
|
buttons->Insert(0, m_btn_copy_to_clipboard, 0, wxLEFT, 5);
|
|
|
|
m_btn_copy_to_clipboard->Bind(wxEVT_BUTTON, &SysInfoDialog::onCopyToClipboard, this);
|
2018-10-25 10:48:19 +00:00
|
|
|
|
2018-12-20 11:52:16 +00:00
|
|
|
this->SetEscapeId(wxID_OK);
|
2018-10-25 10:48:19 +00:00
|
|
|
this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK);
|
|
|
|
main_sizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
|
|
|
|
|
2019-01-15 09:24:58 +00:00
|
|
|
// this->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);
|
2019-01-21 14:40:41 +00:00
|
|
|
// logo->Bind(wxEVT_LEFT_DOWN, &SysInfoDialog::onCloseDialog, this);
|
2018-10-25 10:48:19 +00:00
|
|
|
|
|
|
|
SetSizer(main_sizer);
|
|
|
|
main_sizer->SetSizeHints(this);
|
|
|
|
}
|
|
|
|
|
2019-04-18 13:05:17 +00:00
|
|
|
void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|
|
|
{
|
2019-04-24 23:45:00 +00:00
|
|
|
m_logo_bmp.msw_rescale();
|
2019-04-18 13:05:17 +00:00
|
|
|
m_logo->SetBitmap(m_logo_bmp.bmp());
|
|
|
|
|
|
|
|
wxFont font = GetFont();
|
|
|
|
const int fs = font.GetPointSize() - 1;
|
|
|
|
int font_size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };
|
|
|
|
|
|
|
|
m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
|
|
|
|
m_html->Refresh();
|
|
|
|
|
|
|
|
const int& em = em_unit();
|
|
|
|
|
2019-04-25 13:06:44 +00:00
|
|
|
msw_buttons_rescale(this, em, { wxID_OK, m_btn_copy_to_clipboard->GetId() });
|
|
|
|
|
2019-04-18 13:05:17 +00:00
|
|
|
m_opengl_info_html->SetMinSize(wxSize(-1, 16 * em));
|
|
|
|
m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
|
|
|
|
m_opengl_info_html->Refresh();
|
|
|
|
|
|
|
|
const wxSize& size = wxSize(65 * em, 55 * em);
|
|
|
|
|
|
|
|
SetMinSize(size);
|
2019-04-25 13:06:44 +00:00
|
|
|
Fit();
|
2019-04-18 13:05:17 +00:00
|
|
|
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
2018-10-25 10:48:19 +00:00
|
|
|
void SysInfoDialog::onCopyToClipboard(wxEvent &)
|
|
|
|
{
|
|
|
|
wxTheClipboard->Open();
|
|
|
|
const auto text = get_main_info(false)+"\n"+_3DScene::get_gl_info(false, true);
|
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(text));
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SysInfoDialog::onCloseDialog(wxEvent &)
|
|
|
|
{
|
|
|
|
this->EndModal(wxID_CLOSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|