Skip to content

Commit 7e0dc7c

Browse files
committed
add support for changing default copy option
1 parent c903440 commit 7e0dc7c

File tree

6 files changed

+329
-38
lines changed

6 files changed

+329
-38
lines changed

src/Flow.Launcher.Plugin.ClipboardPlus.Panels/ViewModels/SettingsViewModel.cs

+145-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public SettingsViewModel(IClipboardPlus clipboardPlus)
2424
ClipboardPlus.CultureInfoChanged += ClipboardPlus_CultureInfoChanged;
2525
InitializeRecordOrderSelection();
2626
InitializeClickActionSelection();
27+
InitializeDefaultRichTextCopyOptionSelection();
28+
InitializeDefaultImageCopyOptionSelection();
29+
InitializeDefaultFilesCopyOptionSelection();
2730
InitializeCacheFormatPreview();
2831
InitializeKeepTimeSelection();
2932
}
@@ -157,6 +160,20 @@ private void RefreshRecordOrders()
157160

158161
#endregion
159162

163+
#region Action Top
164+
165+
public bool ActionTop
166+
{
167+
get => Settings.ActionTop;
168+
set
169+
{
170+
Settings.ActionTop = value;
171+
OnPropertyChanged();
172+
}
173+
}
174+
175+
#endregion
176+
160177
#region Click Actions
161178

162179
private IReadOnlyList<EnumBindingModel<ClickAction>> _clickActions;
@@ -202,18 +219,139 @@ private void RefreshClickActions()
202219

203220
#endregion
204221

205-
#region Action Top
222+
#region Default Rich Text Copy Option
206223

207-
public bool ActionTop
224+
private IReadOnlyList<EnumBindingModel<DefaultRichTextCopyOption>> _defaultRichTextCopyOptions;
225+
public IReadOnlyList<EnumBindingModel<DefaultRichTextCopyOption>> DefaultRichTextCopyOptions
208226
{
209-
get => Settings.ActionTop;
227+
get => _defaultRichTextCopyOptions;
210228
set
211229
{
212-
Settings.ActionTop = value;
230+
_defaultRichTextCopyOptions = value;
231+
OnPropertyChanged();
232+
}
233+
}
234+
235+
private EnumBindingModel<DefaultRichTextCopyOption> _selectedDefaultRichTextCopyOption;
236+
public EnumBindingModel<DefaultRichTextCopyOption> SelectedDefaultRichTextCopyOption
237+
{
238+
get => _selectedDefaultRichTextCopyOption;
239+
set
240+
{
241+
_selectedDefaultRichTextCopyOption = value;
242+
Settings.DefaultRichTextCopyOption = value.Value;
243+
OnPropertyChanged();
244+
}
245+
}
246+
247+
[MemberNotNull(nameof(_defaultRichTextCopyOptions),
248+
nameof(_selectedDefaultRichTextCopyOption))]
249+
private void InitializeDefaultRichTextCopyOptionSelection()
250+
{
251+
_defaultRichTextCopyOptions = EnumBindingModel<DefaultRichTextCopyOption>.CreateList(Context);
252+
253+
_selectedDefaultRichTextCopyOption = _defaultRichTextCopyOptions.First(x => x.Value == Settings.DefaultRichTextCopyOption);
254+
}
255+
256+
private void RefreshDefaultRichTextCopyOptions()
257+
{
258+
_defaultRichTextCopyOptions = EnumBindingModel<DefaultRichTextCopyOption>.CreateList(Context);
259+
260+
SelectedDefaultRichTextCopyOption = DefaultRichTextCopyOptions.First(x => x.Value == Settings.DefaultRichTextCopyOption);
261+
262+
OnPropertyChanged(nameof(DefaultRichTextCopyOptions));
263+
}
264+
265+
#endregion
266+
267+
#region Default Image Copy Option
268+
269+
private IReadOnlyList<EnumBindingModel<DefaultImageCopyOption>> _defaultImageCopyOptions;
270+
public IReadOnlyList<EnumBindingModel<DefaultImageCopyOption>> DefaultImageCopyOptions
271+
{
272+
get => _defaultImageCopyOptions;
273+
set
274+
{
275+
_defaultImageCopyOptions = value;
213276
OnPropertyChanged();
214277
}
215278
}
216279

280+
private EnumBindingModel<DefaultImageCopyOption> _selectedDefaultImageCopyOption;
281+
public EnumBindingModel<DefaultImageCopyOption> SelectedDefaultImageCopyOption
282+
{
283+
get => _selectedDefaultImageCopyOption;
284+
set
285+
{
286+
_selectedDefaultImageCopyOption = value;
287+
Settings.DefaultImageCopyOption = value.Value;
288+
OnPropertyChanged();
289+
}
290+
}
291+
292+
[MemberNotNull(nameof(_defaultImageCopyOptions),
293+
nameof(_selectedDefaultImageCopyOption))]
294+
private void InitializeDefaultImageCopyOptionSelection()
295+
{
296+
_defaultImageCopyOptions = EnumBindingModel<DefaultImageCopyOption>.CreateList(Context);
297+
298+
_selectedDefaultImageCopyOption = _defaultImageCopyOptions.First(x => x.Value == Settings.DefaultImageCopyOption);
299+
}
300+
301+
private void RefreshDefaultImageCopyOptions()
302+
{
303+
_defaultImageCopyOptions = EnumBindingModel<DefaultImageCopyOption>.CreateList(Context);
304+
305+
SelectedDefaultImageCopyOption = DefaultImageCopyOptions.First(x => x.Value == Settings.DefaultImageCopyOption);
306+
307+
OnPropertyChanged(nameof(DefaultImageCopyOptions));
308+
}
309+
310+
#endregion
311+
312+
#region Default Files Copy Option
313+
314+
private IReadOnlyList<EnumBindingModel<DefaultFilesCopyOption>> _defaultFilesCopyOptions;
315+
public IReadOnlyList<EnumBindingModel<DefaultFilesCopyOption>> DefaultFilesCopyOptions
316+
{
317+
get => _defaultFilesCopyOptions;
318+
set
319+
{
320+
_defaultFilesCopyOptions = value;
321+
OnPropertyChanged();
322+
}
323+
}
324+
325+
private EnumBindingModel<DefaultFilesCopyOption> _selectedDefaultFilesCopyOption;
326+
public EnumBindingModel<DefaultFilesCopyOption> SelectedDefaultFilesCopyOption
327+
{
328+
get => _selectedDefaultFilesCopyOption;
329+
set
330+
{
331+
_selectedDefaultFilesCopyOption = value;
332+
Settings.DefaultFilesCopyOption = value.Value;
333+
OnPropertyChanged();
334+
}
335+
}
336+
337+
[MemberNotNull(nameof(_defaultFilesCopyOptions),
338+
nameof(_selectedDefaultFilesCopyOption))]
339+
private void InitializeDefaultFilesCopyOptionSelection()
340+
{
341+
_defaultFilesCopyOptions = EnumBindingModel<DefaultFilesCopyOption>.CreateList(Context);
342+
343+
_selectedDefaultFilesCopyOption = _defaultFilesCopyOptions.First(x => x.Value == Settings.DefaultFilesCopyOption);
344+
}
345+
346+
private void RefreshDefaultFilesCopyOptions()
347+
{
348+
_defaultFilesCopyOptions = EnumBindingModel<DefaultFilesCopyOption>.CreateList(Context);
349+
350+
SelectedDefaultFilesCopyOption = DefaultFilesCopyOptions.First(x => x.Value == Settings.DefaultFilesCopyOption);
351+
352+
OnPropertyChanged(nameof(DefaultFilesCopyOptions));
353+
}
354+
217355
#endregion
218356

219357
#region Cache Images
@@ -445,6 +583,9 @@ private void ClipboardPlus_CultureInfoChanged(object? sender, CultureInfo cultur
445583
{
446584
RefreshRecordOrders();
447585
RefreshClickActions();
586+
RefreshDefaultRichTextCopyOptions();
587+
RefreshDefaultImageCopyOptions();
588+
RefreshDefaultFilesCopyOptions();
448589
RefreshKeepTimes();
449590
}
450591

0 commit comments

Comments
 (0)