diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-03-12 21:31:28 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-03-12 21:31:28 -0400 |
commit | 092ff4289299fc0253bd72b5e62795f1a1ae589d (patch) | |
tree | 3a36fb9ce594204eba597e885756fa7fb0b9d2ba | |
parent | fba1f568c23bd2e9a1cc7852dcb9b1b747611973 (diff) | |
download | abaddon-portaudio-092ff4289299fc0253bd72b5e62795f1a1ae589d.tar.gz abaddon-portaudio-092ff4289299fc0253bd72b5e62795f1a1ae589d.zip |
split out and move some files
-rw-r--r-- | src/abaddon.cpp | 2 | ||||
-rw-r--r-- | src/windows/voice/voicewindow.cpp (renamed from src/windows/voicewindow.cpp) | 80 | ||||
-rw-r--r-- | src/windows/voice/voicewindow.hpp (renamed from src/windows/voicewindow.hpp) | 1 | ||||
-rw-r--r-- | src/windows/voice/voicewindowuserlistentry.cpp | 58 | ||||
-rw-r--r-- | src/windows/voice/voicewindowuserlistentry.hpp | 38 |
5 files changed, 102 insertions, 77 deletions
diff --git a/src/abaddon.cpp b/src/abaddon.cpp index 045b8a7..486d526 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -19,7 +19,7 @@ #include "windows/profilewindow.hpp" #include "windows/pinnedwindow.hpp" #include "windows/threadswindow.hpp" -#include "windows/voicewindow.hpp" +#include "windows/voice/voicewindow.hpp" #include "startup.hpp" #include "notifications/notifications.hpp" #include "remoteauth/remoteauthdialog.hpp" diff --git a/src/windows/voicewindow.cpp b/src/windows/voice/voicewindow.cpp index 9033857..5e050ce 100644 --- a/src/windows/voicewindow.cpp +++ b/src/windows/voice/voicewindow.cpp @@ -2,88 +2,16 @@ // clang-format off +#include "voicewindow.hpp" + #include "abaddon.hpp" #include "audio/manager.hpp" #include "components/lazyimage.hpp" -#include "voicesettingswindow.hpp" -#include "voicewindow.hpp" +#include "voicewindowuserlistentry.hpp" +#include "windows/voicesettingswindow.hpp" // clang-format on -class VoiceWindowUserListEntry : public Gtk::ListBoxRow { -public: - VoiceWindowUserListEntry(Snowflake id) - : m_main(Gtk::ORIENTATION_VERTICAL) - , m_horz(Gtk::ORIENTATION_HORIZONTAL) - , m_avatar(32, 32) - , m_mute("Mute") { - m_name.set_halign(Gtk::ALIGN_START); - m_name.set_hexpand(true); - m_mute.set_halign(Gtk::ALIGN_END); - - m_volume.set_range(0.0, 200.0); - m_volume.set_value_pos(Gtk::POS_LEFT); - m_volume.set_value(100.0); - m_volume.signal_value_changed().connect([this]() { - m_signal_volume.emit(m_volume.get_value() * 0.01); - }); - - m_horz.add(m_avatar); - m_horz.add(m_name); - m_horz.add(m_mute); - m_main.add(m_horz); - m_main.add(m_volume); - m_main.add(m_meter); - add(m_main); - show_all_children(); - - auto &discord = Abaddon::Get().GetDiscordClient(); - const auto user = discord.GetUser(id); - if (user.has_value()) { - m_name.set_text(user->GetUsername()); - m_avatar.SetURL(user->GetAvatarURL("png", "32")); - } else { - m_name.set_text("Unknown user"); - } - - m_mute.signal_toggled().connect([this]() { - m_signal_mute_cs.emit(m_mute.get_active()); - }); - } - - void SetVolumeMeter(double frac) { - m_meter.SetVolume(frac); - } - - void RestoreGain(double frac) { - m_volume.set_value(frac * 100.0); - } - -private: - Gtk::Box m_main; - Gtk::Box m_horz; - LazyImage m_avatar; - Gtk::Label m_name; - Gtk::CheckButton m_mute; - Gtk::Scale m_volume; - VolumeMeter m_meter; - -public: - using type_signal_mute_cs = sigc::signal<void(bool)>; - using type_signal_volume = sigc::signal<void(double)>; - type_signal_mute_cs signal_mute_cs() { - return m_signal_mute_cs; - } - - type_signal_volume signal_volume() { - return m_signal_volume; - } - -private: - type_signal_mute_cs m_signal_mute_cs; - type_signal_volume m_signal_volume; -}; - VoiceWindow::VoiceWindow(Snowflake channel_id) : m_main(Gtk::ORIENTATION_VERTICAL) , m_controls(Gtk::ORIENTATION_HORIZONTAL) diff --git a/src/windows/voicewindow.hpp b/src/windows/voice/voicewindow.hpp index 6d46084..202a0ac 100644 --- a/src/windows/voicewindow.hpp +++ b/src/windows/voice/voicewindow.hpp @@ -17,6 +17,7 @@ // clang-format on class VoiceWindowUserListEntry; + class VoiceWindow : public Gtk::Window { public: VoiceWindow(Snowflake channel_id); diff --git a/src/windows/voice/voicewindowuserlistentry.cpp b/src/windows/voice/voicewindowuserlistentry.cpp new file mode 100644 index 0000000..97a3031 --- /dev/null +++ b/src/windows/voice/voicewindowuserlistentry.cpp @@ -0,0 +1,58 @@ +#include "voicewindowuserlistentry.hpp" + +#include "abaddon.hpp" + +VoiceWindowUserListEntry::VoiceWindowUserListEntry(Snowflake id) + : m_main(Gtk::ORIENTATION_VERTICAL) + , m_horz(Gtk::ORIENTATION_HORIZONTAL) + , m_avatar(32, 32) + , m_mute("Mute") { + m_name.set_halign(Gtk::ALIGN_START); + m_name.set_hexpand(true); + m_mute.set_halign(Gtk::ALIGN_END); + + m_volume.set_range(0.0, 200.0); + m_volume.set_value_pos(Gtk::POS_LEFT); + m_volume.set_value(100.0); + m_volume.signal_value_changed().connect([this]() { + m_signal_volume.emit(m_volume.get_value() * 0.01); + }); + + m_horz.add(m_avatar); + m_horz.add(m_name); + m_horz.add(m_mute); + m_main.add(m_horz); + m_main.add(m_volume); + m_main.add(m_meter); + add(m_main); + show_all_children(); + + auto &discord = Abaddon::Get().GetDiscordClient(); + const auto user = discord.GetUser(id); + if (user.has_value()) { + m_name.set_text(user->GetUsername()); + m_avatar.SetURL(user->GetAvatarURL("png", "32")); + } else { + m_name.set_text("Unknown user"); + } + + m_mute.signal_toggled().connect([this]() { + m_signal_mute_cs.emit(m_mute.get_active()); + }); +} + +void VoiceWindowUserListEntry::SetVolumeMeter(double frac) { + m_meter.SetVolume(frac); +} + +void VoiceWindowUserListEntry::RestoreGain(double frac) { + m_volume.set_value(frac * 100.0); +} + +VoiceWindowUserListEntry::type_signal_mute_cs VoiceWindowUserListEntry::signal_mute_cs() { + return m_signal_mute_cs; +} + +VoiceWindowUserListEntry::type_signal_volume VoiceWindowUserListEntry::signal_volume() { + return m_signal_volume; +} diff --git a/src/windows/voice/voicewindowuserlistentry.hpp b/src/windows/voice/voicewindowuserlistentry.hpp new file mode 100644 index 0000000..4e8c028 --- /dev/null +++ b/src/windows/voice/voicewindowuserlistentry.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include "components/lazyimage.hpp" +#include "components/volumemeter.hpp" +#include "discord/snowflake.hpp" + +#include <gtkmm/box.h> +#include <gtkmm/checkbutton.h> +#include <gtkmm/label.h> +#include <gtkmm/listboxrow.h> +#include <gtkmm/scale.h> + +class VoiceWindowUserListEntry : public Gtk::ListBoxRow { +public: + VoiceWindowUserListEntry(Snowflake id); + + void SetVolumeMeter(double frac); + void RestoreGain(double frac); + +private: + Gtk::Box m_main; + Gtk::Box m_horz; + LazyImage m_avatar; + Gtk::Label m_name; + Gtk::CheckButton m_mute; + Gtk::Scale m_volume; + VolumeMeter m_meter; + +public: + using type_signal_mute_cs = sigc::signal<void(bool)>; + using type_signal_volume = sigc::signal<void(double)>; + type_signal_mute_cs signal_mute_cs(); + type_signal_volume signal_volume(); + +private: + type_signal_mute_cs m_signal_mute_cs; + type_signal_volume m_signal_volume; +}; |