refactor(agent): Rename 'LongKeypressAction' to 'SecondaryRoleAction' (#462)
* refactor(agent): Rename 'LongKeypressAction' to 'SecondaryRoleAction' * build: Change the build order of the modules * fix(user-config): Fix hasSecondaryRoleAction() calculation * fix(user-config): fix stylelint warnings
This commit is contained in:
committed by
László Monda
parent
641248c9e6
commit
3ffaf918cd
@@ -4,6 +4,6 @@
|
||||
height: 100%;
|
||||
|
||||
p {
|
||||
margin: 1.5rem 0px 1.5rem;
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
<h4 *ngIf="activeTab === TabName.Keypress">Press key</h4>
|
||||
<h4 *ngIf="activeTab === TabName.Hold">Hold key</h4>
|
||||
<h4 *ngIf="activeTab === TabName.Release">Release key</h4>
|
||||
<keypress-tab #keypressTab [defaultKeyAction]="defaultKeyAction" [longPressEnabled]="false" (validAction)="validate()"></keypress-tab>
|
||||
<keypress-tab #keypressTab [defaultKeyAction]="defaultKeyAction" [secondaryRoleEnabled]="false"
|
||||
(validAction)="validate()"></keypress-tab>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<div [ngSwitch]="activeTab">
|
||||
<keypress-tab #tab *ngSwitchCase="tabName.Keypress" class="popover-content"
|
||||
[defaultKeyAction]="defaultKeyAction"
|
||||
[longPressEnabled]="true"
|
||||
[secondaryRoleEnabled]="true"
|
||||
(validAction)="keyActionValid=$event"
|
||||
></keypress-tab>
|
||||
<layer-tab #tab *ngSwitchCase="tabName.Layer" class="popover-content"
|
||||
|
||||
@@ -32,12 +32,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="long-press-container" *ngIf="longPressEnabled">
|
||||
<b class="setting-label">Long press action:</b>
|
||||
<select2 #longPressSelect
|
||||
[data]="longPressGroups"
|
||||
[value]="selectedLongPressIndex.toString()"
|
||||
(valueChanged)="onLongpressChange($event)"
|
||||
<div class="long-press-container" *ngIf="secondaryRoleEnabled">
|
||||
<b class="setting-label">Secondary role action:</b>
|
||||
<select2 #secondaryRoleSelect
|
||||
[data]="secondaryRoleGroups"
|
||||
[value]="selectedSecondaryRoleIndex.toString()"
|
||||
(valueChanged)="onSecondaryRoleChange($event)"
|
||||
[width]="140"
|
||||
></select2>
|
||||
<icon name="question-circle"
|
||||
|
||||
@@ -12,7 +12,7 @@ import { MapperService } from '../../../../services/mapper.service';
|
||||
})
|
||||
export class KeypressTabComponent extends Tab implements OnChanges {
|
||||
@Input() defaultKeyAction: KeyAction;
|
||||
@Input() longPressEnabled: boolean;
|
||||
@Input() secondaryRoleEnabled: boolean;
|
||||
|
||||
leftModifiers: string[];
|
||||
rightModifiers: string[];
|
||||
@@ -21,11 +21,11 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
||||
rightModifierSelects: boolean[];
|
||||
|
||||
scanCodeGroups: Array<Select2OptionData>;
|
||||
longPressGroups: Array<Select2OptionData>;
|
||||
secondaryRoleGroups: Array<Select2OptionData>;
|
||||
options: Select2Options;
|
||||
|
||||
selectedScancodeOption: Select2OptionData;
|
||||
selectedLongPressIndex: number;
|
||||
selectedSecondaryRoleIndex: number;
|
||||
|
||||
constructor(private mapper: MapperService) {
|
||||
super();
|
||||
@@ -36,11 +36,11 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
||||
text: 'None'
|
||||
}];
|
||||
this.scanCodeGroups = this.scanCodeGroups.concat(require('./scancodes.json'));
|
||||
this.longPressGroups = require('./longPress.json');
|
||||
this.secondaryRoleGroups = require('./secondaryRole.json');
|
||||
this.leftModifierSelects = Array(this.leftModifiers.length).fill(false);
|
||||
this.rightModifierSelects = Array(this.rightModifiers.length).fill(false);
|
||||
this.selectedScancodeOption = this.scanCodeGroups[0];
|
||||
this.selectedLongPressIndex = -1;
|
||||
this.selectedSecondaryRoleIndex = -1;
|
||||
this.options = {
|
||||
templateResult: this.scanCodeTemplateResult,
|
||||
matcher: (term: string, text: string, data: Select2OptionData) => {
|
||||
@@ -100,9 +100,9 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
||||
this.rightModifierSelects[index] = ((keystrokeAction.modifierMask >> i) & 1) === 1;
|
||||
}
|
||||
|
||||
// Restore longPressAction
|
||||
if (keystrokeAction.longPressAction !== undefined) {
|
||||
this.selectedLongPressIndex = this.mapper.modifierMapper(keystrokeAction.longPressAction);
|
||||
// Restore secondaryRoleAction
|
||||
if (keystrokeAction.secondaryRoleAction !== undefined) {
|
||||
this.selectedSecondaryRoleIndex = this.mapper.modifierMapper(keystrokeAction.secondaryRoleAction);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -123,9 +123,9 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
||||
keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i);
|
||||
}
|
||||
|
||||
keystrokeAction.longPressAction = this.selectedLongPressIndex === -1
|
||||
keystrokeAction.secondaryRoleAction = this.selectedSecondaryRoleIndex === -1
|
||||
? undefined
|
||||
: this.mapper.modifierMapper(this.selectedLongPressIndex);
|
||||
: this.mapper.modifierMapper(this.selectedSecondaryRoleIndex);
|
||||
|
||||
if (this.keyActionValid(keystrokeAction)) {
|
||||
return keystrokeAction;
|
||||
@@ -158,8 +158,8 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
||||
this.validAction.emit(this.keyActionValid());
|
||||
}
|
||||
|
||||
onLongpressChange(event: { value: string }) {
|
||||
this.selectedLongPressIndex = +event.value;
|
||||
onSecondaryRoleChange(event: { value: string }) {
|
||||
this.selectedSecondaryRoleIndex = +event.value;
|
||||
}
|
||||
|
||||
onScancodeChange(event: { value: string }) {
|
||||
|
||||
@@ -28,7 +28,7 @@ ul {
|
||||
|
||||
.sidebar {
|
||||
&__level-0 {
|
||||
padding: 0.5rem 1rem 0 1rem;
|
||||
padding: 0.5rem 1rem 0;
|
||||
}
|
||||
&__level-1 {
|
||||
padding: 0.5rem 1rem 0.5rem 2rem;
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
KeystrokeAction,
|
||||
Layer,
|
||||
LayerName,
|
||||
LongPressAction,
|
||||
SecondaryRoleAction,
|
||||
MouseAction,
|
||||
MouseActionParam,
|
||||
PlayMacroAction,
|
||||
@@ -266,10 +266,10 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
if (keystrokeAction.hasLongPressAction()) {
|
||||
if (keystrokeAction.hasSecondaryRoleAction()) {
|
||||
content.push({
|
||||
name: 'Long press',
|
||||
value: LongPressAction[keystrokeAction.longPressAction]
|
||||
name: 'Secondary role',
|
||||
value: SecondaryRoleAction[keystrokeAction.secondaryRoleAction]
|
||||
});
|
||||
}
|
||||
return Observable.of(content);
|
||||
|
||||
Reference in New Issue
Block a user