Remapping support for tabs
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
import {KeyAction} from '../../../config-serializer/config-items/KeyAction';
|
||||||
|
|
||||||
|
export interface KeyActionSaver {
|
||||||
|
keyActionValid(): boolean;
|
||||||
|
toKeyAction(): KeyAction;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
Output,
|
Output,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
|
ViewChild,
|
||||||
ViewChildren,
|
ViewChildren,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
Renderer,
|
Renderer,
|
||||||
@@ -13,6 +14,8 @@ import {
|
|||||||
|
|
||||||
import {NgSwitch, NgSwitchWhen} from '@angular/common';
|
import {NgSwitch, NgSwitchWhen} from '@angular/common';
|
||||||
|
|
||||||
|
import {KeyAction} from '../../../config-serializer/config-items/KeyAction';
|
||||||
|
|
||||||
import {KeypressTabComponent} from './tab/keypress-tab.component';
|
import {KeypressTabComponent} from './tab/keypress-tab.component';
|
||||||
import {LayerTabComponent} from './tab/layer-tab.component';
|
import {LayerTabComponent} from './tab/layer-tab.component';
|
||||||
import {MouseTabComponent} from './tab/mouse-tab.component';
|
import {MouseTabComponent} from './tab/mouse-tab.component';
|
||||||
@@ -20,6 +23,8 @@ import {MacroTabComponent} from './tab/macro-tab.component';
|
|||||||
import {KeymapTabComponent} from './tab/keymap-tab.component';
|
import {KeymapTabComponent} from './tab/keymap-tab.component';
|
||||||
import {NoneTabComponent} from './tab/none-tab.component';
|
import {NoneTabComponent} from './tab/none-tab.component';
|
||||||
|
|
||||||
|
import {KeyActionSaver} from './key-action-saver';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
selector: 'popover',
|
selector: 'popover',
|
||||||
@@ -70,12 +75,12 @@ import {NoneTabComponent} from './tab/none-tab.component';
|
|||||||
</div>
|
</div>
|
||||||
<div class="row" [ngSwitch]="activeListItemIndex">
|
<div class="row" [ngSwitch]="activeListItemIndex">
|
||||||
<div class="popover-content">
|
<div class="popover-content">
|
||||||
<keypress-tab *ngSwitchWhen="0"></keypress-tab>
|
<keypress-tab #tab *ngSwitchWhen="0"></keypress-tab>
|
||||||
<layer-tab *ngSwitchWhen="1"></layer-tab>
|
<layer-tab #tab *ngSwitchWhen="1"></layer-tab>
|
||||||
<mouse-tab *ngSwitchWhen="2"></mouse-tab>
|
<mouse-tab #tab *ngSwitchWhen="2"></mouse-tab>
|
||||||
<macro-tab *ngSwitchWhen="3"></macro-tab>
|
<macro-tab #tab *ngSwitchWhen="3"></macro-tab>
|
||||||
<keymap-tab *ngSwitchWhen="4"></keymap-tab>
|
<keymap-tab #tab *ngSwitchWhen="4"></keymap-tab>
|
||||||
<none-tab *ngSwitchWhen="5"></none-tab>
|
<none-tab #tab *ngSwitchWhen="5"></none-tab>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -86,7 +91,7 @@ import {NoneTabComponent} from './tab/none-tab.component';
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
styles: [ require('./popover.component.scss') ],
|
styles: [require('./popover.component.scss')],
|
||||||
host: { 'class': 'popover' },
|
host: { 'class': 'popover' },
|
||||||
directives:
|
directives:
|
||||||
[
|
[
|
||||||
@@ -101,8 +106,12 @@ import {NoneTabComponent} from './tab/none-tab.component';
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class PopoverComponent implements OnInit, AfterViewInit {
|
export class PopoverComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
@Output() cancel = new EventEmitter<any>();
|
@Output() cancel = new EventEmitter<any>();
|
||||||
|
@Output() remap = new EventEmitter<KeyAction>();
|
||||||
|
|
||||||
@ViewChildren('keypress,layer,mouse,macro,keymap,none') liElementRefs: QueryList<ElementRef>;
|
@ViewChildren('keypress,layer,mouse,macro,keymap,none') liElementRefs: QueryList<ElementRef>;
|
||||||
|
@ViewChild('tab') selectedTab: KeyActionSaver;
|
||||||
|
|
||||||
private activeListItemIndex: number;
|
private activeListItemIndex: number;
|
||||||
|
|
||||||
@@ -122,7 +131,13 @@ export class PopoverComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onRemapKey(): void {
|
onRemapKey(): void {
|
||||||
|
try {
|
||||||
|
let keyAction = this.selectedTab.toKeyAction();
|
||||||
|
this.remap.emit(keyAction);
|
||||||
|
} catch (e) {
|
||||||
|
// TODO: show error dialog
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onListItemClick(index: number): void {
|
onListItemClick(index: number): void {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import {UhkConfigurationService} from '../../../services/uhk-configuration.service';
|
import {UhkConfigurationService} from '../../../services/uhk-configuration.service';
|
||||||
import {Keymap} from '../../../../config-serializer/config-items/Keymap';
|
import {Keymap} from '../../../../config-serializer/config-items/Keymap';
|
||||||
import {SvgKeyboardComponent} from '../../svg-keyboard.component';
|
import {SvgKeyboardComponent} from '../../svg-keyboard.component';
|
||||||
|
import {KeyActionSaver} from '../key-action-saver';
|
||||||
|
import {SwitchKeymapAction} from '../../../../config-serializer/config-items/SwitchKeymapAction';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
@@ -28,7 +30,7 @@ import {SvgKeyboardComponent} from '../../svg-keyboard.component';
|
|||||||
styles: [require('./keymap-tab.component.scss')],
|
styles: [require('./keymap-tab.component.scss')],
|
||||||
directives: [SvgKeyboardComponent]
|
directives: [SvgKeyboardComponent]
|
||||||
})
|
})
|
||||||
export class KeymapTabComponent implements OnInit {
|
export class KeymapTabComponent implements OnInit, KeyActionSaver {
|
||||||
|
|
||||||
private keymaps: Keymap[];
|
private keymaps: Keymap[];
|
||||||
private selectedKeymapIndex: number;
|
private selectedKeymapIndex: number;
|
||||||
@@ -40,4 +42,17 @@ export class KeymapTabComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
|
keyActionValid(): boolean {
|
||||||
|
return this.selectedKeymapIndex !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
toKeyAction(): SwitchKeymapAction {
|
||||||
|
if (!this.keyActionValid()) {
|
||||||
|
throw new Error('KeyAction is not valid. No selected keymap!');
|
||||||
|
}
|
||||||
|
let keymapAction = new SwitchKeymapAction();
|
||||||
|
keymapAction.keymapId = this.keymaps[this.selectedKeymapIndex].id;
|
||||||
|
return keymapAction;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
|
|
||||||
import { CaptureKeystrokeButtonComponent } from '../widgets/capture-keystroke-button.component';
|
import { CaptureKeystrokeButtonComponent } from '../widgets/capture-keystroke-button.component';
|
||||||
|
|
||||||
|
import { KeyAction } from '../../../../config-serializer/config-items/KeyAction';
|
||||||
import { KeystrokeAction } from '../../../../config-serializer/config-items/KeystrokeAction';
|
import { KeystrokeAction } from '../../../../config-serializer/config-items/KeystrokeAction';
|
||||||
import { KeystrokeModifiersAction } from '../../../../config-serializer/config-items/KeystrokeModifiersAction';
|
import { KeystrokeModifiersAction } from '../../../../config-serializer/config-items/KeystrokeModifiersAction';
|
||||||
import { KeystrokeWithModifiersAction } from '../../../../config-serializer/config-items/KeystrokeWithModifiersAction';
|
import { KeystrokeWithModifiersAction } from '../../../../config-serializer/config-items/KeystrokeWithModifiersAction';
|
||||||
|
import { KeyActionSaver } from '../key-action-saver';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
@@ -45,7 +47,7 @@ import { KeystrokeWithModifiersAction } from '../../../../config-serializer/conf
|
|||||||
`,
|
`,
|
||||||
directives: [CaptureKeystrokeButtonComponent]
|
directives: [CaptureKeystrokeButtonComponent]
|
||||||
})
|
})
|
||||||
export class KeypressTabComponent implements OnInit {
|
export class KeypressTabComponent implements OnInit, KeyActionSaver {
|
||||||
private leftModifiers: string[];
|
private leftModifiers: string[];
|
||||||
private rightModifiers: string[];
|
private rightModifiers: string[];
|
||||||
|
|
||||||
@@ -63,4 +65,11 @@ export class KeypressTabComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyActionValid(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
toKeyAction(): KeyAction {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,48 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
import { LayerName, SwitchLayerAction } from '../../../../config-serializer/config-items/SwitchLayerAction';
|
||||||
|
import { KeyActionSaver } from '../key-action-saver';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
selector: 'layer-tab',
|
selector: 'layer-tab',
|
||||||
template:
|
template:
|
||||||
`
|
`
|
||||||
<select>
|
<select [(ngModel)]="toggle">
|
||||||
<option> Activate </option>
|
<option [ngValue]="false"> Activate </option>
|
||||||
<option> Toggle </option>
|
<option [ngValue]="true"> Toggle </option>
|
||||||
</select>
|
</select>
|
||||||
<span>the</span>
|
<span>the</span>
|
||||||
<select>
|
<select [(ngModel)]="layer">
|
||||||
<option> Mod </option>
|
<option [ngValue]="0"> Mod </option>
|
||||||
<option> Fn </option>
|
<option [ngValue]="1"> Fn </option>
|
||||||
<option> Mouse </option>
|
<option [ngValue]="2"> Mouse </option>
|
||||||
</select>
|
</select>
|
||||||
<span>
|
<span>
|
||||||
layer by holding this key.
|
layer by holding this key.
|
||||||
</span>
|
</span>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class LayerTabComponent implements OnInit {
|
export class LayerTabComponent implements OnInit, KeyActionSaver {
|
||||||
constructor() { }
|
private toggle: boolean;
|
||||||
|
private layer: LayerName;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.toggle = false;
|
||||||
|
this.layer = LayerName.mod;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
|
keyActionValid(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
toKeyAction(): SwitchLayerAction {
|
||||||
|
let keyAction = new SwitchLayerAction();
|
||||||
|
keyAction.isLayerToggleable = this.toggle;
|
||||||
|
keyAction.layer = this.layer;
|
||||||
|
return keyAction;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
import { KeyActionSaver } from '../key-action-saver';
|
||||||
|
import { KeyAction } from '../../../../config-serializer/config-items/KeyAction';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
selector: 'macro-tab',
|
selector: 'macro-tab',
|
||||||
@@ -8,9 +11,17 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
Macro
|
Macro
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class MacroTabComponent implements OnInit {
|
export class MacroTabComponent implements OnInit, KeyActionSaver {
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
|
keyActionValid(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
toKeyAction(): KeyAction {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
import { KeyActionSaver } from '../key-action-saver';
|
||||||
|
import { KeyAction } from '../../../../config-serializer/config-items/KeyAction';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
selector: 'mouse-tab',
|
selector: 'mouse-tab',
|
||||||
@@ -16,11 +19,19 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
<div class="details">
|
<div class="details">
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
styles: [ require('./mouse-tab.component.scss') ]
|
styles: [require('./mouse-tab.component.scss')]
|
||||||
})
|
})
|
||||||
export class MouseTabComponent implements OnInit {
|
export class MouseTabComponent implements OnInit, KeyActionSaver {
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
|
keyActionValid(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
toKeyAction(): KeyAction {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
import { KeyActionSaver } from '../key-action-saver';
|
||||||
|
import { NoneAction } from '../../../../config-serializer/config-items/NoneAction';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
selector: 'none-tab',
|
selector: 'none-tab',
|
||||||
@@ -13,9 +16,17 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
}
|
}
|
||||||
`]
|
`]
|
||||||
})
|
})
|
||||||
export class NoneTabComponent implements OnInit {
|
export class NoneTabComponent implements OnInit, KeyActionSaver {
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
|
keyActionValid(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
toKeyAction(): NoneAction {
|
||||||
|
return new NoneAction();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit, Input} from '@angular/core';
|
import { Component, OnInit, Input} from '@angular/core';
|
||||||
|
|
||||||
import {Module} from '../../config-serializer/config-items/Module';
|
import {Module} from '../../config-serializer/config-items/Module';
|
||||||
|
import {KeyAction} from '../../config-serializer/config-items/KeyAction';
|
||||||
import {SvgKeyboardComponent} from './svg-keyboard.component';
|
import {SvgKeyboardComponent} from './svg-keyboard.component';
|
||||||
import {PopoverComponent} from './popover/popover.component';
|
import {PopoverComponent} from './popover/popover.component';
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ import {PopoverComponent} from './popover/popover.component';
|
|||||||
<svg-keyboard [moduleConfig]="moduleConfig"
|
<svg-keyboard [moduleConfig]="moduleConfig"
|
||||||
(keyClick)="onKeyClick($event.moduleId, $event.keyId)">
|
(keyClick)="onKeyClick($event.moduleId, $event.keyId)">
|
||||||
</svg-keyboard>
|
</svg-keyboard>
|
||||||
<popover *ngIf="popoverEnabled" (cancel)="hidePopover()"></popover>
|
<popover *ngIf="popoverEnabled" (cancel)="hidePopover()" (remap)="onRemap($event)"></popover>
|
||||||
`,
|
`,
|
||||||
styles:
|
styles:
|
||||||
[`
|
[`
|
||||||
@@ -28,13 +29,30 @@ export class SvgKeyboardPopoverComponent implements OnInit {
|
|||||||
@Input() moduleConfig: Module[];
|
@Input() moduleConfig: Module[];
|
||||||
|
|
||||||
private popoverEnabled: boolean;
|
private popoverEnabled: boolean;
|
||||||
|
private keyEditConfig: { moduleId: number, keyId: number };
|
||||||
|
|
||||||
constructor() { }
|
constructor() {
|
||||||
|
this.keyEditConfig = {
|
||||||
|
moduleId: undefined,
|
||||||
|
keyId: undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
onKeyClick(moduleId: number, keyId: number): void {
|
onKeyClick(moduleId: number, keyId: number): void {
|
||||||
this.showPopover();
|
if (!this.popoverEnabled) {
|
||||||
|
this.keyEditConfig = {
|
||||||
|
moduleId,
|
||||||
|
keyId
|
||||||
|
};
|
||||||
|
this.showPopover();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onRemap(keyAction: KeyAction): void {
|
||||||
|
this.changeKeyAction(keyAction);
|
||||||
|
this.hidePopover();
|
||||||
}
|
}
|
||||||
|
|
||||||
showPopover(): void {
|
showPopover(): void {
|
||||||
@@ -45,4 +63,10 @@ export class SvgKeyboardPopoverComponent implements OnInit {
|
|||||||
this.popoverEnabled = false;
|
this.popoverEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeKeyAction(keyAction: KeyAction): void {
|
||||||
|
let moduleId = this.keyEditConfig.moduleId;
|
||||||
|
let keyId = this.keyEditConfig.keyId;
|
||||||
|
this.moduleConfig[moduleId].keyActions.elements[keyId] = keyAction;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user