mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibVT+Terminal: Add the option to disable the bell
This commit is contained in:
parent
0cc970bd07
commit
f1d7d864ae
4 changed files with 46 additions and 10 deletions
|
@ -193,10 +193,28 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
|
||||||
|
|
||||||
auto& sysbell_radio = radio_container.add<GUI::RadioButton>("Use (Audible) System Bell");
|
auto& sysbell_radio = radio_container.add<GUI::RadioButton>("Use (Audible) System Bell");
|
||||||
auto& visbell_radio = radio_container.add<GUI::RadioButton>("Use (Visual) Terminal Bell");
|
auto& visbell_radio = radio_container.add<GUI::RadioButton>("Use (Visual) Terminal Bell");
|
||||||
sysbell_radio.set_checked(terminal.should_beep());
|
auto& nobell_radio = radio_container.add<GUI::RadioButton>("Disable Terminal Bell");
|
||||||
visbell_radio.set_checked(!terminal.should_beep());
|
|
||||||
sysbell_radio.on_checked = [&terminal](const bool checked) {
|
switch (terminal.bell_mode()) {
|
||||||
terminal.set_should_beep(checked);
|
case TerminalWidget::BellMode::Visible:
|
||||||
|
sysbell_radio.set_checked(true);
|
||||||
|
break;
|
||||||
|
case TerminalWidget::BellMode::AudibleBeep:
|
||||||
|
visbell_radio.set_checked(true);
|
||||||
|
break;
|
||||||
|
case TerminalWidget::BellMode::Disabled:
|
||||||
|
nobell_radio.set_checked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sysbell_radio.on_checked = [&terminal](const bool) {
|
||||||
|
terminal.set_bell_mode(TerminalWidget::BellMode::AudibleBeep);
|
||||||
|
};
|
||||||
|
visbell_radio.on_checked = [&terminal](const bool) {
|
||||||
|
terminal.set_bell_mode(TerminalWidget::BellMode::Visible);
|
||||||
|
};
|
||||||
|
nobell_radio.on_checked = [&terminal](const bool) {
|
||||||
|
terminal.set_bell_mode(TerminalWidget::BellMode::Disabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto& slider_container = settings.add<GUI::GroupBox>("Background Opacity");
|
auto& slider_container = settings.add<GUI::GroupBox>("Background Opacity");
|
||||||
|
@ -316,7 +334,15 @@ int main(int argc, char** argv)
|
||||||
terminal.apply_size_increments_to_window(*window);
|
terminal.apply_size_increments_to_window(*window);
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
terminal.set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
|
||||||
|
auto bell = config->read_entry("Window", "Bell", "Visible");
|
||||||
|
if (bell == "AudibleBeep") {
|
||||||
|
terminal.set_bell_mode(TerminalWidget::BellMode::AudibleBeep);
|
||||||
|
} else if (bell == "Disabled") {
|
||||||
|
terminal.set_bell_mode(TerminalWidget::BellMode::Disabled);
|
||||||
|
} else {
|
||||||
|
terminal.set_bell_mode(TerminalWidget::BellMode::Visible);
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<GUI::Window> settings_window;
|
RefPtr<GUI::Window> settings_window;
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
Command=
|
Command=
|
||||||
[Window]
|
[Window]
|
||||||
Opacity=255
|
Opacity=255
|
||||||
AudibleBeep=0
|
Bell=Visible
|
||||||
ScrollLength=4
|
ScrollLength=4
|
||||||
|
|
|
@ -812,7 +812,10 @@ void TerminalWidget::terminal_did_resize(u16 columns, u16 rows)
|
||||||
|
|
||||||
void TerminalWidget::beep()
|
void TerminalWidget::beep()
|
||||||
{
|
{
|
||||||
if (m_should_beep) {
|
if (m_bell_mode == BellMode::Disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_bell_mode == BellMode::AudibleBeep) {
|
||||||
sysbeep();
|
sysbeep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,15 @@ public:
|
||||||
|
|
||||||
void set_opacity(u8);
|
void set_opacity(u8);
|
||||||
float opacity() { return m_opacity; };
|
float opacity() { return m_opacity; };
|
||||||
bool should_beep() { return m_should_beep; }
|
|
||||||
void set_should_beep(bool sb) { m_should_beep = sb; };
|
enum class BellMode {
|
||||||
|
Visible,
|
||||||
|
AudibleBeep,
|
||||||
|
Disabled
|
||||||
|
};
|
||||||
|
|
||||||
|
BellMode bell_mode() { return m_bell_mode; }
|
||||||
|
void set_bell_mode(BellMode bm) { m_bell_mode = bm; };
|
||||||
|
|
||||||
RefPtr<Core::ConfigFile> config() const { return m_config; }
|
RefPtr<Core::ConfigFile> config() const { return m_config; }
|
||||||
|
|
||||||
|
@ -151,7 +158,7 @@ private:
|
||||||
// Snapshot of m_hovered_href when opening a context menu for a hyperlink.
|
// Snapshot of m_hovered_href when opening a context menu for a hyperlink.
|
||||||
String m_context_menu_href;
|
String m_context_menu_href;
|
||||||
|
|
||||||
bool m_should_beep { false };
|
BellMode m_bell_mode { BellMode::Visible };
|
||||||
bool m_belling { false };
|
bool m_belling { false };
|
||||||
bool m_alt_key_held { false };
|
bool m_alt_key_held { false };
|
||||||
bool m_rectangle_selection { false };
|
bool m_rectangle_selection { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue