Skip to content

Commit 3fcadd9

Browse files
authored
Merge pull request #9 from Doka-NT/ubuntu-fixes
More comfortable user experience on linux desktops
2 parents 3663d23 + a19fdac commit 3fcadd9

File tree

5 files changed

+86
-21
lines changed

5 files changed

+86
-21
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,4 @@ typings/
8888
# Electron-Forge
8989
out/
9090

91-
.vscode/
9291
.idea/

.vscode/launch.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
// Используйте IntelliSense, чтобы узнать о возможных атрибутах.
3+
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов.
4+
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Debug",
11+
"skipFiles": [
12+
"<node_internals>/**"
13+
],
14+
"cwd": "${workspaceRoot}",
15+
"runtimeExecutable": "yarn",
16+
"runtimeArgs": [
17+
"start",
18+
],
19+
},
20+
{
21+
"type": "node",
22+
"request": "launch",
23+
"name": "Make",
24+
"skipFiles": [
25+
"<node_internals>/**"
26+
],
27+
"cwd": "${workspaceRoot}",
28+
"runtimeExecutable": "yarn",
29+
"runtimeArgs": [
30+
"make",
31+
],
32+
},
33+
]
34+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "worklog-reminder",
33
"productName": "worklog-reminder",
4-
"version": "1.0.0-beta.1",
4+
"version": "1.0.0-beta.2",
55
"description": "Tool for easily search and add worklog to JIRA issues",
66
"repository": {
77
"type": "git",

src/UI/AppTray.js

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,63 @@ class AppTray
1212
constructor(windowManager) {
1313
this.windowManager = windowManager
1414
this.tray = new Tray(this._resolveIcon())
15+
this.tray.setContextMenu(this._createContextMenu())
16+
this.tray.closeContextMenu()
1517
}
1618

1719
setHandlers()
1820
{
1921
this.tray.on('double-click', this._toggleWindow.bind(this))
2022
this.tray.on('click', event => {
21-
this.tray.setContextMenu(null)
22-
23-
const mainWindow = this.windowManager.getMainWindow()
24-
25-
this._toggleWindow()
26-
27-
if (mainWindow.isVisible() && process.defaultApp && event.metaKey) {
28-
mainWindow.openDevTools({mode: 'detach'})
23+
if (process.platform === 'darwin') {
24+
this.tray.setContextMenu(null)
2925
}
26+
27+
this._showMainWindow(event)
3028
})
29+
3130
this.tray.on('right-click', () => {
32-
const contextMenu = Menu.buildFromTemplate([
33-
{
34-
label: 'Help', click: () => {
35-
new OpenInShellHandler().handle({payload: 'https://github.com/Doka-NT/worklog-reminder'})
36-
}
37-
},
38-
{label: 'Quit', click: () => app.quit()},
39-
])
40-
41-
this.tray.setContextMenu(contextMenu)
31+
if (process.platform === 'darwin') {
32+
this.tray.setContextMenu(this._createContextMenu())
33+
}
34+
this.tray.popUpContextMenu()
4235
})
36+
37+
}
38+
39+
_showMainWindow(event)
40+
{
41+
const mainWindow = this.windowManager.getMainWindow()
42+
43+
this._toggleWindow()
44+
45+
if (mainWindow.isVisible() && process.defaultApp && event.metaKey) {
46+
mainWindow.openDevTools({mode: 'detach'})
47+
}
48+
}
49+
50+
_createContextMenu()
51+
{
52+
const menuItems = [
53+
{
54+
label: 'Help',
55+
click: () => {
56+
new OpenInShellHandler().handle({payload: 'https://github.com/Doka-NT/worklog-reminder'})
57+
}
58+
},
59+
{label: 'Quit', click: () => app.quit()},
60+
]
61+
62+
if (process.platform === 'linux') {
63+
menuItems.unshift({
64+
label: 'Toggle Window',
65+
click: (event) => {
66+
this._showMainWindow(event)
67+
}
68+
})
69+
}
70+
71+
return Menu.buildFromTemplate(menuItems)
4372
}
4473

4574
_resolveIcon()

src/UI/WindowManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import AppTray from "./AppTray";
22
import MainWindow from "./MainWindow";
3+
import config from '../app.config.main';
4+
import path from 'path';
35

46
class WindowManager {
57
/**
@@ -48,7 +50,8 @@ class WindowManager {
4850
fullscreenable: false,
4951
resizable: false,
5052
transparent: false,
51-
skipTaskbar: true,
53+
skipTaskbar: process.platform !== 'linux',
54+
icon: path.join(config.assetsDir, process.platform !== 'win32' ? 'appIconColored.png' : 'appIconColored.ico'),
5255
webPreferences: {
5356
// Prevents renderer process code from not running when window is
5457
// hidden

0 commit comments

Comments
 (0)