1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

eframe: Use NativeOptions::AppId for the persistance location (#3014)

* eframe: Use NativeOptions::AppId for the persistance location

* Fix doclinks

* Fix typo in docs

Closes https://github.com/emilk/egui/issues/3003
This commit is contained in:
Emil Ernerfeldt
2023-05-23 08:38:14 +02:00
committed by GitHub
parent 9d5b324787
commit 03bb89153b
5 changed files with 32 additions and 14 deletions

View File

@@ -105,11 +105,12 @@ pub trait App {
///
/// On web the state is stored to "Local Storage".
/// On native the path is picked using [`directories_next::ProjectDirs::data_dir`](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir) which is:
/// * Linux: `/home/UserName/.local/share/APPNAME`
/// * macOS: `/Users/UserName/Library/Application Support/APPNAME`
/// * Windows: `C:\Users\UserName\AppData\Roaming\APPNAME`
/// * Linux: `/home/UserName/.local/share/APP_ID`
/// * macOS: `/Users/UserName/Library/Application Support/APP_ID`
/// * Windows: `C:\Users\UserName\AppData\Roaming\APP_ID`
///
/// where `APPNAME` is what is given to `eframe::run_native`.
/// where `APP_ID` is determined by either [`NativeOptions::app_id`] or
/// the title argument to [`crate::run_native`].
fn save(&mut self, _storage: &mut dyn Storage) {}
/// Called when the user attempts to close the desktop window and/or quit the application.
@@ -384,7 +385,18 @@ pub struct NativeOptions {
#[cfg(feature = "wgpu")]
pub wgpu_options: egui_wgpu::WgpuConfiguration,
/// On Wayland: Application ID for the window.
/// The application id, used for determining the folder to persist the app to.
///
/// On native the path is picked using [`directories_next::ProjectDirs::data_dir`](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir) which is:
/// * Linux: `/home/UserName/.local/share/APP_ID`
/// * macOS: `/Users/UserName/Library/Application Support/APP_ID`
/// * Windows: `C:\Users\UserName\AppData\Roaming\APP_ID`
///
/// If you don't set [`Self::app_id`], the title argument to [`crate::run_native`]
/// will be used instead.
///
/// ### On Wayland
/// On Wauland this sets the Application ID for the window.
///
/// The application ID is used in several places of the compositor, e.g. for
/// grouping windows of the same application. It is also important for
@@ -415,7 +427,6 @@ pub struct NativeOptions {
/// })
/// }
/// ```
#[cfg(all(feature = "wayland", target_os = "linux"))]
pub app_id: Option<String>,
}
@@ -431,7 +442,6 @@ impl Clone for NativeOptions {
#[cfg(feature = "wgpu")]
wgpu_options: self.wgpu_options.clone(),
#[cfg(all(feature = "wayland", target_os = "linux"))]
app_id: self.app_id.clone(),
..*self
@@ -491,7 +501,6 @@ impl Default for NativeOptions {
#[cfg(feature = "wgpu")]
wgpu_options: egui_wgpu::WgpuConfiguration::default(),
#[cfg(all(feature = "wayland", target_os = "linux"))]
app_id: None,
}
}