Add system beeps for message/mention receiving
This commit is contained in:
parent
901f7a8e05
commit
f486588c48
|
@ -19,6 +19,9 @@ const rgb_color APP_BLACK_COLOR = {0, 0, 0, 255};
|
||||||
const rgb_color APP_SELSTART_COLOR = {254, 150, 57};
|
const rgb_color APP_SELSTART_COLOR = {254, 150, 57};
|
||||||
const rgb_color APP_SELEND_COLOR = {230, 113, 9};
|
const rgb_color APP_SELEND_COLOR = {230, 113, 9};
|
||||||
|
|
||||||
|
#define APP_MENTION_BEEP "Chat-o-Matic mention"
|
||||||
|
#define APP_MESSAGE_BEEP "Chat-o-Matic message"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Miscellaneous.
|
* Miscellaneous.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
|
|
||||||
#include "Conversation.h"
|
#include "Conversation.h"
|
||||||
|
|
||||||
|
#include <Beep.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <DateTimeFormat.h>
|
#include <DateTimeFormat.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <Notification.h>
|
#include <Notification.h>
|
||||||
#include <StringFormat.h>
|
#include <StringFormat.h>
|
||||||
|
|
||||||
|
#include "AppConstants.h"
|
||||||
#include "AppPreferences.h"
|
#include "AppPreferences.h"
|
||||||
#include "Cardie.h"
|
#include "Cardie.h"
|
||||||
#include "ChatProtocolMessages.h"
|
#include "ChatProtocolMessages.h"
|
||||||
|
@ -94,6 +96,14 @@ Conversation::ImMessage(BMessage* msg)
|
||||||
&& text.IFindFirst(contact->GetName()) != B_ERROR)
|
&& text.IFindFirst(contact->GetName()) != B_ERROR)
|
||||||
|| (text.IFindFirst(contact->GetId()) != B_ERROR));
|
|| (text.IFindFirst(contact->GetId()) != B_ERROR));
|
||||||
|
|
||||||
|
// Sound the bell, if appropriate
|
||||||
|
if (mentioned == true && winFocused == false
|
||||||
|
&& AppPreferences::Get()->SoundOnMention == true)
|
||||||
|
system_beep(APP_MENTION_BEEP);
|
||||||
|
else if (winFocused == false && (fUsers.CountItems() <= 2)
|
||||||
|
&& AppPreferences::Get()->SoundOnMessageReceived == true)
|
||||||
|
system_beep(APP_MESSAGE_BEEP);
|
||||||
|
|
||||||
// Send a notification, if appropriate
|
// Send a notification, if appropriate
|
||||||
if (winFocused == false && AppPreferences::Get()->NotifyNewMessage
|
if (winFocused == false && AppPreferences::Get()->NotifyNewMessage
|
||||||
&& (fUsers.CountItems() <= 2 || mentioned == true))
|
&& (fUsers.CountItems() <= 2 || mentioned == true))
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
#include "PreferencesNotifications.h"
|
#include "PreferencesNotifications.h"
|
||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
#include "AppPreferences.h"
|
#include "AppPreferences.h"
|
||||||
|
|
||||||
|
@ -25,6 +27,7 @@ const uint32 kNotifyContactStatus = 'NTcl';
|
||||||
const uint32 kNotifyNewMessage = 'NTms';
|
const uint32 kNotifyNewMessage = 'NTms';
|
||||||
const uint32 kSoundOnMessageReceived = 'Fmsn';
|
const uint32 kSoundOnMessageReceived = 'Fmsn';
|
||||||
const uint32 kSoundOnMention = 'FMsn';
|
const uint32 kSoundOnMention = 'FMsn';
|
||||||
|
const uint32 kEditSounds = 'HKsn';
|
||||||
|
|
||||||
|
|
||||||
PreferencesNotifications::PreferencesNotifications()
|
PreferencesNotifications::PreferencesNotifications()
|
||||||
|
@ -50,12 +53,15 @@ PreferencesNotifications::PreferencesNotifications()
|
||||||
soundsBox->SetLabel(B_TRANSLATE("Sounds"));
|
soundsBox->SetLabel(B_TRANSLATE("Sounds"));
|
||||||
|
|
||||||
fSoundOnMessageReceived = new BCheckBox("SoundOnMessageReceived",
|
fSoundOnMessageReceived = new BCheckBox("SoundOnMessageReceived",
|
||||||
B_TRANSLATE("Sound on message received"), NULL);
|
B_TRANSLATE("Sound on message received"),
|
||||||
fSoundOnMessageReceived->SetEnabled(false); // wow that's a lot
|
new BMessage(kSoundOnMessageReceived));
|
||||||
|
|
||||||
fSoundOnMention = new BCheckBox("SoundOnMention",
|
fSoundOnMention = new BCheckBox("SoundOnMention",
|
||||||
B_TRANSLATE("Sound when mentioned"), NULL);
|
B_TRANSLATE("Sound when mentioned"),
|
||||||
fSoundOnMention->SetEnabled(false); // wow that's a lot
|
new BMessage(kSoundOnMention));
|
||||||
|
|
||||||
|
fSoundsButton = new BButton("EditSoundsButton",
|
||||||
|
B_TRANSLATE("Edit sounds" B_UTF8_ELLIPSIS), new BMessage(kEditSounds));
|
||||||
|
|
||||||
const float spacing = be_control_look->DefaultItemSpacing();
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
|
@ -71,6 +77,7 @@ PreferencesNotifications::PreferencesNotifications()
|
||||||
.SetInsets(spacing, spacing * 2, spacing, spacing)
|
.SetInsets(spacing, spacing * 2, spacing, spacing)
|
||||||
.Add(fSoundOnMessageReceived)
|
.Add(fSoundOnMessageReceived)
|
||||||
.Add(fSoundOnMention)
|
.Add(fSoundOnMention)
|
||||||
|
.Add(fSoundsButton)
|
||||||
.End();
|
.End();
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
|
@ -90,6 +97,7 @@ PreferencesNotifications::AttachedToWindow()
|
||||||
fNotifyNewMessage->SetTarget(this);
|
fNotifyNewMessage->SetTarget(this);
|
||||||
fSoundOnMessageReceived->SetTarget(this);
|
fSoundOnMessageReceived->SetTarget(this);
|
||||||
fSoundOnMention->SetTarget(this);
|
fSoundOnMention->SetTarget(this);
|
||||||
|
fSoundsButton->SetTarget(this);
|
||||||
|
|
||||||
fNotifyProtocols->SetValue(
|
fNotifyProtocols->SetValue(
|
||||||
AppPreferences::Get()->NotifyProtocolStatus);
|
AppPreferences::Get()->NotifyProtocolStatus);
|
||||||
|
@ -128,6 +136,9 @@ PreferencesNotifications::MessageReceived(BMessage* message)
|
||||||
AppPreferences::Get()->SoundOnMention
|
AppPreferences::Get()->SoundOnMention
|
||||||
= fSoundOnMention->Value();
|
= fSoundOnMention->Value();
|
||||||
break;
|
break;
|
||||||
|
case kEditSounds:
|
||||||
|
BRoster().Launch("application/x-vnd.haiku-Sounds");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
|
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
|
||||||
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
||||||
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PREFERENCES_NOTIFICATIONS_H
|
#ifndef _PREFERENCES_NOTIFICATIONS_H
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
class BButton;
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
|
|
||||||
class PreferencesNotifications : public BView {
|
class PreferencesNotifications : public BView {
|
||||||
|
@ -23,6 +25,8 @@ private:
|
||||||
BCheckBox* fNotifyNewMessage;
|
BCheckBox* fNotifyNewMessage;
|
||||||
BCheckBox* fSoundOnMessageReceived;
|
BCheckBox* fSoundOnMessageReceived;
|
||||||
BCheckBox* fSoundOnMention;
|
BCheckBox* fSoundOnMention;
|
||||||
|
|
||||||
|
BButton* fSoundsButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PREFERENCES_BEHAVIOR_H
|
#endif // _PREFERENCES_NOTIFICATIONS_H
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Beep.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
|
@ -63,6 +64,9 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
_InitInterface();
|
_InitInterface();
|
||||||
|
|
||||||
|
add_system_beep_event(APP_MENTION_BEEP);
|
||||||
|
add_system_beep_event(APP_MESSAGE_BEEP);
|
||||||
|
|
||||||
//TODO check for errors here
|
//TODO check for errors here
|
||||||
ReplicantStatusView::InstallReplicant();
|
ReplicantStatusView::InstallReplicant();
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue