ui: icon namings at right side
This commit is contained in:
parent
f759fc0b71
commit
1ddd93342e
2 changed files with 53 additions and 42 deletions
|
@ -37,10 +37,10 @@ if (!isLinux)
|
||||||
|
|
||||||
const statusToSettingsKey = {
|
const statusToSettingsKey = {
|
||||||
icon: { key: "trayMainOverride", label: "Main Icon" },
|
icon: { key: "trayMainOverride", label: "Main Icon" },
|
||||||
idle: { key: "trayIdleOverride", label: "Idle icon" },
|
idle: { key: "trayIdleOverride", label: "Idle Icon" },
|
||||||
speaking: { key: "traySpeakingOverride", label: "Speaking icon" },
|
speaking: { key: "traySpeakingOverride", label: "Speaking Icon" },
|
||||||
muted: { key: "trayMutedOverride", label: "Muted icon" },
|
muted: { key: "trayMutedOverride", label: "Muted Icon" },
|
||||||
deafened: { key: "trayDeafenedOverride", label: "Deafened icon" }
|
deafened: { key: "trayDeafenedOverride", label: "Deafened Icon" }
|
||||||
};
|
};
|
||||||
|
|
||||||
function trayEditButton(iconName: string) {
|
function trayEditButton(iconName: string) {
|
||||||
|
@ -99,49 +99,53 @@ function TrayModalComponent({ modalProps, close }: { modalProps: any; close: ()
|
||||||
<Modals.ModalContent className="vcd-custom-tray-modal">
|
<Modals.ModalContent className="vcd-custom-tray-modal">
|
||||||
{Object.entries(statusToSettingsKey).map(([iconName, { key, label }]) => (
|
{Object.entries(statusToSettingsKey).map(([iconName, { key, label }]) => (
|
||||||
<div key={iconName}>
|
<div key={iconName}>
|
||||||
<Forms.FormTitle tag="h3">{label}</Forms.FormTitle>
|
|
||||||
<Forms.FormSection className="vcd-custom-tray-icon-section">
|
<Forms.FormSection className="vcd-custom-tray-icon-section">
|
||||||
{trayEditButton(iconName)}
|
<div className="vcd-custom-tray-buttons">
|
||||||
<Button
|
{trayEditButton(iconName)}
|
||||||
onClick={async () => {
|
|
||||||
const choice = await VesktopNative.fileManager.selectTrayIcon(iconName);
|
|
||||||
switch (choice) {
|
|
||||||
case "cancelled":
|
|
||||||
return;
|
|
||||||
case "invalid":
|
|
||||||
Toasts.show({
|
|
||||||
message: "Please select a valid .png or .jpg image!",
|
|
||||||
id: Toasts.genId(),
|
|
||||||
type: Toasts.Type.FAILURE
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const iconKey =
|
|
||||||
statusToSettingsKey[iconName as keyof typeof statusToSettingsKey].key;
|
|
||||||
Settings[iconKey] = true;
|
|
||||||
const iconDataURL = VesktopNative.tray.getIconSync(iconName);
|
|
||||||
const img = document.getElementById(iconName) as HTMLImageElement;
|
|
||||||
if (img) {
|
|
||||||
img.src = iconDataURL;
|
|
||||||
}
|
|
||||||
setCurrentTrayIcon();
|
|
||||||
}}
|
|
||||||
look={Button.Looks.OUTLINED}
|
|
||||||
>
|
|
||||||
Choose icon
|
|
||||||
</Button>
|
|
||||||
{Settings[key] && (
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
Settings.trayMainOverride = false;
|
const choice = await VesktopNative.fileManager.selectTrayIcon(iconName);
|
||||||
|
switch (choice) {
|
||||||
|
case "cancelled":
|
||||||
|
return;
|
||||||
|
case "invalid":
|
||||||
|
Toasts.show({
|
||||||
|
message: "Please select a valid .png or .jpg image!",
|
||||||
|
id: Toasts.genId(),
|
||||||
|
type: Toasts.Type.FAILURE
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iconKey =
|
||||||
|
statusToSettingsKey[iconName as keyof typeof statusToSettingsKey].key;
|
||||||
|
Settings[iconKey] = true;
|
||||||
|
const iconDataURL = VesktopNative.tray.getIconSync(iconName);
|
||||||
|
const img = document.getElementById(iconName) as HTMLImageElement;
|
||||||
|
if (img) {
|
||||||
|
img.src = iconDataURL;
|
||||||
|
}
|
||||||
setCurrentTrayIcon();
|
setCurrentTrayIcon();
|
||||||
}}
|
}}
|
||||||
look={Button.Looks.LINK}
|
look={Button.Looks.OUTLINED}
|
||||||
>
|
>
|
||||||
Reset Icon
|
Choose Icon
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
{Settings[key] && (
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
Settings.trayMainOverride = false;
|
||||||
|
setCurrentTrayIcon();
|
||||||
|
}}
|
||||||
|
look={Button.Looks.LINK}
|
||||||
|
>
|
||||||
|
Reset Icon
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Forms.FormText>{label}</Forms.FormText>
|
||||||
|
</div>
|
||||||
</Forms.FormSection>
|
</Forms.FormSection>
|
||||||
<Forms.FormDivider className={`${Margins.top8} ${Margins.bottom8}`} />
|
<Forms.FormDivider className={`${Margins.top8} ${Margins.bottom8}`} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
column-gap: 1em;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vcd-custom-tray-icon-form-text {
|
.vcd-custom-tray-icon-form-text {
|
||||||
|
@ -89,4 +89,11 @@
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vcd-custom-tray-buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
column-gap: 1em;
|
||||||
}
|
}
|
Loading…
Reference in a new issue