@@ -9,8 +9,10 @@ import { computed, ref, watch } from 'vue'
9
9
import IconCancel from ' @mdi/svg/svg/cancel.svg?raw'
10
10
import IconMonitorShare from ' @mdi/svg/svg/monitor-share.svg?raw'
11
11
import NcDialog from ' @nextcloud/vue/dist/Components/NcDialog.js'
12
+ import NcDialogButton from ' @nextcloud/vue/dist/Components/NcDialogButton.js'
12
13
import NcEmptyContent from ' @nextcloud/vue/dist/Components/NcEmptyContent.js'
13
14
import NcLoadingIcon from ' @nextcloud/vue/dist/Components/NcLoadingIcon.js'
15
+ import NcCheckboxRadioSwitch from ' @nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
14
16
import { t } from ' @nextcloud/l10n'
15
17
import { useWindowFocus } from ' @vueuse/core'
16
18
import DesktopMediaSourcePreview from ' ./DesktopMediaSourcePreview.vue'
@@ -20,23 +22,14 @@ const emit = defineEmits<{
20
22
(event : ' cancel' ): void
21
23
}>()
22
24
25
+ const livePreview = ref (false )
23
26
const selectedSourceId = ref <ScreensharingSourceId | null >(null )
24
27
const sources = ref <ScreensharingSource [] | null >(null )
25
28
26
- const dialogButtons = computed (() => [
27
- {
28
- label: t (' talk_desktop' , ' Cancel' ),
29
- icon: IconCancel ,
30
- callback: handleCancel ,
31
- },
32
- {
33
- label: t (' talk_desktop' , ' Share screen' ),
34
- type: ' primary' ,
35
- icon: IconMonitorShare ,
36
- disabled: ! selectedSourceId .value ,
37
- callback: handleSubmit ,
38
- },
39
- ])
29
+ const screenSources = computed (() => sources .value ?.filter ((source ) => source .id .startsWith (' screen:' ) || source .id .startsWith (' entire-desktop:' )))
30
+ const windowSources = computed (() => sources .value ?.filter ((source ) => source .id .startsWith (' window:' )))
31
+
32
+ const singleSource = computed (() => sources .value && sources .value .length === 1 )
40
33
41
34
// On Wayland instead of the list of all available sources,
42
35
// the system picker is used to have a list of a single selected source.
@@ -46,6 +39,7 @@ const dialogButtons = computed(() => [
46
39
// - Sources list update is not possible
47
40
// - There is no the entire-desktop option
48
41
// See also: https://github.com/electron/electron/issues/27732
42
+ const livePreviewAvailable = ! window .systemInfo .isWayland
49
43
if (! window .systemInfo .isWayland ) {
50
44
const isWindowFocused = useWindowFocus ()
51
45
watch (isWindowFocused , requestDesktopCapturerSources )
@@ -125,30 +119,73 @@ function handleCancel() {
125
119
126
120
<template >
127
121
<NcDialog :name =" t('talk_desktop', 'Choose what to share')"
128
- size =" normal"
129
- :buttons =" dialogButtons"
122
+ size =" large"
130
123
@update:open =" handleCancel" >
131
124
<div v-if =" sources" class =" capture-source-grid" >
132
- <DesktopMediaSourcePreview v-for =" source in sources"
125
+ <h3 v-if =" screenSources?.length && !singleSource" class =" capture-source-section-heading" >
126
+ {{ t('talk_desktop', 'Entire screens') }}
127
+ </h3 >
128
+ <DesktopMediaSourcePreview v-for =" source in screenSources"
129
+ :key =" source.id"
130
+ :source =" source"
131
+ :live =" livePreview"
132
+ :selected =" selectedSourceId === source.id"
133
+ @select =" selectedSourceId = source.id"
134
+ @suspend =" handleVideoSuspend(source)" />
135
+
136
+ <h3 v-if =" !singleSource && windowSources?.length" class =" capture-source-section-heading" >
137
+ {{ t('talk_desktop', 'Application windows') }}
138
+ </h3 >
139
+ <DesktopMediaSourcePreview v-for =" source in windowSources"
133
140
:key =" source.id"
134
141
:source =" source"
142
+ :live =" livePreview"
135
143
:selected =" selectedSourceId === source.id"
136
144
@select =" selectedSourceId = source.id"
137
145
@suspend =" handleVideoSuspend(source)" />
138
146
</div >
147
+
139
148
<NcEmptyContent v-else :name =" t('talk_desktop', 'Loading …')" >
140
149
<template #icon >
141
150
<NcLoadingIcon />
142
151
</template >
143
152
</NcEmptyContent >
153
+
154
+ <template #actions >
155
+ <NcCheckboxRadioSwitch v-if =" sources && livePreviewAvailable"
156
+ v-model =" livePreview"
157
+ type =" switch"
158
+ class =" capture-mode-switch" >
159
+ {{ t('talk_desktop', 'Live preview') }}
160
+ </NcCheckboxRadioSwitch >
161
+ <NcDialogButton :icon =" IconCancel" :label =" t('talk_desktop', 'Cancel')" @click =" handleCancel" />
162
+ <NcDialogButton :icon =" IconMonitorShare"
163
+ :label =" t('talk_desktop', 'Share screen')"
164
+ type =" primary"
165
+ :disabled =" !selectedSourceId"
166
+ @click =" handleSubmit" />
167
+ </template >
144
168
</NcDialog >
145
169
</template >
146
170
147
171
<style scoped lang="scss">
148
172
.capture-source-grid {
149
173
display : grid ;
150
- grid-template-columns : repeat (3 , minmax (0 , 1fr ));
174
+ /* 280 is approximately 1/3 of the default large dialog size */
175
+ grid-template-columns : repeat (auto-fit , minmax (280px , 1fr ));
151
176
grid-gap : calc (var (--default-grid-baseline ) * 2 );
152
177
width : 100% ;
178
+ padding : calc (2 * var (--default-grid-baseline ));
179
+ }
180
+
181
+ .capture-source-section-heading {
182
+ grid-column : 1 / -1 ;
183
+ font-size : 18px ;
184
+ text-align : center ;
185
+ margin-block : calc (2 * var (--default-grid-baseline )) 0 ;
186
+ }
187
+
188
+ .capture-mode-switch {
189
+ margin-inline-end : auto ;
153
190
}
154
191
</style >
0 commit comments