Add recommends from review.
This commit is contained in:
parent
c7a24df915
commit
d15d88af71
|
@ -1491,7 +1491,7 @@ bool AudacityApp::InitPart2()
|
|||
}
|
||||
|
||||
#if defined(HAVE_UPDATES_CHECK)
|
||||
mUpdateManager = std::make_unique<UpdateManager>();
|
||||
UpdateManager::Start();
|
||||
#endif
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
|
|
|
@ -114,10 +114,6 @@ class AudacityApp final : public wxApp {
|
|||
std::unique_ptr<wxSocketServer> mIPCServ;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_UPDATES_CHECK)
|
||||
std::unique_ptr<UpdateManager> mUpdateManager;
|
||||
#endif
|
||||
|
||||
public:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -34,12 +34,34 @@ UpdateManager::UpdateManager()
|
|||
std::chrono::milliseconds(std::chrono::hours(12)).count())
|
||||
{
|
||||
mTimer.SetOwner(this, ID_TIMER);
|
||||
mTimer.StartOnce();
|
||||
}
|
||||
|
||||
UpdateManager::~UpdateManager()
|
||||
{
|
||||
mTimer.Stop();
|
||||
Stop();
|
||||
}
|
||||
|
||||
UpdateManager& UpdateManager::GetInstance()
|
||||
{
|
||||
static UpdateManager updateManager;
|
||||
|
||||
return updateManager;
|
||||
}
|
||||
|
||||
void UpdateManager::Start()
|
||||
{
|
||||
auto& instance = GetInstance();
|
||||
|
||||
if (!instance.mTimer.IsRunning())
|
||||
instance.mTimer.StartOnce();
|
||||
}
|
||||
|
||||
void UpdateManager::Stop()
|
||||
{
|
||||
auto& instance = GetInstance();
|
||||
|
||||
if (instance.mTimer.IsRunning())
|
||||
instance.mTimer.Stop();
|
||||
}
|
||||
|
||||
void UpdateManager::enableUpdatesChecking(bool enable)
|
||||
|
@ -65,47 +87,42 @@ void UpdateManager::getUpdates()
|
|||
|
||||
response->setRequestFinishedCallback([response, this](audacity::network_manager::IResponse*) {
|
||||
|
||||
wxFrame* parent = FindProjectFrame(GetActiveProject());
|
||||
wxASSERT(parent);
|
||||
|
||||
if (!parent) return;
|
||||
|
||||
if (response->getError() != audacity::network_manager::NetworkError::NoError)
|
||||
{
|
||||
ShowExceptionDialog(parent,
|
||||
XO("Error checking for update"),
|
||||
XO("Unable to connect to Audacity update server."),
|
||||
wxTheApp->CallAfter([] {ShowExceptionDialog(nullptr,
|
||||
XC("Error checking for update", "update dialog"),
|
||||
XC("Unable to connect to Audacity update server.", "update dialog"),
|
||||
wxString());
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mUpdateDataParser.Parse(response->readAll<VersionPatch::UpdateDataFormat>(), &mVersionPatch))
|
||||
{
|
||||
ShowExceptionDialog(parent,
|
||||
XO("Error checking for update"),
|
||||
XO("Update data was corrupted."),
|
||||
wxTheApp->CallAfter([] {ShowExceptionDialog(nullptr,
|
||||
XC("Error checking for update", "update dialog"),
|
||||
XC("Update data was corrupted.", "update dialog"),
|
||||
wxString());
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVersionPatch.version > CurrentBuildVersion())
|
||||
{
|
||||
parent->CallAfter([this, parent] {
|
||||
UpdatePopupDialog dlg(parent, this);
|
||||
wxTheApp->CallAfter([this] {
|
||||
UpdatePopupDialog dlg(nullptr, this);
|
||||
const int code = dlg.ShowModal();
|
||||
|
||||
if (code == wxID_YES)
|
||||
{
|
||||
if (!wxLaunchDefaultBrowser(mVersionPatch.download))
|
||||
{
|
||||
ShowExceptionDialog(parent,
|
||||
XO("Error downloading update"),
|
||||
XO("Can't open the Audacity download link."),
|
||||
ShowExceptionDialog(nullptr,
|
||||
XC("Error downloading update.", "update dialog"),
|
||||
XC("Can't open the Audacity download link.", "update dialog"),
|
||||
wxString());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -30,6 +30,10 @@ public:
|
|||
UpdateManager();
|
||||
~UpdateManager();
|
||||
|
||||
static UpdateManager& GetInstance();
|
||||
static void Start();
|
||||
static void Stop();
|
||||
|
||||
void getUpdates();
|
||||
|
||||
void enableUpdatesChecking(bool enable);
|
||||
|
|
|
@ -27,7 +27,7 @@ END_EVENT_TABLE()
|
|||
IMPLEMENT_CLASS (UpdatePopupDialog, wxDialogWrapper)
|
||||
|
||||
UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, UpdateManager* updateManager)
|
||||
: wxDialogWrapper (parent, -1, XO ("Update Audacity"),
|
||||
: wxDialogWrapper (parent, -1, XC("Update Audacity", "update dialog"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxCAPTION),
|
||||
mUpdateManager (updateManager)
|
||||
|
@ -49,8 +49,8 @@ UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, UpdateManager* updateMan
|
|||
|
||||
S.Prop(1).AddSpace(1, 0, 1);
|
||||
|
||||
S.Id (wxID_NO).AddButton (XO ("Skip"));
|
||||
S.Id (wxID_YES).AddButton (XO ("Install update"));
|
||||
S.Id (wxID_NO).AddButton (XC ("&Skip", "update dialog"));
|
||||
S.Id (wxID_YES).AddButton (XC("&Install update", "update dialog"));
|
||||
|
||||
S.SetBorder (5);
|
||||
}
|
||||
|
@ -88,14 +88,15 @@ HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
|||
wxStringOutputStream o;
|
||||
wxTextOutputStream informationStr (o);
|
||||
|
||||
static const auto title = XO("Audacity %s is available!")
|
||||
// i18n-hint Substitution of version number for %s.
|
||||
static const auto title = XC("Audacity %s is available!", "update dialog")
|
||||
.Format(mUpdateManager->getVersionPatch().version.getString());
|
||||
|
||||
informationStr
|
||||
<< wxT("<html><body><h3>")
|
||||
<< title.Translation()
|
||||
<< wxT("</h3><h5>")
|
||||
<< XO("Changelog")
|
||||
<< XC("Changelog", "update dialog")
|
||||
<< wxT("</h5><p>");
|
||||
|
||||
informationStr << wxT("<ul>");
|
||||
|
@ -109,7 +110,9 @@ HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
|||
informationStr << wxT("</ul></p>");
|
||||
|
||||
informationStr << wxT("<p>");
|
||||
informationStr << XO("<a href = \"https://github.com/audacity/audacity/releases\">Read more on GitHub</a>");
|
||||
informationStr << wxT("<a href = \"https://github.com/audacity/audacity/releases\">");
|
||||
informationStr << XC("Read more on GitHub", "update dialog");
|
||||
informationStr << wxT("</a>");
|
||||
informationStr << wxT("</p>");
|
||||
|
||||
informationStr << wxT("</body></html>");
|
||||
|
|
|
@ -50,9 +50,8 @@ wxString VersionId::getString() const
|
|||
|
||||
bool VersionId::operator== (const VersionId& other)
|
||||
{
|
||||
return mVersion == other.mVersion &&
|
||||
mRelease == other.mRelease &&
|
||||
mRevision == other.mRevision;
|
||||
return std::tie(mVersion, mRelease, mRevision) ==
|
||||
std::tie(other.mVersion, other.mRelease, other.mRevision);
|
||||
}
|
||||
|
||||
bool VersionId::operator!= (const VersionId& other)
|
||||
|
@ -62,19 +61,8 @@ bool VersionId::operator!= (const VersionId& other)
|
|||
|
||||
bool VersionId::operator< (const VersionId& other)
|
||||
{
|
||||
if (mVersion < other.mVersion)
|
||||
return true;
|
||||
|
||||
if (mRelease < other.mRelease &&
|
||||
mVersion == other.mVersion)
|
||||
return true;
|
||||
|
||||
if (mRevision < other.mRevision &&
|
||||
mVersion == other.mVersion &&
|
||||
mRelease == other.mRelease)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return std::tie(mVersion, mRelease, mRevision) <
|
||||
std::tie(other.mVersion, other.mRelease, other.mRevision);
|
||||
}
|
||||
|
||||
bool VersionId::operator> (const VersionId& other)
|
||||
|
|
Loading…
Reference in New Issue