Make Ctrl-Q accelerator user-configurable
Some devices, such as those using virtual keyboards such as Squeekboard, might find the Ctrl-Q accelerator annoying, as it can be easily mistyped.
This commit is contained in:
parent
2f1f04b3e8
commit
677ac164a9
|
@ -15,6 +15,7 @@ public class Settings : Object {
|
|||
default_encryption = col_to_encryption_or_default("default_encryption", Encryption.OMEMO);
|
||||
send_button = col_to_bool_or_default("send_button", false);
|
||||
enter_newline = col_to_bool_or_default("enter_newline", false);
|
||||
quit_ctrl_q = col_to_bool_or_default("quit_ctrl_q", true);
|
||||
}
|
||||
|
||||
private bool col_to_bool_or_default(string key, bool def) {
|
||||
|
@ -126,6 +127,20 @@ public class Settings : Object {
|
|||
enter_newline_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
public signal void quit_ctrl_q_update(bool active);
|
||||
private bool quit_ctrl_q_;
|
||||
public bool quit_ctrl_q {
|
||||
get { return quit_ctrl_q_; }
|
||||
set {
|
||||
db.settings.upsert()
|
||||
.value(db.settings.key, "quit_ctrl_q", true)
|
||||
.value(db.settings.value, value.to_string())
|
||||
.perform();
|
||||
quit_ctrl_q_ = value;
|
||||
quit_ctrl_q_update(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -172,6 +172,18 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="quit_ctrl_q_checkbutton">
|
||||
<property name="label" translatable="yes">Quit Dino with Ctrl+Q</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">8</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -117,6 +117,8 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
|||
}
|
||||
|
||||
private void create_actions() {
|
||||
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
||||
|
||||
SimpleAction accounts_action = new SimpleAction("accounts", null);
|
||||
accounts_action.activate.connect(show_accounts_window);
|
||||
add_action(accounts_action);
|
||||
|
@ -132,7 +134,20 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
|||
SimpleAction quit_action = new SimpleAction("quit", null);
|
||||
quit_action.activate.connect(quit);
|
||||
add_action(quit_action);
|
||||
set_accels_for_action("app.quit", KEY_COMBINATION_QUIT);
|
||||
|
||||
if (settings.quit_ctrl_q) {
|
||||
set_accels_for_action("app.quit", KEY_COMBINATION_QUIT);
|
||||
}
|
||||
|
||||
settings.quit_ctrl_q_update.connect((active) =>
|
||||
{
|
||||
if (active) {
|
||||
set_accels_for_action("app.quit", KEY_COMBINATION_QUIT);
|
||||
}
|
||||
else {
|
||||
set_accels_for_action("app.quit", {null});
|
||||
}
|
||||
});
|
||||
|
||||
SimpleAction open_conversation_action = new SimpleAction("open-conversation", VariantType.INT32);
|
||||
open_conversation_action.activate.connect((variant) => {
|
||||
|
|
|
@ -16,6 +16,7 @@ class SettingsDialog : Dialog {
|
|||
[GtkChild] private unowned RadioButton encryption_radio_openpgp;
|
||||
[GtkChild] private unowned CheckButton send_button_checkbutton;
|
||||
[GtkChild] private unowned CheckButton enter_newline_checkbutton;
|
||||
[GtkChild] private unowned CheckButton quit_ctrl_q_checkbutton;
|
||||
|
||||
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
||||
|
||||
|
@ -33,6 +34,7 @@ class SettingsDialog : Dialog {
|
|||
send_button_checkbutton.active = settings.send_button;
|
||||
enter_newline_checkbutton.active = settings.enter_newline;
|
||||
enter_newline_checkbutton.sensitive = settings.send_button;
|
||||
quit_ctrl_q_checkbutton.active = settings.quit_ctrl_q;
|
||||
|
||||
typing_checkbutton.toggled.connect(() => { settings.send_typing = typing_checkbutton.active; } );
|
||||
marker_checkbutton.toggled.connect(() => { settings.send_marker = marker_checkbutton.active; } );
|
||||
|
@ -67,6 +69,7 @@ class SettingsDialog : Dialog {
|
|||
enter_newline_checkbutton.active = visible;
|
||||
}
|
||||
});
|
||||
quit_ctrl_q_checkbutton.toggled.connect(() => { settings.quit_ctrl_q = quit_ctrl_q_checkbutton.active; });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue