Merge branch 'master' of github.com:UltimateHackingKeyboard/agent

This commit is contained in:
László Monda
2017-12-29 13:24:26 +01:00
11 changed files with 298 additions and 55 deletions

View File

@@ -4,44 +4,37 @@
</h1> </h1>
<div class="row led-setting"> <div class="row led-setting">
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<label>LED display icon and layer texts brightness</label> <slider-wrapper
<div class="slider-wrapper-container"> label="LED display icon and layer texts brightness"
<slider-wrapper [min]="0"
[min]="0" [max]="255"
[max]="255" [step]="1"
[step]="1" [pips]="sliderPips"
[pips]="sliderPips" [(ngModel)]="iconsAndLayerTextsBrightness"
[(ngModel)]="iconsAndLayerTextsBrightness" (ngModelChange)="onSetPropertyValue('iconsAndLayerTextsBrightness', $event)"></slider-wrapper>
(ngModelChange)="onSetPropertyValue('iconsAndLayerTextsBrightness', $event)"></slider-wrapper>
</div>
</div> </div>
</div> </div>
<div class="row led-setting"> <div class="row led-setting">
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<label>LED display alphanumeric segments brightness</label> <slider-wrapper
<div class="slider-wrapper-container"> label="LED display alphanumeric segments brightness"
<slider-wrapper [min]="0"
[min]="0" [max]="255"
[max]="255" [step]="1"
[step]="1" [pips]="sliderPips"
[pips]="sliderPips" [(ngModel)]="alphanumericSegmentsBrightness"
[(ngModel)]="alphanumericSegmentsBrightness" (ngModelChange)="onSetPropertyValue('alphanumericSegmentsBrightness', $event)"></slider-wrapper>
(ngModelChange)="onSetPropertyValue('alphanumericSegmentsBrightness', $event)"></slider-wrapper>
</div>
</div> </div>
</div> </div>
<div class="row led-setting"> <div class="row led-setting">
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<label>Key backlight brightness</label> <slider-wrapper
<div class="slider-wrapper-container"> label="Key backlight brightness"
<slider-wrapper [min]="0"
[min]="0" [max]="255"
[max]="255" [step]="1"
[step]="1" [pips]="sliderPips"
[pips]="sliderPips" [(ngModel)]="keyBacklightBrightness"
[(ngModel)]="keyBacklightBrightness" (ngModelChange)="onSetPropertyValue('keyBacklightBrightness', $event)"></slider-wrapper>
(ngModelChange)="onSetPropertyValue('keyBacklightBrightness', $event)"></slider-wrapper>
</div>
</div> </div>
</div> </div>

View File

@@ -12,8 +12,4 @@
.led-setting { .led-setting {
margin-bottom: 6rem; margin-bottom: 6rem;
} }
.slider-wrapper-container {
margin-left: 1.6rem;
}
} }

View File

@@ -2,6 +2,41 @@
<i class="fa fa-sliders"></i> <i class="fa fa-sliders"></i>
<span>Mouse speed</span> <span>Mouse speed</span>
</h1> </h1>
<p> <h3>Mouse pointer speed</h3>
Coming soon ... <div class="row mouse-speed-setting" *ngFor="let prop of moveProps">
</p> <div class="col-xs-12 col-md-6">
<slider-wrapper
[label]="prop.title"
[tooltip]="prop.tooltip"
[min]="moveSettings.min"
[max]="moveSettings.max"
[step]="moveSettings.step"
[pips]="sliderPips"
[valueUnit]="prop.valueUnit"
[(ngModel)]="prop.value"
(ngModelChange)="onSetPropertyValue(prop.prop, $event)"></slider-wrapper>
</div>
</div>
<h3>Mouse scroll speed</h3>
<div class="row mouse-speed-setting" *ngFor="let prop of scrollProps">
<div class="col-xs-12 col-md-6">
<slider-wrapper
[label]="prop.title"
[tooltip]="prop.tooltip"
[min]="scrollSettings.min"
[max]="scrollSettings.max"
[step]="scrollSettings.step"
[pips]="sliderPips"
[valueUnit]="prop.valueUnit"
[(ngModel)]="prop.value"
(ngModelChange)="onSetPropertyValue(prop.prop, $event)"></slider-wrapper>
</div>
</div>
<button class="btn btn-danger mouse-speed-reset-button"
mwlConfirmationPopover
title="Are you sure?"
placement="top"
confirmText="Yes"
cancelText="No"
(confirm)="resetToDefault()">Reset speeds to default
</button>

View File

@@ -4,4 +4,25 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
label {
display: block;
font-weight: normal;
icon {
display: inline-block;
}
}
.mouse-speed-reset-button {
display: block;
margin-bottom: 4rem;
}
.mouse-speed-setting {
margin-bottom: 6rem;
+ h3 {
margin-top: 2rem;
}
}
} }

View File

@@ -1,4 +1,14 @@
import { Component } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppState, getUserConfiguration } from '../../../store';
import { SetUserConfigurationValueAction } from '../../../store/actions/user-config';
import { DefaultUserConfigurationService } from '../../../services/default-user-configuration.service';
import { SliderPips, SliderProps } from '../../slider-wrapper/slider-wrapper.component';
import { Subscription } from 'rxjs/Subscription';
import { UserConfiguration } from 'uhk-common';
import { ResetMouseSpeedSettingsAction } from '../../../store/actions/device';
const MOUSE_MOVE_VALUE_MULTIPLIER = 25;
@Component({ @Component({
selector: 'device-mouse-speed', selector: 'device-mouse-speed',
@@ -8,5 +18,131 @@ import { Component } from '@angular/core';
'class': 'container-fluid' 'class': 'container-fluid'
} }
}) })
export class MouseSpeedComponent { export class MouseSpeedComponent implements OnInit, OnDestroy {
public moveProps = [
{
prop: 'mouseMoveInitialSpeed',
title: 'Initial speed',
tooltip: 'When mouse movement begins, this is the starting speed.',
valueUnit: 'px/s',
value: 0
},
{
prop: 'mouseMoveBaseSpeed',
title: 'Base speed',
tooltip: 'This speed is reached after the initial moving speed sufficiently ramps up.',
valueUnit: 'px/s',
value: 0
},
{
prop: 'mouseMoveAcceleration',
title: 'Acceleration',
tooltip: 'The rate of acceleration from the initial movement speed to the base speed.',
valueUnit: 'px/s²',
value: 0
},
{
prop: 'mouseMoveDeceleratedSpeed',
title: 'Decelerated speed',
tooltip: 'This speed is used while moving with the <i>decelerate key</i> pressed.',
valueUnit: 'px/s',
value: 0
},
{
prop: 'mouseMoveAcceleratedSpeed',
title: 'Accelerated speed',
tooltip: 'This speed is used while moving with the <i>accelerate key</i> pressed.',
valueUnit: 'px/s',
value: 0
}
];
public scrollProps = [
{
prop: 'mouseScrollInitialSpeed',
title: 'Initial speed',
tooltip: 'When mouse scrolling begins, this is the starting speed.',
valueUnit: 'pulse/s',
value: 0
},
{
prop: 'mouseScrollBaseSpeed',
title: 'Base speed',
tooltip: 'This speed is reached after the initial scrolling speed sufficiently ramps up.',
valueUnit: 'pulse/s',
value: 0
},
{
prop: 'mouseScrollAcceleration',
title: 'Acceleration',
tooltip: 'The rate of acceleration from the initial scrolling speed to the base speed.',
valueUnit: 'pulse/s²',
value: 0
},
{
prop: 'mouseScrollDeceleratedSpeed',
title: 'Decelerated speed',
tooltip: 'This speed is used while scrolling with the <i>decelerate key</i> pressed.',
valueUnit: 'pulse/s',
value: 0
},
{
prop: 'mouseScrollAcceleratedSpeed',
title: 'Accelerated speed',
tooltip: 'This speed is used while scrolling with the <i>accelerate key</i> pressed.',
valueUnit: 'pulse/s',
value: 0
}
];
public sliderPips: SliderPips = {
mode: 'positions',
values: [0, 50, 100],
density: 6,
stepped: true
};
public moveSettings: SliderProps = {
min: MOUSE_MOVE_VALUE_MULTIPLIER,
max: 6375,
step: MOUSE_MOVE_VALUE_MULTIPLIER
};
public scrollSettings: SliderProps = {
min: 1,
max: 255,
step: 1
};
private userConfig$: Store<UserConfiguration>;
private userConfigSubscription: Subscription;
constructor(private store: Store<AppState>, private defaultUserConfigurationService: DefaultUserConfigurationService) {}
ngOnInit(): void {
this.userConfig$ = this.store.select(getUserConfiguration);
this.userConfigSubscription = this.userConfig$.subscribe(config => {
this.moveProps.forEach(moveProp => {
moveProp.value = config[moveProp.prop] * MOUSE_MOVE_VALUE_MULTIPLIER || 0;
});
this.scrollProps.forEach(scrollProp => {
scrollProp.value = config[scrollProp.prop] || 0;
});
});
}
ngOnDestroy(): void {
this.userConfigSubscription.unsubscribe();
}
onSetPropertyValue(propertyName: string, value: number): void {
this.store.dispatch(new SetUserConfigurationValueAction({
propertyName,
value: propertyName.indexOf('mouseMove') !== -1 ? value / MOUSE_MOVE_VALUE_MULTIPLIER : value
}));
}
resetToDefault() {
this.store.dispatch(new ResetMouseSpeedSettingsAction());
}
} }

View File

@@ -1,13 +1,24 @@
<div class="slider-container"> <label *ngIf="label">
<nouislider <span>{{label}}</span>
[min]="min" <icon name="question-circle"
[max]="max" data-toggle="tooltip"
[step]="step" [title]="tooltip"
[keyboard]="true" html="true"
[tooltips]="true" data-placement="bottom"
[(ngModel)]="value" *ngIf="tooltip"></icon>
(ngModelChange)="onSliderChange($event)"></nouislider> </label>
</div> <div class="slider-wrapper">
<div class="slider-value"> <div class="slider-container">
<div class="value-indicator">{{value}} {{valueUnit}}</div> <nouislider
[min]="min"
[max]="max"
[step]="step"
[keyboard]="true"
[tooltips]="true"
[(ngModel)]="value"
(ngModelChange)="onSliderChange($event)"></nouislider>
</div>
<div class="slider-value">
<div class="value-indicator">{{value}} {{valueUnit}}</div>
</div>
</div> </div>

View File

@@ -1,6 +1,18 @@
:host { :host {
display: flex; label {
flex-direction: row; display: block;
font-weight: normal;
icon {
display: inline-block;
}
}
.slider-wrapper {
display: flex;
flex-direction: row;
padding-left: 1.6rem;
}
.slider-container { .slider-container {
width: 80%; width: 80%;

View File

@@ -13,6 +13,14 @@ export interface SliderPips {
stepped?: boolean; stepped?: boolean;
} }
export interface SliderProps {
min: number;
max: number;
step?: number;
pips?: SliderPips;
valueUnit?: string;
}
@Component({ @Component({
selector: 'slider-wrapper', selector: 'slider-wrapper',
templateUrl: './slider-wrapper.component.html', templateUrl: './slider-wrapper.component.html',
@@ -23,6 +31,8 @@ export interface SliderPips {
}) })
export class SliderWrapperComponent implements AfterViewInit, ControlValueAccessor, OnDestroy { export class SliderWrapperComponent implements AfterViewInit, ControlValueAccessor, OnDestroy {
@ViewChild(NouisliderComponent) slider: NouisliderComponent; @ViewChild(NouisliderComponent) slider: NouisliderComponent;
@Input() label: string;
@Input() tooltip: string;
@Input() min: number; @Input() min: number;
@Input() max: number; @Input() max: number;
@Input() step: number; @Input() step: number;

View File

@@ -193,7 +193,6 @@ import { SliderWrapperComponent } from './components/slider-wrapper/slider-wrapp
DataStorageRepositoryService, DataStorageRepositoryService,
DefaultUserConfigurationService, DefaultUserConfigurationService,
LogService, LogService,
DefaultUserConfigurationService,
AppUpdateRendererService, AppUpdateRendererService,
AppRendererService, AppRendererService,
IpcCommonRenderer, IpcCommonRenderer,

View File

@@ -16,6 +16,7 @@ export const ActionTypes = {
SAVE_TO_KEYBOARD_FAILED: type(PREFIX + 'save to keyboard failed'), SAVE_TO_KEYBOARD_FAILED: type(PREFIX + 'save to keyboard failed'),
HIDE_SAVE_TO_KEYBOARD_BUTTON: type(PREFIX + 'hide save to keyboard button'), HIDE_SAVE_TO_KEYBOARD_BUTTON: type(PREFIX + 'hide save to keyboard button'),
RESET_USER_CONFIGURATION: type(PREFIX + 'reset user configuration'), RESET_USER_CONFIGURATION: type(PREFIX + 'reset user configuration'),
RESET_MOUSE_SPEED_SETTINGS: type(PREFIX + 'reset mouse speed settings'),
UPDATE_FIRMWARE: type(PREFIX + 'update firmware'), UPDATE_FIRMWARE: type(PREFIX + 'update firmware'),
UPDATE_FIRMWARE_WITH: type(PREFIX + 'update firmware with'), UPDATE_FIRMWARE_WITH: type(PREFIX + 'update firmware with'),
UPDATE_FIRMWARE_REPLY: type(PREFIX + 'update firmware reply'), UPDATE_FIRMWARE_REPLY: type(PREFIX + 'update firmware reply'),
@@ -109,6 +110,10 @@ export class UpdateFirmwareOkButtonAction implements Action {
type = ActionTypes.UPDATE_FIRMWARE_OK_BUTTON; type = ActionTypes.UPDATE_FIRMWARE_OK_BUTTON;
} }
export class ResetMouseSpeedSettingsAction implements Action {
type = ActionTypes.RESET_MOUSE_SPEED_SETTINGS;
}
export type Actions export type Actions
= SetPrivilegeOnLinuxAction = SetPrivilegeOnLinuxAction
| SetPrivilegeOnLinuxReplyAction | SetPrivilegeOnLinuxReplyAction
@@ -119,6 +124,7 @@ export type Actions
| SaveToKeyboardSuccessAction | SaveToKeyboardSuccessAction
| SaveToKeyboardSuccessFailed | SaveToKeyboardSuccessFailed
| HideSaveToKeyboardButton | HideSaveToKeyboardButton
| ResetMouseSpeedSettingsAction
| ResetUserConfigurationAction | ResetUserConfigurationAction
| UpdateFirmwareAction | UpdateFirmwareAction
| UpdateFirmwareWithAction | UpdateFirmwareWithAction

View File

@@ -130,6 +130,30 @@ export class DeviceEffects {
.switchMap(() => Observable.of(new HideSaveToKeyboardButton())) .switchMap(() => Observable.of(new HideSaveToKeyboardButton()))
); );
@Effect()
resetMouseSpeedSettings$: Observable<Action> = this.actions$
.ofType(ActionTypes.RESET_MOUSE_SPEED_SETTINGS)
.switchMap(() => {
const config = this.defaultUserConfigurationService.getDefault();
const mouseSpeedDefaultSettings = {};
const mouseSpeedProps = [
'mouseMoveInitialSpeed',
'mouseMoveAcceleration',
'mouseMoveDeceleratedSpeed',
'mouseMoveBaseSpeed',
'mouseMoveAcceleratedSpeed',
'mouseScrollInitialSpeed',
'mouseScrollAcceleration',
'mouseScrollDeceleratedSpeed',
'mouseScrollBaseSpeed',
'mouseScrollAcceleratedSpeed'
];
mouseSpeedProps.forEach(prop => {
mouseSpeedDefaultSettings[prop] = config[prop];
});
return Observable.of(new LoadResetUserConfigurationAction(<UserConfiguration>mouseSpeedDefaultSettings));
});
@Effect() resetUserConfiguration$: Observable<Action> = this.actions$ @Effect() resetUserConfiguration$: Observable<Action> = this.actions$
.ofType(ActionTypes.RESET_USER_CONFIGURATION) .ofType(ActionTypes.RESET_USER_CONFIGURATION)
.switchMap(() => { .switchMap(() => {