mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 17:10:55 +02:00
Add review recommendations.
This commit is contained in:
parent
d9ab95a4b2
commit
93b9bcf470
@ -24,11 +24,10 @@
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum { CheckingUpdatesID = wxID_HIGHEST + 1 };
|
static ComponentInterfaceSymbol s_ComponentInterfaceSymbol{ XO("Application") };
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(ApplicationPrefs, PrefsPanel)
|
BoolSetting ApplicationPrefsSettings::DefaultUpdatesCheckingFlag{
|
||||||
EVT_CHECKBOX(CheckingUpdatesID, ApplicationPrefs::OnCheckingUpdates)
|
L"/Update/DefaultUpdatesChecking", true };
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
ApplicationPrefs::ApplicationPrefs(wxWindow * parent, wxWindowID winid)
|
ApplicationPrefs::ApplicationPrefs(wxWindow * parent, wxWindowID winid)
|
||||||
: PrefsPanel(parent, winid, XO("Application"))
|
: PrefsPanel(parent, winid, XO("Application"))
|
||||||
@ -42,7 +41,7 @@ ApplicationPrefs::~ApplicationPrefs()
|
|||||||
|
|
||||||
ComponentInterfaceSymbol ApplicationPrefs::GetSymbol()
|
ComponentInterfaceSymbol ApplicationPrefs::GetSymbol()
|
||||||
{
|
{
|
||||||
return WARNINGS_PREFS_PLUGIN_SYMBOL;
|
return s_ComponentInterfaceSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslatableString ApplicationPrefs::GetDescription()
|
TranslatableString ApplicationPrefs::GetDescription()
|
||||||
@ -73,10 +72,9 @@ void ApplicationPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
|
|
||||||
S.StartStatic(XO("Update Audacity"));
|
S.StartStatic(XO("Update Audacity"));
|
||||||
{
|
{
|
||||||
// TODO: replace `false` to UpdateManager::GetInstance().isUpdatesChakingEnabled()
|
S.TieCheckBox(
|
||||||
// and XO("Check for Updates...") need remove endian after translation.
|
XO("&Check for Updates...").Stripped(TranslatableString::Ellipses | TranslatableString::MenuCodes),
|
||||||
S.Id(CheckingUpdatesID).AddCheckBox(
|
ApplicationPrefsSettings::DefaultUpdatesCheckingFlag);
|
||||||
XO("Check for Updates"), false);
|
|
||||||
}
|
}
|
||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
S.EndScroller();
|
S.EndScroller();
|
||||||
@ -90,12 +88,6 @@ bool ApplicationPrefs::Commit()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationPrefs::OnCheckingUpdates(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
event.IsChecked();
|
|
||||||
// TODO: add UpdateManager::GetInstance().enableUpdatesChaking(event.IsChecked())
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace{
|
namespace{
|
||||||
PrefsPanel::Registration sAttachment{ "Application",
|
PrefsPanel::Registration sAttachment{ "Application",
|
||||||
[](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
[](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||||
|
@ -14,10 +14,13 @@
|
|||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
|
|
||||||
#include "PrefsPanel.h"
|
#include "PrefsPanel.h"
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
class ShuttleGui;
|
class ShuttleGui;
|
||||||
|
|
||||||
#define WARNINGS_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Application") }
|
namespace ApplicationPrefsSettings {
|
||||||
|
extern AUDACITY_DLL_API BoolSetting DefaultUpdatesCheckingFlag;
|
||||||
|
}
|
||||||
|
|
||||||
class ApplicationPrefs final : public PrefsPanel
|
class ApplicationPrefs final : public PrefsPanel
|
||||||
{
|
{
|
||||||
@ -30,14 +33,9 @@ class ApplicationPrefs final : public PrefsPanel
|
|||||||
bool Commit() override;
|
bool Commit() override;
|
||||||
wxString HelpPageName() override;
|
wxString HelpPageName() override;
|
||||||
|
|
||||||
void OnCheckingUpdates(wxCommandEvent& event);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Populate();
|
void Populate();
|
||||||
void PopulateOrExchange(ShuttleGui & S) override;
|
void PopulateOrExchange(ShuttleGui & S) override;
|
||||||
|
|
||||||
public:
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
|
|
||||||
#include "widgets/ErrorDialog.h"
|
#include "widgets/ErrorDialog.h"
|
||||||
|
#include "prefs/ApplicationPrefs.h"
|
||||||
|
|
||||||
#include <wx/platinfo.h>
|
#include <wx/platinfo.h>
|
||||||
#include <wx/utils.h>
|
#include <wx/utils.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
|
|
||||||
static const char* prefsUpdatePopupDialogShown = "/Update/UpdatePopupDialogShown";
|
|
||||||
static const char* prefsUpdateScheduledTime = "/Update/UpdateScheduledTime";
|
static const char* prefsUpdateScheduledTime = "/Update/UpdateScheduledTime";
|
||||||
|
|
||||||
enum { ID_TIMER = wxID_HIGHEST + 1 };
|
enum { ID_TIMER = wxID_HIGHEST + 1 };
|
||||||
@ -55,17 +55,6 @@ void UpdateManager::Start()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateManager::EnableUpdatesChecking(bool enable)
|
|
||||||
{
|
|
||||||
gPrefs->Write(prefsUpdatePopupDialogShown, enable);
|
|
||||||
gPrefs->Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UpdateManager::IsUpdatesCheckingEnabled()
|
|
||||||
{
|
|
||||||
return gPrefs->ReadBool(prefsUpdatePopupDialogShown, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
VersionPatch UpdateManager::GetVersionPatch() const
|
VersionPatch UpdateManager::GetVersionPatch() const
|
||||||
{
|
{
|
||||||
return mVersionPatch;
|
return mVersionPatch;
|
||||||
@ -103,7 +92,7 @@ void UpdateManager::GetUpdates()
|
|||||||
if (mVersionPatch.version > CurrentBuildVersion())
|
if (mVersionPatch.version > CurrentBuildVersion())
|
||||||
{
|
{
|
||||||
wxTheApp->CallAfter([this] {
|
wxTheApp->CallAfter([this] {
|
||||||
UpdatePopupDialog dlg(nullptr, this);
|
UpdatePopupDialog dlg(nullptr, mVersionPatch);
|
||||||
const int code = dlg.ShowModal();
|
const int code = dlg.ShowModal();
|
||||||
|
|
||||||
if (code == wxID_YES)
|
if (code == wxID_YES)
|
||||||
@ -123,13 +112,15 @@ void UpdateManager::GetUpdates()
|
|||||||
|
|
||||||
void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event))
|
void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (IsUpdatesCheckingEnabled() && IsTimeToUpdate())
|
bool updatesCheckingEnabled = ApplicationPrefsSettings::DefaultUpdatesCheckingFlag.Read();
|
||||||
|
|
||||||
|
if (updatesCheckingEnabled && IsTimeToUpdatesChecking())
|
||||||
GetUpdates();
|
GetUpdates();
|
||||||
|
|
||||||
mTimer.StartOnce(mTrackingInterval);
|
mTimer.StartOnce(mTrackingInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateManager::IsTimeToUpdate()
|
bool UpdateManager::IsTimeToUpdatesChecking()
|
||||||
{
|
{
|
||||||
long long nextUpdatesCheckingTime = std::stoll(
|
long long nextUpdatesCheckingTime = std::stoll(
|
||||||
gPrefs->Read(prefsUpdateScheduledTime, "0").ToStdString());
|
gPrefs->Read(prefsUpdateScheduledTime, "0").ToStdString());
|
||||||
|
@ -35,9 +35,6 @@ public:
|
|||||||
|
|
||||||
void GetUpdates();
|
void GetUpdates();
|
||||||
|
|
||||||
void EnableUpdatesChecking(bool enable);
|
|
||||||
bool IsUpdatesCheckingEnabled();
|
|
||||||
|
|
||||||
VersionPatch GetVersionPatch() const;
|
VersionPatch GetVersionPatch() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -50,7 +47,7 @@ private:
|
|||||||
void OnTimer(wxTimerEvent& event);
|
void OnTimer(wxTimerEvent& event);
|
||||||
|
|
||||||
/// Scheduling update time for avoiding multiplying update notifications.
|
/// Scheduling update time for avoiding multiplying update notifications.
|
||||||
bool IsTimeToUpdate();
|
bool IsTimeToUpdatesChecking();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "ShuttleGui.h"
|
#include "ShuttleGui.h"
|
||||||
#include "widgets/HelpSystem.h"
|
#include "widgets/HelpSystem.h"
|
||||||
|
#include "prefs/ApplicationPrefs.h"
|
||||||
|
|
||||||
#include <wx/debug.h>
|
#include <wx/debug.h>
|
||||||
#include <wx/sstream.h>
|
#include <wx/sstream.h>
|
||||||
@ -26,14 +27,12 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
IMPLEMENT_CLASS (UpdatePopupDialog, wxDialogWrapper)
|
IMPLEMENT_CLASS (UpdatePopupDialog, wxDialogWrapper)
|
||||||
|
|
||||||
UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, UpdateManager* updateManager)
|
UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, const VersionPatch& versionPatch)
|
||||||
: wxDialogWrapper (parent, -1, XC("Update Audacity", "update dialog"),
|
: wxDialogWrapper (parent, -1, XC("Update Audacity", "update dialog"),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxCAPTION),
|
wxCAPTION),
|
||||||
mUpdateManager (updateManager)
|
mVersionPatch(versionPatch)
|
||||||
{
|
{
|
||||||
wxASSERT(mUpdateManager);
|
|
||||||
|
|
||||||
ShuttleGui S (this, eIsCreating);
|
ShuttleGui S (this, eIsCreating);
|
||||||
S.SetBorder (5);
|
S.SetBorder (5);
|
||||||
S.StartVerticalLay (wxEXPAND, 1);
|
S.StartVerticalLay (wxEXPAND, 1);
|
||||||
@ -45,7 +44,8 @@ UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, UpdateManager* updateMan
|
|||||||
S.SetBorder (5);
|
S.SetBorder (5);
|
||||||
|
|
||||||
S.Id (DontShowID).AddCheckBox (
|
S.Id (DontShowID).AddCheckBox (
|
||||||
XO ("Don't show this again at start up"), !mUpdateManager->IsUpdatesCheckingEnabled());
|
XO ("Don't show this again at start up"),
|
||||||
|
!ApplicationPrefsSettings::DefaultUpdatesCheckingFlag.Read());
|
||||||
|
|
||||||
S.Prop(1).AddSpace(1, 0, 1);
|
S.Prop(1).AddSpace(1, 0, 1);
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ void UpdatePopupDialog::OnSkip (wxCommandEvent&)
|
|||||||
|
|
||||||
void UpdatePopupDialog::OnDontShow (wxCommandEvent& event)
|
void UpdatePopupDialog::OnDontShow (wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
mUpdateManager->EnableUpdatesChecking(!event.IsChecked());
|
ApplicationPrefsSettings::DefaultUpdatesCheckingFlag.Write(!event.IsChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
||||||
@ -90,7 +90,7 @@ HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
|||||||
|
|
||||||
// i18n-hint Substitution of version number for %s.
|
// i18n-hint Substitution of version number for %s.
|
||||||
static const auto title = XC("Audacity %s is available!", "update dialog")
|
static const auto title = XC("Audacity %s is available!", "update dialog")
|
||||||
.Format(mUpdateManager->GetVersionPatch().version.GetString());
|
.Format(mVersionPatch.version.GetString());
|
||||||
|
|
||||||
informationStr
|
informationStr
|
||||||
<< wxT("<html><body><h3>")
|
<< wxT("<html><body><h3>")
|
||||||
@ -100,7 +100,7 @@ HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
|||||||
<< wxT("</h5><p>");
|
<< wxT("</h5><p>");
|
||||||
|
|
||||||
informationStr << wxT("<ul>");
|
informationStr << wxT("<ul>");
|
||||||
for (auto& logLine : mUpdateManager->GetVersionPatch().changelog)
|
for (auto& logLine : mVersionPatch.changelog)
|
||||||
{
|
{
|
||||||
informationStr << wxT("<li>");
|
informationStr << wxT("<li>");
|
||||||
// We won't to translate downloaded text.
|
// We won't to translate downloaded text.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
|
|
||||||
#include "update/UpdateManager.h"
|
#include "VersionPatch.h"
|
||||||
|
|
||||||
class HtmlWindow;
|
class HtmlWindow;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
@ -30,7 +30,7 @@ class UpdatePopupDialog final : public wxDialogWrapper
|
|||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS (AboutDialog)
|
DECLARE_DYNAMIC_CLASS (AboutDialog)
|
||||||
public:
|
public:
|
||||||
explicit UpdatePopupDialog (wxWindow* parent, UpdateManager *updateManager);
|
explicit UpdatePopupDialog (wxWindow* parent, const VersionPatch& versionPatch);
|
||||||
virtual ~UpdatePopupDialog();
|
virtual ~UpdatePopupDialog();
|
||||||
|
|
||||||
void OnUpdate (wxCommandEvent& event);
|
void OnUpdate (wxCommandEvent& event);
|
||||||
@ -42,5 +42,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
HtmlWindow* AddHtmlContent (wxWindow* parent);
|
HtmlWindow* AddHtmlContent (wxWindow* parent);
|
||||||
|
|
||||||
UpdateManager* const mUpdateManager;
|
const VersionPatch& mVersionPatch;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user