Skip to content

Commit

Permalink
Fixed Tray
Browse files Browse the repository at this point in the history
- Fixed Tray
- Updated text
  • Loading branch information
Ryzzzen committed Jul 2, 2018
1 parent 29f1c14 commit d24ed02
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ChampionSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function updateDisplay() {
if (Last === User.championId) return;
if ((Last = User.championId) === 0) return;

if (Mana.store.get('enableTrayIcon')) UI.show();
if (Mana.store.get('enableTrayIcon')) UI.tray(false);

ProviderHandler.getChampionData(Mana.champions[User.championId], User.assignedPosition === "" ? null : User.assignedPosition, GameMode).then(data => {
console.dir(data);
Expand Down
17 changes: 8 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ function createWindow () {
win.loadURL(`file://${__dirname}/src/index.html`);
win.setMenu(null);

win.once('ready-to-show', () => !tray ? win.show());
win.once('ready-to-show', () => !tray ? win.show() : null);

ipcMain.on('tray', () => {
if (tray && !tray.isDestroyed()) return;
ipcMain.on('tray', (event, show) => {
if (show && tray && !tray.isDestroyed()) return;
else if (!show) {
if (!tray || tray && tray.isDestroyed()) return;
return tray.destroy();
}

tray = new Tray(__dirname + '/build/icon.png');
tray.setToolTip('Cliquez pour afficher ManaFlux');

tray.on('click', () => win.isVisible() ? win.hide() : win.show());
});

ipcMain.on('tray-destroy', (event, data) => {
if (!tray || tray && tray.isDestroyed()) return;
tray.destroy();
tray.on('click', () => win.isVisible() ? win.hide() : win.showInactive());
});

ipcMain.on('auto-start', (event, enable) => {
Expand Down
2 changes: 2 additions & 0 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Mana.version = require('./package.json').version;
Mana.status = str => $('.status').text(str);
Mana.store = new Store();

if (Mana.store.get('enableTrayIcon')) UI.tray();

console.log('Loading Storage...');
Mana.status('Loading Storage...');

Expand Down
21 changes: 12 additions & 9 deletions src/assets/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ UI.error = function(err) {
$('#warning').show();
}

UI.show = function() {
ipcRenderer.send('destroy-tray');
ipcRenderer.send('win-show');
UI.tray = function(tray = true) {
console.log(`${tray ? 'Enabling' : 'Disabling'} Tray Mode.`);

if (tray) {
ipcRenderer.send('win-hide');
ipcRenderer.send('tray', true);
}
else {
ipcRenderer.send('tray', false);
ipcRenderer.send('win-show');
}
}

UI.tray = function() {
ipcRenderer.send('win-hide');
ipcRenderer.send('tray');
}

UI.tray();

window.onbeforeunload = (e) => UI.tray(false);
ipcRenderer.on('error', (event, data) => UI.error(data));

/*
Expand Down
8 changes: 4 additions & 4 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ <h1>MANAFLUX</h1>
</div>
</div>
<div class="option">
<p class="suboption-name">Démarrage automatique</p>
<p class="suboption-name">Démarrage</p>
<div class="options float-left checkboxContainer">
<input type="checkbox" data-settings-key="auto-start" onclick="autoStart(this.checked)" />
<label>Activer</label>
<label>Au lancement de Windows</label>
</div>
</div>
<div class="option">
<p class="suboption-name">Barre des tâches</p>
<div class="options float-left checkboxContainer">
<input type="checkbox" data-settings-key="enableTrayIcon" />
<label>Se ranger automatiquement hors sélection des champions</label>
<input type="checkbox" data-settings-key="enableTrayIcon" onclick="UI.tray(this.checked)" />
<label>S'y ranger hors sélection des champions</label>
</div>
</div>
<div class="option">
Expand Down

0 comments on commit d24ed02

Please sign in to comment.