Skip to content
Open
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
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = new Config({
lastWindowState: {
width: 800,
height: 600
}
},
showCardShortId: false
}
});
28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@ require('electron-context-menu')();

let mainWindow;
let isQuitting = false;
let showCardShortId = config.get('showCardShortId');

function toggleShowCardShortId(page) {
if (showCardShortId) {
page.insertCSS('.card-short-id.hide { display: inline-flex; padding-right: .3em; }');
} else {
page.insertCSS('.card-short-id.hide { display:none; }');
}
}

function createMainWindow() {
const lastWindowState = config.get('lastWindowState');
const lastShowCardShortId = config.get('showCardShortId');
const win = new electron.BrowserWindow({
title: app.getName(),
show: false,
x: lastWindowState.x,
y: lastWindowState.y,
showCardShortId: lastShowCardShortId,
width: lastWindowState.width,
height: lastWindowState.height,
icon: process.platform === 'linux' && path.join(__dirname, 'static', 'Icon.png'),
Expand All @@ -45,6 +56,7 @@ function createMainWindow() {
if (!mainWindow.isFullScreen()) {
config.set('lastWindowState', mainWindow.getBounds());
}
config.set('showCardShortId', mainWindow.showCardShortId);
} else {
e.preventDefault();

Expand All @@ -65,6 +77,7 @@ app.on('ready', () => {

page.on('dom-ready', () => {
page.insertCSS(fs.readFileSync(path.join(__dirname, 'browser.css'), 'utf8'));
toggleShowCardShortId(page);
mainWindow.show();
});

Expand Down Expand Up @@ -111,6 +124,20 @@ app.on('ready', () => {
{label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:'},
{label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:'}
]
}, {
label: 'View',
submenu: [
{label: 'Show card short id',
type: 'checkbox',
checked: showCardShortId,
click: item => {
showCardShortId = !showCardShortId;
item.checked = showCardShortId;
config.set('showCardShortId', showCardShortId);
toggleShowCardShortId(page);
}
}
]
}
];

Expand All @@ -128,3 +155,4 @@ app.on('activate', () => {
app.on('before-quit', () => {
isQuitting = true;
});