Skip to content

Commit

Permalink
Merge pull request standardnotes#331 from standardnotes/3.0.8
Browse files Browse the repository at this point in the history
3.0.8
  • Loading branch information
Mo Bitar authored Apr 18, 2019
2 parents 4177dd6 + dc94adc commit a65aa3a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 19 deletions.
13 changes: 10 additions & 3 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@

<script>
const {remote, app} = window.nodeRequire('electron');
const Store = window.nodeRequire('./javascripts/main/store.js');
var userDataPath = remote.app.getPath('userData');
let useSystemMenuBar = Store.instance().get("useSystemMenuBar");

angular.element(document).ready(function () {
var desktopManager = angular.element(document).injector().get('desktopManager');
Expand All @@ -88,7 +90,7 @@
Responses from packageManager
*/
ipcRenderer.on('install-component-complete', function (event, data) {
console.log("install-component-complete", data.component.content.name, data.error && data.error.tag);
// console.log("install-component-complete", data.component.content.name, data.error && data.error.tag);
desktopManager.desktop_onComponentInstallationComplete(data.component, data.error);
});

Expand Down Expand Up @@ -148,12 +150,17 @@

// For Mac inset window
var sheet = window.document.styleSheets[0];
if(process.platform == "darwin") {
let isMacOS = process.platform == "darwin";

if(isMacOS) {
sheet.insertRule('#tags-column { padding-top: 25px !important; }', sheet.cssRules.length);
}

if(isMacOS || useSystemMenuBar) {
// !important is important here because #desktop-title-bar has display: flex.
sheet.insertRule('#desktop-title-bar { display: none !important; }', sheet.cssRules.length);
} else {
// If not Mac, take the sn-titlebar-height off of the app content height so its not overflowing
// Use custom title bar. Take the sn-titlebar-height off of the app content height so its not overflowing
sheet.insertRule('.main-ui-view { height: calc(100vh - var(--sn-desktop-titlebar-height)) !important; min-height: calc(100vh - var(--sn-desktop-titlebar-height)) !important; }', sheet.cssRules.length);
}

Expand Down
12 changes: 10 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const url = require('url')
const windowStateKeeper = require('electron-window-state')
const shell = require('electron').shell;
const log = require('electron-log');
const Store = require('./javascripts/main/store.js');

import menuManager from './javascripts/main/menuManager.js'
import archiveManager from './javascripts/main/archiveManager.js';
Expand Down Expand Up @@ -49,6 +50,9 @@ function createWindow () {

let iconLocation = path.join(__dirname, '/icon/Icon-512x512.png');

// Defaults to false in store.js
let useSystemMenuBar = Store.instance().get("useSystemMenuBar");

// Create the window using the state information
win = new BrowserWindow({
'x': winState.x,
Expand All @@ -59,8 +63,12 @@ function createWindow () {
'minHeight': 400,
show: false,
icon: iconLocation,
titleBarStyle: darwin ? 'hiddenInset' : null,
frame: false

// We want hiddenInset on Mac. On Windows/Linux, doesn't seem to have an effect, but we'll default to it's original value before themed title bar changes were put in place.
titleBarStyle: darwin || useSystemMenuBar ? 'hiddenInset' : null,

// Will apply to Windows and Linux only, since titleBarStyle takes precendence for mac. But we'll explicitely specifiy false for mac to be on the safe side
frame: darwin ? false : useSystemMenuBar
})

searchManager.setWindow(win);
Expand Down
5 changes: 1 addition & 4 deletions app/javascripts/main/archiveManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ var fs = require('fs');
var path = require('path');
const Store = require('./store.js');

const store = new Store({
configName: 'user-preferences',
defaults: {}
});
const store = Store.instance();

class ArchiveManager {

Expand Down
20 changes: 18 additions & 2 deletions app/javascripts/main/menuManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const shell = require('electron').shell;
const {app, Menu} = require('electron');
const {app, Menu, dialog} = require('electron');
const path = require('path')
const Store = require('./store.js');

class MenuManager {

Expand All @@ -14,6 +15,7 @@ class MenuManager {
this.updateManager = updateManager;

let updateData = updateManager.getMetadata();
let useSystemMenuBar = Store.instance().get("useSystemMenuBar");

const template = [
{
Expand Down Expand Up @@ -74,7 +76,10 @@ class MenuManager {
role: 'togglefullscreen'
},
{
visible: process.platform === 'darwin' ? false : true,
type: 'separator'
},
{
visible: process.platform !== 'darwin' && useSystemMenuBar,
label: 'Hide Menu Bar',
accelerator: 'Alt + m',
click() {
Expand All @@ -84,6 +89,17 @@ class MenuManager {
window.setMenuBarVisibility(true)
}
}
},
{
visible: process.platform !== 'darwin',
label: `Use Themed Menu Bar`,
type: 'checkbox',
checked: !useSystemMenuBar,
click: () => {
Store.instance().set("useSystemMenuBar", !useSystemMenuBar);
this.reload();
dialog.showMessageBox({title: "Preference Changed", message: "Your menu bar preference has been saved. Please restart the application for the change to take effect."});
}
}
]
},
Expand Down
16 changes: 16 additions & 0 deletions app/javascripts/main/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@ const electron = require('electron');
const path = require('path');
const fs = require('fs');

let instance = null;

class Store {

static instance() {
if (instance == null) {
instance = new Store({
configName: 'user-preferences',
defaults: {
useSystemMenuBar: false
}
});
}

return instance;
}

constructor(opts) {
// Renderer process has to get `app` module via `remote`, whereas the main process can get it directly
// app.getPath('userData') will return a string of the user's app data directory path.
Expand Down
8 changes: 4 additions & 4 deletions app/package-lock.json

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

4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "Standard Notes",
"description": "A simple and private place for your notes, thoughts, and life's work.",
"author": "Standard Notes <[email protected]>",
"version": "3.0.6",
"version": "3.0.8",
"main": "./dist/index.js",
"dependencies": {
"adm-zip": "^0.4.7",
Expand All @@ -18,6 +18,6 @@
"request": "^2.83.0",
"semver": "^5.5.0",
"spellchecker": "github:mobitar/node-spellchecker",
"standard-notes-web": "3.0.7"
"standard-notes-web": "3.0.8"
}
}
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,7 +1,7 @@
{
"name": "standard-notes",
"main": "./app/dist/index.js",
"version": "3.0.6",
"version": "3.0.8",
"license": "AGPL-3.0-or-later",
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down

0 comments on commit a65aa3a

Please sign in to comment.