SystemInfo.pm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package Slic3r::GUI::SystemInfo;
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use Wx qw(:font :html :misc :dialog :sizer :systemsettings :frame :id wxTheClipboard);
  6. use Wx::Event qw(EVT_HTML_LINK_CLICKED EVT_LEFT_DOWN EVT_BUTTON);
  7. use Wx::Html;
  8. use base 'Wx::Dialog';
  9. sub new {
  10. my ($class, %params) = @_;
  11. my $self = $class->SUPER::new($params{parent}, -1, 'Slic3r Prusa Edition - System Information', wxDefaultPosition, [600, 340],
  12. wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | wxRESIZE_BORDER);
  13. $self->{text_info} = $params{text_info};
  14. $self->SetBackgroundColour(Wx::wxWHITE);
  15. my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
  16. $self->SetSizer($vsizer);
  17. # text
  18. my $text =
  19. '<html>' .
  20. '<body bgcolor="#ffffff" link="#808080">' .
  21. ($params{slic3r_info} // '') .
  22. ($params{copyright_info} // '') .
  23. ($params{system_info} // '') .
  24. ($params{opengl_info} // '') .
  25. '</body>' .
  26. '</html>';
  27. my $html = $self->{html} = Wx::HtmlWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
  28. my $font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
  29. my $size = &Wx::wxMSW ? 8 : 10;
  30. $html->SetFonts($font->GetFaceName, $font->GetFaceName, [$size * 1.5, $size * 1.4, $size * 1.3, $size, $size, $size, $size]);
  31. $html->SetBorders(10);
  32. $html->SetPage($text);
  33. $vsizer->Add($html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 0);
  34. EVT_HTML_LINK_CLICKED($self, $html, \&link_clicked);
  35. my $buttons = $self->CreateStdDialogButtonSizer(wxOK);
  36. my $btn_copy_to_clipboard = Wx::Button->new($self, -1, "Copy to Clipboard", wxDefaultPosition, wxDefaultSize);
  37. $buttons->Insert(0, $btn_copy_to_clipboard, 0, wxLEFT, 5);
  38. EVT_BUTTON($self, $btn_copy_to_clipboard, \&copy_to_clipboard);
  39. $self->SetEscapeId(wxID_CLOSE);
  40. EVT_BUTTON($self, wxID_CLOSE, sub {
  41. $self->EndModal(wxID_CLOSE);
  42. $self->Close;
  43. });
  44. # $vsizer->Add($buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
  45. $vsizer->Add($buttons, 0, wxEXPAND | wxALL, 5);
  46. return $self;
  47. }
  48. sub link_clicked {
  49. my ($self, $event) = @_;
  50. Wx::LaunchDefaultBrowser($event->GetLinkInfo->GetHref);
  51. $event->Skip(0);
  52. }
  53. sub copy_to_clipboard {
  54. my ($self, $event) = @_;
  55. my $data = $self->{text_info};
  56. wxTheClipboard->Open;
  57. wxTheClipboard->SetData(Wx::TextDataObject->new($data));
  58. wxTheClipboard->Close;
  59. }
  60. 1;