fix: special shortcut for Windows live notifications (#5975)

This commit is contained in:
8thony
2025-03-09 15:48:26 +01:00
committed by GitHub
parent 81ef344fad
commit ffe28b88a4
10 changed files with 48 additions and 8 deletions
+4
View File
@@ -24,6 +24,10 @@ Modes::Modes()
{
this->isPortable = true;
}
else if (line == "externally-packaged")
{
this->isExternallyPackaged = true;
}
}
}
+6
View File
@@ -11,6 +11,12 @@ public:
bool isNightly{};
bool isPortable{};
/// Marked by the line `externally-packaged`
///
/// The externally packaged mode comes with the following changes:
/// - No shortcuts are created by default
bool isExternallyPackaged{};
};
} // namespace chatterino
+6
View File
@@ -24,6 +24,9 @@
#include <QMessageBox>
#include <QSslSocket>
#include <QStringList>
#ifdef Q_OS_WIN
# include <shobjidl_core.h>
#endif
#include <memory>
@@ -36,6 +39,9 @@ int main(int argc, char **argv)
QCoreApplication::setApplicationName("chatterino");
QCoreApplication::setApplicationVersion(CHATTERINO_VERSION);
QCoreApplication::setOrganizationDomain("chatterino.com");
#ifdef Q_OS_WIN
SetCurrentProcessExplicitAppUserModelID(L"ChatterinoTeam.Chatterino");
#endif
std::unique_ptr<Paths> paths;
+7
View File
@@ -3,6 +3,7 @@
#include "common/Channel.hpp"
#include "common/ChatterinoSetting.hpp"
#include "common/enums/MessageOverflow.hpp"
#include "common/Modes.hpp"
#include "common/SignalVector.hpp"
#include "controllers/filters/FilterRecord.hpp"
#include "controllers/highlights/HighlightBadge.hpp"
@@ -553,6 +554,12 @@ public:
"/notifications/suppressInitialLive", false};
BoolSetting notificationToast = {"/notifications/enableToast", false};
BoolSetting createShortcutForToasts = {
"/notifications/createShortcutForToasts",
(Modes::instance().isPortable || Modes::instance().isExternallyPackaged)
? false
: true,
};
IntSetting openFromToast = {"/notifications/openFromToast",
static_cast<int>(ToastReaction::OpenInBrowser)};
+6 -4
View File
@@ -284,11 +284,13 @@ void Toasts::ensureInitialized()
this->initialized_ = true;
auto *instance = WinToast::instance();
instance->setAppName(L"Chatterino2");
instance->setAppName(L"Chatterino");
instance->setAppUserModelId(
WinToast::configureAUMI(L"", L"Chatterino 2", L"",
Version::instance().version().toStdWString()));
instance->setShortcutPolicy(WinToast::SHORTCUT_POLICY_IGNORE);
WinToast::configureAUMI(L"ChatterinoTeam", L"Chatterino", L"", L""));
if (!getSettings()->createShortcutForToasts)
{
instance->setShortcutPolicy(WinToast::SHORTCUT_POLICY_IGNORE);
}
WinToast::WinToastError error{};
instance->initialize(&error);
@@ -49,6 +49,16 @@ NotificationPage::NotificationPage()
#if defined(Q_OS_WIN) || defined(CHATTERINO_WITH_LIBNOTIFY)
settings.append(this->createCheckBox(
"Show notification", getSettings()->notificationToast));
#endif
#ifdef Q_OS_WIN
settings.append(this->createCheckBox(
"Create start menu shortcut (requires "
"restart)",
getSettings()->createShortcutForToasts,
"When enabled, a shortcut will be created inside your "
"start menu folder if needed by live notifications."
"\n(On portable mode, this is disabled by "
"default)"));
auto openIn = settings.emplace<QHBoxLayout>().withoutMargin();
{
+3 -1
View File
@@ -88,9 +88,11 @@ void SettingsPage::setTab(SettingsDialogTab *tab)
}
QCheckBox *SettingsPage::createCheckBox(
const QString &text, pajlada::Settings::Setting<bool> &setting)
const QString &text, pajlada::Settings::Setting<bool> &setting,
const QString &toolTipText)
{
QCheckBox *checkbox = new SCheckBox(text);
checkbox->setToolTip(toolTipText);
// update when setting changes
setting.connect(
+2 -1
View File
@@ -57,7 +57,8 @@ public:
void setTab(SettingsDialogTab *tab);
QCheckBox *createCheckBox(const QString &text,
pajlada::Settings::Setting<bool> &setting);
pajlada::Settings::Setting<bool> &setting,
const QString &toolTipText = {});
QComboBox *createComboBox(const QStringList &items,
pajlada::Settings::Setting<QString> &setting);
QLineEdit *createLineEdit(pajlada::Settings::Setting<QString> &setting);