Audacity 3.2.0
WhatsNewDialog.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 WhatsNewDialog.cpp
7
8 Vitaly Sverchinsky
9
10**********************************************************************/
11
12#include "WhatsNewDialog.h"
13
14#include <wx/fs_mem.h>
15#include <wx/settings.h>
16#include <wx/mstream.h>
17#include <wx/sstream.h>
18#include <wx/txtstrm.h>
19#include <wx/hyperlink.h>
20#include <wx/checkbox.h>
21#include <wx/frame.h>
22#include <wx/statbmp.h>
23#include <wx/stattext.h>
24
25#include "HelpSystem.h"
26#include "HelpText.h"
27#include "ProjectWindows.h"
28#include "ShuttleGui.h"
29#include "Theme.h"
30#include "AllThemeResources.h"
31
32#include "../images/WhatsNewBtn.jpeg.h"
33#include "../images/MuseHub.jpeg.h"
34
35namespace
36{
37
38#if defined (__WXOSX__) || defined(__WXMSW__)
39# define SHOW_MUSEHUB
40#endif
41
42const char* WhatsNewURL = "https://audacityteam.org/3.6.0-video";
43const char* MuseHubURL = "https://www.musehub.com";
44
45#if defined(SHOW_MUSEHUB)
46 constexpr auto WindowWidth = 720;
47#else
48 constexpr auto WindowWidth = 400;
49#endif
50
51}
52AttachedWindows::RegisteredFactory sWhatsNewWindow{
53 []( AudacityProject &project ) -> wxWeakRef< wxWindow > {
54 auto &window = GetProjectFrame(project);
55 return safenew WhatsNewDialog(&window, wxID_ANY);
56 }
57};
58
59
60namespace
61{
62
63struct FSHelper final
64{
66 : mMemoryFSHandler(std::make_unique<wxMemoryFSHandler>())
67 {
68 wxFileSystem::AddHandler(mMemoryFSHandler.get());
69
70 wxMemoryFSHandler::AddFile(
71 "whats_new_btn.jpeg", bin2c_whats_new_btn_jpeg,
72 sizeof(bin2c_whats_new_btn_jpeg));
73 wxMemoryFSHandler::AddFile(
74 "musehub.jpeg", bin2c_musehub_jpeg,
75 sizeof(bin2c_musehub_jpeg));
76 }
77
79 {
80 wxMemoryFSHandler::RemoveFile("whats_new_btn.jpeg");
81 wxMemoryFSHandler::RemoveFile("musehub.jpeg");
82 wxFileSystem::RemoveHandler(mMemoryFSHandler.get());
83 }
84
85private:
86 std::unique_ptr<wxMemoryFSHandler> mMemoryFSHandler;
87};
88
90{
91 wxStringOutputStream o;
92 wxTextOutputStream s(o);
93 s
94 << wxT("<body>")
95 << wxT("<p><center>")
96 << wxT(R"(<p><a href=")") << WhatsNewURL << wxT(R"(">)")
97 // Bug: (Windows) specified width and height should match exactly to the size of the image
98 << wxT(R"(<img src="memory:whats_new_btn.jpeg" width="263" height="148" /><br></a></p>)")
99 << wxT("<h3>") << XO("What's new in Audacity %s").Format(AUDACITY_VERSION_STRING) << wxT("</h3>")
100 << wxT("<p>")
101 << XO("Watch the [[%s|release video]] or read the [[https://support.audacityteam.org/additional-resources/changelog|changelog]] to learn more!</p>").Format(WhatsNewURL);
102
103 return FormatHtmlText(o.GetString());
104}
105
107{
108 wxStringOutputStream o;
109 wxTextOutputStream s(o);
110 s
111 << wxT("<body>")
112 << wxT("<p><center>")
113 << wxT(R"(<p><a href=")") << MuseHubURL << wxT(R"(">)")
114 // Bug: (Windows) specified width and height should match exactly to the size of the image
115 << wxT(R"(<img src="memory:musehub.jpeg" width="263" height="148" /><br></a></p>)")
116 << wxT("<h3>") << XO("Get free plugins & sounds")<< wxT("</h3>")
117 << XO("<p>Check out our [[%s|Muse Hub app]] for a wide range of audio plugins for Audacity users</p>").Format(MuseHubURL);
118
119 return FormatHtmlText(o.GetString());
120}
121}
122
123BEGIN_EVENT_TABLE(WhatsNewDialog, wxDialogWrapper)
126
127WhatsNewDialog::WhatsNewDialog(wxWindow* parent, wxWindowID id)
128 : wxDialogWrapper(parent, id, XO("Welcome to Audacity!"))
129{
130#if defined(__WXOSX__)
131 SetSize(WindowWidth, 400);
132#else
133 SetSize(FromDIP(wxSize(WindowWidth, 430)));
134#endif
135
136#if defined(__WXMSW__)
137 //On Windows UI controls doesn't use same theme preference
138 //as per application, we should use the latter one to get
139 //match with LinkingHtmlWindow's theme
140 SetBackgroundColour(theTheme.Colour(clrMedium));
141#endif
142 SetName();
143 ShuttleGui S( this, eIsCreating );
144 Populate( S );
145 Centre();
146}
147
149
151{
152 auto dialog = &GetAttachedWindows(project)
154 dialog->CenterOnParent();
155 dialog->wxDialogWrapper::Show();
156}
157
159{
160 bool showSplashScreen;
161 gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &showSplashScreen, true );
162
163 FSHelper helper;
164
165 S.StartHorizontalLay(wxEXPAND);
166 {
167 S.SetBorder(20);
168 const auto whatsnew = safenew LinkingHtmlWindow(S.GetParent());
169 whatsnew->SetPage(MakeWhatsNewText());
170 whatsnew->SetBackgroundColour(S.GetParent()->GetBackgroundColour());
171 S
172 .Prop(1)
173#if defined(SHOW_MUSEHUB)
174 .Position(wxEXPAND | wxLEFT | wxTOP | wxBOTTOM)
175#else
176 .Position(wxEXPAND | wxALL)
177#endif
178 .AddWindow(whatsnew);
179
180#if defined(SHOW_MUSEHUB)
181 S.AddSpace(20);
182
183 const auto getplugins = safenew LinkingHtmlWindow(S.GetParent());
184 getplugins->SetPage(MakeGetPluginsText());
185 getplugins->SetBackgroundColour(S.GetParent()->GetBackgroundColour());
186 S
187 .Prop(1)
188 .Position(wxEXPAND | wxTOP | wxRIGHT | wxBOTTOM)
189 .AddWindow(getplugins);
190#endif
191 }
192 S.EndHorizontalLay();
193
194 const auto line = safenew wxWindow(S.GetParent(), wxID_ANY);
195 line->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
196 line->SetSize(-1, 1);
197
198 S
199 .Prop(0)
200 .Position(wxEXPAND)
201 .AddWindow(line);
202
203 S.StartHorizontalLay(wxALIGN_CENTRE, 0);
204 {
205 S.SetBorder(10);
206 const auto tutorialsLink = safenew wxHyperlinkCtrl(
207 S.GetParent(),
208 wxID_ANY,
209 _("View tutorials"),
210 "https://support.audacityteam.org/");
211 S
212 .Position(wxTOP | wxBOTTOM)
213 .AddWindow(tutorialsLink);
214
215 S.AddSpace(25);
216
217 const auto forumLink = safenew wxHyperlinkCtrl(
218 S.GetParent(),
219 wxID_ANY,
220 _("Visit our forum"),
221 "https://forum.audacityteam.org/");
222 S
223 .Position(wxTOP | wxBOTTOM)
224 .AddWindow(forumLink);
225 }
226 S.EndHorizontalLay();
227
228 S.Position(wxEXPAND).StartPanel(2);
229 {
230 S.StartHorizontalLay(wxEXPAND);
231 {
232 S.SetBorder(4);
234 .Position(wxALL | wxALIGN_CENTRE)
235 .AddCheckBox( XXO("Don't show this again at start up"), !showSplashScreen);
236
237 S.AddSpace(1,1,1);
238
239 S
240 .Id(wxID_OK)
241 .AddButton(XXO("OK"), wxALL, true);
242 }
243 S.EndHorizontalLay();
244 }
245 S.EndPanel();
246}
247
248void WhatsNewDialog::OnOK(wxCommandEvent& evt)
249{
250 gPrefs->Write(wxT("/GUI/ShowSplashScreen"), !mDontShowAgain->IsChecked() );
251 gPrefs->Flush();
253}
wxT("CloseDown"))
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
wxString FormatHtmlText(const wxString &Text)
Definition: HelpText.cpp:258
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
accessors for certain important windows associated with each project
@ eIsCreating
Definition: ShuttleGui.h:37
const auto project
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define S(N)
Definition: ToChars.cpp:64
AttachedWindows::RegisteredFactory sWhatsNewWindow
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:318
An HtmlWindow that handles linked clicked - usually the link will go to our own local copy of the man...
Definition: HelpSystem.h:126
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
wxColour & Colour(int iIndex)
wxCheckBox * mDontShowAgain
void Populate(ShuttleGui &S)
static void Show(AudacityProject &project)
void OnOK(wxCommandEvent &)
~WhatsNewDialog() override
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
STL namespace.
std::unique_ptr< wxMemoryFSHandler > mMemoryFSHandler