Move some functions into Utils::OS namespace

Also remove `Utils::Misc::getUserIDString()` since there are no use of
it.
This commit is contained in:
Chocobo1
2023-10-29 22:16:09 +08:00
parent f20f009b78
commit 794cce38f3
9 changed files with 277 additions and 288 deletions

View File

@@ -32,12 +32,41 @@
#include <QtSystemDetection>
#ifdef Q_OS_WIN
#include <string>
#include <windows.h>
#include <QString>
#endif
#include "base/path.h"
enum class ShutdownDialogAction;
namespace Utils::OS
{
void shutdownComputer(const ShutdownDialogAction &action);
#ifdef Q_OS_MACOS
bool isTorrentFileAssocSet();
void setTorrentFileAssoc();
bool isMagnetLinkAssocSet();
void setMagnetLinkAssoc();
#endif // Q_OS_MACOS
#ifdef Q_OS_WIN
Path windowsSystemPath();
template <typename T>
T loadWinAPI(const QString &source, const char *funcName)
{
const std::wstring path = (windowsSystemPath() / Path(source)).toString().toStdWString();
return reinterpret_cast<T>(::GetProcAddress(::LoadLibraryW(path.c_str()), funcName));
}
#endif // Q_OS_WIN
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
bool applyMarkOfTheWeb(const Path &file, const QString &url = {});
#endif // Q_OS_MACOS || Q_OS_WIN
}