File tree 8 files changed +181
-6
lines changed
8 files changed +181
-6
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,17 @@ import changeViewBackgroundColor
13
13
import setViewScale from '../view/setScale.js'
14
14
import setAboutViewBounds from '../aboutView/setBounds.js'
15
15
import {
16
- isDevelopment
16
+ isDevelopment ,
17
+ windowsDefaultSizes
17
18
} from '../../helpers/utils.js'
18
19
import {
19
20
preloadScriptFilePath
20
21
} from '../../helpers/paths.js'
22
+ import setAboutWindowScale from './setScale.js'
23
+
24
+ function handleResize ( ) {
25
+ setAboutViewBounds ( )
26
+ }
21
27
22
28
function handleClose (
23
29
event
@@ -30,14 +36,23 @@ function handleClose (
30
36
function handleFirstShow ( ) {
31
37
setAboutViewBounds ( )
32
38
39
+ setAboutWindowScale ( )
40
+
33
41
setViewScale (
34
42
aboutView
35
43
)
36
44
}
37
45
38
46
export default function ( ) {
39
- const aboutWindowWidth = 500
40
- const aboutWindowHeight = 275
47
+ const aboutWindowWidth =
48
+ windowsDefaultSizes
49
+ . about
50
+ . width
51
+
52
+ const aboutWindowHeight =
53
+ windowsDefaultSizes
54
+ . about
55
+ . height
41
56
42
57
const aboutWindowOptions = {
43
58
width : aboutWindowWidth ,
@@ -94,6 +109,11 @@ export default function () {
94
109
handleFirstShow
95
110
)
96
111
112
+ aboutWindow . on (
113
+ 'resize' ,
114
+ handleResize
115
+ )
116
+
97
117
aboutWindow . on (
98
118
'close' ,
99
119
handleClose
Original file line number Diff line number Diff line change
1
+ import getSettingsKey from '../settings/getKey.js'
2
+ import getScreenWorkAreaSize from '../screen/getWorkAreaSize.js'
3
+ import {
4
+ windowsDefaultSizes
5
+ } from '../../helpers/utils.js'
6
+
7
+ export default function ( ) {
8
+ const scale =
9
+ getSettingsKey (
10
+ 'layout.scale'
11
+ )
12
+
13
+ const isChangeScale = (
14
+ scale >= 0
15
+ )
16
+
17
+ if ( isChangeScale ) {
18
+ const {
19
+ width,
20
+ height
21
+ } = windowsDefaultSizes . about
22
+
23
+ const widthScaled = width * scale
24
+
25
+ const heightScaled = height * scale
26
+
27
+ const {
28
+ width : screenWorkAreaWidth ,
29
+ height : screenWorkAreaHeight
30
+ } = getScreenWorkAreaSize ( )
31
+
32
+ const minimumWidthScaled =
33
+ Math . min (
34
+ widthScaled ,
35
+ screenWorkAreaWidth - 50
36
+ )
37
+
38
+ const minimumHeightScaled =
39
+ Math . min (
40
+ heightScaled ,
41
+ screenWorkAreaHeight - 50
42
+ )
43
+
44
+ aboutWindow . setMinimumSize (
45
+ minimumWidthScaled ,
46
+ minimumHeightScaled
47
+ )
48
+
49
+ aboutWindow . setSize (
50
+ widthScaled ,
51
+ heightScaled
52
+ )
53
+
54
+ aboutWindow . center ( )
55
+ }
56
+ }
Original file line number Diff line number Diff line change 8
8
import {
9
9
isDevelopment ,
10
10
wait ,
11
- isShowDevTools
11
+ isShowDevTools ,
12
+ windowsDefaultSizes
12
13
} from '../../helpers/utils.js'
13
14
import {
14
15
baseUrl
@@ -32,6 +33,7 @@ import {
32
33
import {
33
34
preloadScriptFilePath
34
35
} from '../../helpers/paths.js'
36
+ import setMainWindowScale from './setScale.js'
35
37
36
38
function handleShow ( ) {
37
39
setTrayMenu ( )
@@ -85,6 +87,8 @@ function handleDidFinishLoad () {
85
87
async function handleFirstShow ( ) {
86
88
resizeViews ( )
87
89
90
+ setMainWindowScale ( )
91
+
88
92
setViewScale (
89
93
mainView
90
94
)
@@ -118,8 +122,15 @@ async function handleFirstShow () {
118
122
}
119
123
120
124
export default function ( ) {
121
- const mainWindowWidth = 900
122
- const mainWindowHeight = 600
125
+ const mainWindowWidth =
126
+ windowsDefaultSizes
127
+ . main
128
+ . width
129
+
130
+ const mainWindowHeight =
131
+ windowsDefaultSizes
132
+ . main
133
+ . height
123
134
124
135
const mainWindowOptions = {
125
136
width : mainWindowWidth ,
Original file line number Diff line number Diff line change
1
+ import getSettingsKey from '../settings/getKey.js'
2
+ import getScreenWorkAreaSize from '../screen/getWorkAreaSize.js'
3
+ import {
4
+ windowsDefaultSizes
5
+ } from '../../helpers/utils.js'
6
+
7
+ export default function ( ) {
8
+ const scale =
9
+ getSettingsKey (
10
+ 'layout.scale'
11
+ )
12
+
13
+ const isChangeScale = (
14
+ scale >= 0 &&
15
+ ! mainWindow . isMaximized ( )
16
+ )
17
+
18
+ if ( isChangeScale ) {
19
+ const {
20
+ width,
21
+ height
22
+ } = windowsDefaultSizes . main
23
+
24
+ const widthScaled = width * scale
25
+
26
+ const heightScaled = height * scale
27
+
28
+ const {
29
+ width : screenWorkAreaWidth ,
30
+ height : screenWorkAreaHeight
31
+ } = getScreenWorkAreaSize ( )
32
+
33
+ const minimumWidthScaled =
34
+ Math . min (
35
+ widthScaled ,
36
+ screenWorkAreaWidth - 50
37
+ )
38
+
39
+ const minimumHeightScaled =
40
+ Math . min (
41
+ heightScaled ,
42
+ screenWorkAreaHeight - 50
43
+ )
44
+
45
+ mainWindow . setMinimumSize (
46
+ minimumWidthScaled ,
47
+ minimumHeightScaled
48
+ )
49
+
50
+ mainWindow . setSize (
51
+ widthScaled ,
52
+ heightScaled
53
+ )
54
+
55
+ mainWindow . center ( )
56
+ }
57
+ }
Original file line number Diff line number Diff line change
1
+ import {
2
+ screen
3
+ } from 'electron'
4
+
5
+ export default function ( ) {
6
+ return screen
7
+ . getPrimaryDisplay ( )
8
+ . workAreaSize
9
+ }
Original file line number Diff line number Diff line change
1
+ import setMainWindowScale from '../mainWindow/setScale.js'
2
+ import setAboutWindowScale from '../aboutWindow/setScale.js'
3
+
4
+ export default function ( ) {
5
+ setMainWindowScale ( )
6
+
7
+ setAboutWindowScale ( )
8
+ }
Original file line number Diff line number Diff line change 1
1
import setViewsDarkMode from '../actions/views/setDarkMode.js'
2
2
import setViewsScale from '../actions/views/setScale.js'
3
+ import setWindowsScale from '../actions/windows/setScale.js'
3
4
4
5
export function handleIsDarkModeChange ( ) {
5
6
setViewsDarkMode ( )
6
7
}
7
8
8
9
export function handleScaleChange ( ) {
10
+ setWindowsScale ( )
11
+
9
12
setViewsScale ( )
10
13
}
Original file line number Diff line number Diff line change @@ -89,6 +89,17 @@ export const isShowDevTools =
89
89
'dev-tools'
90
90
)
91
91
92
+ export const windowsDefaultSizes = {
93
+ main : {
94
+ width : 900 ,
95
+ height : 600
96
+ } ,
97
+ about : {
98
+ width : 500 ,
99
+ height : 275
100
+ }
101
+ }
102
+
92
103
export function createFolderIfNotExists (
93
104
path
94
105
) {
You can’t perform that action at this time.
0 commit comments