Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
What's New in v0.7.0:
Browse files Browse the repository at this point in the history
------
* Removed hard coded language
* Settings should all be working as expected
* Fixed bugs on preferences page
* More improvements for CPU / GPU
  • Loading branch information
Peter Schmalfeldt committed Feb 19, 2018
1 parent b73aa3f commit c2a3f93
Show file tree
Hide file tree
Showing 36 changed files with 901 additions and 292 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weather-bar-app",
"version": "0.6.0",
"version": "0.7.0",
"author": "Peter Schmalfeldt <me@peterschmalfeldt.com>",
"description": "Weather Bar is a Weather Application that lives in your Menu Bar giving you beautiful access to real-time weather conditions and a generous 15-day forecast.",
"keywords": [
Expand Down
168 changes: 92 additions & 76 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import autoUpdater from './auto-update'
import util from './util'
import { version as currentVersion } from '../../package.json'

import { i18n as $t } from '../translations/i18n'

const machineId = machineIdSync({ original: true })

let appSettings = {}
Expand Down Expand Up @@ -49,86 +51,35 @@ app.on('web-contents-created', (event, contents) => {
})
})

// Setup Context Menu
let contextMenu = null

// Setup Main Weather Bar App
const mb = menubar({
index: (process.env.NODE_ENV === 'development') ? 'http://localhost:9080' : `file://${__dirname}/index.html`,
icon: util.getAppIcon(),
width: 280,
height: 480,
alwaysOnTop: true,
title: 'Weather Bar',
title: $t(appSettings.app_language, 'app.title'),
preloadWindow: true,
resizable: false
})

mb.on('ready', function ready () {
autoUpdater()

mb.setOption('title', 'Weather Bar')

globalShortcut.register('CommandOrControl+Shift+W', () => {
if (mb.window.isVisible()) {
mb.window.hide()
} else {
mb.window.show()
}
})

ipcMain.on('save-settings', (event, settings) => {
appSettings = settings
})

ipcMain.on('get-uuid', (event) => {
mb.window.send('set-uuid', machineId)
})

ipcMain.on('set-weather', (event, weather, settings) => {
util.setWeather(mb, weather, settings)
})

ipcMain.on('set-always-on-top', (event, preference) => {
mb.setOption('alwaysOnTop', preference)
appSettings.app_always_on_top = preference
})

ipcMain.on('set-launch-at-startup', (event, preference) => {
console.log('set-launch-at-startup', preference)
})

ipcMain.on('set-icon-preference', (event, preference) => {
console.log('set-icon-preference', preference)
})

ipcMain.on('close', (event, args) => {
app.quit()
})

ipcMain.on('will-navigate', (event, args) => {
const url = args.url
shell.openExternal(url)
})
})

mb.on('focus-lost', () => {
if (!appSettings.app_always_on_top) {
if (mb.window.isVisible()) {
mb.window.hide()
}
}
})

// Add Context Menu to Weather Bar App
mb.on('after-create-window', () => {
const contextMenu = Menu.buildFromTemplate([
const makeMenu = () => {
return Menu.buildFromTemplate([
{
label: 'About Weather Bar',
label: $t(appSettings.app_language, 'context.menu.about'),
click () {
dialog.showMessageBox(null, {
type: 'none',
icon: path.join(__static, '/logo.png'),
message: `Weather Bar v${currentVersion}`,
detail: 'Weather Bar is an Open Source Application created by Peter Schmalfeldt.',
buttons: ['Close', 'Website'],
detail: $t(appSettings.app_language, 'context.menu.dialog.detail'),
buttons: [
$t(appSettings.app_language, 'context.menu.dialog.close'),
$t(appSettings.app_language, 'context.menu.dialog.website')
],
defaultId: 0,
noLink: true
}, (selected) => {
Expand All @@ -139,26 +90,26 @@ mb.on('after-create-window', () => {
}
},
{
label: `Version ${currentVersion}`,
label: $t(appSettings.app_language, 'context.menu.version', { version: currentVersion }),
enabled: false
},
{
type: 'separator'
},
{
label: 'Weather Bar Website',
label: $t(appSettings.app_language, 'context.menu.website'),
click () {
shell.openExternal('https://weatherbarapp.com')
}
},
{
label: 'License Agreement',
label: $t(appSettings.app_language, 'context.menu.license'),
click () {
shell.openExternal('https://github.com/manifestinteractive/weather-bar-app/blob/master/LICENSE')
}
},
{
label: 'Contact Support',
label: $t(appSettings.app_language, 'context.menu.support'),
click () {
shell.openExternal('https://github.com/manifestinteractive/weather-bar-app/issues')
}
Expand All @@ -167,7 +118,7 @@ mb.on('after-create-window', () => {
type: 'separator'
},
{
label: 'Local Weather',
label: $t(appSettings.app_language, 'app.menu.localWeather'),
click () {
mb.window.send('go-to-local-weather')
if (!mb.window.isVisible()) {
Expand All @@ -176,7 +127,7 @@ mb.on('after-create-window', () => {
}
},
{
label: 'Saved Locations',
label: $t(appSettings.app_language, 'app.menu.savedLocations'),
click () {
mb.window.send('go-to-saved-locations')
if (!mb.window.isVisible()) {
Expand All @@ -185,7 +136,7 @@ mb.on('after-create-window', () => {
}
},
{
label: 'New Location',
label: $t(appSettings.app_language, 'app.menu.newLocation'),
click () {
mb.window.send('go-to-new-location')
if (!mb.window.isVisible()) {
Expand All @@ -194,7 +145,7 @@ mb.on('after-create-window', () => {
}
},
{
label: 'Preferences...',
label: $t(appSettings.app_language, 'app.menu.preferences'),
click () {
mb.window.send('go-to-preferences')
if (!mb.window.isVisible()) {
Expand All @@ -206,7 +157,7 @@ mb.on('after-create-window', () => {
type: 'separator'
},
{
label: 'Developer Tools',
label: $t(appSettings.app_language, 'context.menu.devTools'),
click () {
mb.window.webContents.openDevTools()
}
Expand All @@ -215,28 +166,93 @@ mb.on('after-create-window', () => {
type: 'separator'
},
{
label: 'Quit Weather Bar',
label: $t(appSettings.app_language, 'context.menu.quit'),
click () {
mb.app.quit()
}
}
])
}

mb.on('ready', function ready () {
autoUpdater()

mb.setOption('title', $t(appSettings.app_language, 'app.title'))

globalShortcut.register('CommandOrControl+Shift+W', () => {
if (mb.window.isVisible()) {
mb.window.hide()
} else {
mb.window.show()
}
})

ipcMain.on('save-settings', (event, settings) => {
appSettings = settings
contextMenu = makeMenu()
})

ipcMain.on('save-setting', (event, key, value) => {
appSettings[key] = value
contextMenu = makeMenu()
})

ipcMain.on('get-uuid', (event) => {
mb.window.send('set-uuid', machineId)
})

ipcMain.on('set-weather', (event, weather, settings) => {
util.setWeather(mb, weather, settings)
})

ipcMain.on('set-always-on-top', (event, preference) => {
mb.setOption('alwaysOnTop', preference)
appSettings.app_always_on_top = preference
})

ipcMain.on('set-launch-at-startup', (event, preference) => {
console.log('set-launch-at-startup', preference)
})

ipcMain.on('set-icon-preference', (event, preference) => {
console.log('set-icon-preference', preference)
})

ipcMain.on('close', (event, args) => {
app.quit()
})

ipcMain.on('will-navigate', (event, args) => {
const url = args.url
shell.openExternal(url)
})
})

mb.on('focus-lost', () => {
if (!appSettings.app_always_on_top) {
if (mb.window.isVisible()) {
mb.window.hide()
}
}
})

// Add Context Menu to Weather Bar App
mb.on('after-create-window', () => {
contextMenu = makeMenu()

if (process.platform !== 'linux') {
mb.tray.on('right-click', () => {
mb.tray.popUpContextMenu(contextMenu)
})
} else {
mb.tray.setToolTip('Show Weather Bar')
mb.tray.setToolTip($t(appSettings.app_language, 'context.menu.toggle'))
}

mb.tray.on('click', () => {
if (mb.window.isVisible()) {
mb.tray.setToolTip('Hide Weather Bar')
mb.window.send('app-opened')
mb.window.show()
} else {
mb.tray.setToolTip('Show Weather Bar')
mb.window.send('app-closed')
mb.window.hide()
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'

const setWeather = (mb, data) => {
const setWeather = (mb, data, settings) => {
if (process.platform === 'darwin') {
if (data.setting === 'condition') {
mb.tray.setTitle('')
Expand All @@ -26,12 +26,8 @@ const setWeather = (mb, data) => {
}
}

if (process.platform !== 'linux') {
if (data.tooltip) {
mb.tray.setToolTip(data.tooltip)
} else {
mb.tray.setToolTip(`${data.title}°`)
}
if (process.platform !== 'linux' && data.tooltip) {
mb.tray.setToolTip(data.tooltip)
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/renderer/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
EventBus.$on('setClassNames', (classNames) => {
this.classNames = classNames
})
EventBus.$off('updatedSettings')
EventBus.$on('updatedSettings', () => {
this.getWeather()
this.getForecast()
})
},
bindElectronEvents () {
if (typeof this.$electron !== 'undefined' && typeof this.$electron.ipcRenderer !== 'undefined') {
Expand Down Expand Up @@ -182,6 +188,7 @@
if (response.data) {
this.$store.dispatch('loadSettings', response.data)
this.$electron.ipcRenderer.send('save-settings', response.data)
this.$i18n.locale = response.data.app_language
this.updateStatus('settings')
} else {
Expand All @@ -195,7 +202,7 @@
}
},
getWeather () {
const savedLocations = this.$store.getters.getSavedLocations || {}
const savedLocations = Object.assign({}, this.$store.getters.getSavedLocations)
const total = Object.keys(savedLocations).length
let current = 0
Expand Down Expand Up @@ -231,7 +238,7 @@
this.timers.current = setTimeout(this.getWeather, TIMER_CURRENT_WEATHER)
},
getForecast () {
const savedLocations = this.$store.getters.getSavedLocations || {}
const savedLocations = Object.assign({}, this.$store.getters.getSavedLocations)
const total = Object.keys(savedLocations).length
let current = 0
Expand All @@ -244,7 +251,7 @@
api.getWeatherForecastByGeo(location, (forecast) => {
if (typeof forecast.data !== 'undefined' && typeof forecast.data.list !== 'undefined') {
let saveForecast = util.parseWeatherForecast(location.hash_key, forecast.data, this.$store.state.settings)
let saveForecast = util.parseWeatherForecast(location.hash_key, forecast.data, this.$store.state.settings, this.$i18n.t('ui.today'))
this.$store.dispatch('saveForecast', saveForecast)
Expand Down
11 changes: 4 additions & 7 deletions src/renderer/assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ body {
}

#app {
min-width: 280px;
min-height: 480px;
max-width: 480px;
max-height: 853px;
width: 100%;
height: 100%;
width: 280px;
height: 480px;
margin: 0 auto;
box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5);
background: #132936;
background: linear-gradient(to bottom, #2a3641 0%, #535f6a 100%);
position: relative;
overflow: hidden;
transform: translateZ(0);
}

::selection {
Expand Down
Loading

0 comments on commit c2a3f93

Please sign in to comment.