Skip to content

Commit

Permalink
Add View → Show Warnings
Browse files Browse the repository at this point in the history
Allow globally disabling all warnings.
  • Loading branch information
vslavik committed Jul 9, 2018
1 parent f2c2d9b commit e1f1495
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,9 @@ Catalog::ValidationResults Catalog::DoValidate(const wxString& po_file)
i->ClearIssue();

res.errors = (int)err.size();
res.warnings = QAChecker::GetFor(*this)->Check(*this);

if (Config::ShowWarnings())
res.warnings = QAChecker::GetFor(*this)->Check(*this);

for ( GettextErrors::const_iterator i = err.begin(); i != err.end(); ++i )
{
Expand Down
3 changes: 3 additions & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class Config
static ::MergeBehavior MergeBehavior();
static void MergeBehavior(::MergeBehavior b);

static bool ShowWarnings() { return Read("/show_warnings", true); }
static void ShowWarnings(bool show) { Write("/show_warnings", show); }

private:
template<typename T>
static T Read(const std::string& key, T defval)
Expand Down
29 changes: 29 additions & 0 deletions src/edframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ BEGIN_EVENT_TABLE(PoeditFrame, wxFrame)
EVT_MENU (XRCID("menu_purge_deleted"), PoeditFrame::OnPurgeDeleted)
EVT_MENU (XRCID("menu_fuzzy"), PoeditFrame::OnFuzzyFlag)
EVT_MENU (XRCID("menu_ids"), PoeditFrame::OnIDsFlag)
EVT_MENU (XRCID("menu_warnings"), PoeditFrame::OnToggleWarnings)
EVT_MENU (XRCID("sort_by_order"), PoeditFrame::OnSortByFileOrder)
EVT_MENU (XRCID("sort_by_source"), PoeditFrame::OnSortBySource)
EVT_MENU (XRCID("sort_by_translation"), PoeditFrame::OnSortByTranslation)
Expand Down Expand Up @@ -514,6 +515,7 @@ PoeditFrame::PoeditFrame() :
m_toolbar = MainToolbar::Create(this);

GetMenuBar()->Check(XRCID("menu_ids"), m_displayIDs);
GetMenuBar()->Check(XRCID("menu_warnings"), Config::ShowWarnings());

if (wxConfigBase::Get()->ReadBool("/statusbar_shown", true))
CreateStatusBar(1, wxST_SIZEGRIP);
Expand Down Expand Up @@ -1950,6 +1952,33 @@ void PoeditFrame::OnIDsFlag(wxCommandEvent&)
m_list->SetDisplayLines(m_displayIDs);
}

void PoeditFrame::OnToggleWarnings(wxCommandEvent& e)
{
bool enable = (bool)e.GetInt();
Config::ShowWarnings(enable);

// refresh display of items in the window:
if (m_catalog)
{
m_catalog->Validate();
if (m_list && m_list->sortOrder().errorsFirst)
m_list->Sort();
}

if (!enable)
{
wxWindowPtr<wxMessageDialog> err(new wxMessageDialog
(
this,
_("Warnings have been disabled."),
"Poedit",
wxOK
));
err->SetExtendedMessage(_("If you disabled the warnings because of excessive false positives, please consider sending a sample file to [email protected] to help improve them."));
err->ShowWindowModalThenDo([err](int){});
}
}

void PoeditFrame::OnCopyFromSingular(wxCommandEvent&)
{
m_editingArea->CopyFromSingular();
Expand Down
1 change: 1 addition & 0 deletions src/edframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class PoeditFrame : public PoeditFrameBase
void OnRightClick(wxCommandEvent& event);
void OnFuzzyFlag(wxCommandEvent& event);
void OnIDsFlag(wxCommandEvent& event);
void OnToggleWarnings(wxCommandEvent& event);
void OnCopyFromSource(wxCommandEvent& event);
void OnCopyFromSingular(wxCommandEvent& event);
void OnClearTranslation(wxCommandEvent& event);
Expand Down
5 changes: 5 additions & 0 deletions src/resources/menus.xrc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
<label platform="unix|mac">Show String _ID</label>
<checkable>1</checkable>
</object>
<object class="wxMenuItem" name="menu_warnings">
<label platform="win">Show warnings</label>
<label platform="unix|mac">Show Warnings</label>
<checkable>1</checkable>
</object>
<object class="separator"/>
<object class="wxMenuItem" name="sort_by_order">
<label platform="win">Sort by _file order</label>
Expand Down

0 comments on commit e1f1495

Please sign in to comment.