|
| 1 | +// Defines Data Transfer Objects (DTOs) for various UI elements like dialogs, |
| 2 | +// quick picks, and input boxes, used for communication between the backend and |
| 3 | +// frontend. |
| 4 | + |
| 5 | +#![allow(non_snake_case, non_camel_case_types)] |
| 6 | + |
| 7 | +use serde::{Deserialize, Serialize}; |
| 8 | + |
| 9 | +/// Specifies the severity level for a message dialog. |
| 10 | +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 11 | +pub enum MessageSeverity { |
| 12 | + Info, |
| 13 | + Warning, |
| 14 | + Error, |
| 15 | +} |
| 16 | + |
| 17 | +/// Defines options for a message dialog. |
| 18 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 19 | +#[serde(rename_all = "PascalCase")] |
| 20 | +pub struct MessageOptions { |
| 21 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 22 | + pub Title:Option<String>, |
| 23 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 24 | + pub Modal:Option<bool>, |
| 25 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 26 | + pub Detail:Option<String>, |
| 27 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 28 | + pub ItemList:Option<Vec<String>>, |
| 29 | +} |
| 30 | + |
| 31 | +/// Represents a filter for file dialogs. |
| 32 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 33 | +#[serde(rename_all = "PascalCase")] |
| 34 | +pub struct FileFilter { |
| 35 | + pub Name:String, |
| 36 | + #[serde(alias = "extensions")] |
| 37 | + pub ExtensionList:Vec<String>, |
| 38 | +} |
| 39 | + |
| 40 | +/// Common base options for file dialogs. |
| 41 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 42 | +#[serde(rename_all = "PascalCase")] |
| 43 | +pub struct DialogOptions { |
| 44 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 45 | + pub Title:Option<String>, |
| 46 | + #[serde(skip_serializing_if = "Option::is_none", alias = "defaultPath")] |
| 47 | + pub DefaultPath:Option<String>, |
| 48 | + #[serde(skip_serializing_if = "Option::is_none", alias = "filters")] |
| 49 | + pub FilterList:Option<Vec<FileFilter>>, |
| 50 | +} |
| 51 | + |
| 52 | +/// Defines options for a file open dialog. |
| 53 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 54 | +#[serde(rename_all = "PascalCase")] |
| 55 | +pub struct OpenDialogOptions { |
| 56 | + #[serde(flatten)] |
| 57 | + pub Base:DialogOptions, |
| 58 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 59 | + pub Multiple:Option<bool>, |
| 60 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 61 | + pub Directory:Option<bool>, |
| 62 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 63 | + pub Recursive:Option<bool>, |
| 64 | +} |
| 65 | + |
| 66 | +/// Defines options for a file save dialog. |
| 67 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 68 | +#[serde(rename_all = "PascalCase")] |
| 69 | +pub struct SaveDialogOptions { |
| 70 | + #[serde(flatten)] |
| 71 | + pub Base:DialogOptions, |
| 72 | +} |
| 73 | + |
| 74 | +/// Represents a single item in a quick pick list. |
| 75 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 76 | +#[serde(rename_all = "PascalCase")] |
| 77 | +pub struct QuickPickItem { |
| 78 | + pub Label:String, |
| 79 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 80 | + pub Description:Option<String>, |
| 81 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 82 | + pub Detail:Option<String>, |
| 83 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 84 | + pub Picked:Option<bool>, |
| 85 | + #[serde(skip_serializing_if = "Option::is_none", alias = "alwaysShow")] |
| 86 | + pub AlwaysShow:Option<bool>, |
| 87 | +} |
| 88 | + |
| 89 | +/// Defines options for a quick pick UI element. |
| 90 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 91 | +#[serde(rename_all = "PascalCase")] |
| 92 | +pub struct QuickPickOptions { |
| 93 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 94 | + pub Title:Option<String>, |
| 95 | + #[serde(skip_serializing_if = "Option::is_none", alias = "placeHolder")] |
| 96 | + pub PlaceHolder:Option<String>, |
| 97 | + #[serde(skip_serializing_if = "Option::is_none", alias = "canPickMany")] |
| 98 | + pub CanPickMany:Option<bool>, |
| 99 | + #[serde(skip_serializing_if = "Option::is_none", alias = "ignoreFocusOut")] |
| 100 | + pub IgnoreFocusOut:Option<bool>, |
| 101 | +} |
| 102 | + |
| 103 | +/// Defines options for an input box UI element. |
| 104 | +#[derive(Serialize, Deserialize, Debug, Clone, Default)] |
| 105 | +#[serde(rename_all = "PascalCase")] |
| 106 | +pub struct InputBoxOptions { |
| 107 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 108 | + pub Title:Option<String>, |
| 109 | + #[serde(skip_serializing_if = "Option::is_none", alias = "placeHolder")] |
| 110 | + pub PlaceHolder:Option<String>, |
| 111 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 112 | + pub Value:Option<String>, |
| 113 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 114 | + pub Prompt:Option<String>, |
| 115 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 116 | + pub Password:Option<bool>, |
| 117 | + #[serde(skip_serializing_if = "Option::is_none", alias = "ignoreFocusOut")] |
| 118 | + pub IgnoreFocusOut:Option<bool>, |
| 119 | +} |
0 commit comments