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
5156namespace
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.
5783class 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
6897MergeSummaryDialog::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
83154void 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
0 commit comments