Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Show in Tooltip the original length of Pomodoro and the time it ended
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamerlin committed Sep 25, 2019
1 parent 94b430e commit 935cc45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pomodorino",
"productName": "Pomodorino",
"version": "0.4.0",
"version": "0.4.1",
"description": "",
"main": "app/main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function generateContextMenu(): Menu {
{ id: '25', label: '25', type: 'normal', click: _ => pomo.startPomodoro(25) },
{ id: '15', label: '15', type: 'normal', click: _ => pomo.startPomodoro(15) },
{ id: '5', label: '5', type: 'normal', click: _ => pomo.startPomodoro(5) },
{ id: '-2', label: 'Cancel', type: 'normal', click: _ => pomo.reset() },
{ id: '-2', label: 'Cancel', type: 'normal', click: _ => pomo.reset(true) },
{ type: 'separator' },
{ id: '-1', label: 'Quit', type: 'normal', click: _ => cleanUpAndQuit() },
]);
Expand Down
20 changes: 11 additions & 9 deletions src/pomoEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class PomoEngine {
private timer = null;

constructor(alert: Alerts, menu: Menu, baseDir: string) {
this.defaultTrayImg = path.join(baseDir,'/res/tomato.png');
this.alertTrayImg = path.join(baseDir,'/res/yomato.png');
this.defaultTrayImg = path.join(baseDir, '/res/tomato.png');
this.alertTrayImg = path.join(baseDir, '/res/yomato.png');
this.tray = new Tray(this.defaultTrayImg);
this.tray.setContextMenu(menu);
this.tray.on('click', () => this.trayClicked());
Expand All @@ -38,7 +38,7 @@ export class PomoEngine {
if (this.blinkingMode) {
this.tray.setImage(raw.currentSeconds % 2 == 0 ? this.alertTrayImg : this.defaultTrayImg)
} else {
this.tray.setToolTip(`Pomodorino: ${formattedTime} left`);
this.tray.setToolTip(`${minutes} Pomodorino: ${formattedTime} left`);
if (raw.currentMinutes > 0 && raw.currentSeconds == 59) {
this.updateTray(+raw.currentMinutes + 1)
}
Expand All @@ -53,21 +53,23 @@ export class PomoEngine {
this.timer.start();
}

reset(blinking: boolean = false) {
reset(cancelled: boolean = false) {
this.blinkingMode = false;
this.timer.destroy();
this.tray.setToolTip('Pomodorino by Merurino');
if (cancelled)
this.tray.setToolTip("Cancelled");
this.tray.setImage(this.defaultTrayImg);
}

//TODO: Maybe create an eventListener here if we ever want to plug something else from outside.
//example: https://stackoverflow.com/a/40822325/2506478
private pomodoroFinished(minutes: number) {
this.tray.setToolTip(`${minutes} Pomodorino finished at ${new Date().toLocaleTimeString()}`);
if (!this.blinkingMode) this.alert.callAlerts();

this.blinkingMode = (!this.blinkingMode && this.alert.getShouldBlink());
if (this.blinkingMode) this.timer.start();

if (!this.alert.getShouldBlink()) this.reset();
}

Expand All @@ -80,7 +82,7 @@ export class PomoEngine {
private generateImage(overlayText, setTrayImageClosure) {
let useBiggerFonts = (process.platform == "win32")
let Jimp = require("jimp");
let fileName = path.join(this.baseDir,'/res/tomato.png');
let fileName = path.join(this.baseDir, '/res/tomato.png');
let calculatedY = useBiggerFonts ? 0 : 8
let calculatedX = useBiggerFonts ?
(overlayText.length > 1) ? 0 : 8
Expand All @@ -101,7 +103,7 @@ export class PomoEngine {
});
}

trayClicked(){
if(this.blinkingMode) this.reset();
trayClicked() {
if (this.blinkingMode) this.reset();
}
}

0 comments on commit 935cc45

Please sign in to comment.