Skip to content

Commit

Permalink
Merge pull request #56 from mountainash/49-context-menu
Browse files Browse the repository at this point in the history
Added right-click context menu support
  • Loading branch information
mountainash authored Nov 11, 2020
2 parents 300f7b3 + 136049c commit f908321
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 26 deletions.
4 changes: 4 additions & 0 deletions browser.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
::selection {
background-color: transparent;
}
input::selection,
textarea::selection {
background-color: #643e9b57;
}
.ad-header-wrapper,
div[class^="Warnings__Container"],
div[class^="RebrandHeader__"],
Expand Down
17 changes: 10 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const { autoUpdater } = require('electron-updater');
const path = require('path');
const menuTemplate = require('./menu.js');
const menu = Menu.buildFromTemplate(menuTemplate);
const contextMenu = require('electron-context-menu');
const fs = require('fs');
const Config = require('electron-config');
const config = new Config();


const BASE_URL = 'https://www.mixcloud.com/';
const DEBUG = process.env.ELECTRON_DEBUG || false;

Expand All @@ -29,7 +29,7 @@ let page;
let isQuitting = false;

let tray = null;
let contextMenu = null;
let trayContextMenu = null;
var _isPlaying = false;

const isRunning = app.requestSingleInstanceLock();
Expand All @@ -56,11 +56,11 @@ const initTray = () => {
if (!tray) {
tray = new Tray(path.join(__dirname, './static/logoTemplate.png'));
tray.on('click', togglePlay);
tray.on('right-click', displayContextMenu);
tray.on('right-click', displayTrayContextMenu);
tray.on('double-click', toggleWindow);
}

contextMenu = Menu.buildFromTemplate([
trayContextMenu = Menu.buildFromTemplate([
{
label: 'Play/Pause',
click: () => { togglePlay() }
Expand All @@ -72,15 +72,17 @@ const initTray = () => {
]);
};

function displayContextMenu() {
tray.popUpContextMenu(contextMenu);
function displayTrayContextMenu() {
tray.popUpContextMenu(trayContextMenu);
}

app.on('activate', () => { win.show() });
app.on('before-quit', () => isQuitting = true);

app.on('ready', () => {
initTray();
contextMenu();

Menu.setApplicationMenu(menu);

autoUpdater.checkForUpdatesAndNotify();
Expand All @@ -101,7 +103,8 @@ app.on('ready', () => {
nodeIntegration: true, //TODO turn this off
preload: path.join(__dirname, 'browser.js'),
plugins: true,
partition: 'persist:mixcloud'
partition: 'persist:mixcloud',
spellcheck: true
}
};
Object.assign(opts, config.get('winBounds'));
Expand Down
140 changes: 122 additions & 18 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mixcloud-play",
"productName": "Mixcloud Play",
"version": "0.12.0",
"version": "0.13.0",
"description": "The Mixcloud desktop client",
"keywords": [
"music",
Expand Down Expand Up @@ -43,6 +43,7 @@
},
"dependencies": {
"electron-config": "2.0.0",
"electron-context-menu": "2.3.0",
"electron-updater": "4.3.5",
"source-map-support": "0.5.19"
},
Expand Down

0 comments on commit f908321

Please sign in to comment.