diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-01-07 20:14:16 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-01-07 20:16:09 -0500 |
commit | 5e85d16cd61a9f28bd046d4c7921be8f6cc2b2fc (patch) | |
tree | 80b4bf62140bbc55ff12a28a0fde8706cb2d584f /src | |
parent | 78adcf2f5c9858d241dcf6f6e48f2f64bbc63f4e (diff) | |
download | abaddon-portaudio-5e85d16cd61a9f28bd046d4c7921be8f6cc2b2fc.tar.gz abaddon-portaudio-5e85d16cd61a9f28bd046d4c7921be8f6cc2b2fc.zip |
dont disconnect on voice window close, add ability to reopen
Diffstat (limited to 'src')
-rw-r--r-- | src/abaddon.cpp | 22 | ||||
-rw-r--r-- | src/abaddon.hpp | 2 | ||||
-rw-r--r-- | src/components/voiceinfobox.cpp | 12 | ||||
-rw-r--r-- | src/components/voiceinfobox.hpp | 1 |
4 files changed, 27 insertions, 10 deletions
diff --git a/src/abaddon.cpp b/src/abaddon.cpp index 8b760fd..5ed17be 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -432,6 +432,19 @@ void Abaddon::DiscordOnThreadUpdate(const ThreadUpdateData &data) { #ifdef WITH_VOICE void Abaddon::OnVoiceConnected() { m_audio->StartCaptureDevice(); + ShowVoiceWindow(); +} + +void Abaddon::OnVoiceDisconnected() { + m_audio->StopCaptureDevice(); + m_audio->RemoveAllSSRCs(); + if (m_voice_window != nullptr) { + m_voice_window->close(); + } +} + +void Abaddon::ShowVoiceWindow() { + if (m_voice_window != nullptr) return; auto *wnd = new VoiceWindow(m_discord.GetVoiceChannelID()); m_voice_window = wnd; @@ -470,21 +483,12 @@ void Abaddon::OnVoiceConnected() { wnd->show(); wnd->signal_hide().connect([this, wnd]() { - m_discord.DisconnectFromVoice(); m_voice_window = nullptr; delete wnd; delete m_user_menu; SetupUserMenu(); }); } - -void Abaddon::OnVoiceDisconnected() { - m_audio->StopCaptureDevice(); - m_audio->RemoveAllSSRCs(); - if (m_voice_window != nullptr) { - m_voice_window->close(); - } -} #endif SettingsManager::Settings &Abaddon::GetSettings() { diff --git a/src/abaddon.hpp b/src/abaddon.hpp index f45f435..5540c5a 100644 --- a/src/abaddon.hpp +++ b/src/abaddon.hpp @@ -92,6 +92,8 @@ public: #ifdef WITH_VOICE void OnVoiceConnected(); void OnVoiceDisconnected(); + + void ShowVoiceWindow(); #endif SettingsManager::Settings &GetSettings(); diff --git a/src/components/voiceinfobox.cpp b/src/components/voiceinfobox.cpp index f4dc6ed..456c5f0 100644 --- a/src/components/voiceinfobox.cpp +++ b/src/components/voiceinfobox.cpp @@ -70,6 +70,15 @@ VoiceInfoBox::VoiceInfoBox() m_status.set_label(label); }); + AddPointerCursor(m_status_ev); + m_status_ev.signal_button_press_event().connect([this](GdkEventButton *ev) -> bool { + if (ev->type == GDK_BUTTON_PRESS && ev->button == GDK_BUTTON_PRIMARY) { + Abaddon::Get().ShowVoiceWindow(); + return true; + } + return false; + }); + m_status.set_ellipsize(Pango::ELLIPSIZE_END); m_location.set_ellipsize(Pango::ELLIPSIZE_END); @@ -79,7 +88,8 @@ VoiceInfoBox::VoiceInfoBox() m_disconnect_img.set_hexpand(true); m_disconnect_img.set_halign(Gtk::ALIGN_END); - m_left.add(m_status); + m_status_ev.add(m_status); + m_left.add(m_status_ev); m_left.add(m_location); add(m_left); diff --git a/src/components/voiceinfobox.hpp b/src/components/voiceinfobox.hpp index e0bc4e8..0117c0d 100644 --- a/src/components/voiceinfobox.hpp +++ b/src/components/voiceinfobox.hpp @@ -11,6 +11,7 @@ public: private: Gtk::Box m_left; + Gtk::EventBox m_status_ev; Gtk::Label m_status; Gtk::Label m_location; |