Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Jun 23, 2024
1 parent a6b4fa9 commit 0954167
Show file tree
Hide file tree
Showing 20 changed files with 2 additions and 2,731 deletions.
23 changes: 1 addition & 22 deletions src/Magpie.App/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@
#endif
#include "Win32Utils.h"
#include "Logger.h"
#include "ShortcutService.h"
#include "AppSettings.h"
#include "CommonSharedConstants.h"
#include "ScalingService.h"
#include <CoreWindow.h>
#include <Magpie.Core.h>
#include "EffectsService.h"
#include "UpdateService.h"
#include "LocalizationService.h"
#include "Logger.h"

namespace winrt::Magpie::App::implementation {
Expand All @@ -44,8 +39,6 @@ App::App() {
}
});

EffectsService::Get().StartInitialize();

// 初始化 XAML 框架
_windowsXamlManager = Hosting::WindowsXamlManager::InitializeForCurrentThread();

Expand All @@ -58,8 +51,6 @@ App::App() {
ShowWindow(hwndDWXS, SW_HIDE);
}
}

LocalizationService::Get().EarlyInitialize();
}

App::~App() {
Expand Down Expand Up @@ -97,19 +88,10 @@ StartUpOptions App::Initialize(int) {
result.IsWndMaximized= settings.IsWindowMaximized();
result.IsNeedElevated = settings.IsAlwaysRunAsAdmin();

LocalizationService::Get().Initialize();
ShortcutService::Get().Initialize();
ScalingService::Get().Initialize();
UpdateService::Get().Initialize();

return result;
}

void App::Uninitialize() {
ScalingService::Get().Uninitialize();
// 不显示托盘图标的情况下关闭主窗口仍会在后台驻留数秒,推测和 XAML Islands 有关
// 这里提前取消热键注册,这样关闭 Magpie 后立即重新打开不会注册热键失败
ShortcutService::Get().Uninitialize();
}

bool App::IsShowNotifyIcon() const noexcept {
Expand All @@ -127,15 +109,12 @@ void App::IsShowNotifyIconChanged(event_token const& token) {
}

void App::RootPage(Magpie::App::RootPage const& rootPage) noexcept {
// 显示主窗口前等待 EffectsService 完成初始化
EffectsService::Get().WaitForInitialize();

if (rootPage) {
// 不存储对 RootPage 的强引用
// XAML Islands 内部保留着对 RootPage 的强引用,RootPage 的生命周期是无法预知的
_rootPage = weak_ref(rootPage);
} else {
UpdateService::Get().ClosingMainWindow();

}
}

Expand Down
9 changes: 0 additions & 9 deletions src/Magpie.App/App.idl
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
namespace Magpie.App {
delegate void SignalDelegate();
}

#include "BoolNegationConverter.idl"
#include "BoolToNegativeVisibilityConverter.idl"
#include "SettingsExpanderCornerRadiusConverter.idl"
#include "ControlSizeTrigger.idl"
#include "IsEqualStateTrigger.idl"
#include "IsNullStateTrigger.idl"
#include "LoggerHelper.idl"
#include "RootPage.idl"

Expand Down
23 changes: 0 additions & 23 deletions src/Magpie.App/AppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
#include <rapidjson/prettywriter.h>
#include "AutoStartHelper.h"
#include <Magpie.Core.h>
#include "ScalingModesService.h"
#include "JsonHelper.h"
#include "ScalingMode.h"
#include "LocalizationService.h"
#include <ShellScalingApi.h>

#pragma comment(lib, "Shcore.lib")
Expand Down Expand Up @@ -472,8 +470,6 @@ bool AppSettings::_Save(const _AppSettingsData& data) noexcept {
if (_language < 0) {
writer.String("");
} else {
const wchar_t* language = LocalizationService::SupportedLanguages()[_language];
writer.String(StrUtils::UTF16ToUTF8(language).c_str());
}

writer.Key("theme");
Expand Down Expand Up @@ -538,8 +534,6 @@ bool AppSettings::_Save(const _AppSettingsData& data) noexcept {
writer.Key("enableStatisticsForDynamicDetection");
writer.Bool(data._isStatisticsForDynamicDetectionEnabled);

ScalingModesService::Get().Export(writer);

writer.Key("profiles");
writer.StartArray();
WriteProfile(writer, data._defaultProfile);
Expand All @@ -563,21 +557,6 @@ bool AppSettings::_Save(const _AppSettingsData& data) noexcept {
// 永远不会失败,遇到不合法的配置项时静默忽略
void AppSettings::_LoadSettings(const rapidjson::GenericObject<true, rapidjson::Value>& root) noexcept {
{
std::wstring language;
JsonHelper::ReadString(root, "language", language);
if (language.empty()) {
_language = -1;
} else {
StrUtils::ToLowerCase(language);
std::span<const wchar_t*> languages = LocalizationService::SupportedLanguages();
auto it = std::find(languages.begin(), languages.end(), language);
if (it == languages.end()) {
// 未知的语言设置,重置为使用系统设置
_language = -1;
} else {
_language = int(it - languages.begin());
}
}
}

{
Expand Down Expand Up @@ -700,8 +679,6 @@ void AppSettings::_LoadSettings(const rapidjson::GenericObject<true, rapidjson::
}
JsonHelper::ReadBool(root, "enableStatisticsForDynamicDetection", _isStatisticsForDynamicDetectionEnabled);

[[maybe_unused]] bool result = ScalingModesService::Get().Import(root, true);
assert(result);

auto scaleProfilesNode = root.FindMember("profiles");
if (scaleProfilesNode == root.MemberEnd()) {
Expand Down
106 changes: 0 additions & 106 deletions src/Magpie.App/EffectsService.cpp

This file was deleted.

59 changes: 0 additions & 59 deletions src/Magpie.App/EffectsService.h

This file was deleted.

84 changes: 0 additions & 84 deletions src/Magpie.App/LocalizationService.cpp

This file was deleted.

Loading

0 comments on commit 0954167

Please sign in to comment.