Skip to content

Commit f83a84a

Browse files
committed
Better merge summary window UI
Show structured errors. Tweak the UI to look decent.
1 parent 5a35b75 commit f83a84a

File tree

6 files changed

+111
-158
lines changed

6 files changed

+111
-158
lines changed

Poedit.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@
329329
<None Include="src\resources\menus.xrc" />
330330
<None Include="src\resources\prefs.xrc" />
331331
<None Include="src\resources\properties.xrc" />
332-
<None Include="src\resources\summary.xrc" />
333332
<None Include="src\resources\toolbar.xrc" />
334333
</ItemGroup>
335334
<ItemGroup>

Poedit.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,6 @@
481481
<None Include="src\resources\toolbar.xrc">
482482
<Filter>Data Files</Filter>
483483
</None>
484-
<None Include="src\resources\summary.xrc">
485-
<Filter>Data Files</Filter>
486-
</None>
487484
<None Include="packages.config" />
488485
</ItemGroup>
489486
<ItemGroup>

Poedit.xcodeproj/project.pbxproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
B29AE89317103992008D1F8A /* menus.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0601709DA4A009C1328 /* menus.xrc */; };
158158
B29AE89417103992008D1F8A /* prefs.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0611709DA4A009C1328 /* prefs.xrc */; };
159159
B29AE89617103992008D1F8A /* properties.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0631709DA4A009C1328 /* properties.xrc */; };
160-
B29AE89717103992008D1F8A /* summary.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0641709DA4A009C1328 /* summary.xrc */; };
161160
B29AE89A17103992008D1F8A /* toolbar.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0671709DA4A009C1328 /* toolbar.xrc */; };
162161
B29B282019D2E87600D27DC8 /* sidebar.png in Resources */ = {isa = PBXBuildFile; fileRef = B29B281E19D2E87600D27DC8 /* sidebar.png */; };
163162
B29B282119D2E87600D27DC8 /* sidebar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B29B281F19D2E87600D27DC8 /* sidebar@2x.png */; };
@@ -492,7 +491,6 @@
492491
B27EB0601709DA4A009C1328 /* menus.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = menus.xrc; sourceTree = "<group>"; };
493492
B27EB0611709DA4A009C1328 /* prefs.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = prefs.xrc; sourceTree = "<group>"; };
494493
B27EB0631709DA4A009C1328 /* properties.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = properties.xrc; sourceTree = "<group>"; };
495-
B27EB0641709DA4A009C1328 /* summary.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = summary.xrc; sourceTree = "<group>"; };
496494
B27EB0671709DA4A009C1328 /* toolbar.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = toolbar.xrc; sourceTree = "<group>"; };
497495
B27EF64E1986D0DB00C502D2 /* bs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = bs; path = bs.lproj/MoveApplication.strings; sourceTree = "<group>"; };
498496
B27EF6521986D15400C502D2 /* pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/MoveApplication.strings; sourceTree = "<group>"; };
@@ -1099,7 +1097,6 @@
10991097
B27EB0601709DA4A009C1328 /* menus.xrc */,
11001098
B27EB0611709DA4A009C1328 /* prefs.xrc */,
11011099
B27EB0631709DA4A009C1328 /* properties.xrc */,
1102-
B27EB0641709DA4A009C1328 /* summary.xrc */,
11031100
B27EB0671709DA4A009C1328 /* toolbar.xrc */,
11041101
);
11051102
name = "XRC Resources";
@@ -1455,7 +1452,6 @@
14551452
B20F31D1216654DA005B7037 /* StatusWarningBlack@2x.png in Resources */,
14561453
B29AE89417103992008D1F8A /* prefs.xrc in Resources */,
14571454
B29AE89617103992008D1F8A /* properties.xrc in Resources */,
1458-
B29AE89717103992008D1F8A /* summary.xrc in Resources */,
14591455
B29AE89A17103992008D1F8A /* toolbar.xrc in Resources */,
14601456
B26E2C9125A245BD008D6DF1 /* CloseButtonHoverTemplate.png in Resources */,
14611457
B25DB35E1E3E5102006D7228 /* ExtractorsGNUgettext@2x.png in Resources */,
@@ -2583,6 +2579,7 @@
25832579
repositoryURL = "https://github.com/sparkle-project/Sparkle";
25842580
requirement = {
25852581
kind = upToNextMajorVersion;
2582+
maximumVersion = "";
25862583
minimumVersion = 2.7.0;
25872584
};
25882585
};

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ XRC_RESOURCES = \
9494
$(srcdir)/resources/menus.xrc \
9595
$(srcdir)/resources/prefs.xrc \
9696
$(srcdir)/resources/properties.xrc \
97-
$(srcdir)/resources/summary.xrc \
9897
$(srcdir)/resources/toolbar.xrc
9998

10099
compiled_xrc.cpp: $(XRC_RESOURCES)

src/cat_update.cpp

Lines changed: 110 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,120 @@
2727

2828
#include "catalog_po.h"
2929
#include "colorscheme.h"
30+
#include "custom_notebook.h"
3031
#include "errors.h"
3132
#include "extractors/extractor.h"
3233
#include "hidpi.h"
3334
#include "progress_ui.h"
3435
#include "utility.h"
3536

37+
#include <wx/artprov.h>
3638
#include <wx/button.h>
3739
#include <wx/config.h>
40+
#include <wx/dataview.h>
3841
#include <wx/dialog.h>
3942
#include <wx/intl.h>
4043
#include <wx/listbox.h>
4144
#include <wx/log.h>
4245
#include <wx/msgdlg.h>
4346
#include <wx/notebook.h>
4447
#include <wx/numformatter.h>
48+
#include <wx/panel.h>
4549
#include <wx/sizer.h>
4650
#include <wx/statbmp.h>
4751
#include <wx/stattext.h>
48-
#include <wx/xrc/xmlres.h>
52+
#include <wx/stdpaths.h>
53+
#include <wx/wupdlock.h>
4954

5055

5156
namespace
5257
{
5358

54-
/** This class provides simple dialog that displays list
55-
* of changes made in the catalog.
56-
*/
59+
inline auto variant_vector(std::initializer_list<wxVariant>&& init)
60+
{
61+
return wxVector<wxVariant>(init.begin(), init.end());
62+
}
63+
64+
65+
66+
class SummaryList : public wxDataViewListCtrl
67+
{
68+
public:
69+
SummaryList(wxWindow *parent, int flags = 0)
70+
: wxDataViewListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
71+
flags | wxDV_ROW_LINES | wxDV_VARIABLE_LINE_HEIGHT | wxBORDER_NONE)
72+
{
73+
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
74+
#ifdef __WXOSX__
75+
if (@available(macOS 11.0, *))
76+
((NSTableView*)[((NSScrollView*)GetHandle()) documentView]).style = NSTableViewStyleFullWidth;
77+
#endif
78+
}
79+
};
80+
81+
82+
/// This class provides simple dialog that displays list of changes made in the catalog.
5783
class MergeSummaryDialog : public wxDialog
5884
{
59-
public:
60-
MergeSummaryDialog(wxWindow *parent);
61-
~MergeSummaryDialog();
85+
public:
86+
MergeSummaryDialog(wxWindow *parent);
87+
~MergeSummaryDialog();
88+
89+
/// Reads data from catalog and fill dialog's controls.
90+
void TransferTo(const MergeStats& r);
6291

63-
/// Reads data from catalog and fill dialog's controls.
64-
void TransferTo(const MergeStats& r);
92+
private:
93+
SegmentedNotebookBase *m_notebook;
6594
};
6695

6796

6897
MergeSummaryDialog::MergeSummaryDialog(wxWindow *parent)
98+
// TRANSLATORS: Title of window showing summary (added/removed strings, issues) of updating translations from sources or POT file
99+
: wxDialog(parent, wxID_ANY, MSW_OR_OTHER(_("Update summary"), _("Update Summary")),
100+
wxDefaultPosition, wxDefaultSize,
101+
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
69102
{
70-
wxXmlResource::Get()->LoadDialog(this, parent, "summary");
103+
SetName("summary");
104+
105+
#ifdef __WXMSW__
106+
SetIcons(wxIconBundle(wxStandardPaths::Get().GetResourcesDir() + "\\Resources\\Poedit.ico"));
107+
#endif
108+
109+
auto topsizer = new wxBoxSizer(wxVERTICAL);
110+
SetSizer(topsizer);
111+
112+
auto panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | MSW_OR_OTHER(wxBORDER_SIMPLE, wxBORDER_SUNKEN));
113+
114+
ColorScheme::SetupWindowColors(panel, [=]
115+
{
116+
if (ColorScheme::GetWindowMode(panel) == ColorScheme::Light)
117+
panel->SetBackgroundColour(*wxWHITE);
118+
else
119+
panel->SetBackgroundColour(GetDefaultAttributes().colBg);
120+
});
121+
topsizer->Add(panel, wxSizerFlags(1).Expand().Border(wxLEFT|wxRIGHT|wxTOP, PX(20)));
122+
123+
auto sizer = new wxBoxSizer(wxVERTICAL);
124+
panel->SetSizer(sizer);
125+
126+
m_notebook = SegmentedNotebook::Create(panel, SegmentStyle::SidebarPanels);
127+
sizer->Add(m_notebook, wxSizerFlags(1).Expand().Border(wxTOP, PX(1)));
128+
129+
auto buttons = CreateButtonSizer(wxOK);
130+
auto ok = static_cast<wxButton*>(FindWindow(wxID_OK));
131+
ok->SetLabel(_("Close"));
132+
ok->SetDefault();
133+
134+
#ifdef __WXOSX__
135+
topsizer->AddSpacer(PX(5));
136+
topsizer->Add(buttons, wxSizerFlags().Expand().Border(wxLEFT|wxRIGHT|wxBOTTOM, PX(10)));
137+
#else
138+
topsizer->AddSpacer(PX(10));
139+
topsizer->Add(buttons, wxSizerFlags().Expand().Border(wxRIGHT, PX(15)));
140+
topsizer->AddSpacer(PX(15));
141+
#endif
71142

72-
RestoreWindowState(this, wxDefaultSize, WinState_Size);
143+
RestoreWindowState(this, wxSize(PX(700), PX(500)), WinState_Size);
73144
CentreOnParent();
74145
}
75146

@@ -82,66 +153,54 @@ MergeSummaryDialog::~MergeSummaryDialog()
82153

83154
void MergeSummaryDialog::TransferTo(const MergeStats& r)
84155
{
85-
wxString sum;
86-
sum.Printf(_("(New: %i, obsolete: %i)"),
87-
(int)r.added.size(), (int)r.removed.size());
88-
XRCCTRL(*this, "items_count", wxStaticText)->SetLabel(sum);
156+
wxWindowUpdateLocker lock(this);
89157

90-
wxNotebook *notebook = XRCCTRL(*this, "notebook", wxNotebook);
91-
92-
if (!r.removed.empty())
158+
if (r.errors)
93159
{
94-
wxListBox *listbox = XRCCTRL(*this, "obsolete_strings", wxListBox);
95-
#ifdef __WXOSX__
96-
if (@available(macOS 11.0, *))
97-
((NSTableView*)[((NSScrollView*)listbox->GetHandle()) documentView]).style = NSTableViewStyleFullWidth;
98-
#endif
160+
auto list = new SummaryList(m_notebook);
161+
m_notebook->AddPage(list, _("Issues"));
99162

100-
for (auto& s: r.removed)
163+
// TRANSLATORS: Column header in the list of issues where rows are filename:line:text of issue
164+
list->AppendTextColumn(_("File"), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE);
165+
// TRANSLATORS: Column header in the list of issues where rows are filename:line:text of issue
166+
list->AppendTextColumn(_("Line"), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE, wxALIGN_RIGHT);
167+
// TRANSLATORS: Column header in the list of issues where rows are filename:line:text of issue
168+
list->AppendTextColumn(_("Issue"), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE);
169+
170+
for (auto& i: r.errors.items)
101171
{
102-
listbox->Append(s.to_string());
172+
if (i.has_location())
173+
list->AppendItem(variant_vector({i.file, wxString::Format("%d", i.line), i.text}));
174+
else
175+
list->AppendItem(variant_vector({"", "", i.text}));
103176
}
104177
}
105-
else
106-
{
107-
notebook->DeletePage(2);
108-
}
109178

110179
if (!r.added.empty())
111180
{
112-
wxListBox *listbox = XRCCTRL(*this, "new_strings", wxListBox);
113-
#ifdef __WXOSX__
114-
if (@available(macOS 11.0, *))
115-
((NSTableView*)[((NSScrollView*)listbox->GetHandle()) documentView]).style = NSTableViewStyleFullWidth;
116-
#endif
181+
auto list = new SummaryList(m_notebook, wxDV_NO_HEADER);
182+
m_notebook->AddPage(list, MSW_OR_OTHER(_("New strings"), _("New Strings")));
183+
184+
list->AppendTextColumn(MSW_OR_OTHER(_("New strings"), _("New Strings")), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE);
117185

118186
for (auto& s: r.added)
119187
{
120-
listbox->Append(s.to_string());
188+
list->AppendItem(variant_vector({s.to_string()}));
121189
}
122190
}
123-
else
124-
{
125-
notebook->DeletePage(1);
126-
}
127191

128-
if (r.errors)
192+
if (!r.removed.empty())
129193
{
130-
wxListBox *listbox = XRCCTRL(*this, "issues", wxListBox);
131-
#ifdef __WXOSX__
132-
if (@available(macOS 11.0, *))
133-
((NSTableView*)[((NSScrollView*)listbox->GetHandle()) documentView]).style = NSTableViewStyleFullWidth;
134-
#endif
194+
auto list = new SummaryList(m_notebook, wxDV_NO_HEADER);
195+
m_notebook->AddPage(list, MSW_OR_OTHER(_("Removed strings"), _("Removed Strings")));
135196

136-
for (auto& i: r.errors.items)
197+
list->AppendTextColumn(MSW_OR_OTHER(_("Removed strings"), _("Removed Strings")), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE);
198+
199+
for (auto& s: r.removed)
137200
{
138-
listbox->Append(i.pretty_print());
201+
list->AppendItem(variant_vector({s.to_string()}));
139202
}
140203
}
141-
else
142-
{
143-
notebook->DeletePage(0);
144-
}
145204
}
146205

147206

src/resources/summary.xrc

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)