mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(notify): integrate desktop notifications into settings
This commit is contained in:
parent
7189b46d3d
commit
4cb00957f3
|
@ -188,6 +188,7 @@ void Settings::loadGlobal()
|
|||
{
|
||||
showWindow = s.value("showWindow", true).toBool();
|
||||
notify = s.value("notify", true).toBool();
|
||||
desktopNotify = s.value("desktopNotify", false).toBool();
|
||||
groupAlwaysNotify = s.value("groupAlwaysNotify", true).toBool();
|
||||
groupchatPosition = s.value("groupchatPosition", true).toBool();
|
||||
separateWindow = s.value("separateWindow", false).toBool();
|
||||
|
@ -474,6 +475,7 @@ void Settings::saveGlobal()
|
|||
{
|
||||
s.setValue("showWindow", showWindow);
|
||||
s.setValue("notify", notify);
|
||||
s.setValue("desktopNotify", desktopNotify);
|
||||
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
||||
s.setValue("separateWindow", separateWindow);
|
||||
s.setValue("dontGroupWindows", dontGroupWindows);
|
||||
|
@ -1632,6 +1634,22 @@ void Settings::setShowWindow(bool newValue)
|
|||
}
|
||||
}
|
||||
|
||||
bool Settings::getDesktopNotify() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
return desktopNotify;
|
||||
}
|
||||
|
||||
void Settings::setDesktopNotify(bool enabled)
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
||||
if (enabled != desktopNotify) {
|
||||
desktopNotify = enabled;
|
||||
emit desktopNotifyChanged(desktopNotify);
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray Settings::getSplitterState() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
|
|
@ -171,6 +171,7 @@ signals:
|
|||
void lightTrayIconChanged(bool enabled);
|
||||
void minimizeToTrayChanged(bool enabled);
|
||||
void notifyChanged(bool enabled);
|
||||
void desktopNotifyChanged(bool enabled);
|
||||
void showWindowChanged(bool enabled);
|
||||
void makeToxPortableChanged(bool enabled);
|
||||
void busySoundChanged(bool enabled);
|
||||
|
@ -324,6 +325,9 @@ public:
|
|||
bool getShowWindow() const;
|
||||
void setShowWindow(bool newValue);
|
||||
|
||||
bool getDesktopNotify() const;
|
||||
void setDesktopNotify(bool enabled);
|
||||
|
||||
bool getNotifySound() const;
|
||||
void setNotifySound(bool newValue);
|
||||
|
||||
|
@ -603,6 +607,7 @@ private:
|
|||
bool useEmoticons;
|
||||
bool checkUpdates;
|
||||
bool notify;
|
||||
bool desktopNotify;
|
||||
bool showWindow;
|
||||
bool notifySound;
|
||||
bool busySound;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "desktopnotify.h"
|
||||
|
||||
#include <src/persistence/settings.h>
|
||||
|
||||
#include <libsnore/snore.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
@ -31,6 +33,11 @@ DesktopNotify::NotificationPtr DesktopNotify::createNotification(const QString&
|
|||
|
||||
void DesktopNotify::notifyGroupMessage()
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
if(!(s.getNotify() && s.getDesktopNotify())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString text{};
|
||||
const QString title = tr("New group message received");
|
||||
NotificationPtr newNote = createNotification(title, text);
|
||||
|
@ -43,6 +50,11 @@ void DesktopNotify::notifyGroupMessage()
|
|||
|
||||
void DesktopNotify::notifyFriendRequest()
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
if(!(s.getNotify() && s.getDesktopNotify())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString title = tr("New friend request received");
|
||||
const QString text{};
|
||||
NotificationPtr newNote = createNotification(title, text);
|
||||
|
@ -56,6 +68,11 @@ void DesktopNotify::notifyFriendRequest()
|
|||
|
||||
void DesktopNotify::notifyGroupInvite()
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
if(!(s.getNotify() && s.getDesktopNotify())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString title = tr("New group invite received");
|
||||
const QString text{};
|
||||
NotificationPtr newNote = createNotification(title, text);
|
||||
|
@ -69,6 +86,11 @@ void DesktopNotify::notifyGroupInvite()
|
|||
|
||||
void DesktopNotify::notifyFriendMessage()
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
if(!(s.getNotify() && s.getDesktopNotify())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString title = tr("New message received");
|
||||
const QString text{};
|
||||
NotificationPtr newNote = createNotification(title, text);
|
||||
|
|
|
@ -81,6 +81,12 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent)
|
|||
bodyUI->notifySound->setEnabled(s.getNotify());
|
||||
bodyUI->busySound->setChecked(s.getBusySound());
|
||||
bodyUI->busySound->setEnabled(s.getNotifySound() && s.getNotify());
|
||||
#if DESKTOP_NOTIFICATIONS
|
||||
bodyUI->desktopNotify->setChecked(s.getDesktopNotify());
|
||||
bodyUI->desktopNotify->setEnabled(s.getNotify());
|
||||
#else
|
||||
bodyUI->desktopNotify->hide();
|
||||
#endif
|
||||
|
||||
bodyUI->showWindow->setChecked(s.getShowWindow());
|
||||
|
||||
|
@ -278,6 +284,12 @@ void UserInterfaceForm::on_notifySound_stateChanged()
|
|||
bodyUI->busySound->setEnabled(notify);
|
||||
}
|
||||
|
||||
void UserInterfaceForm::on_desktopNotify_stateChanged()
|
||||
{
|
||||
const bool notify = bodyUI->desktopNotify->isChecked();
|
||||
Settings::getInstance().setDesktopNotify(notify);
|
||||
}
|
||||
|
||||
void UserInterfaceForm::on_busySound_stateChanged()
|
||||
{
|
||||
Settings::getInstance().setBusySound(bodyUI->busySound->isChecked());
|
||||
|
|
|
@ -49,6 +49,7 @@ private slots:
|
|||
void on_textStyleComboBox_currentTextChanged();
|
||||
void on_useEmoticons_stateChanged();
|
||||
void on_notify_stateChanged();
|
||||
void on_desktopNotify_stateChanged();
|
||||
void on_notifySound_stateChanged();
|
||||
void on_busySound_stateChanged();
|
||||
void on_showWindow_stateChanged();
|
||||
|
|
|
@ -214,6 +214,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="desktopNotify">
|
||||
<property name="text">
|
||||
<string>Notify via desktop notifications</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Reference in New Issue
Block a user