summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-10-23 02:56:07 +0000
committerGitHub <noreply@github.com>2022-10-23 02:56:07 +0000
commit772598996c24d570cb74686c4d888d6f1aa070ad (patch)
treeea24449b77bc69f9186b1d125acd190bbe27abcc
parentccb82c1676326107133e63b7822dfd0b87afd0f2 (diff)
downloadabaddon-portaudio-772598996c24d570cb74686c4d888d6f1aa070ad.tar.gz
abaddon-portaudio-772598996c24d570cb74686c4d888d6f1aa070ad.zip
Add option to hide the menu bar behind alt key (#115)
-rw-r--r--README.md16
-rw-r--r--src/abaddon.cpp20
-rw-r--r--src/settings.cpp2
-rw-r--r--src/settings.hpp2
-rw-r--r--src/windows/mainwindow.cpp24
-rw-r--r--src/windows/mainwindow.hpp1
6 files changed, 55 insertions, 10 deletions
diff --git a/README.md b/README.md
index a059990..555b129 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/src/abaddon.cpp b/src/abaddon.cpp
index ec567e7..630e584 100644
--- a/src/abaddon.cpp
+++ b/src/abaddon.cpp
@@ -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");
diff --git a/src/settings.cpp b/src/settings.cpp
index dd1fe83..34b3dc0 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -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);
diff --git a/src/settings.hpp b/src/settings.hpp
index 7f5e015..4ab512e 100644
--- a/src/settings.hpp
+++ b/src/settings.hpp
@@ -27,7 +27,7 @@ public:
bool ShowStockEmojis { true };
#endif
bool Unreads { true };
-
+ bool AltMenu { false };
bool HideToTray { false };
// [http]
diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp
index 07a7f17..20da46b 100644
--- a/src/windows/mainwindow.cpp
+++ b/src/windows/mainwindow.cpp
@@ -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();
diff --git a/src/windows/mainwindow.hpp b/src/windows/mainwindow.hpp
index b013e32..6e95b72 100644
--- a/src/windows/mainwindow.hpp
+++ b/src/windows/mainwindow.hpp
@@ -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();