feat: make double tap to hold layer optional per key (#662)

* feat: make double tap to hold layer optional per key

* test: fix test serializer

* fix: remove "application start" text

* Add double-tap.svg

* Add closing dot at the end of the sentence.

* fead: add double-tap icon

* Bundle firmware version 8.3.0

* feat: 'layer-double-tap' feature flag

* feat: convert SwitchLayerMode to string enum
This commit is contained in:
Róbert Kiss
2018-06-07 22:11:41 +02:00
committed by László Monda
parent 81a83994ab
commit 4ae577f936
25 changed files with 1284 additions and 144 deletions

View File

@@ -5,6 +5,7 @@
<svg-keyboard-wrap [keymap]="keymap$ | async"
[halvesSplit]="keyboardSplit"
[keyboardLayout]="keyboardLayout$ | async"
[allowLayerDoubleTap]="allowLayerDoubleTap$ | async"
(descriptionChanged)="descriptionChanged($event)"></svg-keyboard-wrap>
</ng-template>

View File

@@ -1,4 +1,4 @@
import { Component, HostListener, ViewChild } from '@angular/core';
import { Component, HostListener } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { Keymap } from 'uhk-common';
@@ -14,9 +14,8 @@ import 'rxjs/add/operator/combineLatest';
import { saveAs } from 'file-saver';
import { AppState, getKeyboardLayout } from '../../../store';
import { allowLayerDoubleTap, AppState, getKeyboardLayout } from '../../../store';
import { getKeymap, getKeymaps, getUserConfiguration } from '../../../store/reducers/user-configuration';
import { SvgKeyboardWrapComponent } from '../../svg/wrap';
import { KeyboardLayout } from '../../../keyboard/keyboard-layout.enum';
import { KeymapActions } from '../../../store/actions';
import { ChangeKeymapDescription } from '../../../models/ChangeKeymapDescription';
@@ -31,13 +30,12 @@ import { ChangeKeymapDescription } from '../../../models/ChangeKeymapDescription
})
export class KeymapEditComponent {
@ViewChild(SvgKeyboardWrapComponent) wrap: SvgKeyboardWrapComponent;
keyboardSplit: boolean;
deletable$: Observable<boolean>;
keymap$: Observable<Keymap>;
keyboardLayout$: Observable<KeyboardLayout>;
allowLayerDoubleTap$: Observable<boolean>;
constructor(protected store: Store<AppState>,
route: ActivatedRoute) {
@@ -52,6 +50,7 @@ export class KeymapEditComponent {
.map((keymaps: Keymap[]) => keymaps.length > 1);
this.keyboardLayout$ = store.select(getKeyboardLayout);
this.allowLayerDoubleTap$ = store.select(allowLayerDoubleTap);
}
downloadKeymap() {

View File

@@ -55,6 +55,7 @@
<layer-tab #tab *ngSwitchCase="tabName.Layer" class="popover-content"
[defaultKeyAction]="defaultKeyAction"
[currentLayer]="currentLayer"
[allowLayerDoubleTap]="allowLayerDoubleTap"
(validAction)="keyActionValid=$event"
></layer-tab>
<mouse-tab #tab *ngSwitchCase="tabName.Mouse" class="popover-content"

View File

@@ -27,7 +27,7 @@ import {
SwitchLayerAction
} from 'uhk-common';
import { Tab } from './tab/tab';
import { Tab } from './tab';
import { AppState } from '../../store';
import { getKeymaps } from '../../store/reducers/user-configuration';
@@ -82,6 +82,7 @@ export class PopoverComponent implements OnChanges {
@Input() keyPosition: any;
@Input() wrapPosition: any;
@Input() visible: boolean;
@Input() allowLayerDoubleTap: boolean;
@Output() cancel = new EventEmitter<any>();
@Output() remap = new EventEmitter<KeyAction>();

View File

@@ -1,20 +1,32 @@
<ng-template [ngIf]="!isNotBase">
<select (change)="toggleChanged($event.target.value)">
<option *ngFor="let item of toggleData" [value]="item.id" [selected]="toggle === item.id">
{{ item.text }}
</option>
</select>
<span>the</span>
<select (change)="layerChanged($event.target.value)">
<option *ngFor="let item of layerData" [value]="item.id" [selected]="layer === item.id">
{{ item.text }}
</option>
</select>
<span [ngSwitch]="toggle">
<ng-template [ngSwitchCase]="true">layer by tapping this key.</ng-template>
<ng-template ngSwitchDefault>layer by holding this key.</ng-template>
</span>
<div>
<div>
<select (change)="toggleChanged($event.target.value)">
<option *ngFor="let item of toggleData" [value]="item.id" [selected]="toggle === item.id">
{{ item.text }}
</option>
</select>
<span>the</span>
<select (change)="layerChanged($event.target.value)">
<option *ngFor="let item of layerData" [value]="item.id" [selected]="layer === item.id">
{{ item.text }}
</option>
</select>
<span [ngSwitch]="toggle">
<ng-template [ngSwitchCase]="'toggle'">layer by tapping this key.</ng-template>
<ng-template ngSwitchDefault>layer by holding this key.</ng-template>
</span>
</div>
<div *ngIf="toggle === 'active' && allowLayerDoubleTap">
<div class="checkbox">
<label>
<input type="checkbox"
[(ngModel)]="lockLayerWhenDoubleTapping"> Lock layer when double tapping this key.
</label>
</div>
</div>
</div>
</ng-template>
<ng-template [ngIf]="isNotBase">
<span> Layer switching is only possible from the base layer. </span>
</ng-template>
</ng-template>

View File

@@ -1,8 +1,10 @@
import { Component, HostBinding, Input, OnChanges, SimpleChanges } from '@angular/core';
import { KeyAction, LayerName, SwitchLayerAction } from 'uhk-common';
import { KeyAction, LayerName, SwitchLayerAction, SwitchLayerMode } from 'uhk-common';
import { Tab } from '../tab';
export type toggleType = 'active' | 'toggle';
@Component({
selector: 'layer-tab',
templateUrl: './layer-tab.component.html',
@@ -11,16 +13,17 @@ import { Tab } from '../tab';
export class LayerTabComponent extends Tab implements OnChanges {
@Input() defaultKeyAction: KeyAction;
@Input() currentLayer: number;
@Input() allowLayerDoubleTap: boolean;
@HostBinding('class.no-base') isNotBase: boolean;
toggleData: { id: boolean, text: string }[] = [
toggleData: { id: toggleType, text: string }[] = [
{
id: false,
id: 'active',
text: 'Activate'
},
{
id: true,
id: 'toggle',
text: 'Toggle'
}
];
@@ -40,12 +43,13 @@ export class LayerTabComponent extends Tab implements OnChanges {
}
];
toggle: boolean;
toggle: toggleType;
layer: LayerName;
lockLayerWhenDoubleTapping: boolean;
constructor() {
super();
this.toggle = false;
this.toggle = 'active';
this.layer = LayerName.mod;
}
@@ -71,14 +75,39 @@ export class LayerTabComponent extends Tab implements OnChanges {
}
const switchLayerAction: SwitchLayerAction = <SwitchLayerAction>keyAction;
this.toggle = switchLayerAction.isLayerToggleable;
switch (switchLayerAction.switchLayerMode) {
case SwitchLayerMode.holdAndDoubleTapToggle: {
this.toggle = 'active';
this.lockLayerWhenDoubleTapping = true;
break;
}
case SwitchLayerMode.hold: {
this.toggle = 'active';
this.lockLayerWhenDoubleTapping = false;
break;
}
default: {
this.toggle = 'toggle';
this.lockLayerWhenDoubleTapping = false;
}
}
this.layer = switchLayerAction.layer;
return true;
}
toKeyAction(): SwitchLayerAction {
const keyAction = new SwitchLayerAction();
keyAction.isLayerToggleable = this.toggle;
if (this.toggle === 'toggle') {
keyAction.switchLayerMode = SwitchLayerMode.toggle;
} else if (!this.allowLayerDoubleTap || this.lockLayerWhenDoubleTapping) {
keyAction.switchLayerMode = SwitchLayerMode.holdAndDoubleTapToggle;
} else {
keyAction.switchLayerMode = SwitchLayerMode.hold;
}
keyAction.layer = this.layer;
if (!this.keyActionValid()) {
throw new Error('KeyAction is invalid!');
@@ -86,8 +115,8 @@ export class LayerTabComponent extends Tab implements OnChanges {
return keyAction;
}
toggleChanged(value: string) {
this.toggle = value === 'true';
toggleChanged(value: toggleType) {
this.toggle = value;
}
layerChanged(value: number) {

View File

@@ -17,13 +17,14 @@ import {
MouseAction,
PlayMacroAction,
SwitchKeymapAction,
SwitchLayerAction
SwitchLayerAction,
SwitchLayerMode
} from 'uhk-common';
import { CaptureService } from '../../../../services/capture.service';
import { MapperService } from '../../../../services/mapper.service';
import { AppState } from '../../../../store/index';
import { AppState } from '../../../../store';
import { getMacros } from '../../../../store/reducers/user-configuration';
enum LabelTypes {
@@ -288,12 +289,18 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
break;
}
if (keyAction.isLayerToggleable) {
if (keyAction.switchLayerMode === SwitchLayerMode.toggle) {
this.labelType = LabelTypes.TextIcon;
this.labelSource = {
text: newLabelSource,
icon: this.mapper.getIcon('toggle')
};
} else if (keyAction.switchLayerMode === SwitchLayerMode.holdAndDoubleTapToggle) {
this.labelType = LabelTypes.TextIcon;
this.labelSource = {
text: newLabelSource,
icon: this.mapper.getIcon('double-tap')
};
} else {
this.labelType = LabelTypes.OneLineText;
this.labelSource = newLabelSource;

View File

@@ -13,8 +13,18 @@
(capture)="onCapture($event.moduleId, $event.keyId, $event.captured)"
(descriptionChanged)="onDescriptionChanged($event)"
></keyboard-slider>
<popover tabindex="0" [visible]="popoverShown" [keyPosition]="keyPosition" [wrapPosition]="wrapPosition" [defaultKeyAction]="popoverInitKeyAction"
[currentKeymap]="keymap" [currentLayer]="currentLayer" (cancel)="hidePopover()" (remap)="onRemap($event)"></popover>
<popover tabindex="0"
[visible]="popoverShown"
[keyPosition]="keyPosition"
[wrapPosition]="wrapPosition"
[defaultKeyAction]="popoverInitKeyAction"
[currentKeymap]="keymap"
[currentLayer]="currentLayer"
[allowLayerDoubleTap]="allowLayerDoubleTap"
(cancel)="hidePopover()"
(remap)="onRemap($event)"></popover>
<div class="tooltip bottom"
[class.in]="tooltipData.show"
[style.top.px]="tooltipData.posTop"

View File

@@ -32,7 +32,8 @@ import {
PlayMacroAction,
SecondaryRoleAction,
SwitchKeymapAction,
SwitchLayerAction
SwitchLayerAction,
SwitchLayerMode
} from 'uhk-common';
import { MapperService } from '../../../services/mapper.service';
@@ -59,6 +60,8 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
@Input() tooltipEnabled: boolean = false;
@Input() halvesSplit: boolean;
@Input() keyboardLayout: KeyboardLayout.ANSI;
@Input() allowLayerDoubleTap: boolean;
@Output() descriptionChanged = new EventEmitter<ChangeKeymapDescription>();
@ViewChild(PopoverComponent, { read: ElementRef }) popover: ElementRef;
@@ -350,7 +353,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
},
{
name: 'Toogle',
value: switchLayerAction.isLayerToggleable ? 'On' : 'Off'
value: switchLayerAction.switchLayerMode === SwitchLayerMode.toggle ? 'On' : 'Off'
}
];
return Observable.of(content);

View File

@@ -262,6 +262,7 @@ export class MapperService {
private initNameToFileNames(): void {
this.nameToFileName = new Map<string, string>();
this.nameToFileName.set('toggle', 'icon-kbd__fn--toggle');
this.nameToFileName.set('double-tap', 'icon-kbd__fn--double-tap');
this.nameToFileName.set('switch-keymap', 'icon-kbd__mod--switch-keymap');
this.nameToFileName.set('macro', 'icon-icon__macro');
this.nameToFileName.set('shift', 'icon-kbd__default--modifier-shift');

View File

@@ -179,12 +179,12 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -275,7 +275,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -356,7 +356,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -366,7 +366,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -507,7 +507,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -654,7 +654,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -732,7 +732,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -819,7 +819,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
null,
@@ -941,7 +941,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -1156,12 +1156,12 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -1252,7 +1252,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -1333,7 +1333,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -1343,7 +1343,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -1484,7 +1484,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -1641,7 +1641,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -1719,7 +1719,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -1806,7 +1806,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
null,
@@ -1928,7 +1928,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -2143,12 +2143,12 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -2239,7 +2239,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -2320,7 +2320,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -2330,7 +2330,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -2471,7 +2471,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -2618,7 +2618,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -2696,7 +2696,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -2783,7 +2783,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
null,
@@ -2902,7 +2902,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -3117,12 +3117,12 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -3213,7 +3213,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -3294,7 +3294,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -3304,7 +3304,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -3445,7 +3445,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -3602,7 +3602,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -3680,7 +3680,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -3767,7 +3767,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
null,
@@ -3886,7 +3886,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -4101,12 +4101,12 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -4197,7 +4197,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -4278,7 +4278,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -4288,7 +4288,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -4429,7 +4429,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -4576,7 +4576,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -4654,7 +4654,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -4741,7 +4741,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
null,
@@ -4854,7 +4854,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -5069,12 +5069,12 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -5165,7 +5165,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -5246,7 +5246,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -5256,7 +5256,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -5397,7 +5397,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -5554,7 +5554,7 @@
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null
]
@@ -5635,7 +5635,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
{
"keyActionType": "keystroke",
@@ -5722,7 +5722,7 @@
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
null,
@@ -5835,7 +5835,7 @@
{
"keyActionType": "switchLayer",
"layer": "mouse",
"toggle": false
"switchLayerMode": "holdAndDoubleTapToggle"
},
null,
{
@@ -6900,4 +6900,4 @@
]
}
]
}
}

View File

@@ -44,6 +44,7 @@ export const getUserConfiguration = (state: AppState) => state.userConfiguration
export const appState = (state: AppState) => state.app;
export const showAddonMenu = createSelector(appState, fromApp.showAddonMenu);
export const allowLayerDoubleTap = createSelector(appState, fromApp.allowLayerDoubleTap);
export const getUndoableNotification = createSelector(appState, fromApp.getUndoableNotification);
export const getPrevUserConfiguration = createSelector(appState, fromApp.getPrevUserConfiguration);
export const runningInElectron = createSelector(appState, fromApp.runningInElectron);

View File

@@ -1,6 +1,7 @@
import { ROUTER_NAVIGATION } from '@ngrx/router-store';
import { Action } from '@ngrx/store';
import {
CommandLineArgs,
HardwareConfiguration,
Notification,
NotificationType,
@@ -18,7 +19,7 @@ import { PrivilagePageSate } from '../../models/privilage-page-sate';
export interface State {
started: boolean;
showAddonMenu: boolean;
commandLineArgs: CommandLineArgs;
undoableNotification?: Notification;
navigationCountAfterNotification: number;
prevUserConfig?: UserConfiguration;
@@ -32,7 +33,7 @@ export interface State {
export const initialState: State = {
started: false,
showAddonMenu: false,
commandLineArgs: {},
navigationCountAfterNotification: 0,
runningInElectron: runInElectron(),
configLoading: true,
@@ -52,7 +53,7 @@ export function reducer(state = initialState, action: Action & { payload: any })
case ActionTypes.APPLY_COMMAND_LINE_ARGS: {
return {
...state,
showAddonMenu: action.payload.addons
commandLineArgs: action.payload
};
}
@@ -148,7 +149,8 @@ export function reducer(state = initialState, action: Action & { payload: any })
}
}
export const showAddonMenu = (state: State) => state.showAddonMenu;
export const showAddonMenu = (state: State) => state.commandLineArgs.addons;
export const allowLayerDoubleTap = (state: State) => state.commandLineArgs.layerDoubleTap;
export const getUndoableNotification = (state: State) => state.undoableNotification;
export const getPrevUserConfiguration = (state: State) => state.prevUserConfig;
export const runningInElectron = (state: State) => state.runningInElectron;

View File

@@ -1,5 +1,13 @@
import { reducer, initialState } from './user-configuration';
import { KeystrokeAction, KeystrokeType, SwitchLayerAction, UserConfiguration, LayerName, Keymap } from 'uhk-common';
import {
KeystrokeAction,
KeystrokeType,
SwitchLayerAction,
UserConfiguration,
LayerName,
Keymap,
SwitchLayerMode
} from 'uhk-common';
import { getDefaultUserConfig } from '../../../../test/user-config-helper';
import { KeymapActions } from '../actions';
@@ -42,7 +50,11 @@ describe('user-configuration reducer', () => {
const defaultUserConfig = new UserConfiguration().fromJsonObject(getDefaultUserConfig());
const state = new UserConfiguration().fromJsonObject(getDefaultUserConfig());
const destinationLayerId = LayerName.mod;
const switchLayerAction = new SwitchLayerAction({isLayerToggleable: false, layer: destinationLayerId} as any);
const switchLayerAction = new SwitchLayerAction({
switchLayerMode: SwitchLayerMode.toggle,
layer: destinationLayerId
} as any);
const saveKeyAction: KeymapActions.SaveKeyAction = {
type: KeymapActions.SAVE_KEY,
payload: {
@@ -81,7 +93,7 @@ describe('user-configuration reducer', () => {
{
keyActionType: 'switchLayer',
layer: 'mod',
toggle: false
switchLayerMode: 1
},
{
keyActionType: 'keystroke',
@@ -89,9 +101,9 @@ describe('user-configuration reducer', () => {
scancode: 37
},
{
'keyActionType': 'switchLayer',
'layer': 'mod',
'toggle': false
keyActionType: 'switchLayer',
layer: 'mod',
switchLayerMode: 1
}
]
},
@@ -128,7 +140,7 @@ describe('user-configuration reducer', () => {
{
keyActionType: 'switchLayer',
layer: 'mod',
toggle: false
switchLayerMode: 1
},
{
keyActionType: 'keystroke',
@@ -136,9 +148,9 @@ describe('user-configuration reducer', () => {
scancode: 65
},
{
'keyActionType': 'switchLayer',
'layer': 'mod',
'toggle': false
keyActionType: 'switchLayer',
layer: 'mod',
switchLayerMode: 1
}
]
},
@@ -219,7 +231,11 @@ describe('user-configuration reducer', () => {
const defaultUserConfig = new UserConfiguration().fromJsonObject(getDefaultUserConfig());
const state = new UserConfiguration().fromJsonObject(getDefaultUserConfig());
const destinationLayerId = LayerName.fn;
const switchLayerAction = new SwitchLayerAction({isLayerToggleable: false, layer: destinationLayerId} as any);
const switchLayerAction = new SwitchLayerAction({
switchLayerMode: SwitchLayerMode.toggle,
layer: destinationLayerId
} as any);
const saveKeyAction: KeymapActions.SaveKeyAction = {
type: KeymapActions.SAVE_KEY,
payload: {
@@ -266,9 +282,9 @@ describe('user-configuration reducer', () => {
scancode: 37
},
{
'keyActionType': 'switchLayer',
'layer': 'fn',
'toggle': false
keyActionType: 'switchLayer',
layer: 'fn',
switchLayerMode: 1
}
]
},
@@ -345,7 +361,7 @@ describe('user-configuration reducer', () => {
{
keyActionType: 'switchLayer',
layer: 'fn',
toggle: false
switchLayerMode: 1
}
]
},