Add ability to name variant during creation; v2.0.0-alpha2
This commit is contained in:
parent
e27c899d1a
commit
1a4bfb9669
7 changed files with 212 additions and 80 deletions
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -1170,7 +1170,7 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
|||
|
||||
[[package]]
|
||||
name = "powertools"
|
||||
version = "2.0.0-alpha1"
|
||||
version = "2.0.0-alpha2"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "powertools"
|
||||
version = "2.0.0-alpha1"
|
||||
version = "2.0.0-alpha2"
|
||||
edition = "2021"
|
||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||
description = "Backend (superuser) functionality for PowerTools"
|
||||
|
|
|
@ -1,58 +1,8 @@
|
|||
FileJson(
|
||||
version: 0,
|
||||
name: "Main",
|
||||
app_id: 0,
|
||||
variants: {
|
||||
0: SettingsJson(
|
||||
version: 0,
|
||||
name: "Primary",
|
||||
variant: 0,
|
||||
persistent: false,
|
||||
cpus: [CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
)],
|
||||
gpu: GpuJson(
|
||||
fast_ppt: None,
|
||||
slow_ppt: None,
|
||||
clock_limits: None,
|
||||
slow_memory: false,
|
||||
),
|
||||
battery: BatteryJson(
|
||||
charge_rate: None,
|
||||
charge_mode: None,
|
||||
events: [],
|
||||
),
|
||||
provider: None,
|
||||
),
|
||||
42: SettingsJson(
|
||||
version: 0,
|
||||
name: "FortySecondary",
|
||||
|
@ -94,8 +44,63 @@ FileJson(
|
|||
gpu: GpuJson(
|
||||
fast_ppt: None,
|
||||
slow_ppt: None,
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
clock_limits: None,
|
||||
slow_memory: false,
|
||||
memory_clock: None,
|
||||
),
|
||||
battery: BatteryJson(
|
||||
charge_rate: None,
|
||||
charge_mode: None,
|
||||
events: [],
|
||||
),
|
||||
provider: None,
|
||||
),
|
||||
0: SettingsJson(
|
||||
version: 0,
|
||||
name: "Primary",
|
||||
variant: 0,
|
||||
persistent: false,
|
||||
cpus: [CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
), CpuJson(
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil",
|
||||
)],
|
||||
gpu: GpuJson(
|
||||
fast_ppt: None,
|
||||
slow_ppt: None,
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
clock_limits: None,
|
||||
memory_clock: None,
|
||||
),
|
||||
battery: BatteryJson(
|
||||
charge_rate: None,
|
||||
|
|
|
@ -12,7 +12,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -23,7 +28,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -34,7 +44,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -45,7 +60,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -56,7 +76,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -67,7 +92,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -78,7 +108,12 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
), GenericCpuLimit(
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(1400),
|
||||
|
@ -89,9 +124,18 @@ Limits(
|
|||
max: Some(3500),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
skip_resume_reclock: false,
|
||||
experiments: false,
|
||||
)],
|
||||
global_governors: true,
|
||||
extras: LimitExtras(
|
||||
experiments: false,
|
||||
quirks: [],
|
||||
),
|
||||
),
|
||||
),
|
||||
gpu: Limit(
|
||||
|
@ -111,6 +155,7 @@ Limits(
|
|||
ppt_step: Some(1),
|
||||
tdp: None,
|
||||
tdp_boost: None,
|
||||
tdp_divisor: None,
|
||||
tdp_step: None,
|
||||
clock_min: Some(RangeLimit(
|
||||
min: Some(400),
|
||||
|
@ -121,7 +166,16 @@ Limits(
|
|||
max: Some(1600),
|
||||
)),
|
||||
clock_step: Some(100),
|
||||
memory_clock: Some(RangeLimit(
|
||||
min: Some(400),
|
||||
max: Some(800),
|
||||
)),
|
||||
memory_clock_step: Some(400),
|
||||
skip_resume_reclock: false,
|
||||
extras: LimitExtras(
|
||||
experiments: false,
|
||||
quirks: ["pp_dpm_fclk-not-updated-on-LCD", "pp_dpm_fclk-reversed"],
|
||||
),
|
||||
),
|
||||
),
|
||||
battery: Limit(
|
||||
|
@ -137,6 +191,10 @@ Limits(
|
|||
max: Some(90.0),
|
||||
)),
|
||||
extra_readouts: false,
|
||||
extras: LimitExtras(
|
||||
experiments: false,
|
||||
quirks: [],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "PowerTools",
|
||||
"version": "2.0.0-alpha1",
|
||||
"version": "2.0.0-alpha2",
|
||||
"description": "Power tweaks for power users",
|
||||
"scripts": {
|
||||
"build": "shx rm -rf dist && rollup -c",
|
||||
|
|
65
src/components/text_field_modal.tsx
Normal file
65
src/components/text_field_modal.tsx
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Based on https://github.com/isiah-lloyd/radiyo-steam-deck/blob/main/src/TextFieldModal.tsx
|
||||
|
||||
import { ModalRoot, ModalRootProps, Router, TextField, Focusable, DialogButton } from 'decky-frontend-lib';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { HiCheck, HiX } from "react-icons/hi";
|
||||
type props = ModalRootProps & {
|
||||
label: string,
|
||||
placeholder: string,
|
||||
onClosed: (inputText: string) => void;
|
||||
}
|
||||
export const TextFieldModal = ({ closeModal, onClosed, label, placeholder }: props) => {
|
||||
const [inputText, setInputText] = useState('');
|
||||
const handleText = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setInputText(e.target.value);
|
||||
};
|
||||
const textField = useRef<any>();
|
||||
useEffect(() => {
|
||||
Router.CloseSideMenus();
|
||||
//This will open up the virtual keyboard
|
||||
textField.current?.element?.click();
|
||||
}, []);
|
||||
const submit = () => onClosed(inputText);
|
||||
return (
|
||||
<ModalRoot closeModal={closeModal} onEscKeypress={closeModal}>
|
||||
<form onSubmit={submit}>
|
||||
<TextField
|
||||
//@ts-ignore
|
||||
ref={textField}
|
||||
focusOnMount={true}
|
||||
label={label}
|
||||
placeholder={placeholder}
|
||||
onChange={handleText}
|
||||
/>
|
||||
<Focusable style={{
|
||||
alignItems: "center",
|
||||
display: "flex",
|
||||
justifyContent: "space-around",
|
||||
}}
|
||||
flow-children="horizontal"
|
||||
>
|
||||
<DialogButton
|
||||
style={{
|
||||
maxWidth: "45%",
|
||||
minWidth: "auto",
|
||||
}}
|
||||
//layout="below"
|
||||
onClick={(_: MouseEvent) => { submit() }}
|
||||
>
|
||||
<HiCheck/>
|
||||
</DialogButton>
|
||||
<DialogButton
|
||||
style={{
|
||||
maxWidth: "45%",
|
||||
minWidth: "auto",
|
||||
}}
|
||||
//layout="below"
|
||||
onClick={(_: MouseEvent) => { if (closeModal) { closeModal() } }}
|
||||
>
|
||||
<HiX/>
|
||||
</DialogButton>
|
||||
</Focusable>
|
||||
</form>
|
||||
</ModalRoot>
|
||||
);
|
||||
};
|
|
@ -2,25 +2,20 @@ import {
|
|||
ButtonItem,
|
||||
definePlugin,
|
||||
DialogButton,
|
||||
//Menu,
|
||||
//MenuItem,
|
||||
PanelSection,
|
||||
PanelSectionRow,
|
||||
ServerAPI,
|
||||
//showContextMenu,
|
||||
staticClasses,
|
||||
//SliderField,
|
||||
ToggleField,
|
||||
//Dropdown,
|
||||
Field,
|
||||
Dropdown,
|
||||
SingleDropdownOption,
|
||||
Navigation,
|
||||
Focusable,
|
||||
Spinner,
|
||||
//NotchLabel
|
||||
//gamepadDialogClasses,
|
||||
//joinClassNames,
|
||||
showModal,
|
||||
QuickAccessTab,
|
||||
ShowModalResult,
|
||||
} from "decky-frontend-lib";
|
||||
import { VFC, useState } from "react";
|
||||
import { GiDrill, GiFireExtinguisher, GiFireBomb, GiMineExplosion } from "react-icons/gi";
|
||||
|
@ -83,6 +78,8 @@ import { Battery } from "./components/battery";
|
|||
import { Cpus } from "./components/cpus";
|
||||
import { DevMessages } from "./components/message";
|
||||
|
||||
import { TextFieldModal } from "./components/text_field_modal";
|
||||
|
||||
import { StoreResultsPage } from "./store/page";
|
||||
|
||||
var periodicHook: NodeJS.Timeout | null = null;
|
||||
|
@ -346,12 +343,29 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
|
|||
data: elem,
|
||||
label: <span>{elem.name}</span>,
|
||||
};});
|
||||
console.log("variant options", variantOptions);
|
||||
console.log("current variant", get_value(CURRENT_VARIANT_GEN));
|
||||
console.log("variant selected", variantOptions.find((val: SingleDropdownOption, _index, _arr) => {
|
||||
backend.log(backend.LogLevel.Debug, "POWERTOOLS: looking for variant data.id " + (get_value(CURRENT_VARIANT_GEN) as backend.VariantInfo).id.toString());
|
||||
return (val.data as backend.VariantInfo).id == (get_value(CURRENT_VARIANT_GEN) as backend.VariantInfo).id;
|
||||
}));
|
||||
|
||||
var modalResult: ShowModalResult | undefined = undefined;
|
||||
|
||||
const onNewVariantModelClosed = (name: string) => {
|
||||
if (modalResult) {
|
||||
modalResult.Close();
|
||||
}
|
||||
console.log("POWERTOOLS: variant name", name);
|
||||
isVariantLoading = true;
|
||||
backend.resolve(
|
||||
backend.loadGeneralSettingsVariant("please give me a new ID k thx bye" /* anything that cannot be parsed as a u64 will be set to u64::MAX, which will cause the back-end to auto-generate an ID */, name),
|
||||
(ok: boolean) => {
|
||||
isVariantLoading = false;
|
||||
backend.log(backend.LogLevel.Debug, "New settings variant ok? " + ok);
|
||||
reload();
|
||||
backend.resolve(backend.waitForComplete(), (_) => {
|
||||
backend.log(backend.LogLevel.Debug, "Trying to tell UI to re-render due to new settings variant");
|
||||
tryNotifyProfileChange();
|
||||
});
|
||||
}
|
||||
);
|
||||
Navigation.OpenQuickAccessMenu(QuickAccessTab.Decky);
|
||||
};
|
||||
|
||||
return (
|
||||
<PanelSection>
|
||||
|
@ -441,17 +455,7 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
|
|||
//layout="below"
|
||||
onClick={(_: MouseEvent) => {
|
||||
backend.log(backend.LogLevel.Debug, "Creating new PowerTools settings variant");
|
||||
backend.resolve(
|
||||
backend.loadGeneralSettingsVariant("please give me a new ID k thx bye" /* anything that cannot be parsed as a u64 will be set to u64::MAX, which will cause the back-end to auto-generate an ID */, undefined),
|
||||
(ok: boolean) => {
|
||||
backend.log(backend.LogLevel.Debug, "New settings variant ok? " + ok);
|
||||
reload();
|
||||
backend.resolve(backend.waitForComplete(), (_) => {
|
||||
backend.log(backend.LogLevel.Debug, "Trying to tell UI to re-render due to new settings variant");
|
||||
tryNotifyProfileChange();
|
||||
});
|
||||
}
|
||||
);
|
||||
modalResult = showModal(<TextFieldModal label={tr("Profile Variant") /* TODO translate */} placeholder={tr("Variant name") /* TODO translate */} onClosed={onNewVariantModelClosed} closeModal={() => { modalResult?.Close(); Navigation.OpenQuickAccessMenu(QuickAccessTab.Decky)}}/>, window);
|
||||
}}
|
||||
>
|
||||
<HiPlus/>
|
||||
|
|
Loading…
Reference in a new issue