Skip to content

Commit

Permalink
v0.1.0-alpha4
Browse files Browse the repository at this point in the history
  • Loading branch information
GGIEnrike committed Aug 31, 2022
1 parent a075a18 commit 442ea91
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 45 deletions.
68 changes: 35 additions & 33 deletions src/SettingsDropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,46 @@ export class SettingsDropdown {
open: boolean
canOpen: boolean
constructor(xMargin: number, yMargin: number, width: number, height: number, fileName: string, win: BrowserWindow, v: BrowserView, theme: 'dark' | 'light') {
this.view = new BrowserView({webPreferences: {preload: path.join(__dirname, "settingsPreload.js")}})
this.win = win
this.v = v
ipcMain.once('loadedView', () => {
this.view = new BrowserView({webPreferences: {preload: path.join(__dirname, "settingsPreload.js")}})
this.win = win
this.v = v

let y = this.v.getBounds().y + yMargin
let y = this.v.getBounds().y + yMargin

this.win.addBrowserView(this.view)
this.view.setBounds({ x: this.win.getBounds().width - xMargin - width, y: y, width: width, height: height })

this.hide()

this.view.webContents.send('setTheme', theme)

ipcMain.on('toggleSettings', () => {
if (this.open) {
this.hide()
} else {
if (this.canOpen) {
this.show()
}
}
})

ipcMain.on('lockButtonPressed', () => {
y = this.v.getBounds().y + yMargin
this.win.addBrowserView(this.view)
this.view.setBounds({ x: this.win.getBounds().width - xMargin - width, y: y, width: width, height: height })
})

this.hide()

this.view.webContents.send('setTheme', theme)

ipcMain.on('toggleSettings', () => {
if (this.open) {
this.hide()
} else {
if (this.canOpen) {
this.show()
}
}
})

// this.view.webContents.openDevTools()

this.view.webContents.loadFile(path.join(__dirname, fileName))

this.win.on('resize', () => {
this.view.setBounds({ x: this.win.getBounds().width - xMargin - width, y: y, width: width, height: height })
})
ipcMain.on('lockButtonPressed', () => {
y = this.v.getBounds().y + yMargin
this.view.setBounds({ x: this.win.getBounds().width - xMargin - width, y: y, width: width, height: height })
})

this.view.webContents.on('blur', () => {
this.hide()
// this.view.webContents.openDevTools()

this.view.webContents.loadFile(path.join(__dirname, fileName))

this.win.on('resize', () => {
this.view.setBounds({ x: this.win.getBounds().width - xMargin - width, y: y, width: width, height: height })
})

this.view.webContents.on('blur', () => {
this.hide()
})
})
}

Expand Down
11 changes: 3 additions & 8 deletions src/View.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserView, BrowserWindow, ipcMain, dialog, MenuItem, Menu } from "electron"
import { BrowserView, BrowserWindow, ipcMain, dialog } from "electron"
import * as path from "path"
import { LoadingError } from "./LoadingError"

Expand Down Expand Up @@ -190,8 +190,6 @@ export class View {
win.webContents.send('canGoBack', this.view.webContents.canGoBack())
win.webContents.send('canGoForward', this.view.webContents.canGoForward())

// win.webContents.send('canRefresh', this.homePage)

if (this.homePage) {
this.shouldEnableZoom = false
} else {
Expand All @@ -208,11 +206,8 @@ export class View {
}
})

this.view.webContents.on('did-finish-load', () => {
// this.homeCount += 1
// if (this.homeCount > 0) {
// this.homePage = false
// }
this.view.webContents.once('did-finish-load', () => {
ipcMain.emit('loadedView')
})

// this.view.webContents.on('did-navigate', () => {
Expand Down
4 changes: 0 additions & 4 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ window.api.handleCanGoForward((_ev: Event, canGoForward: boolean) => {
forwardButton.disabled = !canGoForward
})

window.api.handleCanRefresh((_ev: Event, canRefresh: boolean) => {
refreshButton.disabled = canRefresh
})

searchBar.addEventListener('keyup' , (event: KeyboardEvent) => {
//key code for enter
if (event.key === 'Enter') {
Expand Down

0 comments on commit 442ea91

Please sign in to comment.