BAlert: play user-selected sound
* Alert sounds are separate from notifications
Change-Id: I9e5545084faea354ddd339154c10b54d6479b404
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8477
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Diff
headers/os/interface/Alert.h | 1 +
headers/private/media/MediaSounds.h | 3 +++
src/kits/interface/Alert.cpp | 25 +++++++++++++++++++++++++
src/kits/interface/Jamfile | 2 +-
src/servers/media/MediaFilesManager.cpp | 3 +++
5 files changed, 33 insertions(+), 1 deletion(-)
@@ -107,6 +107,7 @@
BBitmap* _CreateTypeIcon();
BButton* _CreateButton(int32 which, const char* label);
void _Prepare();
void _PlaySound();
private:
sem_id fAlertSem;
@@ -13,6 +13,9 @@
#define MEDIA_SOUNDS_BEEP "Beep"
#define MEDIA_SOUNDS_STARTUP "Startup"
#define MEDIA_SOUNDS_INFORMATION_ALERT "Information alert"
#define MEDIA_SOUNDS_IMPORTANT_ALERT "Important alert"
#define MEDIA_SOUNDS_ERROR_ALERT "Error alert"
#define MEDIA_SOUNDS_KEY_DOWN "Key down"
#define MEDIA_SOUNDS_KEY_REPEAT "Key repeat"
#define MEDIA_SOUNDS_KEY_UP "Key up"
@@ -6,6 +6,7 @@
* Axel Dörfler, axeld@pinc-software.de
* Erik Jaesler, erik@cgsoftware.com
* John Scipione, jscipione@gmail.com
* Ron Ben Aroya, sed4906birdie@gmail.com
*/
@@ -18,6 +19,7 @@
#include <stdio.h>
#include <Beep.h>
#include <Bitmap.h>
#include <Button.h>
#include <ControlLook.h>
@@ -25,6 +27,7 @@
#include <FindDirectory.h>
#include <IconUtils.h>
#include <LayoutBuilder.h>
#include <MediaSounds.h>
#include <MenuField.h>
#include <MessageFilter.h>
#include <Path.h>
@@ -279,6 +282,7 @@
_Prepare();
Show();
_PlaySound();
if (window != NULL) {
status_t status;
@@ -316,6 +320,7 @@
fInvoker = invoker;
_Prepare();
Show();
_PlaySound();
return B_OK;
}
@@ -651,6 +656,26 @@
MoveTo(static_cast<BWindow*>(this)->AlertPosition(frame));
}
void
BAlert::_PlaySound()
{
switch (Type()) {
case B_INFO_ALERT:
system_beep(MEDIA_SOUNDS_INFORMATION_ALERT);
break;
case B_WARNING_ALERT:
system_beep(MEDIA_SOUNDS_IMPORTANT_ALERT);
break;
case B_STOP_ALERT:
system_beep(MEDIA_SOUNDS_ERROR_ALERT);
break;
default:
break;
}
}
@@ -20,7 +20,7 @@
SetSubDirSupportedPlatforms haiku libbe_test ;
UseLibraryHeaders agg ;
UsePrivateHeaders app input print interface locale shared support tracker ;
UsePrivateHeaders app input print interface locale media shared support tracker ;
UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] ;
@@ -38,6 +38,9 @@
} kInitialItems[] = {
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_BEEP},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_STARTUP},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_INFORMATION_ALERT},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_IMPORTANT_ALERT},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_ERROR_ALERT},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_KEY_DOWN},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_KEY_REPEAT},
{MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_KEY_UP},