Skip to content

Commit

Permalink
do not allow toast notifications on wayland - #1494
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Sep 24, 2024
1 parent 8d447e2 commit 2fc8cf1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/librssguard/gui/mediaplayer/libmpv/libmpvwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void LibMpvWidget::initializeGL() {
#endif

#if defined(QT_FEATURE_wayland)
if (QGuiApplication::platformName() == QStringLiteral("wayland")) {
if (qApp->isWayland()) {
display.type = MPV_RENDER_PARAM_WL_DISPLAY;
display.data = qApp->nativeInterface<QNativeInterface::QWaylandApplication>()->display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BaseToastNotification::BaseToastNotification(QWidget* parent) : QDialog(parent),
setAttribute(Qt::WidgetAttribute::WA_DeleteOnClose, false);

setWindowFlags(
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC)
Qt::WindowType::SubWindow |
#else
Qt::WindowType::Tool |
Expand Down
14 changes: 12 additions & 2 deletions src/librssguard/gui/settings/settingsnotifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ void SettingsNotifications::loadSettings() {
->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool());
m_ui.m_editor->loadNotifications(qApp->notifications()->allNotifications());

m_ui.m_rbNativeNotifications
->setChecked(!settings()->value(GROUP(GUI), SETTING(GUI::UseToastNotifications)).toBool());
if (qApp->isWayland()) {
// Wayland does not support fancy notifications, only system ones.
m_ui.m_rbNativeNotifications->setChecked(true);
m_ui.m_rbCustomNotifications->setEnabled(false);
m_ui.m_rbCustomNotifications
->setText(tr("%1 (not supported on Wayland)").arg(m_ui.m_rbCustomNotifications->text()));
}
else {
m_ui.m_rbNativeNotifications
->setChecked(!settings()->value(GROUP(GUI), SETTING(GUI::UseToastNotifications)).toBool());
}

m_ui.m_sbScreen->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsScreen)).toInt());
m_ui.m_sbWidth->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt());
m_ui.m_sbMargin->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsMargin)).toInt());
Expand Down
10 changes: 7 additions & 3 deletions src/librssguard/miscellaneous/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
m_database = new DatabaseFactory(this);
m_downloadManager = nullptr;
m_notifications = new NotificationFactory(this);
m_toastNotifications = settings()->value(GROUP(GUI), SETTING(GUI::UseToastNotifications)).toBool()
? new ToastNotificationsManager(this)
: nullptr;
m_toastNotifications =
(!isWayland() && m_notifications->useToastNotifications()) ? new ToastNotificationsManager(this) : nullptr;
m_shouldRestart = false;

#if defined(Q_OS_WIN)
Expand Down Expand Up @@ -301,6 +300,7 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin

setupWorkHorsePool();

qDebugNN << LOGSEC_CORE << "Platform:" << QUOTE_W_SPACE_DOT(QGuiApplication::platformName());
qDebugNN << LOGSEC_CORE << "SQLite version:" << QUOTE_W_SPACE_DOT(SQLITE_VERSION);
qDebugNN << LOGSEC_CORE << "OpenSSL version:" << QUOTE_W_SPACE_DOT(QSslSocket::sslLibraryVersionString());
qDebugNN << LOGSEC_CORE << "OpenSSL supported:" << QUOTE_W_SPACE_DOT(QSslSocket::supportsSsl());
Expand Down Expand Up @@ -867,6 +867,10 @@ bool Application::usingLite() const {
#endif
}

bool Application::isWayland() const {
return QGuiApplication::platformName() == QSL("wayland");
}

void Application::onCommitData(QSessionManager& manager) {
qDebugNN << LOGSEC_CORE << "OS asked application to commit its data.";

Expand Down
1 change: 1 addition & 0 deletions src/librssguard/miscellaneous/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
WebViewer* createWebView();

bool usingLite() const;
bool isWayland() const;

#if defined(NO_LITE)
bool forcedLite() const;
Expand Down
2 changes: 1 addition & 1 deletion src/librssguard/miscellaneous/notificationfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bool NotificationFactory::areNotificationsEnabled() const {
}

bool NotificationFactory::useToastNotifications() const {
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool();
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::UseToastNotifications)).toBool();
}

Notification NotificationFactory::notificationForEvent(Notification::Event event) const {
Expand Down

0 comments on commit 2fc8cf1

Please sign in to comment.