diff --git a/libnotificationmanager/settings.cpp b/libnotificationmanager/settings.cpp index 70d70b70f..087dca101 100644 --- a/libnotificationmanager/settings.cpp +++ b/libnotificationmanager/settings.cpp @@ -1,616 +1,619 @@ /* * Copyright 2019 Kai Uwe Broulik * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "settings.h" #include #include #include #include "server.h" #include "mirroredscreenstracker_p.h" #include "debug.h" // Settings #include "donotdisturbsettings.h" #include "notificationsettings.h" #include "jobsettings.h" #include "badgesettings.h" +namespace NotificationManager +{ +constexpr const char s_configFile[] = "plasmanotifyrc"; +} + using namespace NotificationManager; class Q_DECL_HIDDEN Settings::Private { public: explicit Private(Settings *q); ~Private(); void setDirty(bool dirty); Settings::NotificationBehaviors groupBehavior(const KConfigGroup &group) const; void setGroupBehavior(KConfigGroup &group, const Settings::NotificationBehaviors &behavior); KConfigGroup servicesGroup() const; KConfigGroup applicationsGroup() const; QStringList behaviorMatchesList(const KConfigGroup &group, Settings::NotificationBehavior behavior, bool on) const; Settings *q; KSharedConfig::Ptr config; KConfigWatcher::Ptr watcher; QMetaObject::Connection watcherConnection; MirroredScreensTracker::Ptr mirroredScreensTracker; DoNotDisturbSettings dndSettings; NotificationSettings notificationSettings; JobSettings jobSettings; BadgeSettings badgeSettings; bool live = false; // set to true initially in constructor bool dirty = false; - }; Settings::Private::Private(Settings *q) : q(q) { } Settings::Private::~Private() = default; void Settings::Private::setDirty(bool dirty) { if (this->dirty != dirty) { this->dirty = dirty; emit q->dirtyChanged(); } } Settings::NotificationBehaviors Settings::Private::groupBehavior(const KConfigGroup &group) const { Settings::NotificationBehaviors behaviors; behaviors.setFlag(Settings::ShowPopups, group.readEntry("ShowPopups", true)); // show popups in dnd mode implies the show popups behaviors.setFlag(Settings::ShowPopupsInDoNotDisturbMode, behaviors.testFlag(Settings::ShowPopups) && group.readEntry("ShowPopupsInDndMode", false)); behaviors.setFlag(Settings::ShowInHistory, group.readEntry("ShowInHistory", true)); behaviors.setFlag(Settings::ShowBadges, group.readEntry("ShowBadges", true)); return behaviors; } void Settings::Private::setGroupBehavior(KConfigGroup &group, const Settings::NotificationBehaviors &behavior) { if (groupBehavior(group) == behavior) { return; } const bool showPopups = behavior.testFlag(Settings::ShowPopups); if (showPopups && !group.hasDefault("ShowPopups")) { group.revertToDefault("ShowPopups", KConfigBase::Notify); } else { group.writeEntry("ShowPopups", showPopups, KConfigBase::Notify); } const bool showPopupsInDndMode = behavior.testFlag(Settings::ShowPopupsInDoNotDisturbMode); if (!showPopupsInDndMode && !group.hasDefault("ShowPopupsInDndMode")) { group.revertToDefault("ShowPopupsInDndMode", KConfigBase::Notify); } else { group.writeEntry("ShowPopupsInDndMode", showPopupsInDndMode, KConfigBase::Notify); } const bool showInHistory = behavior.testFlag(Settings::ShowInHistory); if (showInHistory && !group.hasDefault("ShowInHistory")) { group.revertToDefault("ShowInHistory", KConfig::Notify); } else { group.writeEntry("ShowInHistory", showInHistory, KConfigBase::Notify); } const bool showBadges = behavior.testFlag(Settings::ShowBadges); if (showBadges && !group.hasDefault("ShowBadges")) { group.revertToDefault("ShowBadges", KConfigBase::Notify); } else { group.writeEntry("ShowBadges", showBadges, KConfigBase::Notify); } setDirty(true); } KConfigGroup Settings::Private::servicesGroup() const { return config->group("Services"); } KConfigGroup Settings::Private::applicationsGroup() const { return config->group("Applications"); } QStringList Settings::Private::behaviorMatchesList(const KConfigGroup &group, Settings::NotificationBehavior behavior, bool on) const { QStringList matches; const QStringList apps = group.groupList(); for (const QString &app : apps) { if (groupBehavior(group.group(app)).testFlag(behavior) == on) { matches.append(app); } } return matches; } Settings::Settings(QObject *parent) - // FIXME static thing for config file name - : Settings(KSharedConfig::openConfig(QStringLiteral("plasmanotifyrc")), parent) -{ - -} - -Settings::Settings(const KSharedConfig::Ptr &config, QObject *parent) : QObject(parent) , d(new Private(this)) { - d->config = config; + d->config = KSharedConfig::openConfig(s_configFile); setLive(true); connect(&Server::self(), &Server::inhibitedByApplicationChanged, this, &Settings::notificationsInhibitedByApplicationChanged); connect(&Server::self(), &Server::inhibitionApplicationsChanged, this, &Settings::notificationInhibitionApplicationsChanged); if (d->dndSettings.whenScreensMirrored()) { d->mirroredScreensTracker = MirroredScreensTracker::createTracker(); connect(d->mirroredScreensTracker.data(), &MirroredScreensTracker::screensMirroredChanged, this, &Settings::screensMirroredChanged); } } +Settings::Settings(const KSharedConfig::Ptr &config, QObject *parent) + : Settings(parent) +{ + d->config = config; +} + Settings::~Settings() { d->config->markAsClean(); } Settings::NotificationBehaviors Settings::applicationBehavior(const QString &desktopEntry) const { return d->groupBehavior(d->applicationsGroup().group(desktopEntry)); } void Settings::setApplicationBehavior(const QString &desktopEntry, NotificationBehaviors behaviors) { KConfigGroup group(d->applicationsGroup().group(desktopEntry)); d->setGroupBehavior(group, behaviors); } Settings::NotificationBehaviors Settings::serviceBehavior(const QString ¬ifyRcName) const { return d->groupBehavior(d->servicesGroup().group(notifyRcName)); } void Settings::setServiceBehavior(const QString ¬ifyRcName, NotificationBehaviors behaviors) { KConfigGroup group(d->servicesGroup().group(notifyRcName)); d->setGroupBehavior(group, behaviors); } void Settings::registerKnownApplication(const QString &desktopEntry) { KService::Ptr service = KService::serviceByDesktopName(desktopEntry); if (!service) { qCDebug(NOTIFICATIONMANAGER) << "Application" << desktopEntry << "cannot be registered as seen application since there is no service for it"; return; } if (service->noDisplay()) { qCDebug(NOTIFICATIONMANAGER) << "Application" << desktopEntry << "will not be registered as seen application since it's marked as NoDisplay"; return; } if (knownApplications().contains(desktopEntry)) { return; } d->applicationsGroup().group(desktopEntry).writeEntry("Seen", true); emit knownApplicationsChanged(); } void Settings::forgetKnownApplication(const QString &desktopEntry) { if (!knownApplications().contains(desktopEntry)) { return; } // Only remove applications that were added through registerKnownApplication if (!d->applicationsGroup().group(desktopEntry).readEntry("Seen", false)) { qCDebug(NOTIFICATIONMANAGER) << "Application" << desktopEntry << "will not be removed from seen applications since it wasn't one."; return; } d->applicationsGroup().deleteGroup(desktopEntry); emit knownApplicationsChanged(); } void Settings::load() { d->config->markAsClean(); d->config->reparseConfiguration(); d->dndSettings.load(); d->notificationSettings.load(); d->jobSettings.load(); d->badgeSettings.load(); emit settingsChanged(); d->setDirty(false); } void Settings::save() { d->dndSettings.save(); d->notificationSettings.save(); d->jobSettings.save(); d->badgeSettings.save(); d->config->sync(); d->setDirty(false); } void Settings::defaults() { d->dndSettings.setDefaults(); d->notificationSettings.setDefaults(); d->jobSettings.setDefaults(); d->badgeSettings.setDefaults(); emit settingsChanged(); d->setDirty(false); } bool Settings::live() const { return d->live; } void Settings::setLive(bool live) { if (live == d->live) { return; } d->live = live; if (live) { d->watcher = KConfigWatcher::create(d->config); d->watcherConnection = connect(d->watcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) { Q_UNUSED(names); if (group.name() == QLatin1String("DoNotDisturb")) { d->dndSettings.load(); bool emitScreensMirroredChanged = false; if (d->dndSettings.whenScreensMirrored()) { if (!d->mirroredScreensTracker) { d->mirroredScreensTracker = MirroredScreensTracker::createTracker(); emitScreensMirroredChanged = d->mirroredScreensTracker->screensMirrored(); connect(d->mirroredScreensTracker.data(), &MirroredScreensTracker::screensMirroredChanged, this, &Settings::screensMirroredChanged); } } else if (d->mirroredScreensTracker) { emitScreensMirroredChanged = d->mirroredScreensTracker->screensMirrored(); d->mirroredScreensTracker.reset(); } if (emitScreensMirroredChanged) { emit screensMirroredChanged(); } } else if (group.name() == QLatin1String("Notifications")) { d->notificationSettings.load(); } else if (group.name() == QLatin1String("Jobs")) { d->jobSettings.load(); } else if (group.name() == QLatin1String("Badges")) { d->badgeSettings.load(); } emit settingsChanged(); }); } else { disconnect(d->watcherConnection); d->watcherConnection = QMetaObject::Connection(); d->watcher.reset(); } emit liveChanged(); } bool Settings::dirty() const { // KConfigSkeleton doesn't write into the KConfig until calling save() // so we need to track d->config->isDirty() manually return d->dirty; } bool Settings::keepCriticalAlwaysOnTop() const { return d->notificationSettings.criticalAlwaysOnTop(); } void Settings::setKeepCriticalAlwaysOnTop(bool enable) { if (this->keepCriticalAlwaysOnTop() == enable) { return; } d->notificationSettings.setCriticalAlwaysOnTop(enable); d->setDirty(true); } bool Settings::criticalPopupsInDoNotDisturbMode() const { return d->notificationSettings.criticalInDndMode(); } void Settings::setCriticalPopupsInDoNotDisturbMode(bool enable) { if (this->criticalPopupsInDoNotDisturbMode() == enable) { return; } d->notificationSettings.setCriticalInDndMode(enable); d->setDirty(true); } bool Settings::lowPriorityPopups() const { return d->notificationSettings.lowPriorityPopups(); } void Settings::setLowPriorityPopups(bool enable) { if (this->lowPriorityPopups() == enable) { return; } d->notificationSettings.setLowPriorityPopups(enable); d->setDirty(true); } bool Settings::lowPriorityHistory() const { return d->notificationSettings.lowPriorityHistory(); } void Settings::setLowPriorityHistory(bool enable) { if (this->lowPriorityHistory() == enable) { return; } d->notificationSettings.setLowPriorityHistory(enable); d->setDirty(true); } Settings::PopupPosition Settings::popupPosition() const { return static_cast(d->notificationSettings.popupPosition()); } void Settings::setPopupPosition(Settings::PopupPosition position) { if (this->popupPosition() == position) { return; } d->notificationSettings.setPopupPosition(position); d->setDirty(true); } int Settings::popupTimeout() const { return d->notificationSettings.popupTimeout(); } void Settings::setPopupTimeout(int timeout) { if (this->popupTimeout() == timeout) { return; } d->notificationSettings.setPopupTimeout(timeout); d->setDirty(true); } void Settings::resetPopupTimeout() { setPopupTimeout(d->notificationSettings.defaultPopupTimeoutValue()); } bool Settings::jobsInTaskManager() const { return d->jobSettings.inTaskManager(); } void Settings::setJobsInTaskManager(bool enable) { if (jobsInTaskManager() == enable) { return; } d->jobSettings.setInTaskManager(enable); d->setDirty(true); } bool Settings::jobsInNotifications() const { return d->jobSettings.inNotifications(); } void Settings::setJobsInNotifications(bool enable) { if (jobsInNotifications() == enable) { return; } d->jobSettings.setInNotifications(enable); d->setDirty(true); } bool Settings::permanentJobPopups() const { return d->jobSettings.permanentPopups(); } void Settings::setPermanentJobPopups(bool enable) { if (permanentJobPopups() == enable) { return; } d->jobSettings.setPermanentPopups(enable); d->setDirty(true); } bool Settings::badgesInTaskManager() const { return d->badgeSettings.inTaskManager(); } void Settings::setBadgesInTaskManager(bool enable) { if (badgesInTaskManager() == enable) { return; } d->badgeSettings.setInTaskManager(enable); d->setDirty(true); } QStringList Settings::knownApplications() const { return d->applicationsGroup().groupList(); } QStringList Settings::popupBlacklistedApplications() const { return d->behaviorMatchesList(d->applicationsGroup(), ShowPopups, false); } QStringList Settings::popupBlacklistedServices() const { return d->behaviorMatchesList(d->servicesGroup(), ShowPopups, false); } QStringList Settings::doNotDisturbPopupWhitelistedApplications() const { return d->behaviorMatchesList(d->applicationsGroup(), ShowPopupsInDoNotDisturbMode, true); } QStringList Settings::doNotDisturbPopupWhitelistedServices() const { return d->behaviorMatchesList(d->servicesGroup(), ShowPopupsInDoNotDisturbMode, true); } QStringList Settings::historyBlacklistedApplications() const { return d->behaviorMatchesList(d->applicationsGroup(), ShowInHistory, false); } QStringList Settings::historyBlacklistedServices() const { return d->behaviorMatchesList(d->servicesGroup(), ShowInHistory, false); } QStringList Settings::badgeBlacklistedApplications() const { return d->behaviorMatchesList(d->applicationsGroup(), ShowBadges, false); } QDateTime Settings::notificationsInhibitedUntil() const { return d->dndSettings.until(); } void Settings::setNotificationsInhibitedUntil(const QDateTime &time) { d->dndSettings.setUntil(time); d->setDirty(true); } void Settings::resetNotificationsInhibitedUntil() { setNotificationsInhibitedUntil(QDateTime());// FIXME d->dndSettings.defaultUntilValue()); } bool Settings::notificationsInhibitedByApplication() const { return Server::self().inhibitedByApplication(); } QStringList Settings::notificationInhibitionApplications() const { return Server::self().inhibitionApplications(); } QStringList Settings::notificationInhibitionReasons() const { return Server::self().inhibitionReasons(); } bool Settings::inhibitNotificationsWhenScreensMirrored() const { return d->dndSettings.whenScreensMirrored(); } void Settings::setInhibitNotificationsWhenScreensMirrored(bool inhibit) { if (inhibit == inhibitNotificationsWhenScreensMirrored()) { return; } d->dndSettings.setWhenScreensMirrored(inhibit); d->setDirty(true); } bool Settings::screensMirrored() const { return d->mirroredScreensTracker && d->mirroredScreensTracker->screensMirrored(); } void Settings::setScreensMirrored(bool mirrored) { if (mirrored) { qCWarning(NOTIFICATIONMANAGER) << "Cannot forcefully set screens mirrored"; return; } if (d->mirroredScreensTracker) { d->mirroredScreensTracker->setScreensMirrored(mirrored); } } void Settings::revokeApplicationInhibitions() { Server::self().clearInhibitions(); } bool Settings::notificationSoundsInhibited() const { return d->dndSettings.notificationSoundsMuted(); } void Settings::setNotificationSoundsInhibited(bool inhibited) { if (inhibited == notificationSoundsInhibited()) { return; } d->dndSettings.setNotificationSoundsMuted(inhibited); d->setDirty(true); } diff --git a/libnotificationmanager/settings.h b/libnotificationmanager/settings.h index 30b617d83..109f17859 100644 --- a/libnotificationmanager/settings.h +++ b/libnotificationmanager/settings.h @@ -1,362 +1,365 @@ /* * Copyright 2019 Kai Uwe Broulik * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #pragma once #include #include #include #include #include #include "notificationmanager_export.h" namespace NotificationManager { /** * @short Notification settings and state * * This class encapsulates all global settings related to notifications * as well as do not disturb mode and other state. * * This class can be used by applications to alter their behavior * depending on user's notification preferences. * * @author Kai Uwe Broulik **/ class NOTIFICATIONMANAGER_EXPORT Settings : public QObject { Q_OBJECT /** * Whether to show critical notification popups in do not disturb mode. */ Q_PROPERTY(bool criticalPopupsInDoNotDisturbMode READ criticalPopupsInDoNotDisturbMode WRITE setCriticalPopupsInDoNotDisturbMode NOTIFY settingsChanged) /** * Whether to keep critical notifications always on top. */ Q_PROPERTY(bool keepCriticalAlwaysOnTop READ keepCriticalAlwaysOnTop WRITE setKeepCriticalAlwaysOnTop NOTIFY settingsChanged) /** * Whether to show popups for low priority notifications. */ Q_PROPERTY(bool lowPriorityPopups READ lowPriorityPopups WRITE setLowPriorityPopups NOTIFY settingsChanged) /** * Whether to add low priority notifications to the history. */ Q_PROPERTY(bool lowPriorityHistory READ lowPriorityHistory WRITE setLowPriorityHistory NOTIFY settingsChanged) /** * The notification popup position on screen. * CloseToWidget means they should be positioned closely to where the plasmoid is located on screen. */ Q_PROPERTY(PopupPosition popupPosition READ popupPosition WRITE setPopupPosition NOTIFY settingsChanged) /** * The default timeout for notification popups that do not have an explicit timeout set, * in milliseconds. Default is 5000ms (5 seconds). */ Q_PROPERTY(int popupTimeout READ popupTimeout WRITE setPopupTimeout RESET resetPopupTimeout NOTIFY settingsChanged) /** * Whether to show application jobs in task manager */ Q_PROPERTY(bool jobsInTaskManager READ jobsInTaskManager WRITE setJobsInTaskManager /*RESET resetJobsInTaskManager*/ NOTIFY settingsChanged) /** * Whether to show application jobs as notifications */ Q_PROPERTY(bool jobsInNotifications READ jobsInNotifications WRITE setJobsInNotifications /*RESET resetJobsPopup*/ NOTIFY settingsChanged) /** * Whether application jobs stay visible for the whole duration of the job */ Q_PROPERTY(bool permanentJobPopups READ permanentJobPopups WRITE setPermanentJobPopups /*RESET resetAutoHideJobsPopup*/ NOTIFY settingsChanged) /** * Whether to show notification badges (numbers in circles) in task manager */ Q_PROPERTY(bool badgesInTaskManager READ badgesInTaskManager WRITE setBadgesInTaskManager NOTIFY settingsChanged) /** * A list of desktop entries of applications that have been seen sending a notification. */ Q_PROPERTY(QStringList knownApplications READ knownApplications NOTIFY knownApplicationsChanged) /** * A list of desktop entries of applications for which no popups should be shown. */ Q_PROPERTY(QStringList popupBlacklistedApplications READ popupBlacklistedApplications NOTIFY settingsChanged) /** * A list of notifyrc names of services for which no popups should be shown. */ Q_PROPERTY(QStringList popupBlacklistedServices READ popupBlacklistedServices NOTIFY settingsChanged) /** * A list of desktop entries of applications for which a popup should be shown even in do not disturb mode. */ Q_PROPERTY(QStringList doNotDisturbPopupWhitelistedApplications READ doNotDisturbPopupWhitelistedApplications NOTIFY settingsChanged) /** * A list of notifyrc names of services for which a popup should be shown even in do not disturb mode. */ Q_PROPERTY(QStringList doNotDisturbPopupWhitelistedServices READ doNotDisturbPopupWhitelistedServices NOTIFY settingsChanged) /** * A list of desktop entries of applications which shouldn't be shown in the history. */ Q_PROPERTY(QStringList historyBlacklistedApplications READ historyBlacklistedApplications NOTIFY settingsChanged) /** * A list of notifyrc names of services which shouldn't be shown in the history. */ Q_PROPERTY(QStringList historyBlacklistedServices READ historyBlacklistedServices NOTIFY settingsChanged) /** * A list of desktop entries of applications which shouldn't show badges in task manager. */ Q_PROPERTY(QStringList badgeBlacklistedApplications READ badgeBlacklistedApplications NOTIFY settingsChanged) /** * The date until which do not disturb mode is enabled. * * When invalid or in the past, do not disturb mode should be considered disabled. * Do not disturb mode is considered active when this property points to a date * in the future OR notificationsInhibitedByApplication is true. */ Q_PROPERTY(QDateTime notificationsInhibitedUntil READ notificationsInhibitedUntil WRITE setNotificationsInhibitedUntil RESET resetNotificationsInhibitedUntil NOTIFY settingsChanged) /** * Whether an application currently requested do not disturb mode. * * Do not disturb mode is considered active when this property is true OR * notificationsInhibitedUntil points to a date in the future. * * @sa revokeApplicationInhibitions */ Q_PROPERTY(bool notificationsInhibitedByApplication READ notificationsInhibitedByApplication NOTIFY notificationsInhibitedByApplicationChanged) Q_PROPERTY(QStringList notificationInhibitionApplications READ notificationInhibitionApplications NOTIFY notificationInhibitionApplicationsChanged) Q_PROPERTY(QStringList notificationInhibitionReasons READ notificationInhibitionReasons NOTIFY notificationInhibitionApplicationsChanged) /** * Whether to enable do not disturb mode when screens are mirrored/overlapping * * @since 5.17 */ Q_PROPERTY(bool inhibitNotificationsWhenScreensMirrored READ inhibitNotificationsWhenScreensMirrored WRITE setInhibitNotificationsWhenScreensMirrored NOTIFY settingsChanged) /** * Whether there currently are mirrored/overlapping screens * * This property is only updated when @c inhibitNotificationsWhenScreensMirrored * is set to true, otherwise it is always false. * You can assign false to this property if you want to temporarily revoke automatic do not disturb * mode when screens are mirrored until the screen configuration changes. * * @since 5.17 */ Q_PROPERTY(bool screensMirrored READ screensMirrored WRITE setScreensMirrored NOTIFY screensMirroredChanged) /** * Whether notification sounds should be disabled * * This does not reflect the actual mute state of the Notification Sounds * stream but only remembers what value was assigned to this property. * * This way you can tell whether to unmute notification sounds or not, in case * the user had them explicitly muted previously. * * @note This does not actually mute or unmute the actual sound stream, * you need to do this yourself using e.g. PulseAudio. */ Q_PROPERTY(bool notificationSoundsInhibited READ notificationSoundsInhibited WRITE setNotificationSoundsInhibited NOTIFY settingsChanged) /** * Whether to update the properties immediately when they are changed on disk * * This can be undesirable for a settings dialog where outside changes * should not suddenly cause the UI to change. * * Default is true. */ Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged) /** * Whether the settings have changed and need to be saved * * @sa save() */ Q_PROPERTY(bool dirty READ dirty NOTIFY dirtyChanged) public: explicit Settings(QObject *parent = nullptr); + /** + * @deprecated + */ Settings(const KSharedConfig::Ptr &config, QObject *parent = nullptr); ~Settings() override; enum PopupPosition { CloseToWidget = 0, TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight }; Q_ENUM(PopupPosition) enum NotificationBehavior { ShowPopups = 1 << 1, ShowPopupsInDoNotDisturbMode = 1 << 2, ShowInHistory = 1 << 3, ShowBadges = 1 << 4 }; Q_ENUM(NotificationBehavior) Q_DECLARE_FLAGS(NotificationBehaviors, NotificationBehavior) Q_FLAG(NotificationBehaviors) Q_INVOKABLE NotificationBehaviors applicationBehavior(const QString &desktopEntry) const; Q_INVOKABLE void setApplicationBehavior(const QString &desktopEntry, NotificationBehaviors behaviors); Q_INVOKABLE NotificationBehaviors serviceBehavior(const QString &desktopEntry) const; Q_INVOKABLE void setServiceBehavior(const QString &desktopEntry, NotificationBehaviors behaviors); Q_INVOKABLE void registerKnownApplication(const QString &desktopEntry); Q_INVOKABLE void forgetKnownApplication(const QString &desktopEntry); Q_INVOKABLE void load(); Q_INVOKABLE void save(); Q_INVOKABLE void defaults(); bool live() const; void setLive(bool live); bool dirty() const; bool criticalPopupsInDoNotDisturbMode() const; void setCriticalPopupsInDoNotDisturbMode(bool enable); bool keepCriticalAlwaysOnTop() const; void setKeepCriticalAlwaysOnTop(bool enable); bool lowPriorityPopups() const; void setLowPriorityPopups(bool enable); bool lowPriorityHistory() const; void setLowPriorityHistory(bool enable); PopupPosition popupPosition() const; void setPopupPosition(PopupPosition popupPosition); int popupTimeout() const; void setPopupTimeout(int popupTimeout); void resetPopupTimeout(); bool jobsInTaskManager() const; void setJobsInTaskManager(bool enable); bool jobsInNotifications() const; void setJobsInNotifications(bool enable); bool permanentJobPopups() const; void setPermanentJobPopups(bool enable); bool badgesInTaskManager() const; void setBadgesInTaskManager(bool enable); QStringList knownApplications() const; QStringList popupBlacklistedApplications() const; QStringList popupBlacklistedServices() const; QStringList doNotDisturbPopupWhitelistedApplications() const; QStringList doNotDisturbPopupWhitelistedServices() const; QStringList historyBlacklistedApplications() const; QStringList historyBlacklistedServices() const; QStringList badgeBlacklistedApplications() const; QDateTime notificationsInhibitedUntil() const; void setNotificationsInhibitedUntil(const QDateTime &time); void resetNotificationsInhibitedUntil(); bool notificationsInhibitedByApplication() const; QStringList notificationInhibitionApplications() const; QStringList notificationInhibitionReasons() const; bool inhibitNotificationsWhenScreensMirrored() const; void setInhibitNotificationsWhenScreensMirrored(bool mirrored); bool screensMirrored() const; void setScreensMirrored(bool enable); bool notificationSoundsInhibited() const; void setNotificationSoundsInhibited(bool inhibited); /** * Revoke application notification inhibitions. * * @note Applications are not notified of the fact that their * inhibition might have been taken away. */ Q_INVOKABLE void revokeApplicationInhibitions(); signals: void settingsChanged(); void liveChanged(); void dirtyChanged(); void knownApplicationsChanged(); void notificationsInhibitedByApplicationChanged(bool notificationsInhibitedByApplication); void notificationInhibitionApplicationsChanged(); void screensMirroredChanged(); private: class Private; QScopedPointer d; }; } // namespace NotificationManager Q_DECLARE_OPERATORS_FOR_FLAGS(NotificationManager::Settings::NotificationBehaviors)