From c82690ba61e072ea75b00bc224055ebe65751e31 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Tue, 27 Jul 2021 22:41:29 +0200 Subject: [PATCH] feat(modulo): improve troubleshooting UI --- .../sys/troubleshooting/troubleshooting.cpp | 14 ++++- .../sys/troubleshooting/troubleshooting.fbp | 58 +++++++++++++++++++ .../troubleshooting/troubleshooting_gui.cpp | 3 + .../sys/troubleshooting/troubleshooting_gui.h | 2 + 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/espanso-modulo/src/sys/troubleshooting/troubleshooting.cpp b/espanso-modulo/src/sys/troubleshooting/troubleshooting.cpp index 802a351..f34bd75 100644 --- a/espanso-modulo/src/sys/troubleshooting/troubleshooting.cpp +++ b/espanso-modulo/src/sys/troubleshooting/troubleshooting.cpp @@ -61,7 +61,7 @@ public: header_sizer = new wxBoxSizer(wxHORIZONTAL); wxString path = wxString::FromUTF8(error_set_metadata->file_path); - wxString filename = wxString::Format(wxT("%s (%i errors)"), path, error_set_metadata->errors_count); + wxString filename = wxString::Format(wxT("\u2022 %s (%i errors)"), path, error_set_metadata->errors_count); filename_label = new wxStaticText(this, wxID_ANY, filename, wxDefaultPosition, wxDefaultSize, 0); filename_label->Wrap(-1); filename_label->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString)); @@ -129,17 +129,25 @@ public: DerivedTroubleshootingFrame::DerivedTroubleshootingFrame(wxWindow *parent) : TroubleshootingFrame(parent) { - if (troubleshooting_metadata->is_fatal_error) { + if (troubleshooting_metadata->error_sets_count == 0) { + dont_show_checkbox->Hide(); + ignore_button->Hide(); + info_label->SetLabel(wxT("Looks like your configuration is correct!")); + title_label->SetLabel(wxT("No errors detected")); + } else if (troubleshooting_metadata->is_fatal_error) { dont_show_checkbox->Hide(); ignore_button->Hide(); info_label->SetLabel(wxT("Espanso couldn't load some files due to configuration errors and won't be able to start until you fix them.")); title_label->SetLabel(wxT("Errors detected, action needed")); } + // If there is just one error, expand the error panel to fit the container + int error_set_proportion = troubleshooting_metadata->error_sets_count == 1 ? 1 : 0; + for (int i = 0; ierror_sets_count; i++) { const ErrorSetMetadata * metadata = &troubleshooting_metadata->error_sets[i]; ErrorSetPanel *panel = new ErrorSetPanel(scrollview, metadata); - this->scrollview_sizer->Add(panel, 0, wxEXPAND | wxALL, 5); + this->scrollview_sizer->Add(panel, error_set_proportion, wxEXPAND | wxALL, 5); } } diff --git a/espanso-modulo/src/sys/troubleshooting/troubleshooting.fbp b/espanso-modulo/src/sys/troubleshooting/troubleshooting.fbp index c54271f..ab412c2 100644 --- a/espanso-modulo/src/sys/troubleshooting/troubleshooting.fbp +++ b/espanso-modulo/src/sys/troubleshooting/troubleshooting.fbp @@ -191,6 +191,64 @@ -1 + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + 5 wxEXPAND | wxALL diff --git a/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.cpp b/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.cpp index fc9f21a..0ce9fc3 100644 --- a/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.cpp +++ b/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.cpp @@ -32,6 +32,9 @@ TroubleshootingFrame::TroubleshootingFrame( wxWindow* parent, wxWindowID id, con info_label->Wrap( -1 ); bSizer1->Add( info_label, 0, wxALL, 10 ); + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer1->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + scrollview = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); scrollview->SetScrollRate( 5, 5 ); scrollview_sizer = new wxBoxSizer( wxVERTICAL ); diff --git a/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.h b/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.h index 2882667..3c63763 100644 --- a/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.h +++ b/espanso-modulo/src/sys/troubleshooting/troubleshooting_gui.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ class TroubleshootingFrame : public wxFrame protected: wxStaticText* title_label; wxStaticText* info_label; + wxStaticLine* m_staticline1; wxScrolledWindow* scrollview; wxBoxSizer* scrollview_sizer; wxCheckBox* dont_show_checkbox;