1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-07 06:55:52 +01:00

Adds a dialog, that notifies the user about update checks.

This dialog is only shown once. It has links to privacy policy and application preferences.
This commit is contained in:
Dmitry Vedenko
2021-07-14 22:15:11 +03:00
parent e9b33785a6
commit 2a2477eda0
6 changed files with 189 additions and 1 deletions

View File

@@ -995,6 +995,8 @@ list( APPEND SOURCES
update/UpdateDataParser.cpp
update/UpdateManager.h
update/UpdateManager.cpp
update/UpdateNoticeDialog.h
update/UpdateNoticeDialog.cpp
update/UpdatePopupDialog.h
update/UpdatePopupDialog.cpp
prefs/ApplicationPrefs.h

View File

@@ -475,7 +475,9 @@ void KeyConfigPrefs::OnShow(wxShowEvent & event)
{
event.Skip();
if (event.IsShown())
// This is required to prevent a crash if Preferences
// were opened without a project.
if (event.IsShown() && mView != nullptr)
{
mView->Refresh();
}

View File

@@ -782,6 +782,11 @@ void PrefsDialog::SelectPageByName(const wxString &pageName)
for (size_t i = 0; i < n; i++) {
if (mCategories->GetPageText(i) == pageName) {
mCategories->SetSelection(i);
// This covers the case, when ShowModal is called
// after selecting the page.
// ShowModal will select the page previously used by
// user
SavePreferredPage();
return;
}
}

View File

@@ -8,7 +8,9 @@
**********************************************************************/
#include "UpdateManager.h"
#include "UpdatePopupDialog.h"
#include "UpdateNoticeDialog.h"
#include "AudioIO.h"
#include "NetworkManager.h"
@@ -26,6 +28,9 @@
static const char* prefsUpdateScheduledTime = "/Update/UpdateScheduledTime";
static BoolSetting
prefUpdatesNoticeShown(wxT("/Update/UpdateNoticeShown"), false);
using Clock = std::chrono::system_clock;
using TimePoint = Clock::time_point;
@@ -51,10 +56,27 @@ void UpdateManager::Start()
auto& instance = GetInstance();
static std::once_flag flag;
std::call_once(flag, [&instance] {
instance.mTimer.SetOwner(&instance, ID_TIMER);
instance.mTimer.StartOnce(1);
});
// Show the dialog only once.
if (!prefUpdatesNoticeShown.Read())
{
// DefaultUpdatesCheckingFlag survives the "Reset Preferences"
// action, so check, if the updates were previously disabled as well.
if (DefaultUpdatesCheckingFlag.Read())
{
UpdateNoticeDialog notice(nullptr);
notice.ShowModal();
}
prefUpdatesNoticeShown.Write(true);
gPrefs->Flush();
}
}
VersionPatch UpdateManager::GetVersionPatch() const

View File

@@ -0,0 +1,127 @@
/*!********************************************************************
Audacity: A Digital Audio Editor
@file UpdateNoticeDialog.cpp
@brief Declare a dialog to notify the user about automatic update checking.
Dmitry Vedenko
**********************************************************************/
#include "UpdateNoticeDialog.h"
#include <wx/button.h>
#include <wx/stattext.h>
#include "ShuttleGui.h"
#include "CodeConversions.h"
#include "prefs/PrefsDialog.h"
#include "ui/AccessibleLinksFormatter.h"
static const auto title =
/* i18n-hint: Title of the app update notice dialog. */
XO("App update checking");
static const auto firstParagraph =
/* i18-hint: The first paragraph of app update notice dialog. */
XO("To stay up to date, you will receive an in-app notification whenever there is a new version of Audacity available to download.");
static const auto secondParagraph =
/* i18-hint: The second paragraph of app update notice dialog */
XO("In order to protect your privacy, Audacity does not collect any personal information. However, app update checking does require network access.");
static const auto thirdParagraph =
/* i18-hint: Hint to the user about how to turn the app update off. %s is replaced with "Preferences > Application" link*/
XO("You can turn off app update checking at any time in %s.");
BEGIN_EVENT_TABLE(UpdateNoticeDialog, wxDialogWrapper)
EVT_BUTTON(wxID_OK, UpdateNoticeDialog::OnOk)
END_EVENT_TABLE()
IMPLEMENT_CLASS(UpdateNoticeDialog, wxDialogWrapper)
UpdateNoticeDialog::UpdateNoticeDialog(wxWindow* parent)
: wxDialogWrapper(
/* i18n-hint: Title of the app update notice dialog. */
parent, -1, XO("App updates"), wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxCLOSE_BOX)
{
ShuttleGui S(this, eIsCreating);
S.StartVerticalLay();
{
S.AddSpace(0, 16);
S.StartHorizontalLay();
{
S.AddSpace(24, 0);
S.StartPanel();
{
S.SetBorder(8);
wxStaticText* titleCtrl = S.AddVariableText(title, false, 0, 500);
wxFont font = titleCtrl->GetFont().MakeLarger().MakeBold();
titleCtrl->SetFont(font);
S.AddFixedText(firstParagraph, false, 500);
S.AddFixedText(secondParagraph, false, 500);
/* i18n-hint: %s will be replaced with "our Privacy Policy" */
AccessibleLinksFormatter privacyPolicy(XO("See %s for more info."));
privacyPolicy.FormatLink(
/* i18n-hint: Title of hyperlink to the privacy policy. This is an object of "See". */
wxT("%s"), XO("our Privacy Policy"),
"https://www.audacityteam.org/about/desktop-privacy-notice/");
privacyPolicy.Populate(S);
S.AddSpace(0, 8);
AccessibleLinksFormatter preferencesMessage(thirdParagraph);
preferencesMessage.FormatLink(
wxT("%s"), XO("Preferences > Application"), [this]() {
GlobalPrefsDialog dialog(this /* parent */, nullptr);
dialog.SelectPageByName(XO("Application").Translation());
dialog.ShowModal();
});
preferencesMessage.Populate(S);
}
S.EndPanel();
S.AddSpace(24, 0);
}
S.EndHorizontalLay();
S.StartHorizontalLay(wxEXPAND, 0);
{
S.AddSpace(1, 0, 1);
S.Id(wxID_OK).AddButton(XO("&OK"))->SetFocus();
S.AddSpace(8, 0);
}
S.EndHorizontalLay();
}
S.EndVerticalLay();
Layout();
Fit();
Center();
}
void UpdateNoticeDialog::OnOk(wxCommandEvent&)
{
EndModal(wxOK);
}

View File

@@ -0,0 +1,30 @@
/*!********************************************************************
Audacity: A Digital Audio Editor
@file UpdateNoticeDialog.h
@brief Define a dialog to notify the user about automatic update checking.
Dmitry Vedenko
**********************************************************************/
#pragma once
#include "widgets/wxPanelWrapper.h"
#include "wx/string.h"
class HtmlWindow;
class wxWindow;
//! Dialog, that notifies the users about automatic updates checking
class UpdateNoticeDialog final : public wxDialogWrapper
{
DECLARE_DYNAMIC_CLASS (AboutDialog)
public:
explicit UpdateNoticeDialog (wxWindow* parent);
private:
void OnOk (wxCommandEvent& event);
DECLARE_EVENT_TABLE ()
};