Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Restrict initial window size on big screens - Closes #221 #226

Merged
merged 3 commits into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 31 additions & 35 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ let win;
function createWindow() {
const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize;
win = new BrowserWindow({
width: width - 250,
height: height - 150,
width: width > 2000 ? Math.floor(width * 0.5) : width - 250,
height: height > 1000 ? Math.floor(height * 0.7) : height - 150,
center: true,
});

Expand Down Expand Up @@ -49,7 +49,7 @@ function createWindow() {
},
{
role: 'togglefullscreen',
}
},
],
},
{
Expand All @@ -65,36 +65,36 @@ function createWindow() {
submenu: [
{
label: 'Lisk Website',
click: function () {
click() {
electron.shell.openExternal('https://lisk.io');
}
},
},
{
label: 'Lisk Chat',
click: function () {
click() {
electron.shell.openExternal('https://lisk.chat');
}
},
},
{
label: 'Lisk Forum',
click: function () {
click() {
electron.shell.openExternal('https://forum.lisk.io');
}
},
},
{
type: 'separator',
},
{
label: 'Report Issue...',
click: function () {
click() {
electron.shell.openExternal('https://github.com/LiskHQ/lisk-nano/issues/new');
}
},
},
{
label: 'What\'s New...',
click: function () {
click() {
electron.shell.openExternal('https://github.com/LiskHQ/lisk-nano/releases');
}
},
},
],
},
Expand All @@ -119,16 +119,16 @@ function createWindow() {
} else {
template[template.length - 1].submenu.push({
label: 'About',
click: function (item, focusedWindow) {
click(item, focusedWindow) {
if (focusedWindow) {
const options = {
buttons: ['OK'],
icon: `${__dirname}/assets/lisk.png`,
message: `Lisk Nano\nVersion ${app.getVersion()}\nCopyright © 2017 Lisk Foundation`,
}
electron.dialog.showMessageBox(focusedWindow, options, function () {})
};
electron.dialog.showMessageBox(focusedWindow, options, () => {});
}
}
},
});
}

Expand All @@ -139,33 +139,29 @@ function createWindow() {

win.on('closed', () => win = null);

setupContextMenu(win);
}

function setupContextMenu(window) {
const selectionMenu = Menu.buildFromTemplate([
{role: 'copy'},
{type: 'separator'},
{role: 'selectall'},
{ role: 'copy' },
{ type: 'separator' },
{ role: 'selectall' },
]);

const inputMenu = Menu.buildFromTemplate([
{role: 'undo'},
{role: 'redo'},
{type: 'separator'},
{role: 'cut'},
{role: 'copy'},
{role: 'paste'},
{type: 'separator'},
{role: 'selectall'},
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ type: 'separator' },
{ role: 'selectall' },
]);

window.webContents.on('context-menu', (e, props) => {
win.webContents.on('context-menu', (e, props) => {
const { selectionText, isEditable } = props;
if (isEditable) {
inputMenu.popup(window);
inputMenu.popup(win);
} else if (selectionText && selectionText.trim() !== '') {
selectionMenu.popup(window);
selectionMenu.popup(win);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function (grunt) {
fix: false,
},
all: {
src: ['app/**/*.js', 'spec/**/*.js', 'test/**/*.js', '*.js'],
src: ['app/**/*.js', 'spec/**/*.js', 'test/**/*.js', '../app/main.js', '*.js'],
},
},
});
Expand Down