Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(ui): apply requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Monsterovich committed May 23, 2019
1 parent 84e4130 commit f8b54b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/platform/desktop_notifications/desktopnotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ void DesktopNotify::notifyMessageSimple(const MessageType type)
{
QString message;
switch (type) {
case MSG_FRIEND: message = tr("New message"); break;
case MSG_FRIEND_FILE: message = tr("Incoming file transfer"); break;
case MSG_FRIEND_REQUEST: message = tr("Friend request received"); break;
case MSG_GROUP: message = tr("New group message"); break;
case MSG_GROUP_INVITE: message = tr("Group invite received"); break;
case MessageType::FRIEND: message = tr("New message"); break;
case MessageType::FRIEND_FILE: message = tr("Incoming file transfer"); break;
case MessageType::FRIEND_REQUEST: message = tr("Friend request received"); break;
case MessageType::GROUP: message = tr("New group message"); break;
case MessageType::GROUP_INVITE: message = tr("Group invite received"); break;
default: break;
}

Expand Down
12 changes: 6 additions & 6 deletions src/platform/desktop_notifications/desktopnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class DesktopNotify : public QObject
public:
DesktopNotify();

enum MessageType {
MSG_FRIEND = 0,
MSG_FRIEND_FILE,
MSG_FRIEND_REQUEST,
MSG_GROUP,
MSG_GROUP_INVITE
enum class MessageType {
FRIEND,
FRIEND_FILE,
FRIEND_REQUEST,
GROUP,
GROUP_INVITE
};

public slots:
Expand Down
20 changes: 8 additions & 12 deletions src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,8 @@ bool Widget::newFriendMessageAlert(const ToxPk& friendId, const QString text, bo
widget->updateStatusLight();
ui->friendList->trackWidget(widget);
#if DESKTOP_NOTIFICATIONS
const Settings& s = Settings::getInstance();
if (s.getNotifyHide()) {
notifier.notifyMessageSimple(file ? DesktopNotify::MSG_FRIEND_FILE : DesktopNotify::MSG_FRIEND);
if (settings.getNotifyHide()) {
notifier.notifyMessageSimple(file ? DesktopNotify::MessageType::FRIEND_FILE : DesktopNotify::MessageType::FRIEND);
} else {
QString title = f->getDisplayedName();
if (file) {
Expand Down Expand Up @@ -1430,9 +1429,8 @@ bool Widget::newGroupMessageAlert(const GroupId& groupId, const ToxPk authorPk,
g->setEventFlag(true);
widget->updateStatusLight();
#if DESKTOP_NOTIFICATIONS
const Settings& s = Settings::getInstance();
if (s.getNotifyHide()) {
notifier.notifyMessageSimple(DesktopNotify::MSG_GROUP);
if (settings.getNotifyHide()) {
notifier.notifyMessageSimple(DesktopNotify::MessageType::GROUP);
} else {
Friend *f = FriendList::findFriend(authorPk);
QString title = g->getPeerList().value(authorPk) + " (" + g->getDisplayedName() + ")";
Expand Down Expand Up @@ -1517,9 +1515,8 @@ void Widget::onFriendRequestReceived(const ToxPk& friendPk, const QString& messa
friendRequestsUpdate();
newMessageAlert(window(), isActiveWindow(), true, true);
#if DESKTOP_NOTIFICATIONS
const Settings& s = Settings::getInstance();
if (s.getNotifyHide()) {
notifier.notifyMessageSimple(DesktopNotify::MSG_FRIEND_REQUEST);
if (settings.getNotifyHide()) {
notifier.notifyMessageSimple(DesktopNotify::MessageType::FRIEND_REQUEST);
} else {
notifier.notifyMessage(friendPk.toString() + tr(" sent you a friend request."), message);
}
Expand Down Expand Up @@ -1761,9 +1758,8 @@ void Widget::onGroupInviteReceived(const GroupInvite& inviteInfo)
groupInvitesUpdate();
newMessageAlert(window(), isActiveWindow(), true, true);
#if DESKTOP_NOTIFICATIONS
const Settings& s = Settings::getInstance();
if (s.getNotifyHide()) {
notifier.notifyMessageSimple(DesktopNotify::MSG_GROUP_INVITE);
if (settings.getNotifyHide()) {
notifier.notifyMessageSimple(DesktopNotify::MessageType::GROUP_INVITE);
} else {
notifier.notifyMessagePixmap(f->getDisplayedName() + tr(" invites you to join a group."), {}, Nexus::getProfile()->loadAvatar(f->getPublicKey()));
}
Expand Down

0 comments on commit f8b54b3

Please sign in to comment.