From 00b8949e3ea74a7143463614adb5049723364d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=97=AD?= Date: Thu, 26 Oct 2023 14:51:41 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9=E7=AE=A1=E7=90=86=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E6=98=AF=E5=90=A6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Magpie.App/AboutPage.cpp | 4 ++ src/Magpie.App/AboutPage.h | 2 + src/Magpie.App/AboutPage.xaml | 3 +- src/Magpie.App/AppSettings.cpp | 3 ++ src/Magpie.App/AppSettings.h | 10 ++++ src/Magpie.App/SettingsPage.xaml | 77 +++++++++++++++------------- src/Magpie.App/SettingsViewModel.cpp | 15 ++++++ src/Magpie.App/SettingsViewModel.h | 3 ++ src/Magpie.App/SettingsViewModel.idl | 2 + 9 files changed, 82 insertions(+), 37 deletions(-) diff --git a/src/Magpie.App/AboutPage.cpp b/src/Magpie.App/AboutPage.cpp index a370a1abd..03361d28c 100644 --- a/src/Magpie.App/AboutPage.cpp +++ b/src/Magpie.App/AboutPage.cpp @@ -7,6 +7,10 @@ namespace winrt::Magpie::App::implementation { +void AboutPage::VersionTextBlock_DoubleTapped(IInspectable const&, Input::DoubleTappedRoutedEventArgs const&) { + OutputDebugString(L"test"); +} + void AboutPage::BugReportButton_Click(IInspectable const&, RoutedEventArgs const&) { Win32Utils::ShellOpen(L"https://github.com/Blinue/Magpie/issues/new?assignees=&labels=bug&template=01_bug.yaml"); } diff --git a/src/Magpie.App/AboutPage.h b/src/Magpie.App/AboutPage.h index 8f3e3635a..93358e8c6 100644 --- a/src/Magpie.App/AboutPage.h +++ b/src/Magpie.App/AboutPage.h @@ -8,6 +8,8 @@ struct AboutPage : AboutPageT { return _viewModel; } + void VersionTextBlock_DoubleTapped(IInspectable const&, Input::DoubleTappedRoutedEventArgs const&); + void BugReportButton_Click(IInspectable const&, RoutedEventArgs const&); void FeatureRequestButton_Click(IInspectable const&, RoutedEventArgs const&); void DiscussionsButton_Click(IInspectable const&, RoutedEventArgs const&); diff --git a/src/Magpie.App/AboutPage.xaml b/src/Magpie.App/AboutPage.xaml index d830a40e7..226a44c9e 100644 --- a/src/Magpie.App/AboutPage.xaml +++ b/src/Magpie.App/AboutPage.xaml @@ -23,7 +23,8 @@ Spacing="4"> - diff --git a/src/Magpie.App/AppSettings.cpp b/src/Magpie.App/AppSettings.cpp index 9cf22ee09..ae84bbdcd 100644 --- a/src/Magpie.App/AppSettings.cpp +++ b/src/Magpie.App/AppSettings.cpp @@ -494,6 +494,8 @@ bool AppSettings::_Save(const _AppSettingsData& data) noexcept { writer.Bool(data._isAutoRestore); writer.Key("countdownSeconds"); writer.Uint(data._countdownSeconds); + writer.Key("developerMode"); + writer.Bool(data._isDeveloperMode); writer.Key("debugMode"); writer.Bool(data._isDebugMode); writer.Key("disableEffectCache"); @@ -640,6 +642,7 @@ void AppSettings::_LoadSettings(const rapidjson::GenericObject 5) { _countdownSeconds = 3; } + JsonHelper::ReadBool(root, "developerMode", _isDeveloperMode); JsonHelper::ReadBool(root, "debugMode", _isDebugMode); JsonHelper::ReadBool(root, "disableEffectCache", _isDisableEffectCache); JsonHelper::ReadBool(root, "disableFontCache", _isDisableFontCache); diff --git a/src/Magpie.App/AppSettings.h b/src/Magpie.App/AppSettings.h index a3816b93e..9a6f13e9d 100644 --- a/src/Magpie.App/AppSettings.h +++ b/src/Magpie.App/AppSettings.h @@ -48,6 +48,7 @@ struct _AppSettingsData { bool _isPortableMode = false; bool _isAlwaysRunAsAdmin = false; + bool _isDeveloperMode = false; bool _isDebugMode = false; bool _isDisableEffectCache = false; bool _isDisableFontCache = false; @@ -185,6 +186,15 @@ class AppSettings : private _AppSettingsData { _countdownSecondsChangedEvent.remove(token); } + bool IsDeveloperMode() const noexcept { + return _isDeveloperMode; + } + + void IsDeveloperMode(bool value) noexcept { + _isDeveloperMode = value; + SaveAsync(); + } + bool IsDebugMode() const noexcept { return _isDebugMode; } diff --git a/src/Magpie.App/SettingsPage.xaml b/src/Magpie.App/SettingsPage.xaml index 4022a443a..4e297ed79 100644 --- a/src/Magpie.App/SettingsPage.xaml +++ b/src/Magpie.App/SettingsPage.xaml @@ -141,43 +141,48 @@ IsOn="{x:Bind ViewModel.IsInlineParams, Mode=TwoWay}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Magpie.App/SettingsViewModel.cpp b/src/Magpie.App/SettingsViewModel.cpp index 50b6de7f5..f753a270a 100644 --- a/src/Magpie.App/SettingsViewModel.cpp +++ b/src/Magpie.App/SettingsViewModel.cpp @@ -212,6 +212,21 @@ void SettingsViewModel::IsInlineParams(bool value) noexcept { _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsInlineParams")); } +bool SettingsViewModel::IsDeveloperMode() const noexcept { + return AppSettings::Get().IsDeveloperMode(); +} + +void SettingsViewModel::IsDeveloperMode(bool value) noexcept { + AppSettings& settings = AppSettings::Get(); + + if (settings.IsDeveloperMode() == value) { + return; + } + + settings.IsDeveloperMode(value); + _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsDeveloperMode")); +} + bool SettingsViewModel::IsDebugMode() const noexcept { return AppSettings::Get().IsDebugMode(); } diff --git a/src/Magpie.App/SettingsViewModel.h b/src/Magpie.App/SettingsViewModel.h index a50601138..eb65a398e 100644 --- a/src/Magpie.App/SettingsViewModel.h +++ b/src/Magpie.App/SettingsViewModel.h @@ -53,6 +53,9 @@ struct SettingsViewModel : SettingsViewModelT { bool IsInlineParams() const noexcept; void IsInlineParams(bool value) noexcept; + bool IsDeveloperMode() const noexcept; + void IsDeveloperMode(bool value) noexcept; + bool IsDebugMode() const noexcept; void IsDebugMode(bool value) noexcept; diff --git a/src/Magpie.App/SettingsViewModel.idl b/src/Magpie.App/SettingsViewModel.idl index 58ad3b1fa..2c8b8f7f9 100644 --- a/src/Magpie.App/SettingsViewModel.idl +++ b/src/Magpie.App/SettingsViewModel.idl @@ -21,6 +21,8 @@ namespace Magpie.App { Boolean IsAllowScalingMaximized; Boolean IsSimulateExclusiveFullscreen; Boolean IsInlineParams; + + Boolean IsDeveloperMode; Boolean IsDebugMode; Boolean IsDisableEffectCache; Boolean IsDisableFontCache; From a30f3765ad8a5cfd0dd7e4b036a4fc13b5ec4eb8 Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Tue, 31 Oct 2023 22:36:59 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E5=8F=8C=E5=87=BB=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E6=98=BE=E7=A4=BA=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Magpie.App/AboutPage.cpp | 4 +++- src/Magpie.App/AboutViewModel.cpp | 8 ++++++++ src/Magpie.App/AboutViewModel.h | 3 +++ src/Magpie.App/AboutViewModel.idl | 2 ++ src/Magpie.App/AppSettings.cpp | 14 ++++++++++++++ src/Magpie.App/AppSettings.h | 5 +---- src/Magpie.App/SettingsPage.xaml | 1 + 7 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/Magpie.App/AboutPage.cpp b/src/Magpie.App/AboutPage.cpp index 03361d28c..acdf2f7de 100644 --- a/src/Magpie.App/AboutPage.cpp +++ b/src/Magpie.App/AboutPage.cpp @@ -8,7 +8,9 @@ namespace winrt::Magpie::App::implementation { void AboutPage::VersionTextBlock_DoubleTapped(IInspectable const&, Input::DoubleTappedRoutedEventArgs const&) { - OutputDebugString(L"test"); + if (!_viewModel.IsDeveloperMode() && (GetAsyncKeyState(VK_MENU) & 0x8000)) { + _viewModel.IsDeveloperMode(true); + } } void AboutPage::BugReportButton_Click(IInspectable const&, RoutedEventArgs const&) { diff --git a/src/Magpie.App/AboutViewModel.cpp b/src/Magpie.App/AboutViewModel.cpp index 59c8fe4d0..2b892ea0f 100644 --- a/src/Magpie.App/AboutViewModel.cpp +++ b/src/Magpie.App/AboutViewModel.cpp @@ -81,6 +81,14 @@ hstring AboutViewModel::Version() const noexcept { )); } +bool AboutViewModel::IsDeveloperMode() const noexcept { + return AppSettings::Get().IsDeveloperMode(); +} + +void AboutViewModel::IsDeveloperMode(bool value) { + AppSettings::Get().IsDeveloperMode(value); +} + fire_and_forget AboutViewModel::CheckForUpdates() { return UpdateService::Get().CheckForUpdatesAsync(false); } diff --git a/src/Magpie.App/AboutViewModel.h b/src/Magpie.App/AboutViewModel.h index 3e71efd6b..ab8a4fe1c 100644 --- a/src/Magpie.App/AboutViewModel.h +++ b/src/Magpie.App/AboutViewModel.h @@ -21,6 +21,9 @@ struct AboutViewModel : AboutViewModelT { hstring Version() const noexcept; + bool IsDeveloperMode() const noexcept; + void IsDeveloperMode(bool value); + fire_and_forget CheckForUpdates(); bool IsCheckForPreviewUpdates() const noexcept; diff --git a/src/Magpie.App/AboutViewModel.idl b/src/Magpie.App/AboutViewModel.idl index 322f8d0e4..cadd86678 100644 --- a/src/Magpie.App/AboutViewModel.idl +++ b/src/Magpie.App/AboutViewModel.idl @@ -6,6 +6,8 @@ namespace Magpie.App { String Version { get; }; + Boolean IsDeveloperMode; + void CheckForUpdates(); Boolean IsCheckingForUpdates { get; }; Boolean IsCheckForUpdatesButtonEnabled { get; }; diff --git a/src/Magpie.App/AppSettings.cpp b/src/Magpie.App/AppSettings.cpp index ae84bbdcd..5161c84af 100644 --- a/src/Magpie.App/AppSettings.cpp +++ b/src/Magpie.App/AppSettings.cpp @@ -397,6 +397,20 @@ void AppSettings::CountdownSeconds(uint32_t value) noexcept { SaveAsync(); } +void AppSettings::IsDeveloperMode(bool value) noexcept { + _isDeveloperMode = value; + if (!value) { + // 关闭开发者模式则禁用所有开发者选项 + _isDebugMode = false; + _isDisableEffectCache = false; + _isDisableFontCache = false; + _isSaveEffectSources = false; + _isWarningsAreErrors = false; + } + + SaveAsync(); +} + void AppSettings::IsAlwaysRunAsAdmin(bool value) noexcept { if (_isAlwaysRunAsAdmin == value) { return; diff --git a/src/Magpie.App/AppSettings.h b/src/Magpie.App/AppSettings.h index 9a6f13e9d..9582d0532 100644 --- a/src/Magpie.App/AppSettings.h +++ b/src/Magpie.App/AppSettings.h @@ -190,10 +190,7 @@ class AppSettings : private _AppSettingsData { return _isDeveloperMode; } - void IsDeveloperMode(bool value) noexcept { - _isDeveloperMode = value; - SaveAsync(); - } + void IsDeveloperMode(bool value) noexcept; bool IsDebugMode() const noexcept { return _isDebugMode; diff --git a/src/Magpie.App/SettingsPage.xaml b/src/Magpie.App/SettingsPage.xaml index 4e297ed79..8a7eb79fe 100644 --- a/src/Magpie.App/SettingsPage.xaml +++ b/src/Magpie.App/SettingsPage.xaml @@ -145,6 +145,7 @@ From 7cd795661f5b0c46472f0ef2a9222184bc004a72 Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Wed, 1 Nov 2023 00:25:22 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=E5=90=AF=E7=94=A8=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E8=80=85=E6=A8=A1=E5=BC=8F=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Magpie.App/AboutPage.cpp | 1 + src/Magpie.App/AboutPage.xaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/Magpie.App/AboutPage.cpp b/src/Magpie.App/AboutPage.cpp index acdf2f7de..90b4813ce 100644 --- a/src/Magpie.App/AboutPage.cpp +++ b/src/Magpie.App/AboutPage.cpp @@ -10,6 +10,7 @@ namespace winrt::Magpie::App::implementation { void AboutPage::VersionTextBlock_DoubleTapped(IInspectable const&, Input::DoubleTappedRoutedEventArgs const&) { if (!_viewModel.IsDeveloperMode() && (GetAsyncKeyState(VK_MENU) & 0x8000)) { _viewModel.IsDeveloperMode(true); + DeveloperModeTeachingTip().IsOpen(true); } } diff --git a/src/Magpie.App/AboutPage.xaml b/src/Magpie.App/AboutPage.xaml index 226a44c9e..b8e5ca705 100644 --- a/src/Magpie.App/AboutPage.xaml +++ b/src/Magpie.App/AboutPage.xaml @@ -27,6 +27,9 @@ FontSize="{StaticResource SecondaryTextFontSize}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="{x:Bind ViewModel.Version, Mode=OneTime}" /> + From 0d5a9d13f3d615b0eb93221c087c16a6c775b372 Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:17:14 +0800 Subject: [PATCH 4/7] =?UTF-8?q?UI:=20=E4=BC=98=E5=8C=96=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Magpie.App/AboutPage.xaml | 5 +++-- src/Magpie.App/App.xaml | 3 +++ src/Magpie.App/Resources.language-en-US.resw | 3 +++ src/Magpie.App/Resources.language-zh-Hans.resw | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Magpie.App/AboutPage.xaml b/src/Magpie.App/AboutPage.xaml index b8e5ca705..77454260e 100644 --- a/src/Magpie.App/AboutPage.xaml +++ b/src/Magpie.App/AboutPage.xaml @@ -28,8 +28,9 @@ Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="{x:Bind ViewModel.Version, Mode=OneTime}" /> + IsLightDismissEnabled="True"> + + diff --git a/src/Magpie.App/App.xaml b/src/Magpie.App/App.xaml index b8c040b81..e44b313ab 100644 --- a/src/Magpie.App/App.xaml +++ b/src/Magpie.App/App.xaml @@ -669,6 +669,9 @@ 14 + + 0 + 220