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