diff --git a/main.js b/main.js index 9e3dcc4..6a32b87 100644 --- a/main.js +++ b/main.js @@ -1,23 +1,24 @@ 'use strict' // Import parts of electron to use -const { app, BrowserWindow, dialog, ipcMain, Menu} = require('electron') +const {app, BrowserWindow, dialog, ipcMain, Menu, screen, Tray} = require('electron') const openAboutWindow = require('about-window').default const path = require('path') const url = require('url') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. -let mainWindow; +let mainWindow, tray; +let devBrowserProperties = {}; + +function createTray() { + tray = new Tray('./marvin16x16.png'); + tray.setToolTip('Marvin') +} // Keep a reference for dev mode let dev = false -// Broken: -// if (process.defaultApp || /[\\/]electron-prebuilt[\\/]/.test(process.execPath) || /[\\/]electron[\\/]/.test(process.execPath)) { -// dev = true -// } - if (process.env.NODE_ENV !== undefined && process.env.NODE_ENV === 'development') { dev = true } @@ -31,8 +32,8 @@ if (process.platform === 'win32') { // Functions - async function handleFileOpen() { - const { canceled, filePaths } = await dialog.showOpenDialog(mainWindow, {properties: ['openDirectory']}) +async function handleFileOpen() { + const {canceled, filePaths} = await dialog.showOpenDialog(mainWindow, {properties: ['openDirectory']}) if (canceled) { return } else { @@ -102,7 +103,7 @@ let mainMenu = Menu.buildFromTemplate( click: () => { openAboutWindow({ icon_path: path.join(__dirname, 'marvin.ico'), - bug_report_url:'mailto:r.nasarek@gnm.de', + bug_report_url: 'mailto:r.nasarek@gnm.de', bug_link_text: 'Einen Fehler melden', license: 'MIT', description: 'App zur Dokumentverwaltung im IKK am Germanischen Nationalmuseum.', @@ -117,12 +118,26 @@ let mainMenu = Menu.buildFromTemplate( ) +function createWindow(dimensions) { + if (dev !== true) { + devBrowserProperties = { + fullscreenable: false, + resizable: false, + } -function createWindow() { + } + // Create tray icon. + createTray() + let appWidth = 400; + let appHeight = 720; + let xPosition = (dimensions.width - appWidth) // Create the browser window. mainWindow = new BrowserWindow({ - width: 400, - height: 600, + ...devBrowserProperties, + x: xPosition, + y: 0, + width: appWidth, + height: appHeight, icon: __dirname + '/marvin.ico', show: false, webPreferences: { @@ -163,23 +178,17 @@ function createWindow() { // Don't show until we are ready and loaded mainWindow.once('ready-to-show', () => { mainWindow.show() - // Open the DevTools automatically if developing if (dev) { - const { default: installExtension, REACT_DEVELOPER_TOOLS } = require('electron-devtools-installer') - + const {default: installExtension, REACT_DEVELOPER_TOOLS} = require('electron-devtools-installer') installExtension(REACT_DEVELOPER_TOOLS) .catch(err => console.log('Error loading React DevTools: ', err)) mainWindow.webContents.openDevTools() } }) - // Emitted when the window is closed. - mainWindow.on('closed', function() { - // Dereference the window object, usually you would store windows - // in an array if your app supports multi windows, this is the time - // when you should delete the corresponding element. - mainWindow = null + mainWindow.on('closed', function () { + mainWindow = null; }) } @@ -188,7 +197,9 @@ function createWindow() { // Some APIs can only be used after this event occurs. app.on('ready', () => { ipcMain.handle('dialog:openFile', handleFileOpen) - createWindow(); + const display = screen.getPrimaryDisplay(); + const dimensions = display.size; + createWindow(dimensions); }) diff --git a/marvin16x16.png b/marvin16x16.png new file mode 100644 index 0000000..55e811d Binary files /dev/null and b/marvin16x16.png differ diff --git a/resources/files/config/config.json b/resources/files/config/config.json index 4abbf33..b0b532a 100644 --- a/resources/files/config/config.json +++ b/resources/files/config/config.json @@ -1,3 +1,3 @@ { - "rootDir": "/home/rbrt/WebstormProjects/marvin" + "rootDir": "/home/rbrt/Schreibtisch/marvin" } \ No newline at end of file diff --git a/splashScreen.css b/splashScreen.css new file mode 100644 index 0000000..4c3b9af --- /dev/null +++ b/splashScreen.css @@ -0,0 +1,52 @@ +body { + background-color: #f9f9fa; + background-image: url('background.jpg'); +} + +.flex { + -webkit-box-flex: 1; + -ms-flex: 1 1 auto; + flex: 1 1 auto +} +.loader { + border: 5px solid rgba(18, 65, 145, 255); + border-radius: 50%; + border-top: 5px solid #ffffff; + width: 40px; + height: 40px; + -webkit-animation: spin 1s linear infinite; + /* Safari */ + animation: spin 1s linear infinite; + margin: auto; + left: 0; + right: 0; + top: 0px; + bottom: 0; + position: fixed; +} + +/* Safari */ +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + } + + 100% { + -webkit-transform: rotate(360deg); + } +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} + +.center { + border: none !important; + text-align: center; +} diff --git a/splashScreen.html b/splashScreen.html new file mode 100644 index 0000000..a25901a --- /dev/null +++ b/splashScreen.html @@ -0,0 +1,9 @@ + +
+ + + +