[win] cnotification: adaptation for portable version

This commit is contained in:
SimplestStudio
2025-07-03 14:21:40 +03:00
parent 2165730628
commit d49f9c45eb

View File

@ -269,18 +269,22 @@ bool CNotification::init()
}
WinToast::instance()->setAppName(TEXT(WINDOW_TITLE));
WinToast::instance()->setAppUserModelId(TEXT(APP_USER_MODEL_ID));
WinToast::instance()->setShortcutPolicy(WinToastLib::WinToast::SHORTCUT_POLICY_REQUIRE_NO_CREATE);
PWSTR progPath = nullptr;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_CommonPrograms, 0, nullptr, &progPath))) {
std::wstring shortcutPath(progPath);
shortcutPath.append(L"\\");
shortcutPath.append(TEXT(APP_REG_NAME));
shortcutPath.append(TEXT(APP_SHORTCUT_NAME));
WinToast::instance()->setShortcutPath(shortcutPath);
if (IsPackage(Portable)) {
WinToast::instance()->setShortcutPolicy(WinToastLib::WinToast::SHORTCUT_POLICY_REQUIRE_CREATE);
const QString shortcutTarget = qApp->applicationDirPath() + APP_LAUNCH_NAME;
WinToast::instance()->setShortcutTarget(QDir::toNativeSeparators(shortcutTarget).toStdWString());
} else {
WinToast::instance()->setShortcutPolicy(WinToastLib::WinToast::SHORTCUT_POLICY_REQUIRE_NO_CREATE);
PWSTR progPath = nullptr;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_CommonPrograms, 0, nullptr, &progPath))) {
std::wstring shortcutPath(progPath);
shortcutPath.append(L"\\");
shortcutPath.append(TEXT(APP_REG_NAME));
shortcutPath.append(TEXT(APP_SHORTCUT_NAME));
WinToast::instance()->setShortcutPath(shortcutPath);
}
CoTaskMemFree(progPath);
}
CoTaskMemFree(progPath);
const QString shortcutTarget = qApp->applicationDirPath() + APP_LAUNCH_NAME;
WinToast::instance()->setShortcutTarget(QDir::toNativeSeparators(shortcutTarget).toStdWString());
pimpl->isInit = WinToast::instance()->initialize();
#endif
return pimpl->isInit;