Skip to content

Commit c90354b

Browse files
committed
feat(settings): Use new settings configuration
1 parent aecd334 commit c90354b

9 files changed

+185
-133
lines changed

DiscordActionBase.py

Lines changed: 0 additions & 106 deletions
This file was deleted.

actions/ChangeTextChannel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from gi.repository import Gtk, Adw
22

3-
from ..DiscordActionBase import DiscordActionBase
3+
from src.backend.PluginManager.ActionBase import ActionBase
44
from ..discordrpc.commands import VOICE_CHANNEL_SELECT
55

66
from loguru import logger as log
77

88

9-
class ChangeTextChannel(DiscordActionBase):
9+
class ChangeTextChannel(ActionBase):
1010
def __init__(self, *args, **kwargs):
1111
super().__init__(*args, **kwargs)
1212
self.channel_id: str = None
13+
self.has_configuration = True
1314

1415
def on_ready(self):
1516
self.load_config()
@@ -34,7 +35,6 @@ def on_tick(self):
3435
"actions.changetextchannel.update_channel"))
3536

3637
def load_config(self):
37-
super().load_config()
3838
settings = self.get_settings()
3939
self.channel_id = settings.get('channel_id')
4040

actions/ChangeVoiceChannelAction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
from gi.repository import Gtk, Adw
22

3-
from ..DiscordActionBase import DiscordActionBase
3+
from src.backend.PluginManager.ActionBase import ActionBase
44
from ..discordrpc.commands import VOICE_CHANNEL_SELECT
55
from src.backend.DeckManagement.InputIdentifier import InputEvent, Input
66

77
from loguru import logger as log
88

99

10-
class ChangeVoiceChannelAction(DiscordActionBase):
10+
class ChangeVoiceChannelAction(ActionBase):
1111
def __init__(self, *args, **kwargs):
1212
super().__init__(*args, **kwargs)
1313
self.current_channel: str = None
1414
self.channel_id: str = None
15+
self.has_configuration = True
1516

1617
def on_ready(self):
1718
self.load_config()
@@ -36,7 +37,6 @@ def on_tick(self):
3637
"actions.changevoicechannel.update_channel"))
3738

3839
def load_config(self):
39-
super().load_config()
4040
settings = self.get_settings()
4141
self.channel_id = settings.get('channel_id')
4242

actions/DeafenAction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
from gi.repository import Gtk, Adw
44

5-
from ..DiscordActionBase import DiscordActionBase
5+
from src.backend.PluginManager.ActionBase import ActionBase
66
from ..discordrpc.commands import VOICE_SETTINGS_UPDATE
77

88
from loguru import logger as log
99

1010

11-
class DeafenAction(DiscordActionBase):
11+
class DeafenAction(ActionBase):
1212
def __init__(self, *args, **kwargs):
1313
super().__init__(*args, **kwargs)
1414
self.mode: str = 'Toggle'
@@ -46,7 +46,6 @@ def on_tick(self):
4646
"Not\nDeafened", position=self.label_location.lower())
4747

4848
def load_config(self):
49-
super().load_config()
5049
settings = self.get_settings()
5150
self.mode = settings.get('mode')
5251
if not self.mode:

actions/MuteAction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
from gi.repository import Gtk, Adw, Gio, GObject
44

5-
from ..DiscordActionBase import DiscordActionBase
5+
from src.backend.PluginManager.ActionBase import ActionBase
66
from ..discordrpc.commands import VOICE_SETTINGS_UPDATE
77

88
from loguru import logger as log
99

1010

11-
class MuteAction(DiscordActionBase):
11+
class MuteAction(ActionBase):
1212
def __init__(self, *args, **kwargs):
1313
super().__init__(*args, **kwargs)
1414
self.mode: str = 'Toggle'
@@ -45,7 +45,6 @@ def on_tick(self):
4545
self.set_label("Unmuted", position=self.label_location.lower())
4646

4747
def load_config(self):
48-
super().load_config()
4948
settings = self.get_settings()
5049
self.mode = settings.get('mode')
5150
if not self.mode:

actions/TogglePushToTalkAction.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
from gi.repository import Gtk, Adw
44

5-
from ..DiscordActionBase import DiscordActionBase
5+
from src.backend.PluginManager.ActionBase import ActionBase
66
from ..discordrpc.commands import VOICE_SETTINGS_UPDATE
77

88
from loguru import logger as log
99

1010

11-
class TogglePushToTalkAction(DiscordActionBase):
11+
class TogglePushToTalkAction(ActionBase):
1212
def __init__(self, *args, **kwargs):
1313
super().__init__(*args, **kwargs)
1414
self.mode: str = 'Toggle'
@@ -19,6 +19,7 @@ def __init__(self, *args, **kwargs):
1919
"PUSH_TO_TALK": True,
2020
"VOICE_ACTIVITY": False
2121
}
22+
self.has_configuration = True
2223

2324
def on_ready(self):
2425
self.load_config()
@@ -46,13 +47,13 @@ def on_tick(self):
4647
# page transition. I don't like it, but it works for now
4748
self.update_display({'mode': {"type": self.ptt_string}})
4849
if self.ptt:
49-
self.set_label("Push to\ntalk", position=self.label_location.lower())
50+
self.set_label("Push to\ntalk",
51+
position=self.label_location.lower())
5052
else:
5153
self.set_label(
5254
"Voice\nActivity", position=self.label_location.lower())
5355

5456
def load_config(self):
55-
super().load_config()
5657
settings = self.get_settings()
5758
self.mode = settings.get('mode')
5859
if not self.mode:
@@ -119,4 +120,4 @@ def on_key_down(self):
119120
self.show_error(5)
120121
case "Toggle":
121122
if not self.plugin_base.backend.set_push_to_talk("VOICE_ACTIVITY" if self.ptt == True else "PUSH_TO_TALK"):
122-
self.show_error(5)
123+
self.show_error(5)

main.py

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import os
2+
import json
23

34
# Import StreamController modules
45
from src.backend.PluginManager.PluginBase import PluginBase
56
from src.backend.PluginManager.ActionHolder import ActionHolder
7+
from src.backend.DeckManagement.InputIdentifier import Input
8+
from src.backend.PluginManager.ActionInputSupport import ActionInputSupport
69

710
# Import actions
11+
from .settings import PluginSettings
812
from .actions.MuteAction import MuteAction
913
from .actions.DeafenAction import DeafenAction
1014
from .actions.ChangeVoiceChannelAction import ChangeVoiceChannelAction
@@ -25,51 +29,90 @@ def __init__(self):
2529
self.lm = self.locale_manager
2630
self.lm.set_to_os_default()
2731

32+
self._settings_manager = PluginSettings(self)
33+
self.has_plugin_settings = True
34+
2835
self.message_mute_action_holder = ActionHolder(
2936
plugin_base=self,
3037
action_base=MuteAction,
3138
action_id="com_imdevinc_StreamControllerDiscordPlugin::Mute",
32-
action_name="Mute"
39+
action_name="Mute",
40+
action_support={
41+
Input.Key: ActionInputSupport.SUPPORTED,
42+
Input.Dial: ActionInputSupport.UNTESTED,
43+
Input.Touchscreen: ActionInputSupport.UNTESTED,
44+
}
3345
)
3446
self.add_action_holder(self.message_mute_action_holder)
3547

3648
self.message_deafen_action_holder = ActionHolder(
3749
plugin_base=self,
3850
action_base=DeafenAction,
3951
action_id="com_imdevinc_StreamControllerDiscordPlugin::Deafen",
40-
action_name="Deafen"
52+
action_name="Deafen",
53+
action_support={
54+
Input.Key: ActionInputSupport.SUPPORTED,
55+
Input.Dial: ActionInputSupport.UNTESTED,
56+
Input.Touchscreen: ActionInputSupport.UNTESTED,
57+
}
4158
)
4259
self.add_action_holder(self.message_deafen_action_holder)
4360

4461
self.change_voice_channel_action = ActionHolder(
4562
plugin_base=self,
4663
action_base=ChangeVoiceChannelAction,
4764
action_id="com_imdevinc_StreamControllerDiscordPlugin::ChangeVoiceChannel",
48-
action_name="Change Voice Channel"
65+
action_name="Change Voice Channel",
66+
action_support={
67+
Input.Key: ActionInputSupport.SUPPORTED,
68+
Input.Dial: ActionInputSupport.UNTESTED,
69+
Input.Touchscreen: ActionInputSupport.UNTESTED,
70+
}
4971
)
5072
self.add_action_holder(self.change_voice_channel_action)
5173

5274
self.change_text_channel_action = ActionHolder(
5375
plugin_base=self,
5476
action_base=ChangeTextChannel,
5577
action_id="com_imdevinc_StreamControllerDiscordPlugin::ChangeTextChannel",
56-
action_name="Change Text Channel"
78+
action_name="Change Text Channel",
79+
action_support={
80+
Input.Key: ActionInputSupport.SUPPORTED,
81+
Input.Dial: ActionInputSupport.UNTESTED,
82+
Input.Touchscreen: ActionInputSupport.UNTESTED,
83+
}
5784
)
5885
self.add_action_holder(self.change_text_channel_action)
5986

6087
self.message_ptt_action_holder = ActionHolder(
6188
plugin_base=self,
6289
action_base=TogglePushToTalkAction,
6390
action_id="com_imdevinc_StreamControllerDiscordPlugin::Push_To_Talk",
64-
action_name="Toggle push to talk"
91+
action_name="Toggle push to talk",
92+
action_support={
93+
Input.Key: ActionInputSupport.SUPPORTED,
94+
Input.Dial: ActionInputSupport.UNTESTED,
95+
Input.Touchscreen: ActionInputSupport.UNTESTED,
96+
}
6597
)
6698
self.add_action_holder(self.message_ptt_action_holder)
6799

100+
try:
101+
with open(os.path.join(self.PATH, "manifest.json"), "r", encoding="UTF-8") as f:
102+
data = json.load(f)
103+
except Exception as ex:
104+
log.error(ex)
105+
data = {}
106+
app_manifest = {
107+
"plugin_version": data.get("version", "0.0.0"),
108+
"app_version": data.get("app-version", "0.0.0")
109+
}
110+
68111
self.register(
69112
plugin_name="Discord",
70113
github_repo="https://github.com/imdevinc/StreamControllerDiscordPlugin",
71-
plugin_version="1.0.0",
72-
app_version="1.5.0"
114+
plugin_version=app_manifest.get("plugin_version"),
115+
app_version=app_manifest.get("app_version")
73116
)
74117

75118
settings = self.get_settings()
@@ -104,3 +147,6 @@ def handle_callback(self, key: str, data: any):
104147
def on_auth_callback(self, success: bool, message: str = None):
105148
if self.auth_callback_fn:
106149
self.auth_callback_fn(success, message)
150+
151+
def get_settings_area(self):
152+
return self._settings_manager.get_settings_area()

manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.3",
2+
"version": "1.1.0",
33
"thumbnail": "store/thumbnail.png",
44
"id": "com_imdevinc_StreamControllerDiscordPlugin",
55
"name": "Discord",
@@ -8,8 +8,8 @@
88
"tags": [
99
"discord"
1010
],
11-
"minimum-app-version": "1.5.0-beta.6",
12-
"app-version": "1.5.0-beta.6",
11+
"minimum-app-version": "1.5.0-beta.8",
12+
"app-version": "1.5.0-beta.8",
1313
"description": "Adds controls for Discord including mute, deafen, and change channel",
1414
"short-description": "Control Discord"
1515
}

0 commit comments

Comments
 (0)