summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-10-24 02:48:57 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-10-24 02:48:57 -0400
commitf751037717ee1f5592e437e2b91f4daa45239aae (patch)
tree93c18a7c1ee9e71893055f30c6eace03c2186f41 /src
parente888306272304224ac8edd37b3b2bd24ad8c0765 (diff)
parent64245bf7457a81eed063901ad8e5ce55fdc2ca0c (diff)
downloadabaddon-portaudio-f751037717ee1f5592e437e2b91f4daa45239aae.tar.gz
abaddon-portaudio-f751037717ee1f5592e437e2b91f4daa45239aae.zip
Merge branch 'master' into voice
Diffstat (limited to 'src')
-rw-r--r--src/abaddon.cpp25
-rw-r--r--src/settings.cpp4
-rw-r--r--src/settings.hpp3
-rw-r--r--src/windows/mainwindow.cpp24
-rw-r--r--src/windows/mainwindow.hpp1
5 files changed, 50 insertions, 7 deletions
diff --git a/src/abaddon.cpp b/src/abaddon.cpp
index 664c0bd..692526c 100644
--- a/src/abaddon.cpp
+++ b/src/abaddon.cpp
@@ -80,14 +80,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;
@@ -97,6 +96,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();
@@ -105,6 +105,7 @@ static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) {
main_window->GoForward();
break;
}
+#endif
return false;
}
@@ -120,6 +121,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:
@@ -146,6 +156,7 @@ static bool HandleKeyEvents(GdkEvent *event, MainWindow *main_window) {
return true;
}
}
+#endif
return false;
}
@@ -155,7 +166,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");
@@ -567,6 +577,11 @@ void Abaddon::RunFirstTimeDiscordStartup() {
confirm.SetAcceptOnly(true);
confirm.run();
}
+
+ // autoconnect
+ if (cookie.has_value() && build_number.has_value() && GetSettings().Autoconnect && !GetDiscordToken().empty()) {
+ ActionConnect();
+ }
});
}
diff --git a/src/settings.cpp b/src/settings.cpp
index dd1fe83..0019a00 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -39,6 +39,7 @@ void SettingsManager::ReadSettings() {
SMSTR("discord", "token", DiscordToken);
SMBOOL("discord", "memory_db", UseMemoryDB);
SMBOOL("discord", "prefetch", Prefetch);
+ SMBOOL("discord", "autoconnect", Autoconnect);
SMSTR("gui", "css", MainCSS);
SMBOOL("gui", "animated_guild_hover_only", AnimatedGuildHoverOnly);
SMBOOL("gui", "animations", ShowAnimations);
@@ -48,6 +49,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);
@@ -93,6 +95,7 @@ void SettingsManager::Close() {
SMSTR("discord", "token", DiscordToken);
SMBOOL("discord", "memory_db", UseMemoryDB);
SMBOOL("discord", "prefetch", Prefetch);
+ SMBOOL("discord", "autoconnect", Autoconnect);
SMSTR("gui", "css", MainCSS);
SMBOOL("gui", "animated_guild_hover_only", AnimatedGuildHoverOnly);
SMBOOL("gui", "animations", ShowAnimations);
@@ -102,6 +105,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..9d32d2e 100644
--- a/src/settings.hpp
+++ b/src/settings.hpp
@@ -12,6 +12,7 @@ public:
std::string DiscordToken;
bool UseMemoryDB { false };
bool Prefetch { false };
+ bool Autoconnect { false };
// [gui]
std::string MainCSS { "main.css" };
@@ -27,7 +28,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();