Skip to content

Commit

Permalink
Add right-click menu on main input
Browse files Browse the repository at this point in the history
  • Loading branch information
NTag committed Jun 15, 2017
1 parent 8e99be9 commit 21bb5cf
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="input-div">
<form method="post" (submit)="execute($event)">
<input type="text" class="input-main" id="input-main" i18n-placeholder placeholder="What do you want to download?" (keydown)="search($event)" name="queryi" [(ngModel)]="queryi" autofocus="autofocus" [ngClass]="{'input-main-open': (suggestions.songs || suggestions.albums)}" />
<input type="text" class="input-main" id="input-main" i18n-placeholder placeholder="What do you want to download?" (keydown)="search($event)" name="queryi" [(ngModel)]="queryi" autofocus="autofocus" [ngClass]="{'input-main-open': (suggestions.songs || suggestions.albums)}" (contextmenu)="contextMenu.openEditMenu()" />
<button type="submit" style="display: none"></button>
</form>
<div class="legend" *ngIf="unsupported" i18n>
Expand Down
3 changes: 2 additions & 1 deletion app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as _ from 'lodash';
declare var electron: any;
import { Alltomp3Service } from './alltomp3.service';
import { DatabaseService } from './database.service';
import { ContextMenuService } from './contextmenu.service';

@Component({
selector: 'app-root',
Expand Down Expand Up @@ -39,7 +40,7 @@ export class AppComponent {
displayHelp:boolean = false;
displayHelpMax:number = 2;

constructor(private alltomp3: Alltomp3Service, private db: DatabaseService) {
constructor(private alltomp3: Alltomp3Service, private db: DatabaseService, private contextMenu: ContextMenuService) {
this.requests = alltomp3.requests;

this.db.getHelpDisplayed().then(helpDisplay => {
Expand Down
10 changes: 9 additions & 1 deletion app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Alltomp3Service } from './alltomp3.service';
import { LoggerService } from './logger.service';
import { LoggerErrorService } from './loggererror.service';
import { TransService } from './trans.service';
import { ContextMenuService } from './contextmenu.service';

import { AppComponent } from './app.component';
import { SavingPathComponent } from './saving-path/saving-path.component';
Expand All @@ -32,7 +33,14 @@ import { NewsComponent } from './news/news.component';
FormsModule,
HttpModule
],
providers: [DatabaseService, Alltomp3Service, TransService, LoggerService, {provide: ErrorHandler, useClass: LoggerErrorService}],
providers: [
DatabaseService,
Alltomp3Service,
TransService,
LoggerService,
ContextMenuService,
{provide: ErrorHandler, useClass: LoggerErrorService}
],
bootstrap: [AppComponent]
})
export class AppModule { }
41 changes: 41 additions & 0 deletions app/src/app/contextmenu.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Injectable } from '@angular/core';
import { TransService } from './trans.service';
declare var electron: any;

@Injectable()
export class ContextMenuService {

public editMenu;

constructor(private trans: TransService) {
this.editMenu = electron.remote.Menu.buildFromTemplate([{
label: trans.t.undo,
role: 'undo',
}, {
label: trans.t.redo,
role: 'redo',
}, {
type: 'separator',
}, {
label: trans.t.cut,
role: 'cut',
}, {
label: trans.t.copy,
role: 'copy',
}, {
label: trans.t.paste,
role: 'paste',
}, {
type: 'separator',
}, {
label: trans.t.selectAll,
role: 'selectall',
},
]);
}

public openEditMenu() {
this.editMenu.popup(electron.remote.getCurrentWindow());
}

}
18 changes: 16 additions & 2 deletions app/src/app/trans.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,28 @@ export class TransService {
dlfinished: 'Téléchargement terminé',
dlfrom: 'de',
dldownloaded: 'a été téléchargé',
songs: 'morceaux'
songs: 'morceaux',
edit: 'Édition',
undo: 'Annuler',
redo: 'Répéter',
cut: 'Couper',
copy: 'Copier',
paste: 'Coller',
selectAll: 'Tout sélectionner'
},
en: {
antivirus: 'An error occured. If you have an antivirus, try to deactivate it and try again. It may interfere with AllToMP3.',
dlfinished: 'Download finished',
dlfrom: 'from',
dldownloaded: 'has been downloaded',
songs: 'songs'
songs: 'songs',
edit: 'Edit',
undo: 'Undo',
redo: 'Redo',
cut: 'Cut',
copy: 'Copy',
paste: 'Paste',
selectAll: 'Select All'
}
};

Expand Down

0 comments on commit 21bb5cf

Please sign in to comment.