Audacity 3.2.0
UpdatePopupDialog.cpp
Go to the documentation of this file.
1/*!********************************************************************
2 Audacity: A Digital Audio Editor
3
4 @file UpdatePopupDialog.cpp
5 @brief Define a dialog for notifying users about new version available.
6
7 Anton Gerasimov
8 **********************************************************************/
9
10#include "UpdatePopupDialog.h"
11#include "UpdateManager.h"
12
13#include "ShuttleGui.h"
14#include "HelpSystem.h"
15
16#include <wx/debug.h>
17#include <wx/sstream.h>
18#include <wx/txtstrm.h>
19
20enum { DontShowID = wxID_HIGHEST + 1 };
21
22BEGIN_EVENT_TABLE (UpdatePopupDialog, wxDialogWrapper)
27
29
30UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, const VersionPatch& versionPatch, bool configurableNotification)
31 : wxDialogWrapper (parent, -1, XC("Update Audacity", "update dialog"),
32 wxDefaultPosition, wxDefaultSize,
33 wxCAPTION),
34 mVersionPatch(versionPatch)
35{
36 ShuttleGui S (this, eIsCreating);
37 S.SetBorder (5);
38 S.StartVerticalLay (wxEXPAND, 1);
39 {
40 S.AddWindow (AddHtmlContent (S.GetParent()));
41
42 S.StartHorizontalLay (wxEXPAND, 0);
43 {
44 S.SetBorder (5);
45
46 if (configurableNotification)
47 {
48 S.Id(DontShowID).AddCheckBox(
49 XO("Don't show this again at start up"),
51 }
52
53 S.Prop(1).AddSpace(1, 0, 1);
54
55 S.Id (wxID_NO).AddButton (XC ("&Skip", "update dialog"));
56 S.Id (wxID_YES).AddButton (XC("&Install update", "update dialog"));
57
58 S.SetBorder (5);
59 }
60 S.EndHorizontalLay();
61 }
62 S.EndVerticalLay();
63
64 Layout();
65 Fit();
66 Center();
67}
68
70{
71 ;
72}
73
74void UpdatePopupDialog::OnUpdate (wxCommandEvent&)
75{
76 EndModal (wxID_YES);
77}
78
79void UpdatePopupDialog::OnSkip (wxCommandEvent&)
80{
81 EndModal (wxID_NO);
82}
83
84void UpdatePopupDialog::OnDontShow (wxCommandEvent& event)
85{
86 DefaultUpdatesCheckingFlag.Write(!event.IsChecked());
87}
88
90{
91 wxStringOutputStream o;
92 wxTextOutputStream informationStr (o);
93
94 informationStr
95 << wxT("<html><body><h3>")
96 // i18n-hint Substitution of version number for %s.
97 << XC("Audacity %s is available!", "update dialog").Format(mVersionPatch.version.GetString()).Translation()
98 << wxT("</h3><h5>")
99 << XC("Changelog", "update dialog")
100 << wxT("</h5><p>");
101
102 informationStr << wxT("<ul>");
103 for (auto& logLine : mVersionPatch.changelog)
104 {
105 informationStr << wxT("<li>");
106 // We won't to translate downloaded text.
107 informationStr << logLine;
108 informationStr << wxT("</li>");
109 }
110 informationStr << wxT("</ul></p>");
111
112 informationStr << wxT("<p>");
113 informationStr << wxT("<a href = \"https://github.com/audacity/audacity/releases\">");
114 informationStr << XC("Read more on GitHub", "update dialog");
115 informationStr << wxT("</a>");
116 informationStr << wxT("</p>");
117
118 informationStr << wxT("</body></html>");
119
120 HtmlWindow* html = safenew LinkingHtmlWindow (parent, -1,
121 wxDefaultPosition,
122 wxSize (500, -1),
123 wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
124
125 html->SetBorders (20);
126 html->SetPage (o.GetString());
127
128 wxHtmlContainerCell* cell = html->GetInternalRepresentation();
129
130 cell->Layout (500);
131
132 const wxSize size = wxSize (500, cell->GetHeight());
133
134 html->SetMinSize (size);
135 html->SetMaxSize (size);
136 html->SetSize (size);
137
138 return html;
139}
wxT("CloseDown"))
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
#define XC(s, c)
Definition: Internat.h:37
#define safenew
Definition: MemoryX.h:10
BoolSetting DefaultUpdatesCheckingFlag
Definition: Prefs.cpp:63
IMPLEMENT_CLASS(cloud::ShareAudioToolbar, ToolBar)
@ eIsCreating
Definition: ShuttleGui.h:37
#define S(N)
Definition: ToChars.cpp:64
Declare a class that handles managing of updates.
@ DontShowID
Define a dialog for notifying users about new version available.
HtmlWindow Class.
Definition: HtmlWindow.h:37
An HtmlWindow that handles linked clicked - usually the link will go to our own local copy of the man...
Definition: HelpSystem.h:126
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:257
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:205
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:630
Show dialog window with update information for the user.
void OnSkip(wxCommandEvent &event)
void OnDontShow(wxCommandEvent &event)
void OnUpdate(wxCommandEvent &event)
HtmlWindow * AddHtmlContent(wxWindow *parent)
const VersionPatch & mVersionPatch
wxString GetString() const
Make string with version by MakeString() from instance values.
Definition: VersionId.cpp:46
A structure that describes patch fields.
Definition: VersionPatch.h:15
VersionId version
Definition: VersionPatch.h:20
wxArrayString changelog
Definition: VersionPatch.h:21