Add option to hide the menu bar behind alt key (#115)

This commit is contained in:
ouwou 2022-10-23 02:56:07 +00:00 committed by GitHub
parent ccb82c1676
commit 772598996c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 10 deletions

View File

@ -25,13 +25,15 @@ Current features:
* Thread support<sup>3</sup>
* Animated avatars, server icons, emojis (can be turned off)
1 - Abaddon tries its best (though is not perfect) to make Discord think it's a legitimate web client. Some of the things done to do this
1 - Abaddon tries its best (though is not perfect) to make Discord think it's a legitimate web client. Some of the
things done to do this
include: using a browser user agent, sending the same IDENTIFY message that the official web client does, using API v9
endpoints in all cases, and not using endpoints the web client does not normally use. There are still a few smaller
inconsistencies, however. For example the web client sends lots of telemetry via the `/science` endpoint (uBlock origin
stops this) as well as in the headers of all requests.<br>
**See [here](#the-spam-filter)** for things you might want to avoid if you are worried about being caught in the spam filter.
**See [here](#the-spam-filter)** for things you might want to avoid if you are worried about being caught in the spam
filter.
2 - Unicode emojis are substituted manually as opposed to rendered by GTK on non-Windows platforms. This can be changed
with the `stock_emojis` setting as shown at the bottom of this README. A CBDT-based font using Twemoji is provided to
@ -99,7 +101,12 @@ no `abaddon.ini` in the working directory
#### The Spam Filter
Discord likes disabling accounts/forcing them to reset their passwords if they think the user is a spam bot or potentially had their account compromised. While the official client still often gets users caught in the spam filter, third party clients tend to upset the spam filter more often. If you get caught by it, you can usually [appeal](https://support.discord.com/hc/en-us/requests/new?ticket_form_id=360000029731) it and get it restored. Here are some things you might want to do with the official client instead if you are particularly afraid of evoking the spam filter's wrath:
Discord likes disabling accounts/forcing them to reset their passwords if they think the user is a spam bot or
potentially had their account compromised. While the official client still often gets users caught in the spam filter,
third party clients tend to upset the spam filter more often. If you get caught by it, you can
usually [appeal](https://support.discord.com/hc/en-us/requests/new?ticket_form_id=360000029731) it and get it restored.
Here are some things you might want to do with the official client instead if you are particularly afraid of evoking the
spam filter's wrath:
* Joining or leaving servers (usually main cause of getting caught)
* Frequently disconnecting and reconnecting
@ -252,6 +259,9 @@ For example, memory_db would be set by adding `memory_db = true` under the line
over
* owner_crown (true or false, default true) - show a crown next to the owner
* unreads (true or false, default true) - show unread indicators and mention badges
* save_state (true or false, default true) - save the state of the gui (active channels, tabs, expanded channels)
* alt_menu (true or false, default false) - keep the menu hidden unless revealed with alt key
* hide_to_tray (true or false, default false) - hide abaddon to the system tray on window close
#### style

View File

@ -68,14 +68,13 @@ Abaddon &Abaddon::Get() {
return instance;
}
#ifdef WITH_LIBHANDY
#ifdef _WIN32
#ifdef _WIN32
constexpr static guint BUTTON_BACK = 4;
constexpr static guint BUTTON_FORWARD = 5;
#else
#else
constexpr static guint BUTTON_BACK = 8;
constexpr static guint BUTTON_FORWARD = 9;
#endif
#endif
static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) {
if (event->type != GDK_BUTTON_PRESS) return false;
@ -85,6 +84,7 @@ static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) {
auto *window = gtk_widget_get_toplevel(widget);
if (static_cast<void *>(window) != static_cast<void *>(main_window->gobj())) return false; // is this the right way???
#ifdef WITH_LIBHANDY
switch (event->button.button) {
case BUTTON_BACK:
main_window->GoBack();
@ -93,6 +93,7 @@ static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) {
main_window->GoForward();
break;
}
#endif
return false;
}
@ -108,6 +109,15 @@ static bool HandleKeyEvents(GdkEvent *event, MainWindow *main_window) {
const bool ctrl = (event->key.state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK;
const bool shft = (event->key.state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK;
constexpr static guint EXCLUDE_STATES = GDK_CONTROL_MASK | GDK_SHIFT_MASK;
if (!(event->key.state & EXCLUDE_STATES) && event->key.keyval == GDK_KEY_Alt_L) {
if (Abaddon::Get().GetSettings().AltMenu) {
main_window->ToggleMenuVisibility();
}
}
#ifdef WITH_LIBHANDY
if (ctrl) {
switch (event->key.keyval) {
case GDK_KEY_Tab:
@ -134,6 +144,7 @@ static bool HandleKeyEvents(GdkEvent *event, MainWindow *main_window) {
return true;
}
}
#endif
return false;
}
@ -143,7 +154,6 @@ static void MainEventHandler(GdkEvent *event, void *main_window) {
if (HandleKeyEvents(event, static_cast<MainWindow *>(main_window))) return;
gtk_main_do_event(event);
}
#endif
int Abaddon::StartGTK() {
m_gtk_app = Gtk::Application::create("com.github.uowuo.abaddon");

View File

@ -48,6 +48,7 @@ void SettingsManager::ReadSettings() {
SMBOOL("gui", "save_state", SaveState);
SMBOOL("gui", "stock_emojis", ShowStockEmojis);
SMBOOL("gui", "unreads", Unreads);
SMBOOL("gui", "alt_menu", AltMenu);
SMBOOL("gui", "hide_to_tray", HideToTray);
SMINT("http", "concurrent", CacheHTTPConcurrency);
SMSTR("http", "user_agent", UserAgent);
@ -102,6 +103,7 @@ void SettingsManager::Close() {
SMBOOL("gui", "save_state", SaveState);
SMBOOL("gui", "stock_emojis", ShowStockEmojis);
SMBOOL("gui", "unreads", Unreads);
SMBOOL("gui", "alt_menu", AltMenu);
SMBOOL("gui", "hide_to_tray", HideToTray);
SMINT("http", "concurrent", CacheHTTPConcurrency);
SMSTR("http", "user_agent", UserAgent);

View File

@ -27,7 +27,7 @@ public:
bool ShowStockEmojis { true };
#endif
bool Unreads { true };
bool AltMenu { false };
bool HideToTray { false };
// [http]

View File

@ -158,6 +158,10 @@ void MainWindow::UpdateMenus() {
OnViewSubmenuPopup();
}
void MainWindow::ToggleMenuVisibility() {
m_menu_bar.set_visible(!m_menu_bar.get_visible());
}
#ifdef WITH_LIBHANDY
void MainWindow::GoBack() {
m_chat.GoBack();
@ -279,7 +283,25 @@ void MainWindow::SetupMenu() {
m_menu_bar.append(m_menu_file);
m_menu_bar.append(m_menu_discord);
m_menu_bar.append(m_menu_view);
m_menu_bar.show_all();
if (Abaddon::Get().GetSettings().AltMenu) {
auto set_hide_cb = [this](Gtk::Menu &menu) {
for (auto *child : menu.get_children()) {
auto *item = dynamic_cast<Gtk::MenuItem *>(child);
if (item != nullptr) {
item->signal_activate().connect([this]() {
m_menu_bar.hide();
});
}
}
};
set_hide_cb(m_menu_discord_sub);
set_hide_cb(m_menu_file_sub);
set_hide_cb(m_menu_view_sub);
m_menu_bar.show_all_children();
} else {
m_menu_bar.show_all();
}
m_menu_discord_connect.signal_activate().connect([this] {
m_signal_action_connect.emit();

View File

@ -24,6 +24,7 @@ public:
void UpdateChatReactionAdd(Snowflake id, const Glib::ustring &param);
void UpdateChatReactionRemove(Snowflake id, const Glib::ustring &param);
void UpdateMenus();
void ToggleMenuVisibility();
#ifdef WITH_LIBHANDY
void GoBack();