Skip to content

armgit / WacOS

Public Imported from GitHub
0

A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.

Rust

Finder: play a sound when moving items to Trash

Eternity070628b736da5524ec
diff --git a/src/finder/main.cpp b/src/finder/main.cpp
index afd26c7..161e83f 100644
--- a/src/finder/main.cpp
+++ b/src/finder/main.cpp
@@ -10,6 +10,8 @@
#include <d2d1effects.h> // Leopard: a perspectiva 3D do Cover Flow
#pragma comment(lib, "dxguid.lib")
#include <windowsx.h>
+#include <mmsystem.h>
+#pragma comment(lib, "winmm.lib")
#include <shlobj.h>
#include <shlwapi.h>
#include <map>
@@ -1697,7 +1699,19 @@ static void RecordTrash(const std::vector<std::wstring>& paths) {
if (GetKeyState(VK_SHIFT) < 0) return; // permanente
UndoOp op{ UndoOp::Trash };
for (auto& p : paths) if (GetFileAttributesW(p.c_str()) == INVALID_FILE_ATTRIBUTES) op.items.push_back({ p, L"" });
- if (!op.items.empty()) PushUndo(std::move(op));
+ if (op.items.empty()) return;
+ PushUndo(std::move(op));
+
+ wchar_t exe[MAX_PATH]{};
+ ExePath(exe, MAX_PATH);
+ std::wstring path = exe;
+ const auto bin = path.find_last_of(L'\\');
+ if (bin == std::wstring::npos || bin == 0) return;
+ const auto root = path.find_last_of(L'\\', bin - 1);
+ if (root == std::wstring::npos) return;
+ path.resize(root);
+ path += L"\\sons\\mac\\move_to_trash.wav";
+ PlaySoundW(path.c_str(), nullptr, SND_FILENAME | SND_ASYNC | SND_NODEFAULT);
}
static std::wstring LowerPath(std::wstring s) { for (auto& c : s) c = towlower(c); return s; }