Disable OSD Pretty on Wayland
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
@@ -80,22 +81,48 @@ void OSDBase::ReloadSettings() {
|
|||||||
custom_text2_ = s.value("CustomText2").toString();
|
custom_text2_ = s.value("CustomText2").toString();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
if (!IsTypeSupported(type_)) {
|
||||||
if (!SupportsNativeNotifications() && !SupportsTrayPopups() && type_ == OSDSettings::Type::Native) {
|
type_ = GetSupportedType();
|
||||||
#else
|
|
||||||
if (!SupportsNativeNotifications() && type_ == OSDSettings::Type::Native) {
|
|
||||||
#endif
|
|
||||||
type_ = OSDSettings::Type::Pretty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SupportsTrayPopups() && type_ == OSDSettings::Type::TrayPopup) {
|
|
||||||
type_ = OSDSettings::Type::Disabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReloadPrettyOSDSettings();
|
ReloadPrettyOSDSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSDSettings::Type OSDBase::GetSupportedType() const {
|
||||||
|
|
||||||
|
if (SupportsNativeNotifications()) {
|
||||||
|
return OSDSettings::Type::Native;
|
||||||
|
}
|
||||||
|
if (SupportsOSDPretty()) {
|
||||||
|
return OSDSettings::Type::Pretty;
|
||||||
|
}
|
||||||
|
if (SupportsTrayPopups()) {
|
||||||
|
return OSDSettings::Type::TrayPopup;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OSDSettings::Type::Disabled;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OSDBase::IsTypeSupported(const OSDSettings::Type type) const {
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case OSDSettings::Type::Native:
|
||||||
|
return SupportsNativeNotifications();
|
||||||
|
case OSDSettings::Type::TrayPopup:
|
||||||
|
return SupportsTrayPopups();
|
||||||
|
case OSDSettings::Type::Pretty:
|
||||||
|
return SupportsOSDPretty();
|
||||||
|
break;
|
||||||
|
case OSDSettings::Type::Disabled:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Reload just Pretty OSD settings, not everything
|
// Reload just Pretty OSD settings, not everything
|
||||||
void OSDBase::ReloadPrettyOSDSettings() {
|
void OSDBase::ReloadPrettyOSDSettings() {
|
||||||
|
|
||||||
@@ -432,14 +459,24 @@ void OSDBase::SetPrettyOSDToggleMode(const bool toggle) {
|
|||||||
pretty_popup_->set_toggle_mode(toggle);
|
pretty_popup_->set_toggle_mode(toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSDBase::SupportsNativeNotifications() {
|
bool OSDBase::SupportsNativeNotifications() const {
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
return SupportsTrayPopups();
|
||||||
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSDBase::SupportsTrayPopups() {
|
bool OSDBase::SupportsTrayPopups() const {
|
||||||
return tray_icon_->IsSystemTrayAvailable();
|
return tray_icon_->IsSystemTrayAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OSDBase::SupportsOSDPretty() {
|
||||||
|
return QGuiApplication::platformName() != "wayland"_L1;
|
||||||
|
}
|
||||||
|
|
||||||
void OSDBase::ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
|
void OSDBase::ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
|
||||||
|
|
||||||
Q_UNUSED(summary)
|
Q_UNUSED(summary)
|
||||||
|
|||||||
@@ -50,8 +50,11 @@ class OSDBase : public QObject {
|
|||||||
void ReloadPrettyOSDSettings();
|
void ReloadPrettyOSDSettings();
|
||||||
void SetPrettyOSDToggleMode(bool toggle);
|
void SetPrettyOSDToggleMode(bool toggle);
|
||||||
|
|
||||||
virtual bool SupportsNativeNotifications();
|
OSDSettings::Type GetSupportedType() const;
|
||||||
virtual bool SupportsTrayPopups();
|
bool IsTypeSupported(const OSDSettings::Type type) const;
|
||||||
|
virtual bool SupportsNativeNotifications() const;
|
||||||
|
virtual bool SupportsTrayPopups() const;
|
||||||
|
static bool SupportsOSDPretty();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ void OSDDBus::Init() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSDDBus::SupportsNativeNotifications() { return true; }
|
bool OSDDBus::SupportsNativeNotifications() const { return true; }
|
||||||
|
|
||||||
bool OSDDBus::SupportsTrayPopups() { return true; }
|
bool OSDDBus::SupportsTrayPopups() const { return true; }
|
||||||
|
|
||||||
void OSDDBus::ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
|
void OSDDBus::ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class OSDDBus : public OSDBase {
|
|||||||
|
|
||||||
static const char *kSettingsGroup;
|
static const char *kSettingsGroup;
|
||||||
|
|
||||||
bool SupportsNativeNotifications() override;
|
bool SupportsNativeNotifications() const override;
|
||||||
bool SupportsTrayPopups() override;
|
bool SupportsTrayPopups() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class OSDMac : public OSDBase {
|
|||||||
explicit OSDMac(const SharedPtr<SystemTrayIcon> tray_icon, QObject *parent = nullptr);
|
explicit OSDMac(const SharedPtr<SystemTrayIcon> tray_icon, QObject *parent = nullptr);
|
||||||
~OSDMac() override;
|
~OSDMac() override;
|
||||||
|
|
||||||
bool SupportsNativeNotifications() override;
|
bool SupportsNativeNotifications() const override;
|
||||||
bool SupportsTrayPopups() override;
|
bool SupportsTrayPopups() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) override;
|
void ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) override;
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ OSDMac::OSDMac(const SharedPtr<SystemTrayIcon> tray_icon, QObject *parent) : OSD
|
|||||||
|
|
||||||
OSDMac::~OSDMac() = default;
|
OSDMac::~OSDMac() = default;
|
||||||
|
|
||||||
bool OSDMac::SupportsNativeNotifications() {
|
bool OSDMac::SupportsNativeNotifications() const {
|
||||||
return NotificationCenterSupported();
|
return NotificationCenterSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSDMac::SupportsTrayPopups() { return false; }
|
bool OSDMac::SupportsTrayPopups() const { return false; }
|
||||||
|
|
||||||
void OSDMac::ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
|
void OSDMac::ShowMessageNative(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
|
||||||
|
|
||||||
|
|||||||
@@ -115,18 +115,9 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, OSD
|
|||||||
QObject::connect(ui_->notifications_exp_chooser2, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableSecondLine);
|
QObject::connect(ui_->notifications_exp_chooser2, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableSecondLine);
|
||||||
QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled);
|
QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
ui_->notifications_native->setEnabled(osd_->SupportsNativeNotifications());
|
||||||
if (!osd_->SupportsNativeNotifications() && !osd_->SupportsTrayPopups()) {
|
ui_->notifications_tray->setEnabled(osd_->SupportsTrayPopups());
|
||||||
ui_->notifications_native->setEnabled(false);
|
ui_->notifications_pretty->setEnabled(osd_->SupportsOSDPretty());
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (!osd_->SupportsNativeNotifications()) {
|
|
||||||
ui_->notifications_native->setEnabled(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!osd_->SupportsTrayPopups()) {
|
|
||||||
ui_->notifications_tray->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::UpdatePopupVisible);
|
QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::UpdatePopupVisible);
|
||||||
|
|
||||||
@@ -161,30 +152,20 @@ void NotificationsSettingsPage::Load() {
|
|||||||
Settings s;
|
Settings s;
|
||||||
|
|
||||||
s.beginGroup(OSDSettings::kSettingsGroup);
|
s.beginGroup(OSDSettings::kSettingsGroup);
|
||||||
const OSDSettings::Type osd_type = static_cast<OSDSettings::Type>(s.value(OSDSettings::kType, static_cast<int>(OSDSettings::Type::Native)).toInt());
|
OSDSettings::Type osd_type = static_cast<OSDSettings::Type>(s.value(OSDSettings::kType, static_cast<int>(OSDSettings::Type::Native)).toInt());
|
||||||
|
if (!osd_->IsTypeSupported(osd_type)) {
|
||||||
|
osd_type = osd_->GetSupportedType();
|
||||||
|
}
|
||||||
switch (osd_type) {
|
switch (osd_type) {
|
||||||
case OSDSettings::Type::Native:
|
case OSDSettings::Type::Native:
|
||||||
#ifdef Q_OS_WIN32
|
ui_->notifications_native->setChecked(true);
|
||||||
if (osd_->SupportsNativeNotifications() || osd_->SupportsTrayPopups()) {
|
break;
|
||||||
#else
|
|
||||||
if (osd_->SupportsNativeNotifications()) {
|
|
||||||
#endif
|
|
||||||
ui_->notifications_native->setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Fallthrough
|
|
||||||
|
|
||||||
case OSDSettings::Type::Pretty:
|
case OSDSettings::Type::Pretty:
|
||||||
ui_->notifications_pretty->setChecked(true);
|
ui_->notifications_pretty->setChecked(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSDSettings::Type::TrayPopup:
|
case OSDSettings::Type::TrayPopup:
|
||||||
if (osd_->SupportsTrayPopups()) {
|
ui_->notifications_tray->setChecked(true);
|
||||||
ui_->notifications_tray->setChecked(true);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Fallthrough
|
|
||||||
|
|
||||||
case OSDSettings::Type::Disabled:
|
case OSDSettings::Type::Disabled:
|
||||||
default:
|
default:
|
||||||
ui_->notifications_none->setChecked(true);
|
ui_->notifications_none->setChecked(true);
|
||||||
@@ -238,9 +219,9 @@ void NotificationsSettingsPage::Save() {
|
|||||||
|
|
||||||
OSDSettings::Type osd_type = OSDSettings::Type::Disabled;
|
OSDSettings::Type osd_type = OSDSettings::Type::Disabled;
|
||||||
if (ui_->notifications_none->isChecked()) osd_type = OSDSettings::Type::Disabled;
|
if (ui_->notifications_none->isChecked()) osd_type = OSDSettings::Type::Disabled;
|
||||||
else if (ui_->notifications_native->isChecked()) osd_type = OSDSettings::Type::Native;
|
else if (osd_->SupportsNativeNotifications() && ui_->notifications_native->isChecked()) osd_type = OSDSettings::Type::Native;
|
||||||
else if (ui_->notifications_tray->isChecked()) osd_type = OSDSettings::Type::TrayPopup;
|
else if (osd_->SupportsTrayPopups() && ui_->notifications_tray->isChecked()) osd_type = OSDSettings::Type::TrayPopup;
|
||||||
else if (ui_->notifications_pretty->isChecked()) osd_type = OSDSettings::Type::Pretty;
|
else if (osd_->SupportsOSDPretty() && ui_->notifications_pretty->isChecked()) osd_type = OSDSettings::Type::Pretty;
|
||||||
|
|
||||||
s.beginGroup(OSDSettings::kSettingsGroup);
|
s.beginGroup(OSDSettings::kSettingsGroup);
|
||||||
s.setValue(OSDSettings::kType, static_cast<int>(osd_type));
|
s.setValue(OSDSettings::kType, static_cast<int>(osd_type));
|
||||||
|
|||||||
Reference in New Issue
Block a user