refactor: Change name of actions (#470)
* style: shorter import in key-macro-action.ts * refactor: rename 'press' macro key action to 'tap' * refactor: rename 'hold' macro key action to 'press' * refactor: rename 'press' macro mouse action to 'click' * style: fix stylelint
This commit is contained in:
committed by
László Monda
parent
133f8be370
commit
6c6e2af047
+6
-6
@@ -1,16 +1,16 @@
|
||||
<div class="col-xs-12 macro-key__container">
|
||||
<div class="col-xs-3 macro-key__types">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li #keyMove [class.active]="activeTab === TabName.Keypress" (click)="selectTab(TabName.Keypress)">
|
||||
<li #keyMove [class.active]="activeTab === TabName.Tap" (click)="selectTab(TabName.Tap)">
|
||||
<a>
|
||||
<i class="fa fa-hand-pointer-o"></i>
|
||||
<span>Press key</span>
|
||||
<span>Tap key</span>
|
||||
</a>
|
||||
</li>
|
||||
<li #keyHold [class.active]="activeTab === TabName.Hold" (click)="selectTab(TabName.Hold)">
|
||||
<li #keyHold [class.active]="activeTab === TabName.Press" (click)="selectTab(TabName.Press)">
|
||||
<a>
|
||||
<i class="fa fa-hand-rock-o"></i>
|
||||
<span>Hold key</span>
|
||||
<span>Press key</span>
|
||||
</a>
|
||||
</li>
|
||||
<li #keyRelease [class.active]="activeTab === TabName.Release" (click)="selectTab(TabName.Release)">
|
||||
@@ -23,8 +23,8 @@
|
||||
</div>
|
||||
<div class="col-xs-9 macro-key__action-container">
|
||||
<div class="macro-key__action">
|
||||
<h4 *ngIf="activeTab === TabName.Keypress">Press key</h4>
|
||||
<h4 *ngIf="activeTab === TabName.Hold">Hold key</h4>
|
||||
<h4 *ngIf="activeTab === TabName.Tap">Tap key</h4>
|
||||
<h4 *ngIf="activeTab === TabName.Press">Press key</h4>
|
||||
<h4 *ngIf="activeTab === TabName.Release">Release key</h4>
|
||||
<keypress-tab #keypressTab [defaultKeyAction]="defaultKeyAction" [secondaryRoleEnabled]="false"
|
||||
(validAction)="validate()"></keypress-tab>
|
||||
|
||||
+13
-13
@@ -1,12 +1,12 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
|
||||
import { KeyMacroAction, KeystrokeAction, MacroSubAction } from 'uhk-common';
|
||||
import { KeyMacroAction, KeystrokeAction, MacroKeySubAction } from 'uhk-common';
|
||||
import { KeypressTabComponent, Tab } from '../../../../popover/tab';
|
||||
import { MacroBaseComponent } from '../macro-base.component';
|
||||
|
||||
enum TabName {
|
||||
Keypress,
|
||||
Hold,
|
||||
Tap,
|
||||
Press,
|
||||
Release
|
||||
}
|
||||
|
||||
@@ -45,22 +45,22 @@ export class MacroKeyTabComponent extends MacroBaseComponent implements OnInit {
|
||||
|
||||
getTabName(macroAction: KeyMacroAction): TabName {
|
||||
if (!macroAction.action) {
|
||||
return TabName.Keypress;
|
||||
} else if (macroAction.action === MacroSubAction.hold) {
|
||||
return TabName.Hold;
|
||||
} else if (macroAction.action === MacroSubAction.release) {
|
||||
return TabName.Tap;
|
||||
} else if (macroAction.action === MacroKeySubAction.press) {
|
||||
return TabName.Press;
|
||||
} else if (macroAction.action === MacroKeySubAction.release) {
|
||||
return TabName.Release;
|
||||
}
|
||||
}
|
||||
|
||||
getActionType(tab: TabName): MacroSubAction {
|
||||
getActionType(tab: TabName): MacroKeySubAction {
|
||||
switch (tab) {
|
||||
case TabName.Keypress:
|
||||
return MacroSubAction.press;
|
||||
case TabName.Hold:
|
||||
return MacroSubAction.hold;
|
||||
case TabName.Tap:
|
||||
return MacroKeySubAction.tap;
|
||||
case TabName.Press:
|
||||
return MacroKeySubAction.press;
|
||||
case TabName.Release:
|
||||
return MacroSubAction.release;
|
||||
return MacroKeySubAction.release;
|
||||
default:
|
||||
throw new Error('Invalid tab type');
|
||||
}
|
||||
|
||||
+7
-7
@@ -4,7 +4,7 @@ import {
|
||||
MouseButtonMacroAction,
|
||||
MoveMouseMacroAction,
|
||||
ScrollMouseMacroAction,
|
||||
MacroSubAction
|
||||
MacroMouseSubAction
|
||||
} from 'uhk-common';
|
||||
import { Tab } from '../../../../popover/tab';
|
||||
import { MacroBaseComponent } from '../macro-base.component';
|
||||
@@ -48,7 +48,7 @@ export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit
|
||||
ngOnInit() {
|
||||
if (!this.macroAction) {
|
||||
this.macroAction = new MouseButtonMacroAction();
|
||||
this.macroAction.action = MacroSubAction.press;
|
||||
this.macroAction.action = MacroMouseSubAction.click;
|
||||
}
|
||||
const tabName = this.getTabName(this.macroAction);
|
||||
this.selectTab(tabName);
|
||||
@@ -96,14 +96,14 @@ export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit
|
||||
return this.selectedButtons[index];
|
||||
}
|
||||
|
||||
getAction(tab: TabName): MacroSubAction {
|
||||
getAction(tab: TabName): MacroMouseSubAction {
|
||||
switch (tab) {
|
||||
case TabName.Click:
|
||||
return MacroSubAction.press;
|
||||
return MacroMouseSubAction.click;
|
||||
case TabName.Hold:
|
||||
return MacroSubAction.hold;
|
||||
return MacroMouseSubAction.hold;
|
||||
case TabName.Release:
|
||||
return MacroSubAction.release;
|
||||
return MacroMouseSubAction.release;
|
||||
default:
|
||||
throw new Error(`Invalid tab name: ${TabName[tab]}`);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit
|
||||
|
||||
getTabName(action: MouseMacroAction): TabName {
|
||||
if (action instanceof MouseButtonMacroAction) {
|
||||
if (!action.action || action.isOnlyPressAction()) {
|
||||
if (!action.action || action.isOnlyClickAction()) {
|
||||
return TabName.Click;
|
||||
} else if (action.isOnlyHoldAction()) {
|
||||
return TabName.Hold;
|
||||
|
||||
@@ -124,14 +124,14 @@ export class MacroItemComponent implements OnInit, OnChanges {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.isPressAction()) {
|
||||
// Press key
|
||||
if (action.isTapAction()) {
|
||||
// Tap key
|
||||
this.iconName = 'hand-pointer';
|
||||
this.title = 'Press key: ';
|
||||
} else if (action.isHoldAction()) {
|
||||
// Hold key
|
||||
this.title = 'Tap key: ';
|
||||
} else if (action.isPressAction()) {
|
||||
// Press key
|
||||
this.iconName = 'hand-rock';
|
||||
this.title = 'Hold key: ';
|
||||
this.title = 'Press key: ';
|
||||
} else if (action.isReleaseAction()) {
|
||||
// Release key
|
||||
this.iconName = 'hand-paper';
|
||||
@@ -146,7 +146,7 @@ export class MacroItemComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
if (action.hasModifiers()) {
|
||||
// Press/hold/release modifiers
|
||||
// Tap/press/release modifiers
|
||||
for (let i = KeyModifiers.leftCtrl; i <= KeyModifiers.rightGui; i <<= 1) {
|
||||
if (action.isModifierActive(i)) {
|
||||
this.title += ' ' + KeyModifiers[i];
|
||||
@@ -181,7 +181,7 @@ export class MacroItemComponent implements OnInit, OnChanges {
|
||||
|
||||
private setMouseButtonActionContent(action: MouseButtonMacroAction): void {
|
||||
// Press/hold/release mouse buttons
|
||||
if (action.isOnlyPressAction()) {
|
||||
if (action.isOnlyClickAction()) {
|
||||
this.iconName = 'mouse-pointer';
|
||||
this.title = 'Click mouse button: ';
|
||||
} else if (action.isOnlyHoldAction()) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, EventEmitter, Input, Output, QueryList, ViewChildren, forwardRef } from '@angular/core';
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import { DragulaService } from 'ng2-dragula/ng2-dragula';
|
||||
import { Macro, MacroAction, KeyMacroAction, KeystrokeAction, MacroSubAction } from 'uhk-common';
|
||||
import { Macro, MacroAction, KeyMacroAction, KeystrokeAction, MacroKeySubAction } from 'uhk-common';
|
||||
|
||||
import { MapperService } from '../../../services/mapper.service';
|
||||
import { MacroItemComponent } from '../item';
|
||||
@@ -127,7 +127,7 @@ export class MacroListComponent {
|
||||
|
||||
onKeysCapture(event: { code: number, left: boolean[], right: boolean[] }) {
|
||||
const keyMacroAction = Object.assign(new KeyMacroAction(), this.toKeyAction(event));
|
||||
keyMacroAction.action = MacroSubAction.press;
|
||||
keyMacroAction.action = MacroKeySubAction.tap;
|
||||
|
||||
this.add.emit({
|
||||
macroId: this.macro.id,
|
||||
|
||||
Reference in New Issue
Block a user