Skip to content

Commit 2679a06

Browse files
committed
✨ Support removing the "OpenKneeboard Logs" folder
Fixes #5
1 parent a22725d commit 2679a06

5 files changed

Lines changed: 82 additions & 0 deletions

File tree

src/Artifact.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Artifact {
1111
enum class Kind {
1212
Software,
1313
UserSettings,
14+
Logs,
1415
};
1516
virtual ~Artifact() = default;
1617

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ add_executable(
5050
artifacts/ProgramData.hpp
5151
artifacts/SavedGamesSettings.cpp
5252
artifacts/SavedGamesSettings.hpp
53+
artifacts/LogsFolder.cpp
54+
artifacts/LogsFolder.hpp
5355
)
5456
set_target_properties(
5557
main

src/artifacts/LogsFolder.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2025 Fred Emmott <fred@fredemmott.com>
2+
// SPDX-License-Identifier: MIT
3+
#include "LogsFolder.hpp"
4+
5+
#include <Windows.h>
6+
#include <shlobj_core.h>
7+
#include <wil/resource.h>
8+
9+
#include <FredEmmott/GUI.hpp>
10+
#include <memory>
11+
12+
#include "Versions.hpp"
13+
14+
namespace {
15+
std::filesystem::path GetPathForConstructor() {
16+
wil::unique_hlocal_string path;
17+
if (FAILED(SHGetKnownFolderPath(
18+
FOLDERID_LocalAppData, 0, nullptr, std::out_ptr(path)))) {
19+
return {};
20+
}
21+
const auto ret
22+
= std::filesystem::path {std::wstring_view {path.get()}} / L"OpenKneeboard Logs";
23+
if (!std::filesystem::exists(ret)) {
24+
return {};
25+
}
26+
return ret;
27+
}
28+
}// namespace
29+
30+
LogsFolder::LogsFolder()
31+
: FilesystemArtifact(GetPathForConstructor()) {}
32+
33+
std::string_view LogsFolder::GetTitle() const {
34+
return "Logs in Local App Data";
35+
}
36+
37+
void LogsFolder::DrawCardContent() const {
38+
namespace fuii = FredEmmott::GUI::Immediate;
39+
fuii::Label("Found in {}", GetPath().string());
40+
}
41+
42+
Version LogsFolder::GetEarliestVersion() const {
43+
return Versions::v1_10;
44+
}
45+
46+
std::optional<Version> LogsFolder::GetRemovedVersion() const {
47+
return std::nullopt;
48+
}
49+
Artifact::Kind LogsFolder::GetKind() const {
50+
return Kind::Logs;
51+
}

src/artifacts/LogsFolder.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2025 Fred Emmott <fred@fredemmott.com>
2+
// SPDX-License-Identifier: MIT
3+
#pragma once
4+
5+
#include <filesystem>
6+
7+
#include "Artifact.hpp"
8+
#include "FilesystemArtifact.hpp"
9+
10+
class LogsFolder final : public FilesystemArtifact {
11+
public:
12+
LogsFolder();
13+
~LogsFolder() override = default;
14+
[[nodiscard]] std::string_view GetTitle() const override;
15+
void DrawCardContent() const override;
16+
[[nodiscard]] Version GetEarliestVersion() const override;
17+
[[nodiscard]] std::optional<Version> GetRemovedVersion() const override;
18+
Kind GetKind() const override;
19+
20+
private:
21+
std::filesystem::path mPath;
22+
};

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "artifacts/MSIInstallation.hpp"
1818
#include "artifacts/MSIXInstallation.hpp"
1919
#include "artifacts/MultipleMSIInstallations.hpp"
20+
#include "artifacts/LogsFolder.hpp"
2021
#include "artifacts/ProgramData.hpp"
2122
#include "artifacts/SavedGamesSettings.hpp"
2223
#include "config.hpp"
@@ -159,6 +160,7 @@ auto& GetArtifacts() {
159160
std::make_unique<DCSHooks>(),
160161
std::make_unique<SavedGamesSettings>(),
161162
std::make_unique<LocalAppDataSettings>(),
163+
std::make_unique<LogsFolder>(),
162164
};
163165
for (auto&& it: artifacts) {
164166
if (!it->IsPresent()) {
@@ -180,6 +182,10 @@ void ShowArtifact(ArtifactState& artifact) {
180182
break;
181183
case Artifact::Kind::UserSettings:
182184
icon = "\uEF58";// PlayerSettings
185+
break;
186+
case Artifact::Kind::Logs:
187+
icon = "\uE9A4";// TextBulletListSquare
188+
break;
183189
}
184190
FontIcon(icon, SystemFont::Subtitle)
185191
.Styled(Style().AlignSelf(YGAlignFlexStart));

0 commit comments

Comments
 (0)