Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

draft: support for backend list #64

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ def _init_setup_options(self):
{"name": "Dutch", "code": "nl", "system_code": "nl_NL"}
]

if "backend_list" not in self.settings:
# backend_name: display name to display in UI
# backend_icon: display icon to display in UI
# backend_type: backend type for configuration
self.settings["backend_list"] = [
{"backend_name": "No Backend", "backend_icon": "icons/nobackend.svg", "backend_type": "offline"},
{"backend_name": "Personal Backend", "backend_icon": "icons/personal.svg", "backend_type": "personal"},
{"backend_name": "OpenVoice Backend", "backend_icon": "icons/ovos.svg", "backend_type": "ovos"},
Copy link
Member

@JarbasAl JarbasAl Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency i think this should say OpenVoiceOS Backend, we are using OVOS or OpenVoiceOS everywhere. just OpenVoice can be confusing since theres many projects using that wording for various different things

{"backend_name": "Neon Backend", "backend_icon": "icons/neongecko.svg", "backend_type": "neon"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we leave Neon commented out for now? its not fully implemented yet, should only be added after OpenVoiceOS/ovos-backend-client#11

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NeonDaniel should this say Neon Backend, NeonGecko Backend or NeonGeckoCom Backend ?

{"backend_name": "Selene Backend", "backend_icon": "icons/selene.svg", "backend_type": "selene"}
]

# read default plugins for simplified voice route from settings
# TODO - validate that these are in fact installed
# TODO - parse default value from OPM sorted list,
Expand Down Expand Up @@ -583,6 +595,7 @@ def handle_backend_menu(self):

self.state = SetupState.SELECTING_BACKEND
self.send_stop_signal("pairing.confirmation.stop")
self.gui["backend_list"] = self.settings["backend_list"]
self.handle_display_manager("BackendSelect")
self.speak_dialog("backend.intro", wait=True)
if self.pairing_mode != PairingMode.VOICE:
Expand Down Expand Up @@ -635,14 +648,15 @@ def handle_backend_confirmation(self, selection):
BackendType.OFFLINE,
BackendType.PERSONAL):
raise ValueError(f"Invalid selection: {selection}")
self.speak_dialog(f"backend.confirm.intro.{selection}", wait=True)

if self.pairing_mode != PairingMode.VOICE:
self.handle_display_manager(f"Backend{selection.title()}")
self.speak_dialog(f"backend.confirm.intro.{selection}", wait=True)
self.speak_dialog("backend.confirm.gui",
{'backend': self._translate("backend", selection)},
wait=True)
if self.pairing_mode != PairingMode.GUI:
self.speak_dialog(f"backend.confirm.intro.{selection}", wait=True)
self._backend_confirmation_voice(selection)

def _backend_confirmation_voice(self, selection):
Expand Down
1 change: 1 addition & 0 deletions locale/en-us/dialog/backend.confirm.intro.neon.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Auto connects you with Neon Gecko backend API service to provide you with free API endpoints.
1 change: 1 addition & 0 deletions locale/en-us/dialog/backend.confirm.intro.ovos.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Auto connects you with Open Voice OS backend API service to provide you with free API endpoints.
108 changes: 20 additions & 88 deletions ui/BackendButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import Mycroft 1.0 as Mycroft

Button {
id: backendButtonControl
property string backendName
property string backendIcon
property string backendType
property bool horizontalMode: false
topInset: Mycroft.Units.gridUnit / 2
leftInset: Mycroft.Units.gridUnit / 2
rightInset: Mycroft.Units.gridUnit / 2
bottomInset: Mycroft.Units.gridUnit / 2

background: Rectangle {
color: backendButtonControl.down ? "transparent" : Kirigami.Theme.highlightColor
Expand All @@ -45,106 +46,37 @@ Button {
}
}

contentItem: Loader {
id: backendButtonLoader
sourceComponent: backendButtonControl.horizontalMode ? horizontalButtonContent : verticalButtonContent
onLoaded: {
backendButtonLoader.item.backendName = backendButtonControl.backendName
backendButtonLoader.item.backendIcon = backendButtonControl.backendIcon
}
}

onClicked: {
Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sounds/clicked.wav"))
triggerGuiEvent("mycroft.device.set.backend",
{"backend": backendButtonControl.backendType})
}

Component {
id: horizontalButtonContent

ColumnLayout {
id: backendButtonContentsLayout
spacing: Mycroft.Units.gridUnit
anchors.fill: parent
property string backendName
property string backendIcon

Item {
Layout.fillWidth: true
Layout.preferredHeight: parent.height < 300 ? 0 : Mycroft.Units.gridUnit * 2
}

Item {
Layout.preferredWidth: parent.width - Kirigami.Units.iconSizes.large * 4
Layout.preferredHeight: parent.width - Kirigami.Units.iconSizes.large * 4
Layout.minimumWidth: parent.height < 300 ? Kirigami.Units.iconSizes.large * 1.4 : Kirigami.Units.iconSizes.large * 2
Layout.minimumHeight: parent.height < 300 ? Kirigami.Units.iconSizes.large * 1.4 : Kirigami.Units.iconSizes.large * 2
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom

Kirigami.Icon {
width: parent.width * 0.8
height: parent.height * 0.8
anchors.centerIn: parent
source: backendButtonContentsLayout.backendIcon
}
}

Label {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: Mycroft.Units.gridUnit
Layout.rightMargin: Mycroft.Units.gridUnit
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
contentItem: Item {

verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
elide: Text.ElideRight
font.pixelSize: 32
minimumPixelSize: 8
fontSizeMode: Text.Fit
text: backendButtonContentsLayout.backendName
}

Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}

Component {
id: verticalButtonContent

RowLayout {
id: backendButtonContentsLayout
spacing: Mycroft.Units.gridUnit
anchors.fill: parent
property string backendName
property string backendIcon
anchors.margins: Mycroft.Units.gridUnit * 2
spacing: Mycroft.Units.gridUnit

Kirigami.Icon {
Layout.preferredWidth: parent.height * 0.5
Layout.preferredHeight: width
Layout.preferredWidth: backendButtonControl.horizontalMode ? parent.width * 0.3 : parent.height
Layout.preferredHeight: backendButtonControl.horizontalMode ? width : parent.height
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: Mycroft.Units.gridUnit / 2
source: backendButtonContentsLayout.backendIcon
source: Qt.resolvedUrl(model.backend_icon)
}

Label {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: Mycroft.Units.gridUnit / 2
Layout.rightMargin: Mycroft.Units.gridUnit / 2

verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 32
minimumPixelSize: 16
fontSizeMode: Text.Fit
text: backendButtonContentsLayout.backendName
font.pixelSize: backendButtonControl.horizontalMode ? parent.width * 0.125 : parent.height * 0.7
wrapMode: Text.WordWrap
text: model.backend_name
}
}
}
}

onClicked: {
Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sounds/clicked.wav"))
triggerGuiEvent("mycroft.device.set.backend",
{"backend": model.backend_type})
}
}
Loading