hrev53765 adds 1 changeset to branch 'master'
old head: 1e7069152e5b98acf98d043c9ff94c406e94d935
new head: d623ab8459581ea9a4c168b21bd69436086813ef
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=d623ab845958+%5E1e7069152e5b
----------------------------------------------------------------------------
d623ab845958: DeskCalc: Remove audio feedback and add error handling
Change-Id: If470e91581d7569ed2589f67721e813cccd83fe2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2095
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
[ Zotyamester <szatmary.zoltan1222@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev53765
Commit: d623ab8459581ea9a4c168b21bd69436086813ef
URL: https://git.haiku-os.org/haiku/commit/?id=d623ab845958
Author: Zotyamester <szatmary.zoltan1222@xxxxxxxxx>
Date: Sat Jan 18 15:07:07 2020 UTC
Committer: Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sat Jan 25 11:42:20 2020 UTC
----------------------------------------------------------------------------
2 files changed, 10 insertions(+), 57 deletions(-)
src/apps/deskcalc/CalcView.cpp | 60 +++++++-------------------------------
src/apps/deskcalc/CalcView.h | 7 -----
----------------------------------------------------------------------------
diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index bd6006c3f2..fc54589461 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -23,7 +23,6 @@
#include <Alert.h>
#include <Application.h>
#include <AppFileInfo.h>
-#include <Beep.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <ControlLook.h>
@@ -33,7 +32,6 @@
#include <MenuItem.h>
#include <Message.h>
#include <MessageRunner.h>
-#include <PlaySound.h>
#include <Point.h>
#include <PopUpMenu.h>
#include <Region.h>
@@ -210,7 +208,6 @@ CalcView::CalcView(BRect frame, rgb_color rgbBaseColor,
BMessage* settings)
fPopUpMenu(NULL),
fAutoNumlockItem(NULL),
- fAudioFeedbackItem(NULL),
fOptions(new CalcOptions()),
fEvaluateThread(-1),
fEvaluateMessageRunner(NULL),
@@ -249,7 +246,6 @@ CalcView::CalcView(BMessage* archive)
fPopUpMenu(NULL),
fAutoNumlockItem(NULL),
- fAudioFeedbackItem(NULL),
fOptions(new CalcOptions()),
fEvaluateThread(-1),
fEvaluateMessageRunner(NULL),
@@ -316,10 +312,6 @@ CalcView::MessageReceived(BMessage* message)
ToggleAutoNumlock();
return;
- case MSG_OPTIONS_AUDIO_FEEDBACK:
- ToggleAudioFeedback();
- return;
-
case MSG_OPTIONS_ANGLE_MODE_RADIAN:
SetDegreeMode(false);
return;
@@ -810,15 +802,16 @@ CalcView::Copy()
{
// access system clipboard
if (be_clipboard->Lock()) {
- be_clipboard->Clear();
- BMessage* clipper = be_clipboard->Data();
- clipper->what = B_MIME_DATA;
- // TODO: should check return for errors!
- BString expression = fExpressionTextView->Text();
- clipper->AddData("text/plain", B_MIME_TYPE,
- expression.String(), expression.Length());
- //clipper->PrintToStream();
- be_clipboard->Commit();
+ BMessage* clipper;
+ if (be_clipboard->Clear() == B_OK
+ && (clipper = be_clipboard->Data()) == B_OK) {
+ BString expression = fExpressionTextView->Text();
+ if (clipper->AddData("text/plain", B_MIME_TYPE,
+ expression.String(), expression.Length() ==
B_OK) {
+ clipper->what = B_MIME_DATA;
+ be_clipboard->Commit();
+ }
+ }
be_clipboard->Unlock();
}
}
@@ -953,7 +946,6 @@ CalcView::Evaluate()
return;
}
- _AudioFeedback(false);
_SetEnabled(false);
// Disable input while we evaluate
@@ -995,14 +987,6 @@ CalcView::ToggleAutoNumlock(void)
}
-void
-CalcView::ToggleAudioFeedback(void)
-{
- fOptions->audio_feedback = !fOptions->audio_feedback;
- fAudioFeedbackItem->SetMarked(fOptions->audio_feedback);
-}
-
-
void
CalcView::SetDegreeMode(bool degrees)
{
@@ -1331,8 +1315,6 @@ CalcView::_PressKey(int key)
fExpressionTextView->Insert(fKeypad[key].code);
}
}
-
- _AudioFeedback(true);
}
@@ -1379,22 +1361,6 @@ CalcView::_FlashKey(int32 key, uint32 flashFlags)
}
-void
-CalcView::_AudioFeedback(bool inBackGround)
-{
- // TODO: Use beep events... This interface is not implemented on Haiku
- // anyways...
-#if 0
- if (fOptions->audio_feedback) {
- BEntry zimp("key.AIFF");
- entry_ref zimp_ref;
- zimp.GetRef(&zimp_ref);
- play_sound(&zimp_ref, true, false, inBackGround);
- }
-#endif
-}
-
-
void
CalcView::_Colorize()
{
@@ -1429,8 +1395,6 @@ CalcView::_CreatePopUpMenu(bool addKeypadModeMenuItems)
// construct items
fAutoNumlockItem = new BMenuItem(B_TRANSLATE("Enable Num Lock on
startup"),
new BMessage(MSG_OPTIONS_AUTO_NUM_LOCK));
- fAudioFeedbackItem = new BMenuItem(B_TRANSLATE("Audio Feedback"),
- new BMessage(MSG_OPTIONS_AUDIO_FEEDBACK));
fAngleModeRadianItem = new BMenuItem(B_TRANSLATE("Radians"),
new BMessage(MSG_OPTIONS_ANGLE_MODE_RADIAN));
fAngleModeDegreeItem = new BMenuItem(B_TRANSLATE("Degrees"),
@@ -1446,7 +1410,6 @@ CalcView::_CreatePopUpMenu(bool addKeypadModeMenuItems)
// apply current settings
fAutoNumlockItem->SetMarked(fOptions->auto_num_lock);
- fAudioFeedbackItem->SetMarked(fOptions->audio_feedback);
fAngleModeRadianItem->SetMarked(!fOptions->degree_mode);
fAngleModeDegreeItem->SetMarked(fOptions->degree_mode);
@@ -1454,9 +1417,6 @@ CalcView::_CreatePopUpMenu(bool addKeypadModeMenuItems)
fPopUpMenu = new BPopUpMenu("pop-up", false, false);
fPopUpMenu->AddItem(fAutoNumlockItem);
- // TODO: Enable this when we use beep events which can be configured
- // in the Sounds preflet.
- //fPopUpMenu->AddItem(fAudioFeedbackItem);
fPopUpMenu->AddSeparatorItem();
fPopUpMenu->AddItem(fAngleModeRadianItem);
fPopUpMenu->AddItem(fAngleModeDegreeItem);
diff --git a/src/apps/deskcalc/CalcView.h b/src/apps/deskcalc/CalcView.h
index ed61313309..391d38a649 100644
--- a/src/apps/deskcalc/CalcView.h
+++ b/src/apps/deskcalc/CalcView.h
@@ -18,7 +18,6 @@
enum {
MSG_OPTIONS_AUTO_NUM_LOCK = 'oanl',
- MSG_OPTIONS_AUDIO_FEEDBACK = 'oafb',
MSG_OPTIONS_ANGLE_MODE_RADIAN = 'oamr',
MSG_OPTIONS_ANGLE_MODE_DEGREE = 'oamd',
MSG_OPTIONS_KEYPAD_MODE_COMPACT = 'okmc',
@@ -87,10 +86,6 @@ class CalcView : public BView {
// Toggle whether or not the Num Lock key starts on
void ToggleAutoNumlock(void);
- // Toggle whether or not to provide audio feedback
- // (option currently disabled)
- void
ToggleAudioFeedback(void);
-
// Set the angle mode to degrees or radians
void SetDegreeMode(bool
degrees);
@@ -107,7 +102,6 @@ class CalcView : public BView {
void _PressKey(const char*
label);
int32 _KeyForLabel(const
char* label) const;
void _FlashKey(int32 key,
uint32 flashFlags);
- void _AudioFeedback(bool
inBackGround);
void _Colorize();
@@ -156,7 +150,6 @@ class CalcView : public BView {
// pop-up context menu.
BPopUpMenu* fPopUpMenu;
BMenuItem* fAutoNumlockItem;
- BMenuItem* fAudioFeedbackItem;
BMenuItem* fAngleModeRadianItem;
BMenuItem* fAngleModeDegreeItem;