do not allow toast notifications on wayland - #1494

This commit is contained in:
Martin Rotter 2024-09-24 07:43:59 +02:00
parent 8d447e2ff8
commit 2fc8cf1e25
6 changed files with 23 additions and 8 deletions

View File

@ -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();
}

View File

@ -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 |

View File

@ -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());

View File

@ -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)
@ -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());
@ -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.";

View File

@ -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;

View File

@ -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 {