feat(modulo): improve troubleshooting UI

This commit is contained in:
Federico Terzi 2021-07-27 22:41:29 +02:00
parent 925a411460
commit c82690ba61
4 changed files with 74 additions and 3 deletions

View File

@ -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; i<troubleshooting_metadata->error_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);
}
}

View File

@ -191,6 +191,64 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>

View File

@ -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 );

View File

@ -15,6 +15,7 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/scrolwin.h>
#include <wx/checkbox.h>
@ -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;