Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a profiles panel. #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions src/components/panel-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ const PANELS_INFO = [
}
}
},
{
name: 'Profile Switcher',
description: 'Switch the current profile',
icon: 'cog',
iconSettings: {},
type: 'Profiles'
},
{
name: 'Scenes Switcher',
description: 'Switch the current scene',
Expand Down
2 changes: 2 additions & 0 deletions src/components/panels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Grid from './grid'
import Iframe from './iframe'
import Invalid from './invalid'
import Scenes from './scenes'
import Profiles from './profiles'
import Sources from './sources'
import Mixer from './mixer'
import Stream from './stream'
Expand All @@ -15,6 +16,7 @@ const components = {
Grid,
Iframe,
Invalid,
Profiles,
Scenes,
Sources,
Mixer,
Expand Down
41 changes: 41 additions & 0 deletions src/components/panels/profiles.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<panel-wrapper :content-class="['button-grid', 'has-per-row-1', 'overflow-y-auto', 'flex-wrap', 'text-3xl']">
<template #name>
Profiles
</template>

<button
v-for="profile in profiles"
:key="profile['profile-name']"
class="button"
:class="[profile['profile-name'] === currentProfile ? 'is-active' : 'is-inactive']"
@click="switchProfile(profile['profile-name'])"
>
{{ profile['profile-name'] }}
</button>
</panel-wrapper>
</template>
<script>
import {mapState, mapActions, mapGetters} from 'vuex'

import panelMixin from '@/mixins/panel'

export default {
mixins: [panelMixin],
computed: {
...mapState('obs', {
currentProfile: state => state.profiles.selected,
profiles: state => state.profiles.list
}),
...mapGetters('obs', ['profile-name'])
},
methods: {
async switchProfile(name) {
await this.setProfile({name})
},
...mapActions('obs', {
setProfile: 'profiles/current'
})
}
}
</script>
48 changes: 48 additions & 0 deletions src/store/plugins/obs/module/profiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export default {
state: {
selected: null,
list: []
},
actions: {
'connection/closed'({commit}) {
commit('profiles/reset')
},
async 'connection/ready'({dispatch}) {
return dispatch('profiles/reload')
},
async 'profiles/reload'({commit, getters: {client}}) {
const {profiles} = await client.send({'request-type': 'ListProfiles'})
const {'profile-name': cur} = await client.send({'request-type': 'GetCurrentProfile'})
commit('profiles/list', {profiles})
commit('profiles/current', {
'profile-name': cur
})
},
'profiles/current'({getters: {client}}, {name}) {
return client.send({'request-type': 'SetCurrentProfile', 'profile-name': name})
},
'event/ProfileChanged'({dispatch}) {
return dispatch('profiles/reload')
},
'event/SwitchProfiles'({commit}, data) {
commit('profiles/current', data)
}
},
getters: {
currentProfile(state) {
return state.list.find(profile => profile['profile-name'] === state.selected)
}
},
mutations: {
'profiles/current'(state, {'profile-name': name}) {
state.selected = name
},
'profiles/list'(state, {profiles}) {
state.list = profiles
},
'profiles/reset'(state) {
state.selected = null
state.list = []
}
}
}
2 changes: 2 additions & 0 deletions src/store/plugins/obs/modules.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import scenes from './module/scenes'
import profiles from './module/profiles'
import * as sources from './module/sources'
import stream from './module/stream'
import transitions from './module/transitions'
import durations from './module/durations'

export default {
scenes,
profiles,
sources,
stream,
transitions,
Expand Down