diff --git a/CHANGELOG.md b/CHANGELOG.md index 5958602a..f5c947c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ - Dev: Emoji style / set is now stored lowercase (and matched case-insensitively). Changing emoji style from this point on and then running an old version might mean you will use the Twitter emoji style by default. (#6300) - Dev: Refactored `OnceFlag`. (#6237, #6316) - Dev: Bumped clang-format requirement to 19. (#6236) +- Dev: Factored out AUMID to `Version`. (#6321) ## 2.5.3 diff --git a/src/common/Version.cpp b/src/common/Version.cpp index 5e23272c..21052dcb 100644 --- a/src/common/Version.cpp +++ b/src/common/Version.cpp @@ -36,6 +36,11 @@ Version::Version() this->generateBuildString(); this->generateRunningString(); + +#ifdef Q_OS_WIN + // keep in sync with .CI/chatterino-installer.iss + this->appUserModelID_ = L"ChatterinoTeam.Chatterino"; +#endif } const Version &Version::instance() @@ -165,4 +170,11 @@ void Version::generateRunningString() this->runningString_ = s; } +#ifdef Q_OS_WIN +const std::wstring &Version::appUserModelID() const +{ + return this->appUserModelID_; +} +#endif + } // namespace chatterino diff --git a/src/common/Version.hpp b/src/common/Version.hpp index 6a43d8bc..a93b27f9 100644 --- a/src/common/Version.hpp +++ b/src/common/Version.hpp @@ -2,6 +2,10 @@ #include +#ifdef Q_OS_WIN +# include +#endif + namespace chatterino { /** @@ -52,6 +56,13 @@ public: // Returns a string about the current running system const QString &runningString() const; +#ifdef Q_OS_WIN + /// Chatterino's App ID on Windows + /// + /// See https://learn.microsoft.com/en-us/windows/win32/shell/appids + const std::wstring &appUserModelID() const; +#endif + private: Version(); @@ -69,6 +80,10 @@ private: QString runningString_; // Generate a running string (e.g. Running on Arch Linux, kernel 5.14.3) and store it in runningString_ for future use void generateRunningString(); + +#ifdef Q_OS_WIN + std::wstring appUserModelID_; +#endif }; }; // namespace chatterino diff --git a/src/main.cpp b/src/main.cpp index 697eb596..2cd96929 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,8 @@ int main(int argc, char **argv) QCoreApplication::setApplicationVersion(CHATTERINO_VERSION); QCoreApplication::setOrganizationDomain("chatterino.com"); #ifdef Q_OS_WIN - SetCurrentProcessExplicitAppUserModelID(L"ChatterinoTeam.Chatterino"); + SetCurrentProcessExplicitAppUserModelID( + Version::instance().appUserModelID().c_str()); #endif std::unique_ptr paths; diff --git a/src/singletons/Toasts.cpp b/src/singletons/Toasts.cpp index 945bcee1..49065d41 100644 --- a/src/singletons/Toasts.cpp +++ b/src/singletons/Toasts.cpp @@ -285,8 +285,7 @@ void Toasts::ensureInitialized() auto *instance = WinToast::instance(); instance->setAppName(L"Chatterino"); - instance->setAppUserModelId( - WinToast::configureAUMI(L"ChatterinoTeam", L"Chatterino", L"", L"")); + instance->setAppUserModelId(Version::instance().appUserModelID()); if (!getSettings()->createShortcutForToasts) { instance->setShortcutPolicy(WinToast::SHORTCUT_POLICY_IGNORE);