mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-22 18:13:28 +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">
|
||||
<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>
|
||||
<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>
|
||||
<div class="uk-grid-small" uk-grid>
|
||||
<div class="uk-width-2-3@s">
|
||||
|
@ -117,6 +117,7 @@ function preFillSettings() {
|
||||
}
|
||||
const settings = require('electron-settings');
|
||||
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
|
||||
});
|
||||
});
|
||||
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() {
|
||||
|
37
main.js
37
main.js
@ -6,7 +6,7 @@ if (setupEvents.handleSquirrelEvent()) {
|
||||
}
|
||||
|
||||
// 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
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
@ -21,15 +21,15 @@ function createWindow () {
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
mainWindow.setOpacity(0.95);
|
||||
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.webContents.openDevTools()
|
||||
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function () {
|
||||
// Dereference the window object, usually you would store windows
|
||||
@ -37,6 +37,33 @@ function createWindow () {
|
||||
// when you should delete the corresponding element.
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user