Skip to content

Commit

Permalink
Bug fix for plugin localisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjadev64 committed Aug 17, 2024
1 parent a284266 commit 7ff3532
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 83 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ Special thanks go to the developers of [Tauri](https://github.com/tauri-apps/tau
- Open the installed application. Note: if you receive a warning about OpenDeck being distributed by an unknown developer, *right-click the app in Finder and then click Open* to suppress the warning.
- If you intend to use plugins that are only compiled for Windows, you will need to have [Wine](https://www.winehq.org/) installed on your system.

## Showcase

![Main menu](.github/readme/mainmenu.png)
![Light mode](.github/readme/lightmode.png)
![Multi action](.github/readme/multiaction.png)
![Plugins](.github/readme/plugins.png)
![Profiles](.github/readme/profiles.png)

## Support

### How do I...?
Expand All @@ -50,17 +42,18 @@ To view or modify an action's settings, left-click on it to display its property

To edit an action's appearance, right-click on it and select "Edit" in the context menu. You should then be able to customise the image and title of each of its states. To choose an image from your device: left-click on the image, to reset it to the plugin-provided default: right-click on the image, and to remove the image entirely: CTRL+right-click on the image.

To select another device, or to view, switch, modify, import or export profiles, use the dropdowns in the top right corner. You can organise profiles into group-like folders by prefixing the profile name with the folder name and a forward slash.
To select another device, or to view or switch profiles, use the dropdowns in the top right corner. You can organise profiles into group-like folders by prefixing the profile name with the folder name and a forward slash.

To enable automatic launch on startup, the light theme, or to change the language plugins are localised in, open Settings. From here, you can also view information about your version of OpenDeck or open the configuration directory. To add or remove plugins, visit the Plugins tab.

### Solutions to frequent problems

- Check the OpenDeck log file for any important messages. This file should be included with any support request.
- GNU+Linux: `~/config/com.amansprojects.opendeck/logs/`
- Windows: `%appdata%/com.amansprojects.opendeck/logs`
- macOS: `~/Library/Application Support/com.amansprojects.opendeck/logs`
- When trying to run Windows-only plugins (which are the majority of plugins) on GNU+Linux or macOS, please ensure you have the latest version of Wine installed on your system.
- Windows: `%appdata%\com.amansprojects.opendeck\logs\`
- macOS: `~/Library/Application Support/com.amansprojects.opendeck/logs/`
- For issues with plugins, you can also check the plugin's logs (in the same folder as above, sometimes as well as a file named `plugin.log` or similar in the plugin's own folder).
- When trying to run Windows-only plugins (which are the majority of plugins) on GNU+Linux or macOS, please ensure you have the latest version of Wine (and Wine Mono) installed on your system.
- If your device isn't showing up, ensure you have the correct permissions to access it, and that you have restarted OpenDeck since connecting it.

### Support forums
Expand All @@ -76,3 +69,11 @@ You'll need to ensure that all of the [prerequisites for building a Tauri applic
When submitting a pull request, ensure that all of your Rust code has been formatted using `cargo fmt`, `cargo clippy` returns no violations, `deno task check` returns no violations, and modified Svelte code sticks to the existing style used as far as possible. Feel free to reach out on the support channels above for guidance when contributing!

OpenDeck is licensed under the MIT license.

## Showcase

![Main menu](.github/readme/mainmenu.png)
![Light mode](.github/readme/lightmode.png)
![Multi action](.github/readme/multiaction.png)
![Plugins](.github/readme/plugins.png)
![Profiles](.github/readme/profiles.png)
7 changes: 2 additions & 5 deletions src-tauri/src/events/frontend/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn get_selected_profile(device: String) -> Result<crate::shared::Profi

#[allow(clippy::flat_map_identity)]
#[command]
pub async fn set_selected_profile(app: AppHandle, device: String, id: String, profile: Option<crate::shared::Profile>) -> Result<(), Error> {
pub async fn set_selected_profile(app: AppHandle, device: String, id: String) -> Result<(), Error> {
let mut device_stores = DEVICE_STORES.write().await;
let devices = DEVICES.read().await;
let mut profile_stores = PROFILE_STORES.write().await;
Expand All @@ -44,10 +44,7 @@ pub async fn set_selected_profile(app: AppHandle, device: String, id: String, pr

// We must use the mutable version of get_profile_store in order to create the store if it does not exist.
let store = profile_stores.get_profile_store_mut(devices.get(&device).unwrap(), &id, &app).await?;
let new_profile = &mut store.value;
if let Some(profile) = profile {
*new_profile = profile;
}
let new_profile = &store.value;
for instance in new_profile.keys.iter().flatten().chain(&mut new_profile.sliders.iter().flatten()) {
if !matches!(instance.action.uuid.as_str(), "com.amansprojects.opendeck.multiaction" | "com.amansprojects.opendeck.toggleaction") {
let _ = crate::events::outbound::will_appear::will_appear(instance, false).await;
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/plugins/info_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub async fn make_info(uuid: String, version: String, wine: bool) -> Info {
Info {
application: ApplicationInfo {
font: "ui-sans-serif".to_owned(),
language: "en".to_owned(),
language: crate::store::get_settings(crate::APP_HANDLE.get().unwrap()).unwrap().value.language,
platform: if !wine { platform.to_owned() } else { "windows".to_owned() },
platformVersion: if !wine { os_info::get().version().to_string() } else { "10.0.19045.4474".to_owned() },
version: env!("CARGO_PKG_VERSION").to_owned(),
Expand Down
67 changes: 2 additions & 65 deletions src/components/ProfileSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
getProfiles(device);
export let profile: Profile;
export async function setProfile(id: string, toSet: Profile | undefined = undefined) {
export async function setProfile(id: string) {
if (!device || !id) return;
if (value != id) {
value = id;
return;
}
await invoke("set_selected_profile", { device: device.id, id, profile: toSet });
await invoke("set_selected_profile", { device: device.id, id });
profile = await invoke("get_selected_profile", { device: device.id });
let folder = id.includes("/") ? id.split("/")[0] : "";
Expand All @@ -52,43 +52,6 @@
folders = folders;
}
function exportProfile() {
navigator.clipboard.writeText(JSON.stringify(
profile,
(k: string, v: string) => {
if (k == "context") return v.replace(device.id, "no-device");
return v;
},
2
));
alert(`Copied profile ${value} to clipboard.`);
}
let fileInput: HTMLInputElement;
function importProfile() {
if (!fileInput.files || fileInput.files.length == 0) return;
const reader = new FileReader();
reader.onload = async () => {
let p: Profile = JSON.parse(
reader.result! as string,
(k: string, v: string) => {
if (k == "context") return v.replace("no-device", device.id);
return v;
}
);
if (p.keys.length != device.rows * device.columns || p.sliders.length != device.sliders) {
alert("The imported profile is incompatible with the selected device.");
return;
}
if ((p.id.includes("/") ? folders[p.id.split("/")[0]] : folders[""]).includes(p.id)) {
if (!await confirm(`Are you sure you want to overwrite profile ${p.id}?`)) return;
}
setProfile(p.id, p);
value = p.id;
};
reader.readAsText(fileInput.files[0]);
}
let oldValue: string;
$: {
if (value == "opendeck_edit_profiles") {
Expand Down Expand Up @@ -135,22 +98,6 @@
placeholder='Profile ID (e.g. "folder/profile")'
/>

<input
type="file"
bind:this={fileInput}
on:change={importProfile}
class="hidden"
/>
<button
on:click={() => fileInput.click()}
class="px-3 dark:text-neutral-300 bg-neutral-200 dark:bg-neutral-900 border-r border-neutral-300 dark:border-neutral-700"
>
<Upload
size="20"
color={document.documentElement.classList.contains("dark") ? "#C0BFBC" : "#77767B"}
/>
</button>

<button
on:click={async () => {
if (!nameInput.checkValidity()) return;
Expand Down Expand Up @@ -184,16 +131,6 @@
color={document.documentElement.classList.contains("dark") ? "#C0BFBC" : "#77767B"}
/>
</button>
{:else}
<button
on:click={exportProfile}
class="float-right"
>
<Download
size="20"
color={document.documentElement.classList.contains("dark") ? "#C0BFBC" : "#77767B"}
/>
</button>
{/if}
</div>
{/each}
Expand Down

0 comments on commit 7ff3532

Please sign in to comment.