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