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