mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-23 02:23:31 +07:00
See #1 Added minimize to tray capability.
This commit is contained in:
parent
50a935fd45
commit
45dfaacffe
@ -72,6 +72,8 @@
|
|||||||
<li class="uk-container uk-animation-fade">
|
<li class="uk-container uk-animation-fade">
|
||||||
<h3>Auto apply on launch:</h3>
|
<h3>Auto apply on launch:</h3>
|
||||||
<label><input class="uk-checkbox" type="checkbox" id="apply_last_settings_on_launch"> When checked, Ryzen Controller will try to apply latest used settings on launch.</label>
|
<label><input class="uk-checkbox" type="checkbox" id="apply_last_settings_on_launch"> When checked, Ryzen Controller will try to apply latest used settings on launch.</label>
|
||||||
|
<h3>Minimize to tray:</h3>
|
||||||
|
<label><input class="uk-checkbox" type="checkbox" id="minimize_to_tray"> When checked, Ryzen Controller will minimize to tray instead of taskbar.</label>
|
||||||
<h3>Ryzenadj path:</h3>
|
<h3>Ryzenadj path:</h3>
|
||||||
<div class="uk-grid-small" uk-grid>
|
<div class="uk-grid-small" uk-grid>
|
||||||
<div class="uk-width-2-3@s">
|
<div class="uk-width-2-3@s">
|
||||||
|
@ -117,6 +117,7 @@ function preFillSettings() {
|
|||||||
}
|
}
|
||||||
const settings = require('electron-settings');
|
const settings = require('electron-settings');
|
||||||
document.getElementById('apply_last_settings_on_launch').checked = settings.get('settings.apply_last_settings_on_launch');
|
document.getElementById('apply_last_settings_on_launch').checked = settings.get('settings.apply_last_settings_on_launch');
|
||||||
|
document.getElementById('minimize_to_tray').checked = settings.get('settings.minimize_to_tray');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,6 +205,13 @@ function registerEventListenerForSettingsInput() {
|
|||||||
apply_last_settings_on_launch: !!apply_last_settings_on_launch.checked
|
apply_last_settings_on_launch: !!apply_last_settings_on_launch.checked
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
var minimize_to_tray = document.getElementById('minimize_to_tray');
|
||||||
|
minimize_to_tray.addEventListener('change', function() {
|
||||||
|
settings.set('settings', {
|
||||||
|
...settings.get('settings'),
|
||||||
|
minimize_to_tray: !!minimize_to_tray.checked
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayVersion() {
|
function displayVersion() {
|
||||||
|
29
main.js
29
main.js
@ -6,7 +6,7 @@ if (setupEvents.handleSquirrelEvent()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const {app, BrowserWindow} = require('electron')
|
const {app, BrowserWindow, Menu, Tray} = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
@ -37,6 +37,33 @@ function createWindow () {
|
|||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const settings = require('electron-settings');
|
||||||
|
mainWindow.on('minimize',function(event){
|
||||||
|
if (settings.get('settings.minimize_to_tray')) {
|
||||||
|
event.preventDefault();
|
||||||
|
mainWindow.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: 'Show App',
|
||||||
|
click: function () {
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Quit',
|
||||||
|
click: function () {
|
||||||
|
application.isQuiting = true;
|
||||||
|
application.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
var appIcon = new Tray(__dirname + '/assets/icon.ico');
|
||||||
|
appIcon.setContextMenu(contextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
|
Loading…
Reference in New Issue
Block a user