From c6b915eb90394da80d0ddf5c23d87604748f8933 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 22 Dec 2020 16:44:52 +0000 Subject: [PATCH] - Added preliminary autohide setup - Stopped crash when joining private call - - No way to know who is in a call until they talk currently. --- discover_overlay/discord_connector.py | 9 ++- discover_overlay/overlay.py | 7 +++ discover_overlay/settings.py | 9 +++ discover_overlay/text_settings.py | 52 +++++++++------- discover_overlay/voice_settings.py | 86 +++++++++++++++------------ 5 files changed, 101 insertions(+), 62 deletions(-) diff --git a/discover_overlay/discord_connector.py b/discover_overlay/discord_connector.py index 562b303..27e3b7b 100644 --- a/discover_overlay/discord_connector.py +++ b/discover_overlay/discord_connector.py @@ -108,9 +108,12 @@ class DiscordConnector: self.current_voice = "0" return if channel != self.current_voice: - channel_name = self.channels[channel]['name'] - logging.info( - "Joined room: %s", channel_name) + if channel in self.channels: + channel_name = self.channels[channel]['name'] + logging.info( + "Joined room: %s", channel_name) + else: + logging.info("Joining private room") self.sub_voice_channel(channel) self.current_voice = channel if need_req: diff --git a/discover_overlay/overlay.py b/discover_overlay/overlay.py index ca8e13b..4edc915 100644 --- a/discover_overlay/overlay.py +++ b/discover_overlay/overlay.py @@ -89,6 +89,7 @@ class OverlayWindow(Gtk.Window): self.floating = False self.force_xshape = False self.context = None + self.autohide=False def set_wayland_state(self): """ @@ -256,3 +257,9 @@ class OverlayWindow(Gtk.Window): self.show_all() else: self.hide() + + def set_hide_on_mouseover(self, hide): + """ + Set Mouseover hide + """ + self.autohide = hide diff --git a/discover_overlay/settings.py b/discover_overlay/settings.py index 74ea1c5..54f48de 100644 --- a/discover_overlay/settings.py +++ b/discover_overlay/settings.py @@ -55,6 +55,7 @@ class SettingsWindow(Gtk.VBox): self.align_x = None self.align_y = None self.enabled = None + self.autohide = None def init_config(self): """ @@ -226,3 +227,11 @@ class SettingsWindow(Gtk.VBox): self.enabled = button.get_active() self.save_config() + + def change_hide_on_mouseover(self, button): + """ + Autohide setting changed + """ + self.overlay.set_hide_on_mouseover(button.get_active()) + self.autohide = button.get_active() + self.save_config() diff --git a/discover_overlay/text_settings.py b/discover_overlay/text_settings.py index 3227e40..fe490d1 100644 --- a/discover_overlay/text_settings.py +++ b/discover_overlay/text_settings.py @@ -220,6 +220,7 @@ class TextSettingsWindow(SettingsWindow): self.text_time = config.getint("text", "text_time", fallback=30) self.show_attach = config.getboolean( "text", "show_attach", fallback=True) + self.autohide = config.getboolean("text", "autohide", fallback=False) logging.info( "Loading saved channel %s", self.channel) @@ -237,6 +238,7 @@ class TextSettingsWindow(SettingsWindow): self.overlay.set_popup_style(self.popup_style) self.overlay.set_text_time(self.text_time) self.overlay.set_show_attach(self.show_attach) + self.overlay.set_hide_on_mouseover(self.autohide) def save_config(self): """ @@ -282,6 +284,12 @@ class TextSettingsWindow(SettingsWindow): enabled.set_active(self.enabled) enabled.connect("toggled", self.change_enabled) + # Autohide + autohide_label = Gtk.Label.new("Hide on mouseover") + autohide = Gtk.CheckButton.new() + autohide.set_active(self.autohide) + autohide.connect("toggled", self.change_hide_on_mouseover) + # Popup Style popup_style_label = Gtk.Label.new("Popup Style") popup_style = Gtk.CheckButton.new() @@ -401,29 +409,31 @@ class TextSettingsWindow(SettingsWindow): box.attach(enabled_label, 0, 0, 1, 1) box.attach(enabled, 1, 0, 1, 1) - box.attach(popup_style_label, 0, 1, 1, 1) - box.attach(popup_style, 1, 1, 1, 1) - box.attach(text_time_label, 0, 2, 1, 1) - box.attach(text_time, 1, 2, 1, 1) - box.attach(guild_label, 0, 3, 1, 1) - box.attach(guild, 1, 3, 1, 1) + #box.attach(autohide_label, 0, 1, 1, 1) + #box.attach(autohide, 1, 1, 1, 1) + box.attach(popup_style_label, 0, 2, 1, 1) + box.attach(popup_style, 1, 2, 1, 1) + box.attach(text_time_label, 0, 3, 1, 1) + box.attach(text_time, 1, 3, 1, 1) + box.attach(guild_label, 0, 4, 1, 1) + box.attach(guild, 1, 4, 1, 1) - box.attach(channel_label, 0, 4, 1, 1) - box.attach(channel, 1, 4, 1, 1) - box.attach(font_label, 0, 5, 1, 1) - box.attach(font, 1, 5, 1, 1) - box.attach(fg_col_label, 0, 6, 1, 1) - box.attach(fg_col, 1, 6, 1, 1) - box.attach(bg_col_label, 0, 7, 1, 1) - box.attach(bg_col, 1, 7, 1, 1) - box.attach(align_label, 0, 8, 1, 5) + box.attach(channel_label, 0, 5, 1, 1) + box.attach(channel, 1, 5, 1, 1) + box.attach(font_label, 0, 6, 1, 1) + box.attach(font, 1, 6, 1, 1) + box.attach(fg_col_label, 0, 7, 1, 1) + box.attach(fg_col, 1, 7, 1, 1) + box.attach(bg_col_label, 0, 8, 1, 1) + box.attach(bg_col, 1, 8, 1, 1) + box.attach(align_label, 0, 9, 1, 5) #box.attach(align_type_box, 1, 8, 1, 1) - box.attach(monitor, 1, 9, 1, 1) - box.attach(align_x, 1, 10, 1, 1) - box.attach(align_y, 1, 11, 1, 1) - box.attach(align_placement_button, 1, 12, 1, 1) - box.attach(show_attach_label, 0, 13, 1, 1) - box.attach(show_attach, 1, 13, 1, 1) + box.attach(monitor, 1, 10, 1, 1) + box.attach(align_x, 1, 11, 1, 1) + box.attach(align_y, 1, 12, 1, 1) + box.attach(align_placement_button, 1, 13, 1, 1) + box.attach(show_attach_label, 0, 14, 1, 1) + box.attach(show_attach, 1, 14, 1, 1) self.add(box) diff --git a/discover_overlay/voice_settings.py b/discover_overlay/voice_settings.py index 535fa54..e75f952 100644 --- a/discover_overlay/voice_settings.py +++ b/discover_overlay/voice_settings.py @@ -110,6 +110,7 @@ class VoiceSettingsWindow(SettingsWindow): self.floating_w = config.getint("main", "floating_w", fallback=400) self.floating_h = config.getint("main", "floating_h", fallback=400) self.order = config.getint("main", "order", fallback=0) + self.autohide = config.getboolean("text", "autohide", fallback=False) # Pass all of our config over to the overlay self.overlay.set_align_x(self.align_x) @@ -131,6 +132,7 @@ class VoiceSettingsWindow(SettingsWindow): self.overlay.set_vert_edge_padding(self.vert_edge_padding) self.overlay.set_horz_edge_padding(self.horz_edge_padding) self.overlay.set_order(self.order) + self.overlay.set_hide_on_mouseover(self.autohide) self.overlay.set_floating( self.floating, self.floating_x, self.floating_y, self.floating_w, self.floating_h) @@ -184,6 +186,12 @@ class VoiceSettingsWindow(SettingsWindow): """ box = Gtk.Grid() + # Autohide + autohide_label = Gtk.Label.new("Hide on mouseover") + autohide = Gtk.CheckButton.new() + autohide.set_active(self.autohide) + autohide.connect("toggled", self.change_hide_on_mouseover) + # Font chooser font_label = Gtk.Label.new("Font") font = Gtk.FontButton() @@ -350,44 +358,46 @@ class VoiceSettingsWindow(SettingsWindow): order.pack_start(renderer_text, True) order.add_attribute(renderer_text, "text", 0) - box.attach(font_label, 0, 0, 1, 1) - box.attach(font, 1, 0, 1, 1) - box.attach(bg_col_label, 0, 1, 1, 1) - box.attach(bg_col, 1, 1, 1, 1) - box.attach(fg_col_label, 0, 2, 1, 1) - box.attach(fg_col, 1, 2, 1, 1) - box.attach(tk_col_label, 0, 3, 1, 1) - box.attach(tk_col, 1, 3, 1, 1) - box.attach(mt_col_label, 0, 4, 1, 1) - box.attach(mt_col, 1, 4, 1, 1) - box.attach(avatar_size_label, 0, 5, 1, 1) - box.attach(avatar_size, 1, 5, 1, 1) - box.attach(align_label, 0, 6, 1, 5) - box.attach(align_type_box, 1, 6, 1, 1) - box.attach(monitor, 1, 7, 1, 1) - box.attach(align_x, 1, 8, 1, 1) - box.attach(align_y, 1, 9, 1, 1) - box.attach(align_placement_button, 1, 10, 1, 1) - box.attach(icon_spacing_label, 0, 11, 1, 1) - box.attach(icon_spacing, 1, 11, 1, 1) - box.attach(text_padding_label, 0, 12, 1, 1) - box.attach(text_padding, 1, 12, 1, 1) - box.attach(text_baseline_label, 0, 13, 1, 1) - box.attach(text_baseline, 1, 13, 1, 1) - box.attach(vert_edge_padding_label, 0, 14, 1, 1) - box.attach(vert_edge_padding, 1, 14, 1, 1) - box.attach(horz_edge_padding_label, 0, 15, 1, 1) - box.attach(horz_edge_padding, 1, 15, 1, 1) - box.attach(square_avatar_label, 0, 16, 1, 1) - box.attach(square_avatar, 1, 16, 1, 1) - box.attach(only_speaking_label, 0, 17, 1, 1) - box.attach(only_speaking, 1, 17, 1, 1) - box.attach(highlight_self_label, 0, 18, 1, 1) - box.attach(highlight_self, 1, 18, 1, 1) - box.attach(icon_only_label, 0, 19, 1, 1) - box.attach(icon_only, 1, 19, 1, 1) - box.attach(order_label, 0, 20, 1, 1) - box.attach(order, 1, 20, 1, 1) + box.attach(autohide_label, 0, 0, 1, 1) + box.attach(autohide, 1, 0, 1, 1) + box.attach(font_label, 0, 1, 1, 1) + box.attach(font, 1, 1, 1, 1) + box.attach(bg_col_label, 0, 2, 1, 1) + box.attach(bg_col, 1, 2, 1, 1) + box.attach(fg_col_label, 0, 3, 1, 1) + box.attach(fg_col, 1, 3, 1, 1) + box.attach(tk_col_label, 0, 4, 1, 1) + box.attach(tk_col, 1, 4, 1, 1) + box.attach(mt_col_label, 0, 5, 1, 1) + box.attach(mt_col, 1, 5, 1, 1) + box.attach(avatar_size_label, 0, 6, 1, 1) + box.attach(avatar_size, 1, 6, 1, 1) + box.attach(align_label, 0, 7, 1, 5) + box.attach(align_type_box, 1, 7, 1, 1) + box.attach(monitor, 1, 8, 1, 1) + box.attach(align_x, 1, 9, 1, 1) + box.attach(align_y, 1, 10, 1, 1) + box.attach(align_placement_button, 1, 11, 1, 1) + box.attach(icon_spacing_label, 0, 12, 1, 1) + box.attach(icon_spacing, 1, 12, 1, 1) + box.attach(text_padding_label, 0, 13, 1, 1) + box.attach(text_padding, 1, 13, 1, 1) + box.attach(text_baseline_label, 0, 14, 1, 1) + box.attach(text_baseline, 1, 14, 1, 1) + box.attach(vert_edge_padding_label, 0, 15, 1, 1) + box.attach(vert_edge_padding, 1, 15, 1, 1) + box.attach(horz_edge_padding_label, 0, 16, 1, 1) + box.attach(horz_edge_padding, 1, 16, 1, 1) + box.attach(square_avatar_label, 0, 17, 1, 1) + box.attach(square_avatar, 1, 17, 1, 1) + box.attach(only_speaking_label, 0, 18, 1, 1) + box.attach(only_speaking, 1, 18, 1, 1) + box.attach(highlight_self_label, 0, 19, 1, 1) + box.attach(highlight_self, 1, 19, 1, 1) + box.attach(icon_only_label, 0, 20, 1, 1) + box.attach(icon_only, 1, 20, 1, 1) + box.attach(order_label, 0, 21, 1, 1) + box.attach(order, 1, 21, 1, 1) self.add(box)