Skip to content

Commit 282d05f

Browse files
authored
Splash screen: make sure that the copyright and version information are shown on Windows.
2 parents 9e47768 + 0b93a05 commit 282d05f

File tree

9 files changed

+24
-46
lines changed

9 files changed

+24
-46
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,18 @@ target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
130130
${NODE_ADDON_API_DIR})
131131

132132
add_definitions(-DNAPI_VERSION=3)
133+
134+
# Configure our splash screen.
135+
136+
string(TIMESTAMP CURRENT_YEAR "%Y")
137+
138+
if(CURRENT_YEAR EQUAL 2024)
139+
set(COPYRIGHT "2024")
140+
else()
141+
set(COPYRIGHT "2024-${CURRENT_YEAR}")
142+
endif()
143+
144+
set(VERSION ${PROJECT_VERSION})
145+
146+
configure_file(src/main/assets/splashscreen.html.in
147+
${CMAKE_BINARY_DIR}/splashscreen.html)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"clean": "node res/clean.js",
2727
"dev": "pnpm build:libopencor && electron-vite dev --watch",
2828
"dev:web": "(cd ./src/renderer && vite dev)",
29-
"format": "prettier --write . && clang-format -i src/libopencor/src/*",
30-
"format:check": "prettier --check . && clang-format --dry-run -Werror src/libopencor/src/*",
29+
"format": "prettier --log-level silent --write . && clang-format -i src/libopencor/src/*",
30+
"format:check": "prettier --log-level silent --check . && clang-format --dry-run -Werror src/libopencor/src/*",
3131
"lint": "eslint --fix .",
3232
"package": "pnpm build && electron-builder",
3333
"package:linux": "pnpm build && electron-builder --linux",

src/electronapi.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ interface ElectronAPI {
66
disableMenu: () => void
77

88
// Renderer process listening to the main process.
9-
// Note: no onInitSplashScreenWindow() method since it's only called from our splash screen window and it doesn't seem
10-
// to be able to import this file.
119

1210
onResetAll: (callback: () => void) => void
1311
onAbout: (callback: () => void) => void

src/main/SplashScreenWindow.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ApplicationWindow } from './ApplicationWindow'
22
import { retrieveMainWindowState } from './MainWindow'
33

44
export class SplashScreenWindow extends ApplicationWindow {
5-
constructor(copyright: string, version: string) {
5+
constructor() {
66
// Initialise ourselves.
77

88
const width = 413 + 24
@@ -22,17 +22,8 @@ export class SplashScreenWindow extends ApplicationWindow {
2222
alwaysOnTop: true
2323
})
2424

25-
this.loadFile('./src/main/assets/splashscreen.html').catch((err: unknown) => {
25+
this.loadFile('./out/libOpenCOR/splashscreen.html').catch((err: unknown) => {
2626
console.error('Failed to load splash screen:', err)
2727
})
28-
29-
// Initialise our Web contents.
30-
31-
this.on('ready-to-show', () => {
32-
this.webContents.send('init-splash-screen-window', {
33-
copyright: copyright,
34-
version: version
35-
})
36-
})
3728
}
3829
}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@
88
http-equiv="Content-Security-Policy"
99
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
1010
/>
11-
<link rel="stylesheet" href="splashscreen.css" />
11+
<link rel="stylesheet" href="../../src/main/assets/splashscreen.css" />
1212
</head>
13-
1413
<body>
1514
<table class="contents">
1615
<tr>
1716
<td class="logo" colspan="2">
18-
<img class="logo" src="../../renderer/src/assets/logo.svg" />
17+
<img class="logo" src="../../src/renderer/src/assets/logo.svg" />
1918
</td>
2019
</tr>
2120
<tr>
22-
<td class="copyright">Copyright <span id="copyright" /></td>
23-
<td class="version">Version <span id="version" /></td>
21+
<td class="copyright">Copyright @COPYRIGHT@</td>
22+
<td class="version">Version @VERSION@</td>
2423
</tr>
2524
</table>
26-
27-
<script src="splashscreen.ts"></script>
2825
</body>
2926
</html>

src/main/assets/splashscreen.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/main/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,7 @@ app
4848
.then(() => {
4949
// Create our splash window, if we are not in development mode, and pass it our copyright and version values.
5050

51-
let splashScreenWindow: SplashScreenWindow = null as unknown as SplashScreenWindow
52-
53-
if (!isDevMode()) {
54-
const currentYear = new Date().getFullYear()
55-
56-
splashScreenWindow = new SplashScreenWindow(
57-
currentYear === 2024 ? '2024' : `2024-${currentYear.toString()}`,
58-
app.getVersion()
59-
)
60-
}
51+
const splashScreenWindow: SplashScreenWindow | null = isDevMode() ? null : new SplashScreenWindow()
6152

6253
// Set our app user model id for Windows.
6354

src/preload/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
1313

1414
// Renderer process listening to the main process.
1515

16-
onInitSplashScreenWindow: (callback: (info: unknown) => void) =>
17-
ipcRenderer.on('init-splash-screen-window', (_event, info) => {
18-
callback(info)
19-
}),
2016
onResetAll: (callback: () => void) =>
2117
ipcRenderer.on('reset-all', () => {
2218
callback()

src/renderer/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
content="default-src 'self'; script-src 'unsafe-eval'; script-src-elem 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
1010
/>
1111
</head>
12-
1312
<body>
1413
<div id="app" />
1514
<script type="module" src="./src/main.ts"></script>

0 commit comments

Comments
 (0)